Add a Configure menu item to Networks in the buffer list
authorgenius3000 <genius3000@g3k.solutions>
Wed, 23 Nov 2016 09:04:46 +0000 (02:04 -0700)
committerManuel Nickschas <sputnick@quassel-irc.org>
Wed, 6 Jun 2018 17:11:14 +0000 (19:11 +0200)
Add 'Configure' above 'Disconnect' in the right-click menu from a
network in the buffer list. Clicking 'Configure' will open the
Configure Networks dialog to the selected network.
Fixes #607

src/qtui/mainwin.cpp
src/qtui/mainwin.h
src/qtui/settingspages/networkssettingspage.cpp
src/qtui/settingspages/networkssettingspage.h
src/uisupport/contextmenuactionprovider.cpp
src/uisupport/networkmodelcontroller.cpp
src/uisupport/networkmodelcontroller.h

index 1db5f89..14644fb 100644 (file)
@@ -204,6 +204,7 @@ void MainWin::init()
         SLOT(messagesInserted(const QModelIndex &, int, int)));
     connect(GraphicalUi::contextMenuActionProvider(), SIGNAL(showChannelList(NetworkId)), SLOT(showChannelList(NetworkId)));
     connect(Client::instance(), SIGNAL(showChannelList(NetworkId)), SLOT(showChannelList(NetworkId)));
         SLOT(messagesInserted(const QModelIndex &, int, int)));
     connect(GraphicalUi::contextMenuActionProvider(), SIGNAL(showChannelList(NetworkId)), SLOT(showChannelList(NetworkId)));
     connect(Client::instance(), SIGNAL(showChannelList(NetworkId)), SLOT(showChannelList(NetworkId)));
+    connect(GraphicalUi::contextMenuActionProvider(), SIGNAL(showNetworkConfig(NetworkId)), SLOT(showNetworkConfig(NetworkId)));
     connect(GraphicalUi::contextMenuActionProvider(), SIGNAL(showIgnoreList(QString)), SLOT(showIgnoreList(QString)));
     connect(Client::instance(), SIGNAL(showIgnoreList(QString)), SLOT(showIgnoreList(QString)));
 
     connect(GraphicalUi::contextMenuActionProvider(), SIGNAL(showIgnoreList(QString)), SLOT(showIgnoreList(QString)));
     connect(Client::instance(), SIGNAL(showIgnoreList(QString)), SLOT(showIgnoreList(QString)));
 
@@ -1414,6 +1415,15 @@ void MainWin::showChannelList(NetworkId netId)
 }
 
 
 }
 
 
+void MainWin::showNetworkConfig(NetworkId netId)
+{
+    SettingsPageDlg dlg(new NetworksSettingsPage(this), this);
+    if (netId.isValid())
+        qobject_cast<NetworksSettingsPage *>(dlg.currentPage())->bufferList_Open(netId);
+    dlg.exec();
+}
+
+
 void MainWin::showIgnoreList(QString newRule)
 {
     SettingsPageDlg dlg(new IgnoreListSettingsPage(this), this);
 void MainWin::showIgnoreList(QString newRule)
 {
     SettingsPageDlg dlg(new IgnoreListSettingsPage(this), this);
index d27b892..431a308 100644 (file)
@@ -119,6 +119,7 @@ private slots:
     void messagesInserted(const QModelIndex &parent, int start, int end);
     void showAboutDlg();
     void showChannelList(NetworkId netId = NetworkId());
     void messagesInserted(const QModelIndex &parent, int start, int end);
     void showAboutDlg();
     void showChannelList(NetworkId netId = NetworkId());
+    void showNetworkConfig(NetworkId netId = NetworkId());
     void showCoreConnectionDlg();
     void showCoreConfigWizard(const QVariantList &, const QVariantList &);
     void showCoreInfoDlg();
     void showCoreConnectionDlg();
     void showCoreConfigWizard(const QVariantList &, const QVariantList &);
     void showCoreInfoDlg();
index bcc8811..f0aeac1 100644 (file)
@@ -567,6 +567,14 @@ QListWidgetItem *NetworksSettingsPage::insertNetwork(const NetworkInfo &info)
 }
 
 
 }
 
 
