Only enable the relevant highlight depending on core features
authorJanne Koschinski <janne@kuschku.de>
Thu, 21 Dec 2017 21:18:11 +0000 (22:18 +0100)
committerManuel Nickschas <sputnick@quassel-irc.org>
Wed, 28 Mar 2018 21:05:37 +0000 (23:05 +0200)
- If connected to a modern core, disable local highlights
- Otherwise, disable remote highlights

src/qtui/settingsdlg.cpp
src/qtui/settingspages/corehighlightsettingspage.cpp
src/qtui/settingspages/corehighlightsettingspage.h
src/qtui/settingspages/highlightsettingspage.cpp
src/qtui/settingspages/highlightsettingspage.h
src/uisupport/settingspage.h

index 7d41346..82548b3 100644 (file)
@@ -81,7 +81,9 @@ void SettingsDlg::setItemState(QTreeWidgetItem *item)
 {
     SettingsPage *sp = qobject_cast<SettingsPage *>(item->data(0, SettingsPageRole).value<QObject *>());
     Q_ASSERT(sp);
-    item->setDisabled(!Client::isConnected() && sp->needsCoreConnection());
+    bool disabledDueToConnection = !Client::isConnected() && sp->needsCoreConnection();
+    bool disabledDueToOwnChoice = !sp->isSelectable();
+    item->setDisabled(disabledDueToConnection || disabledDueToOwnChoice);
 }
 
 
index d8eaa9f..3a6d6eb 100644 (file)
@@ -26,7 +26,7 @@
 #include "qtui.h"
 
 CoreHighlightSettingsPage::CoreHighlightSettingsPage(QWidget *parent)
-    : SettingsPage(tr("Interface"), tr("Core-Side Highlights"), parent)
+    : SettingsPage(tr("Interface"), tr("Remote Highlights"), parent)
 {
     ui.setupUi(this);
 
@@ -496,3 +496,7 @@ void CoreHighlightSettingsPage::importRules() {
     setChangedState(false);
     load();
 }
+
+bool CoreHighlightSettingsPage::isSelectable() const {
+    return Client::isConnected() && Client::isCoreFeatureEnabled(Quassel::Feature::CoreSideHighlights);
+}
index bd4dd46..637c3ba 100644 (file)
@@ -37,6 +37,8 @@ public:
 
     bool hasDefaults() const override;
 
+    bool isSelectable() const override;
+
 public slots:
     void save() override;
     void load() override;
index 57bd526..cb84b9f 100644 (file)
 
 #include "highlightsettingspage.h"
 
+#include "client.h"
 #include "qtui.h"
 #include "uisettings.h"
 
 #include <QHeaderView>
 
 HighlightSettingsPage::HighlightSettingsPage(QWidget *parent)
-    : SettingsPage(tr("Interface"), tr("Highlight"), parent)
+    : SettingsPage(tr("Interface"), tr("Local Highlights"), parent)
 {
     ui.setupUi(this);
     ui.highlightTable->verticalHeader()->hide();
@@ -292,3 +293,7 @@ bool HighlightSettingsPage::testHasChanged()
 
     return false;
 }
+
+bool HighlightSettingsPage::isSelectable() const {
+    return !Client::isConnected() || !Client::isCoreFeatureEnabled(Quassel::Feature::CoreSideHighlights);
+}
index 563074c..87ff64b 100644 (file)
@@ -36,6 +36,8 @@ public:
 
     bool hasDefaults() const;
 
+    bool isSelectable() const override;
+
 public slots:
     void save();
     void load();
index c3c9a60..c158c6b 100644 (file)
@@ -74,6 +74,13 @@ public:
      */
     inline virtual bool needsCoreConnection() const { return false; }
 
+    /**
+     * Whether the settingspage should be selectable or not, in a given situation
+     * Used for pages that should only be visible if certain features are available (or not).
+     * @return
+     */
+    inline virtual bool isSelectable() const { return true; }
+
     //! The key this settings page stores its values under
     /** This needs to be overriden to enable automatic loading/saving/hasChanged checking of widgets.
      *  The child widgets' values will be stored in client settings under this key. Every widget that