Disable the highlights page when not connected
authorJanne Koschinski <janne@kuschku.de>
Thu, 21 Dec 2017 20:57:03 +0000 (21:57 +0100)
committerManuel Nickschas <sputnick@quassel-irc.org>
Wed, 28 Mar 2018 20:59:45 +0000 (22:59 +0200)
src/qtui/settingspages/corehighlightsettingspage.cpp
src/qtui/settingspages/corehighlightsettingspage.h

index fba21eb..d4be7cf 100644 (file)
@@ -37,6 +37,9 @@ CoreHighlightSettingsPage::CoreHighlightSettingsPage(QWidget *parent)
     ui.highlightNicksComboBox->addItem(tr("Current Nick"), QVariant(HighlightRuleManager::CurrentNick));
     ui.highlightNicksComboBox->addItem(tr("None"), QVariant(HighlightRuleManager::NoNick));
 
+    coreConnectionStateChanged(Client::isConnected()); // need a core connection!
+    connect(Client::instance(), SIGNAL(coreConnectionStateChanged(bool)), this, SLOT(coreConnectionStateChanged(bool)));
+
     connect(ui.highlightAdd, SIGNAL(clicked(bool)), this, SLOT(addNewHighlightRow()));
     connect(ui.highlightRemove, SIGNAL(clicked(bool)), this, SLOT(removeSelectedHighlightRows()));
 
@@ -76,6 +79,16 @@ CoreHighlightSettingsPage::CoreHighlightSettingsPage(QWidget *parent)
     connect(Client::instance(), SIGNAL(connected()), this, SLOT(clientConnected()));
 }
 
+void CoreHighlightSettingsPage::coreConnectionStateChanged(bool state)
+{
+    setEnabled(state);
+    if (state) {
+        load();
+    } else {
+        revert();
+    }
+}
+
 void CoreHighlightSettingsPage::setupRuleTable(QTableWidget *table) const
 {
     table->verticalHeader()->hide();
index 722bf00..fe0113f 100644 (file)
@@ -45,6 +45,7 @@ public slots:
     void clientConnected();
 
 private slots:
+    void coreConnectionStateChanged(bool state);
     void widgetHasChanged();
     void addNewHighlightRow(bool enable = true, const QString &name = tr("highlight rule"), bool regex = false,
                             bool cs = false, const QString &sender = "", const QString &chanName = "",