+// Called when selecting 'Configure' from the buffer list
+void NetworksSettingsPage::bufferList_Open(NetworkId netId)
+{
+    QListWidgetItem *item = networkItem(netId);
+    ui.networkList->setCurrentItem(item, QItemSelectionModel::SelectCurrent);
+}
+
+
 void NetworksSettingsPage::displayNetwork(NetworkId id)
 {
     _ignoreWidgetChanges = true;
 void NetworksSettingsPage::displayNetwork(NetworkId id)
 {
     _ignoreWidgetChanges = true;
index 52d4277..3ce0190 100644 (file)
@@ -47,6 +47,7 @@ public:
 public slots:
     void save();
     void load();
 public slots:
     void save();
     void load();
+    void bufferList_Open(NetworkId);
 
 private slots:
     void widgetHasChanged();
 
 private slots:
     void widgetHasChanged();
index 608a611..8a0ca82 100644 (file)
@@ -90,6 +90,7 @@ ContextMenuActionProvider::ContextMenuActionProvider(QObject *parent) : NetworkM
     registerAction(HideBufferTemporarily, tr("Hide Chat(s) Temporarily"));
     registerAction(HideBufferPermanently, tr("Hide Chat(s) Permanently"));
     registerAction(ShowChannelList, tr("Show Channel List"));
     registerAction(HideBufferTemporarily, tr("Hide Chat(s) Temporarily"));
     registerAction(HideBufferPermanently, tr("Hide Chat(s) Permanently"));
     registerAction(ShowChannelList, tr("Show Channel List"));
+    registerAction(ShowNetworkConfig, tr("Configure"));
     registerAction(ShowIgnoreList, tr("Show Ignore List"));
 
     QMenu *hideEventsMenu = new QMenu();
     registerAction(ShowIgnoreList, tr("Show Ignore List"));
 
     QMenu *hideEventsMenu = new QMenu();
@@ -285,6 +286,8 @@ void ContextMenuActionProvider::addNetworkItemActions(QMenu *menu, const QModelI
     if (!network)
         return;
 
     if (!network)
         return;
 
+    addAction(ShowNetworkConfig, menu, index);
+    menu->addSeparator();
     addAction(NetworkConnect, menu, network->connectionState() == Network::Disconnected);
     addAction(NetworkDisconnect, menu, network->connectionState() != Network::Disconnected);
     menu->addSeparator();
     addAction(NetworkConnect, menu, network->connectionState() == Network::Disconnected);
     addAction(NetworkDisconnect, menu, network->connectionState() != Network::Disconnected);
     menu->addSeparator();
index 16243ef..10807d9 100644 (file)
@@ -414,6 +414,10 @@ void NetworkModelController::handleGeneralAction(ActionType type, QAction *actio
         if (networkId.isValid())
             emit showChannelList(networkId);
         break;
         if (networkId.isValid())
             emit showChannelList(networkId);
         break;
+    case ShowNetworkConfig:
+        if (networkId.isValid())
+            emit showNetworkConfig(networkId);
+        break;
     case ShowIgnoreList:
         if (networkId.isValid())
             emit showIgnoreList(QString());
     case ShowIgnoreList:
         if (networkId.isValid())
             emit showIgnoreList(QString());
index 0885a4a..73ceabb 100644 (file)
@@ -75,6 +75,7 @@ public:
         JoinChannel = 0x1000,
         ShowChannelList = 0x2000,
         ShowIgnoreList = 0x3000,
         JoinChannel = 0x1000,
         ShowChannelList = 0x2000,
         ShowIgnoreList = 0x3000,
+        ShowNetworkConfig = 0x4000,
 
         // Nick actions
         NickMask = 0xff0000,
 
         // Nick actions
         NickMask = 0xff0000,
@@ -154,6 +155,7 @@ protected slots:
 
 signals:
     void showChannelList(NetworkId);
 
 signals:
     void showChannelList(NetworkId);
+    void showNetworkConfig(NetworkId);
     void showIgnoreList(QString);
 
 protected:
     void showIgnoreList(QString);
 
 protected: