aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar BlindSight2015-11-04 14:23:28 -0500
committerGravatar BlindSight2015-11-04 14:23:28 -0500
commite28590d76f7a25288405fb2f8a79c1bdce00c4ea (patch)
treea5752dfd284f582278855c4d8c062fd35952b3f5
parentFix button label capitalization (diff)
parentSmall cleanups (diff)
downloadKVIrc-e28590d76f7a25288405fb2f8a79c1bdce00c4ea.tar.gz
KVIrc-e28590d76f7a25288405fb2f8a79c1bdce00c4ea.tar.bz2
KVIrc-e28590d76f7a25288405fb2f8a79c1bdce00c4ea.zip
Merge pull request #1714 from blindsighttf2/favorites
Add Favorite Servers!
-rw-r--r--data/pics/coresmall/kcs_serverfavorite.pngbin0 -> 748 bytes
-rw-r--r--data/pics/coresmall/kcs_tilewindows.pngbin1182 -> 0 bytes
-rw-r--r--src/kvilib/irc/KviIrcServer.cpp9
-rw-r--r--src/kvilib/irc/KviIrcServer.h34
-rw-r--r--src/kvirc/kernel/KviApplication.cpp2
-rw-r--r--src/kvirc/kernel/KviCoreActions.cpp2
-rw-r--r--src/kvirc/kernel/KviIconManager.cpp4
-rw-r--r--src/kvirc/kernel/KviIconManager.h2
-rw-r--r--src/kvirc/kernel/KviOptions.cpp3
-rw-r--r--src/kvirc/kernel/KviOptions.h3
-rw-r--r--src/modules/options/OptionsWidgetContainer.cpp7
-rw-r--r--src/modules/options/OptionsWidgetContainer.h1
-rw-r--r--src/modules/options/OptionsWidget_servers.cpp155
-rw-r--r--src/modules/options/OptionsWidget_servers.h15
-rw-r--r--src/modules/serverdb/libkviserverdb.cpp21
15 files changed, 198 insertions, 60 deletions
diff --git a/data/pics/coresmall/kcs_serverfavorite.png b/data/pics/coresmall/kcs_serverfavorite.png
new file mode 100644
index 000000000..e6eeb2860
--- /dev/null
+++ b/data/pics/coresmall/kcs_serverfavorite.png
Binary files differ
diff --git a/data/pics/coresmall/kcs_tilewindows.png b/data/pics/coresmall/kcs_tilewindows.png
deleted file mode 100644
index f7f4a3767..000000000
--- a/data/pics/coresmall/kcs_tilewindows.png
+++ /dev/null
Binary files differ
diff --git a/src/kvilib/irc/KviIrcServer.cpp b/src/kvilib/irc/KviIrcServer.cpp
index 69eac4f69..8462c33e8 100644
--- a/src/kvilib/irc/KviIrcServer.cpp
+++ b/src/kvilib/irc/KviIrcServer.cpp
@@ -125,7 +125,7 @@ void KviIrcServer::operator=(const KviIrcServer & serv)
m_szLinkFilter = serv.m_szLinkFilter;
m_szId = serv.m_szId;
m_szUserIdentityId = serv.m_szUserIdentityId;
- m_iProxy = serv.m_iProxy;
+ m_iProxy = serv.m_iProxy;
m_bAutoConnect = serv.m_bAutoConnect;
m_szSaslNick = serv.m_szSaslNick;
m_szSaslPass = serv.m_szSaslPass;
@@ -287,6 +287,8 @@ bool KviIrcServer::load(KviConfigurationFile * pCfg, const QString & szPrefix)
setProxy(pCfg->readIntEntry(szTmp,-2));
szTmp = QString("%1UserIdentityId").arg(szPrefix);
m_szUserIdentityId = pCfg->readEntry(szTmp);
+ szTmp = QString("%1Favorite").arg(szPrefix);
+ setFavorite(pCfg->readBoolEntry(szTmp,false));
return true;
}
@@ -427,4 +429,9 @@ void KviIrcServer::save(KviConfigurationFile * pCfg, const QString & szPrefix)
szTmp = QString("%1UserIdentityId").arg(szPrefix);
pCfg->writeEntry(szTmp,m_szUserIdentityId);
}
+ if(favorite())
+ {
+ szTmp = QString("%1Favorite").arg(szPrefix);
+ pCfg->writeEntry(szTmp,favorite());
+ }
}
diff --git a/src/kvilib/irc/KviIrcServer.h b/src/kvilib/irc/KviIrcServer.h
index 6e17948cb..33bf2402f 100644
--- a/src/kvilib/irc/KviIrcServer.h
+++ b/src/kvilib/irc/KviIrcServer.h
@@ -61,7 +61,8 @@ public:
SSL = 4, /**< SSL support */
STARTTLS = 8, /**< STARTTLS support */
SASL = 16, /**< SASL support */
- CAP = 32 /**< CAP support */
+ CAP = 32, /**< CAP support */
+ FAVORITE = 64 /**< Favorite Server */
};
/**
@@ -485,7 +486,7 @@ public:
if(bSet)
m_uFlags |= KviIrcServer::IPv6;
else
- m_uFlags &= ((unsigned short)~KviIrcServer::IPv6);
+ m_uFlags &= static_cast<unsigned short>(~KviIrcServer::IPv6);
};
/**
@@ -498,7 +499,7 @@ public:
if(bSet)
m_uFlags |= KviIrcServer::SSL;
else
- m_uFlags &= ((unsigned short)~KviIrcServer::SSL);
+ m_uFlags &= static_cast<unsigned short>(~KviIrcServer::SSL);
};
/**
@@ -511,7 +512,7 @@ public:
if(bSet)
m_uFlags |= KviIrcServer::STARTTLS;
else
- m_uFlags &= ((unsigned short)~KviIrcServer::STARTTLS);
+ m_uFlags &= static_cast<unsigned short>(~KviIrcServer::STARTTLS);
};
/**
@@ -524,7 +525,7 @@ public:
if(bSet)
m_uFlags |= KviIrcServer::CAP;
else
- m_uFlags &= ((unsigned short)~KviIrcServer::CAP);
+ m_uFlags &= static_cast<unsigned short>(~KviIrcServer::CAP);
};
/**
@@ -537,7 +538,7 @@ public:
if(bSet)
m_uFlags |= KviIrcServer::SASL;
else
- m_uFlags &= ((unsigned short)~KviIrcServer::SASL);
+ m_uFlags &= static_cast<unsigned short>(~KviIrcServer::SASL);
};
/**
@@ -550,7 +551,7 @@ public:
if(bSet)
m_uFlags |= KviIrcServer::CacheIP;
else
- m_uFlags &= ((unsigned short)~KviIrcServer::CacheIP);
+ m_uFlags &= static_cast<unsigned short>(~KviIrcServer::CacheIP);
};
/**
@@ -588,6 +589,25 @@ public:
* \return void
*/
void operator=(const KviIrcServer & serv);
+
+ /**
+ * \brief Sets the server to a favorite
+ * \param bSet wether the server is a favorite or not
+ * \return void
+ */
+ inline void setFavorite(bool bSet)
+ {
+ if(bSet)
+ m_uFlags |= KviIrcServer::FAVORITE;
+ else
+ m_uFlags &= static_cast<unsigned short>(~KviIrcServer::FAVORITE);
+ };
+
+ /**
+ * \brief Returns if the server is a favorite
+ * \return bool
+ */
+ inline bool favorite() const { return (m_uFlags & KviIrcServer::FAVORITE); };
};
#endif //_KVI_IRCSERVER_H_
diff --git a/src/kvirc/kernel/KviApplication.cpp b/src/kvirc/kernel/KviApplication.cpp
index c7e9c6e3a..d6d69dd54 100644
--- a/src/kvirc/kernel/KviApplication.cpp
+++ b/src/kvirc/kernel/KviApplication.cpp
@@ -2283,5 +2283,3 @@ void KviApplication::timerEvent(QTimerEvent * e)
#ifdef Bool
#undef Bool
#endif
-
-
diff --git a/src/kvirc/kernel/KviCoreActions.cpp b/src/kvirc/kernel/KviCoreActions.cpp
index c4204f207..ae099268d 100644
--- a/src/kvirc/kernel/KviCoreActions.cpp
+++ b/src/kvirc/kernel/KviCoreActions.cpp
@@ -976,7 +976,7 @@ void KviChangeUserModeAction::popupAboutToShow()
pAction = m_pPopup->addAction(*(g_pIconManager->getSmallIcon(KviIconManager::ServerNotice)),__tr2qs("s: Server Notices"));
pAction->setCheckable(true);
// Only if the IRCd allows us
- pAction->setEnabled(c->connection()->serverInfo()->getNeedsOperToSetS() ? c->connection()->userInfo()->hasUserMode('o') : 1);
+ pAction->setEnabled(c->connection()->serverInfo()->getNeedsOperToSetS() ? c->connection()->userInfo()->hasUserMode('o') : true);
pAction->setChecked(c->connection()->userInfo()->hasUserMode('s'));
}
diff --git a/src/kvirc/kernel/KviIconManager.cpp b/src/kvirc/kernel/KviIconManager.cpp
index 624cc0a43..0e009db95 100644
--- a/src/kvirc/kernel/KviIconManager.cpp
+++ b/src/kvirc/kernel/KviIconManager.cpp
@@ -201,7 +201,7 @@ static const char * g_szIconNames[KviIconManager::IconCount] =
"unsetmode", // 115
"maxvertical", // 116
"maxhorizontal", // 117
- "tilewindows", // 118
+ "serverfavorite", // 118
"log", // 119
"remove", // 120
"file", // 121
@@ -732,7 +732,7 @@ KviIconManager::SmallIcon KviIconManager::iconName(int iIcon)
case 115: return KviIconManager::UnsetMode; break;
case 116: return KviIconManager::MaxVertical; break;
case 117: return KviIconManager::MaxHorizontal; break;
- case 118: return KviIconManager::TileWindows; break;
+ case 118: return KviIconManager::ServerFavorite; break;
case 119: return KviIconManager::Log; break;
case 120: return KviIconManager::Remove; break;
case 121: return KviIconManager::File; break;
diff --git a/src/kvirc/kernel/KviIconManager.h b/src/kvirc/kernel/KviIconManager.h
index 8068f14dc..b7d8121b3 100644
--- a/src/kvirc/kernel/KviIconManager.h
+++ b/src/kvirc/kernel/KviIconManager.h
@@ -283,7 +283,7 @@ public:
UnsetMode = 115,
MaxVertical = 116,
MaxHorizontal = 117,
- TileWindows = 118,
+ ServerFavorite = 118,
Log = 119,
Remove = 120,
File = 121,
diff --git a/src/kvirc/kernel/KviOptions.cpp b/src/kvirc/kernel/KviOptions.cpp
index 18e956423..5148ae620 100644
--- a/src/kvirc/kernel/KviOptions.cpp
+++ b/src/kvirc/kernel/KviOptions.cpp
@@ -334,7 +334,8 @@ KviBoolOption g_boolOptionsTable[KVI_NUM_BOOL_OPTIONS]=
BOOL_OPTION("PopupNotifierOnNewNotices",true,KviOption_sectFlagFrame),
BOOL_OPTION("UserListViewUseAwayColor",true,KviOption_sectFlagUserListView | KviOption_resetUpdateGui),
BOOL_OPTION("ShowUserFlagForChannelsInWindowList",true,KviOption_sectFlagWindowList | KviOption_resetUpdateGui),
- BOOL_OPTION("EnableCustomCursorWidth",false,KviOption_sectFlagGui | KviOption_resetUpdateGui)
+ BOOL_OPTION("EnableCustomCursorWidth",false,KviOption_sectFlagGui | KviOption_resetUpdateGui),
+ BOOL_OPTION("ShowFavoriteServersOnly",false,KviOption_sectFlagFrame)
};
#define STRING_OPTION(_txt,_val,_flags) KviStringOption(KVI_STRING_OPTIONS_PREFIX _txt,_val,_flags)
diff --git a/src/kvirc/kernel/KviOptions.h b/src/kvirc/kernel/KviOptions.h
index 87aff7f14..f1fabb8bd 100644
--- a/src/kvirc/kernel/KviOptions.h
+++ b/src/kvirc/kernel/KviOptions.h
@@ -354,8 +354,9 @@ DECLARE_OPTION_STRUCT(KviStringListOption,QStringList)
#define KviOption_boolUserListViewUseAwayColor 259 /* userlist */
#define KviOption_boolShowUserFlagForChannelsInWindowList 260
#define KviOption_boolEnableCustomCursorWidth 261 /* interface */
+#define KviOption_boolShowFavoriteServersOnly 262 /* connection::ircservers */
-#define KVI_NUM_BOOL_OPTIONS 262
+#define KVI_NUM_BOOL_OPTIONS 263
#define KVI_STRING_OPTIONS_PREFIX "string"
diff --git a/src/modules/options/OptionsWidgetContainer.cpp b/src/modules/options/OptionsWidgetContainer.cpp
index 86b872eb2..875420b7f 100644
--- a/src/modules/options/OptionsWidgetContainer.cpp
+++ b/src/modules/options/OptionsWidgetContainer.cpp
@@ -68,6 +68,13 @@ void OptionsWidgetContainer::setLeftCornerWidget(QWidget * pWidget)
m_pLayout->addWidget(pWidget,1,0);
}
+void OptionsWidgetContainer::setNextToLeft(QWidget * pWidget)
+{
+ if(!pWidget)
+ return;
+ m_pLayout->addWidget(pWidget,2,0);
+}
+
void OptionsWidgetContainer::optionsWidgetDestroyed()
{
m_pOptionsWidget = NULL;
diff --git a/src/modules/options/OptionsWidgetContainer.h b/src/modules/options/OptionsWidgetContainer.h
index 54164c3cf..42880ce16 100644
--- a/src/modules/options/OptionsWidgetContainer.h
+++ b/src/modules/options/OptionsWidgetContainer.h
@@ -44,6 +44,7 @@ protected:
public:
void setup(KviOptionsWidget * w);
void setLeftCornerWidget(QWidget * pWidget);
+ void setNextToLeft(QWidget * pWidget);
protected:
virtual void closeEvent(QCloseEvent *e);
virtual void showEvent(QShowEvent *e);
diff --git a/src/modules/options/OptionsWidget_servers.cpp b/src/modules/options/OptionsWidget_servers.cpp
index 7ed49db06..ba1631a3f 100644
--- a/src/modules/options/OptionsWidget_servers.cpp
+++ b/src/modules/options/OptionsWidget_servers.cpp
@@ -229,8 +229,8 @@ IrcNetworkDetailsWidget::IrcNetworkDetailsWidget(QWidget * par,KviIrcNetwork * n
while(d->pcName)
{
tmp = QString("%1 (%2)").arg(d->pcName,d->pcDescription);
- m_pEncodingEditor->insertItem(m_pEncodingEditor->count(),tmp);
- m_pTextEncodingEditor->insertItem(m_pTextEncodingEditor->count(),tmp);
+ m_pEncodingEditor->insertItem(m_pEncodingEditor->count(),tmp);
+ m_pTextEncodingEditor->insertItem(m_pTextEncodingEditor->count(),tmp);
if(KviQString::equalCI(d->pcName,n->encoding()))
srvcurrent = i + 1;
if(KviQString::equalCI(d->pcName,n->textEncoding()))
@@ -785,8 +785,8 @@ IrcServerDetailsWidget::IrcServerDetailsWidget(QWidget * par,KviIrcServer * s)
while(d->pcName)
{
tmp = QString("%1 (%2)").arg(d->pcName,d->pcDescription);
- m_pEncodingEditor->insertItem(m_pEncodingEditor->count(),tmp);
- m_pTextEncodingEditor->insertItem(m_pTextEncodingEditor->count(),tmp);
+ m_pEncodingEditor->insertItem(m_pEncodingEditor->count(),tmp);
+ m_pTextEncodingEditor->insertItem(m_pTextEncodingEditor->count(),tmp);
if(KviQString::equalCI(d->pcName,s->encoding()))
srvcurrent = i + 1;
if(KviQString::equalCI(d->pcName,s->textEncoding()))
@@ -814,7 +814,7 @@ IrcServerDetailsWidget::IrcServerDetailsWidget(QWidget * par,KviIrcServer * s)
KviPointerList<KviProxy> * proxylist = g_pProxyDataBase->proxyList();
for(KviProxy * p = proxylist->first();p;p = proxylist->next())
{
- m_pProxyEditor->insertItem(m_pProxyEditor->count(),QString("%1:%2").arg(p->hostName()).arg(p->port()));
+ m_pProxyEditor->insertItem(m_pProxyEditor->count(),QString("%1:%2").arg(p->hostName()).arg(p->port()));
}
if(m_pProxyEditor->count() > (s->proxy()+2))
m_pProxyEditor->setCurrentIndex(s->proxy()+2);
@@ -945,11 +945,10 @@ IrcServerDetailsWidget::IrcServerDetailsWidget(QWidget * par,KviIrcServer * s)
pSASLLayout->addWidget(m_pSaslPassEditor,2,1);
pSASLGroup->setEnabled(s->enabledCAP());
- QObject::connect(m_pEnableCAPCheck,SIGNAL(toggled(bool)),pSASLGroup,SLOT(setEnabled(bool)));
+ connect(m_pEnableCAPCheck,SIGNAL(toggled(bool)),pSASLGroup,SLOT(setEnabled(bool)));
iRow++;
-
l = new QLabel(__tr2qs_ctx("Link filter:","options"),tab);
gl->addWidget(l,iRow,0);
m_pLinkFilterEditor = new QComboBox(tab);
@@ -999,7 +998,6 @@ IrcServerDetailsWidget::IrcServerDetailsWidget(QWidget * par,KviIrcServer * s)
"You will then be able to use /server -x &lt;this_id&gt; to make the connection. This is especially " \
"useful when you have multiple server entries with the same hostname and port in different networks (bouncers?)</center>","options"));
-
iRow++;
tw->addTab(tab,__tr2qs_ctx("Advanced","options"));
@@ -1268,11 +1266,11 @@ OptionsWidget_servers::OptionsWidget_servers(QWidget * parent)
createLayout();
- m_pContextPopup = new QMenu(this);
- m_pImportPopup = new QMenu(this);
+ m_pContextPopup = new QMenu(this);
+ m_pImportPopup = new QMenu(this);
connect(m_pImportPopup,SIGNAL(aboutToShow()),this,SLOT(importPopupAboutToShow()));
- connect(m_pImportPopup,SIGNAL(triggered(QAction *)),this,SLOT(importPopupActivated(QAction *)));
+ connect(m_pImportPopup,SIGNAL(triggered(QAction *)),this,SLOT(importPopupActivated(QAction *)));
m_pServerDetailsDialog = 0;
m_pNetworkDetailsDialog = 0;
@@ -1296,7 +1294,7 @@ OptionsWidget_servers::OptionsWidget_servers(QWidget * parent)
m_pTreeWidget->setColumnWidth(1,250);
m_pTreeWidget->setSortingEnabled(true);
- m_pTreeWidget->sortByColumn(0,Qt::AscendingOrder);
+ m_pTreeWidget->sortByColumn(0,Qt::AscendingOrder);
m_pTreeWidget->setHeaderLabels(columLabels);
m_pTreeWidget->setRootIsDecorated(true);
m_pTreeWidget->setAllColumnsShowFocus(true);
@@ -1367,6 +1365,15 @@ OptionsWidget_servers::OptionsWidget_servers(QWidget * parent)
KviTalToolTip::add(m_pImportButton,__tr2qs_ctx("Import List","options"));
+ f = new QFrame(vbox);
+ f->setFrameStyle(QFrame::Sunken | QFrame::HLine);
+
+ m_pFavoriteServerButton = new QToolButton(vbox);
+ m_pFavoriteServerButton->setIcon(QIcon(*(g_pIconManager->getSmallIcon(KviIconManager::ServerFavorite))));
+ m_pFavoriteServerButton->setAutoRaise(true);
+ connect(m_pFavoriteServerButton,SIGNAL(clicked()),this,SLOT(favoriteServer()));
+ KviTalToolTip::add(m_pFavoriteServerButton,__tr2qs_ctx("Favorite Server","options"));
+
QFrame * lll = new QFrame(vbox);
vbox->setStretchFactor(lll,100);
@@ -1381,9 +1388,9 @@ OptionsWidget_servers::OptionsWidget_servers(QWidget * parent)
connect(m_pDetailsButton,SIGNAL(clicked()),this,SLOT(detailsClicked()));
KviTalToolTip::add(m_pDetailsButton,__tr2qs_ctx("<center>Click here to edit advanced options for this entry</center>","options"));
- m_pRecentPopup = new QMenu(gbox);
+ m_pRecentPopup = new QMenu(gbox);
connect(m_pRecentPopup,SIGNAL(aboutToShow()),this,SLOT(recentServersPopupAboutToShow()));
- connect(m_pRecentPopup,SIGNAL(triggered(QAction *)),this,SLOT(recentServersPopupClicked(QAction *)));
+ connect(m_pRecentPopup,SIGNAL(triggered(QAction *)),this,SLOT(recentServersPopupClicked(QAction *)));
QToolButton * tb = new QToolButton(gbox);
tb->setIcon(QIcon(*(g_pIconManager->getSmallIcon(KviIconManager::Time))));
@@ -1394,6 +1401,7 @@ OptionsWidget_servers::OptionsWidget_servers(QWidget * parent)
KviTalToolTip::add(tb,__tr2qs_ctx("<center>This button shows a list of recently used servers. It allows you to quickly find them in the list.</center>","options"));
m_pShowThisDialogAtStartupSelector = NULL;
+ m_pShowFavoritesOnly = NULL;
// The "Show this dialog at startup" option is shown only when the server options widget is shown as standalone dialog
if(parent->inherits("OptionsWidgetContainer"))
@@ -1446,11 +1454,16 @@ OptionsWidget_servers::OptionsWidget_servers(QWidget * parent)
{
m_pShowThisDialogAtStartupSelector = addBoolSelector(pContainer,__tr2qs_ctx("Show this dialog at startup","options"),KviOption_boolShowServersConnectDialogOnStart);
pContainer->setLeftCornerWidget(m_pShowThisDialogAtStartupSelector);
+ m_pShowFavoritesOnly = addBoolSelector(pContainer,__tr2qs_ctx("Only display favorite servers","options"),KviOption_boolShowFavoriteServersOnly);
+ pContainer->setNextToLeft(m_pShowFavoritesOnly);
// This selector can be destroyed upon reparenting: make sure it's removed from the selector list
// (or we'll get a crash at commit() time...).
- QObject::connect(m_pShowThisDialogAtStartupSelector,SIGNAL(destroyed()),this,SLOT(slotShowThisDialogAtStartupSelectorDestroyed()));
-
+ connect(m_pShowThisDialogAtStartupSelector,SIGNAL(destroyed()),this,SLOT(slotShowThisDialogAtStartupSelectorDestroyed()));
KviTalToolTip::add(m_pShowThisDialogAtStartupSelector,__tr2qs_ctx("<center>If this option is enabled, the servers dialog will appear every time you start KVIrc</center>","options"));
+
+ connect(m_pShowFavoritesOnly,SIGNAL(destroyed()),this,SLOT(slotSetShowFavoritesOnly()));
+ connect(m_pShowFavoritesOnly,SIGNAL(toggled(bool)),this,SLOT(updateFavoritesFilter(bool))); // Sets the server to a favorite
+ KviTalToolTip::add(m_pShowFavoritesOnly,__tr2qs_ctx("<center>If this option is enabled, only servers you have favorited will be displayed</center>","options"));
}
new QShortcut(Qt::Key_Escape, parent, SLOT(close()));
@@ -1462,7 +1475,10 @@ OptionsWidget_servers::OptionsWidget_servers(QWidget * parent)
m_pClipboard = 0;
+ m_bShowingFavoritesOnly = KVI_OPTION_BOOL(KviOption_boolShowFavoriteServersOnly);
+
fillServerList();
+ updateFavoritesFilter(KVI_OPTION_BOOL(KviOption_boolShowFavoriteServersOnly));
layout()->setRowStretch(1,1);
layout()->setColumnStretch(1,1);
@@ -1494,11 +1510,19 @@ void OptionsWidget_servers::slotShowThisDialogAtStartupSelectorDestroyed()
m_pShowThisDialogAtStartupSelector = NULL;
}
+void OptionsWidget_servers::slotSetShowFavoritesOnly()
+{
+ KVI_ASSERT(m_pShowFavoritesOnly);
+
+ removeSelector(m_pShowFavoritesOnly);
+ m_pShowFavoritesOnly = NULL;
+}
+
void OptionsWidget_servers::recentServersPopupAboutToShow()
{
g_pApp->fillRecentServersPopup(m_pRecentPopup);
- m_pRecentPopup->addSeparator();
+ m_pRecentPopup->addSeparator();
m_pRecentPopup->addAction(*(g_pIconManager->getSmallIcon(KviIconManager::Remove)),__tr2qs("Clear Recent Servers List"));
}
@@ -1511,7 +1535,7 @@ void OptionsWidget_servers::recentServersPopupClicked(QAction *pAction)
if(!c)
return;
- QString szItemText = pAction->text();
+ QString szItemText = pAction->text();
szItemText.remove(QChar('&'));
if(szItemText.isEmpty())
return;
@@ -1622,7 +1646,8 @@ void OptionsWidget_servers::fillServerList()
for(KviIrcServer * s = sl->first();s;s = sl->next())
{
- srv = new IrcServerOptionsTreeWidgetItem(net,*(g_pIconManager->getSmallIcon(KviIconManager::Server)),s);
+ unsigned icon = s->favorite() ? KviIconManager::ServerFavorite : KviIconManager::Server;
+ srv = new IrcServerOptionsTreeWidgetItem(net,*(g_pIconManager->getSmallIcon(icon)),s);
if((s == r->currentServer()) && bCurrent)
{
srv->setSelected(true);
@@ -1661,6 +1686,7 @@ void OptionsWidget_servers::currentItemChanged(QTreeWidgetItem *it,QTreeWidgetIt
m_pRemoveButton->setEnabled(true);
m_pCopyServerButton->setEnabled(m_pLastEditedItem->m_pServerData);
+ m_pFavoriteServerButton->setEnabled(m_pLastEditedItem->m_pServerData);
if(m_pLastEditedItem->m_pServerData)
{
@@ -1673,6 +1699,7 @@ void OptionsWidget_servers::currentItemChanged(QTreeWidgetItem *it,QTreeWidgetIt
} else {
m_pRemoveButton->setEnabled(false);
m_pCopyServerButton->setEnabled(true);
+ m_pFavoriteServerButton->setEnabled(true);
if(m_pConnectCurrent)
m_pConnectCurrent->setEnabled(false);
@@ -1817,27 +1844,31 @@ void OptionsWidget_servers::commit()
void OptionsWidget_servers::customContextMenuRequested(const QPoint &pnt)
{
- QTreeWidgetItem *it=(QTreeWidgetItem *) m_pTreeWidget->itemAt(pnt);
- bool bServer = (it && ((IrcServerOptionsTreeWidgetItem *)it)->m_pServerData);
+ QTreeWidgetItem *it = static_cast<QTreeWidgetItem *>(m_pTreeWidget->itemAt(pnt));
+ bool bServer = (it && static_cast<IrcServerOptionsTreeWidgetItem *>(it)->m_pServerData);
+ bool bFavorite = (bServer && static_cast<IrcServerOptionsTreeWidgetItem *>(it)->m_pServerData->favorite());
m_pContextPopup->clear();
m_pContextPopup->addAction(*(g_pIconManager->getSmallIcon(KviIconManager::World)),__tr2qs_ctx("New Network","options"),this,SLOT(newNetwork()));
- m_pContextPopup->addAction(*(g_pIconManager->getSmallIcon(KviIconManager::Cut)),__tr2qs_ctx("Remove Network","options"),this,SLOT(removeCurrent()))
- ->setEnabled(!bServer);
- m_pContextPopup->addSeparator();
- m_pContextPopup->addAction(*(g_pIconManager->getSmallIcon(KviIconManager::Server)),__tr2qs_ctx("&New Server","options"),this,SLOT(newServer()));
- m_pContextPopup->addAction(*(g_pIconManager->getSmallIcon(KviIconManager::Cut)),__tr2qs_ctx("Re&move Server","options"),this,SLOT(removeCurrent()))
- ->setEnabled(bServer);
- m_pContextPopup->addAction(*(g_pIconManager->getSmallIcon(KviIconManager::Copy)),__tr2qs_ctx("&Copy Server","options"),this,SLOT(copyServer()));
- m_pContextPopup->setEnabled(bServer);
- m_pContextPopup->addAction(*(g_pIconManager->getSmallIcon(KviIconManager::Paste)),__tr2qs_ctx("&Paste Server","options"),this,SLOT(pasteServer()))
- ->setEnabled(m_pClipboard);
+ m_pContextPopup->addAction(*(g_pIconManager->getSmallIcon(KviIconManager::Cut)),__tr2qs_ctx("Remove Network","options"),this,SLOT(removeCurrent()))
+ ->setEnabled(!bServer);
+ m_pContextPopup->addSeparator();
+ m_pContextPopup->addAction(*(g_pIconManager->getSmallIcon(KviIconManager::Server)),__tr2qs_ctx("&New Server","options"),this,SLOT(newServer()));
+ m_pContextPopup->addAction(*(g_pIconManager->getSmallIcon(KviIconManager::Cut)),__tr2qs_ctx("Re&move Server","options"),this,SLOT(removeCurrent()))
+ ->setEnabled(bServer);
+ m_pContextPopup->addAction(*(g_pIconManager->getSmallIcon(KviIconManager::Copy)),__tr2qs_ctx("&Copy Server","options"),this,SLOT(copyServer()));
+ m_pContextPopup->setEnabled(bServer);
+ m_pContextPopup->addAction(*(g_pIconManager->getSmallIcon(KviIconManager::Paste)),__tr2qs_ctx("&Paste Server","options"),this,SLOT(pasteServer()))
+ ->setEnabled(m_pClipboard);
- m_pContextPopup->addSeparator();
- // m_pContextPopup->addAction(__c2q(__tr("Merge list from server.ini","options")),this,SLOT(importFromIni()));
+ m_pContextPopup->addSeparator();
m_pContextPopup->addAction(__tr2qs_ctx("Clear List","options"),this,SLOT(clearList()));
- m_pContextPopup->addSeparator();
- m_pContextPopup->addAction(__tr2qs_ctx("Import List","options"))->setMenu(m_pImportPopup);
+ m_pContextPopup->addSeparator();
+ m_pContextPopup->addAction(__tr2qs_ctx("Import List","options"))->setMenu(m_pImportPopup);
m_pContextPopup->popup(QCursor::pos());
+ m_pContextPopup->addSeparator();
+ m_pContextPopup->addAction(*(g_pIconManager->getSmallIcon(KviIconManager::ServerFavorite)),
+ __tr2qs_ctx(bFavorite?"Unfavorite Server":"Favorite Server","options"),this,SLOT(favoriteServer()));
+ m_pContextPopup->setEnabled(bServer);
}
void OptionsWidget_servers::importPopupAboutToShow()
@@ -1849,7 +1880,7 @@ void OptionsWidget_servers::importPopupAboutToShow()
if(!l)return;
- QAction *pAction;
+ QAction *pAction;
for(KviModuleExtensionDescriptor * d = l->first();d;d = l->next())
{
@@ -1884,10 +1915,10 @@ void OptionsWidget_servers::importPopupActivated(QAction *pAction)
m_pImportFilter = 0;
}
- bool bOk=false;
- int id = pAction->data().toInt(&bOk);
- if(!bOk)
- return;
+ bool bOk=false;
+ int id = pAction->data().toInt(&bOk);
+ if(!bOk)
+ return;
m_pImportFilter = (KviMexServerImport *)KviModuleExtensionManager::instance()->allocateExtension("serverimport",id,0);
@@ -1984,6 +2015,50 @@ void OptionsWidget_servers::newServer()
}
}
+void OptionsWidget_servers::favoriteServer()
+{
+ if(m_pLastEditedItem)
+ {
+ if(m_pLastEditedItem->m_pServerData->favorite())
+ m_pLastEditedItem->m_pServerData->setFavorite(false);
+ else
+ m_pLastEditedItem->m_pServerData->setFavorite(true);
+
+ unsigned icon = m_pLastEditedItem->m_pServerData->favorite() ? KviIconManager::ServerFavorite : KviIconManager::Server;
+ m_pLastEditedItem->setIcon(0,*(g_pIconManager->getSmallIcon(icon)));
+
+ if(m_bShowingFavoritesOnly)
+ updateFavoritesFilter(true);
+ }
+}
+
+void OptionsWidget_servers::updateFavoritesFilter(bool bSet)
+{
+ m_bShowingFavoritesOnly = bSet;
+ IrcServerOptionsTreeWidgetItem * network;
+ for(unsigned i = 0; i < m_pTreeWidget->topLevelItemCount(); i++)
+ {
+ network = static_cast<IrcServerOptionsTreeWidgetItem *>(m_pTreeWidget->topLevelItem(i));
+ uint uServers = 0;
+
+ IrcServerOptionsTreeWidgetItem * ch;
+ for (int j = 0; j < network->childCount(); j++)
+ {
+ bool bHidden = bSet ? true : false;
+ ch = static_cast<IrcServerOptionsTreeWidgetItem *>(network->child(j));
+ if(ch->m_pServerData && bSet)
+ {
+ if(ch->m_pServerData->favorite())
+ bHidden = false;
+ }
+ if(!bHidden)
+ uServers++;
+ ch->setHidden(bHidden);
+ }
+ network->setHidden(!uServers);
+ }
+}
+
void OptionsWidget_servers::copyServer()
{
if(m_pLastEditedItem)
diff --git a/src/modules/options/OptionsWidget_servers.h b/src/modules/options/OptionsWidget_servers.h
index 536175a90..ca330ac03 100644
--- a/src/modules/options/OptionsWidget_servers.h
+++ b/src/modules/options/OptionsWidget_servers.h
@@ -96,7 +96,7 @@ protected:
QCheckBox * m_pAutoConnectCheck;
- QTreeWidget * m_pNickServTreeWidget;
+ QTreeWidget * m_pNickServTreeWidget;
QCheckBox * m_pNickServCheck;
QPushButton * m_pAddRuleButton;
QPushButton * m_pDelRuleButton;
@@ -182,9 +182,9 @@ protected:
QLabel * m_pFilterLabel;
QLineEdit * m_pFilterEdit;
QPushButton * m_pDetailsButton;
- QMenu * m_pRecentPopup;
- QMenu * m_pContextPopup;
- QMenu * m_pImportPopup;
+ QMenu * m_pRecentPopup;
+ QMenu * m_pContextPopup;
+ QMenu * m_pImportPopup;
KviIrcServer * m_pClipboard;
QPushButton * m_pConnectCurrent;
QPushButton * m_pConnectNew;
@@ -193,13 +193,17 @@ protected:
IrcNetworkDetailsWidget * m_pNetworkDetailsDialog;
KviMexServerImport * m_pImportFilter;
KviBoolSelector * m_pShowThisDialogAtStartupSelector;
+ KviBoolSelector * m_pShowFavoritesOnly;
QToolButton * m_pNewServerButton;
QToolButton * m_pNewNetworkButton;
QToolButton * m_pRemoveButton;
+ QToolButton * m_pFavoriteServer;
QToolButton * m_pCopyServerButton;
QToolButton * m_pPasteServerButton;
QToolButton * m_pImportButton;
+ QToolButton * m_pFavoriteServerButton;
+ bool m_bShowingFavoritesOnly;
private:
void fillServerList();
void saveLastItem();
@@ -215,6 +219,9 @@ protected slots:
void newNetwork();
void removeCurrent();
void newServer();
+ void slotSetShowFavoritesOnly();
+ void updateFavoritesFilter(bool bSet);
+ void favoriteServer();
void copyServer();
void pasteServer();
void clearList();
diff --git a/src/modules/serverdb/libkviserverdb.cpp b/src/modules/serverdb/libkviserverdb.cpp
index f3fcbdb27..0bfd24f76 100644
--- a/src/modules/serverdb/libkviserverdb.cpp
+++ b/src/modules/serverdb/libkviserverdb.cpp
@@ -65,6 +65,7 @@ extern KVIRC_API KviIrcServerDataBase * g_pServerDataBase;
[cmd]serverdb.setServerJoinChannels[/cmd]: sets the server autojoin channels list[br]
[br]
It provides the following set of functions:[br]
+ [fnc]$serverdb.favorite[/fnc]: returns if the server is favorited or not[br]
[fnc]$serverdb.cacheIp[/fnc]: returns the cache-ip status for a server[br]
[fnc]$serverdb.networkConnectCommand[/fnc]: returns the "on connect" script for a network[br]
[fnc]$serverdb.networkDescription[/fnc]: returns the description for a network[br]
@@ -754,6 +755,21 @@ SERVERDB_GET_SERVER_PROPERTY(serverdb_kvs_fnc_serverSSL,useSSL,setBoolean)
SERVERDB_GET_SERVER_PROPERTY(serverdb_kvs_fnc_serverCacheIp,cacheIp,setBoolean)
/*
+ @doc: serverdb.favorite
+ @type:
+ function
+ @title:
+ $serverdb.favorite
+ @short:
+ Returns if the server is favorited
+ @syntax:
+ <bool> $serverdb.favorite(<network:string>,<server:string>)
+ @description:
+ Returns true if KVIrc has the server set to a favorite, false otherwise
+*/
+SERVERDB_GET_SERVER_PROPERTY(serverdb_kvs_fnc_serverFavorite,favorite,setBoolean)
+
+/*
@doc: serverdb.serverJoinChannels
@type:
function
@@ -860,6 +876,9 @@ static bool serverdb_kvs_cmd_addNetwork(KviKvsModuleCommandCall * c)
!sw: -c | --cache-ip
Caches the server IP at first connect to save bandwitch for future connects.[br]
+ !sw: -f | --favorite
+ Sets the server as a favorite.[br]
+
!sw: -i | --ipv6
Use IPv6 socket to connect to the server.[br]
@@ -924,6 +943,7 @@ static bool serverdb_kvs_cmd_addServer(KviKvsModuleCommandCall * c)
if(c->switches()->find('a',"autoconnect")) pServer->setAutoConnect(true);
if(c->switches()->find('c',"cache-ip")) pServer->setCacheIp(true);
+ if(c->switches()->find('f',"favorite")) pServer->setFavorite(true);
if(c->switches()->find('i',"ipv6")) pServer->setIPv6(true);
if(c->switches()->find('s',"ssl")) pServer->setUseSSL(true);
@@ -1471,6 +1491,7 @@ static bool serverdb_module_init(KviModule * m)
KVSM_REGISTER_SIMPLE_COMMAND(m,"updateList",serverdb_kvs_cmd_updateList);
*/
+ KVSM_REGISTER_FUNCTION(m,"favorite",serverdb_kvs_fnc_serverFavorite);
KVSM_REGISTER_FUNCTION(m,"cacheIp",serverdb_kvs_fnc_serverCacheIp);
KVSM_REGISTER_FUNCTION(m,"networkConnectCommand",serverdb_kvs_fnc_networkConnectCommand);
KVSM_REGISTER_FUNCTION(m,"networkDescription",serverdb_kvs_fnc_networkDescription);