client: Show when Remote Highlights unsupported
authorShane Synan <digitalcircuit36939@gmail.com>
Fri, 2 Mar 2018 16:20:12 +0000 (10:20 -0600)
committerManuel Nickschas <sputnick@quassel-irc.org>
Wed, 6 Jun 2018 17:15:14 +0000 (19:15 +0200)
Add a header to "Remote Highlights" page to warn when the Quassel
core is too old to support core-side highlights, including a
"Details..." to explain the purpose and what version is required.
Core connection is still required to make the UI selectable,
following the convention set by other panels.

This should help avoid people asking about "Remote Highlights" when
their core is too old.

Wrap the rest of the settings page in a widget to simplify enabling
and disabling all of it.

src/qtui/settingspages/corehighlightsettingspage.cpp
src/qtui/settingspages/corehighlightsettingspage.h
src/qtui/settingspages/corehighlightsettingspage.ui

index 55266d0..644a902 100644 (file)
@@ -19,6 +19,7 @@
  ***************************************************************************/
 
 #include <QHeaderView>
  ***************************************************************************/
 
 #include <QHeaderView>
+#include <QMessageBox>
 #include <QTableWidget>
 
 #include "client.h"
 #include <QTableWidget>
 
 #include "client.h"
@@ -83,10 +84,14 @@ CoreHighlightSettingsPage::CoreHighlightSettingsPage(QWidget *parent)
             SLOT(ignoredTableChanged(QTableWidgetItem * )));
 
     connect(Client::instance(), SIGNAL(connected()), this, SLOT(clientConnected()));
             SLOT(ignoredTableChanged(QTableWidgetItem * )));
 
     connect(Client::instance(), SIGNAL(connected()), this, SLOT(clientConnected()));
+
+    // Warning icon
+    ui.coreUnsupportedIcon->setPixmap(QIcon::fromTheme("dialog-warning").pixmap(16));
 }
 
 void CoreHighlightSettingsPage::coreConnectionStateChanged(bool state)
 {
 }
 
 void CoreHighlightSettingsPage::coreConnectionStateChanged(bool state)
 {
+    updateCoreSupportStatus(state);
     setEnabled(state);
     if (state) {
         load();
     setEnabled(state);
     if (state) {
         load();
@@ -142,6 +147,21 @@ void CoreHighlightSettingsPage::setupRuleTable(QTableWidget *table) const
 #endif
 }
 
 #endif
 }
 
+void CoreHighlightSettingsPage::updateCoreSupportStatus(bool state)
+{
+    // Assume connected state as enforced by the settings page UI
+    if (!state || Client::isCoreFeatureEnabled(Quassel::Feature::CoreSideHighlights)) {
+        // Either disconnected or core supports highlights, enable highlight configuration and hide
+        // warning.  Don't show the warning needlessly when disconnected.
+        ui.highlightsConfigWidget->setEnabled(true);
+        ui.coreUnsupportedWidget->setVisible(false);
+    } else {
+        // Core does not support highlights, show warning and disable highlight configuration
+        ui.highlightsConfigWidget->setEnabled(false);
+        ui.coreUnsupportedWidget->setVisible(true);
+    }
+}
+
 void CoreHighlightSettingsPage::clientConnected()
 {
     connect(Client::highlightRuleManager(), SIGNAL(updated()), SLOT(revert()));
 void CoreHighlightSettingsPage::clientConnected()
 {
     connect(Client::highlightRuleManager(), SIGNAL(updated()), SLOT(revert()));
@@ -549,6 +569,25 @@ void CoreHighlightSettingsPage::widgetHasChanged()
     setChangedState(true);
 }
 
     setChangedState(true);
 }
 
+void CoreHighlightSettingsPage::on_coreUnsupportedDetails_clicked()
+{
+    // Re-use translations of "Local Highlights" as this is a word-for-word reference, forcing all
+    // spaces to non-breaking
+    const QString localHighlightsName = tr("Local Highlights").replace(" ", "&nbsp;");
+
+    const QString remoteHighlightsMsgText =
+            QString("<p><b>%1</b></p></br><p>%2</p></br><p>%3</p>"
+                    ).arg(tr("Your Quassel core is too old to support remote highlights"),
+                          tr("You need a Quassel core v0.13.0 or newer to configure remote "
+                             "highlights."),
+                          tr("You can still configure highlights for this device only in "
+                             "<i>%1</i>.").arg(localHighlightsName));
+
+    QMessageBox::warning(this,
+                         tr("Remote Highlights unsupported"),
+                         remoteHighlightsMsgText);
+}
+
 void CoreHighlightSettingsPage::importRules() {
     NotificationSettings notificationSettings;
 
 void CoreHighlightSettingsPage::importRules() {
     NotificationSettings notificationSettings;
 
@@ -575,5 +614,7 @@ void CoreHighlightSettingsPage::importRules() {
 }
 
 bool CoreHighlightSettingsPage::isSelectable() const {
 }
 
 bool CoreHighlightSettingsPage::isSelectable() const {
-    return Client::isConnected() && Client::isCoreFeatureEnabled(Quassel::Feature::CoreSideHighlights);
+    return Client::isConnected();
+    // We check for Quassel::Feature::CoreSideHighlights when loading this page, allowing us to show
+    // a friendly error message.
 }
 }
index 5859d00..1a0ea71 100644 (file)
@@ -68,6 +68,11 @@ private slots:
      */
     void importRules();
 
      */
     void importRules();
 
+    /**
+     * Event handler for core unspported Details button
+     */
+    void on_coreUnsupportedDetails_clicked();
+
 private:
     Ui::CoreHighlightSettingsPage ui;
 
 private:
     Ui::CoreHighlightSettingsPage ui;
 
@@ -89,5 +94,14 @@ private:
 
     void setupRuleTable(QTableWidget *highlightTable) const;
 
 
     void setupRuleTable(QTableWidget *highlightTable) const;
 
+    /** Update the UI to show core support for highlights
+     *
+     * Shows or hides the UI warnings around core-side highlights according to core connection and
+     * core feature support.
+     *
+     * @param state  True if connected to core, otherwise false
+     */
+    void updateCoreSupportStatus(bool state);
+
     bool _initialized;
 };
     bool _initialized;
 };
index 1c102bf..19dae1e 100644 (file)
   </property>
   <layout class="QVBoxLayout">
    <item>
   </property>
   <layout class="QVBoxLayout">
    <item>
-    <widget class="QTabWidget" name="tabWidget">
-     <property name="currentIndex">
+    <widget class="QFrame" name="coreUnsupportedWidget">
+     <property name="frameShape">
+      <enum>QFrame::NoFrame</enum>
+     </property>
+     <property name="frameShadow">
+      <enum>QFrame::Plain</enum>
+     </property>
+     <property name="lineWidth">
       <number>0</number>
      </property>
       <number>0</number>
      </property>
-     <widget class="QWidget" name="highlightTab">
-      <attribute name="title">
-       <string>Highlight Rules</string>
-      </attribute>
-      <layout class="QVBoxLayout" name="verticalLayout_3">
-       <item>
-        <widget class="QGroupBox" name="nickBox">
-         <property name="title">
-          <string>Highlight Nicks</string>
-         </property>
-         <layout class="QHBoxLayout" name="horizontalLayout">
+     <layout class="QHBoxLayout">
+      <property name="leftMargin">
+       <number>0</number>
+      </property>
+      <property name="topMargin">
+       <number>0</number>
+      </property>
+      <property name="rightMargin">
+       <number>0</number>
+      </property>
+      <property name="bottomMargin">
+       <number>0</number>
+      </property>
+      <item>
+       <widget class="QLabel" name="coreUnsupportedIcon">
+        <property name="text">
+         <string notr="true">[icon]</string>
+        </property>
+       </widget>
+      </item>
+      <item>
+       <widget class="QLabel" name="coreUnsupportedLabel">
+        <property name="sizePolicy">
+         <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
+          <horstretch>0</horstretch>
+          <verstretch>0</verstretch>
+         </sizepolicy>
+        </property>
+        <property name="text">
+         <string>Your Quassel core is too old to support remote highlights</string>
+        </property>
+       </widget>
+      </item>
+      <item>
+       <widget class="QPushButton" name="coreUnsupportedDetails">
+        <property name="text">
+         <string>Details...</string>
+        </property>
+       </widget>
+      </item>
+     </layout>
+    </widget>
+   </item>
+   <item>
+    <widget class="QWidget" name="highlightsConfigWidget" native="true">
+     <layout class="QVBoxLayout" name="highlightConfigLayout">
+     <property name="leftMargin">
+       <number>0</number>
+      </property>
+      <property name="topMargin">
+       <number>0</number>
+      </property>
+      <property name="rightMargin">
+       <number>0</number>
+      </property>
+      <property name="bottomMargin">
+       <number>0</number>
+      </property>
+      <item>
+       <widget class="QTabWidget" name="tabWidget">
+        <property name="currentIndex">
+         <number>0</number>
+        </property>
+        <widget class="QWidget" name="highlightTab">
+         <attribute name="title">
+          <string>Highlight Rules</string>
+         </attribute>
+         <layout class="QVBoxLayout" name="verticalLayout_3">
           <item>
           <item>
-           <widget class="QComboBox" name="highlightNicksComboBox">
-            <property name="sizePolicy">
-             <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
-              <horstretch>0</horstretch>
-              <verstretch>0</verstretch>
-             </sizepolicy>
-            </property>
-            <property name="minimumSize">
-             <size>
-              <width>0</width>
-              <height>0</height>
-             </size>
-            </property>
-            <property name="currentIndex">
-             <number>-1</number>
-            </property>
-            <property name="sizeAdjustPolicy">
-             <enum>QComboBox::AdjustToContents</enum>
+           <widget class="QGroupBox" name="nickBox">
+            <property name="title">
+             <string>Highlight Nicks</string>
             </property>
             </property>
+            <layout class="QHBoxLayout" name="horizontalLayout">
+             <item>
+              <widget class="QComboBox" name="highlightNicksComboBox">
+               <property name="sizePolicy">
+                <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+                 <horstretch>0</horstretch>
+                 <verstretch>0</verstretch>
+                </sizepolicy>
+               </property>
+               <property name="minimumSize">
+                <size>
+                 <width>0</width>
+                 <height>0</height>
+                </size>
+               </property>
+               <property name="currentIndex">
+                <number>-1</number>
+               </property>
+               <property name="sizeAdjustPolicy">
+                <enum>QComboBox::AdjustToContents</enum>
+               </property>
+              </widget>
+             </item>
+             <item>
+              <widget class="QCheckBox" name="nicksCaseSensitive">
+               <property name="text">
+                <string>Case sensitive</string>
+               </property>
+               <property name="checked">
+                <bool>true</bool>
+               </property>
+              </widget>
+             </item>
+             <item>
+              <spacer name="horizontalSpacer">
+               <property name="orientation">
+                <enum>Qt::Horizontal</enum>
+               </property>
+               <property name="sizeHint" stdset="0">
+                <size>
+                 <width>40</width>
+                 <height>20</height>
+                </size>
+               </property>
+              </spacer>
+             </item>
+            </layout>
            </widget>
           </item>
           <item>
            </widget>
           </item>
           <item>
-           <widget class="QCheckBox" name="nicksCaseSensitive">
-            <property name="text">
-             <string>Case sensitive</string>
-            </property>
-            <property name="checked">
-             <bool>true</bool>
+           <widget class="QGroupBox" name="rulesBox">
+            <property name="title">
+             <string>Custom Highlights</string>
             </property>
             </property>
+            <layout class="QVBoxLayout" name="highlightLayout">
+             <item>
+              <widget class="QTableWidget" name="highlightTable">
+               <property name="toolTip">
+                <string/>
+               </property>
+               <property name="styleSheet">
+                <string notr="true"/>
+               </property>
+               <column>
+                <property name="text">
+                 <string>Enabled</string>
+                </property>
+               </column>
+               <column>
+                <property name="text">
+                 <string>Rule</string>
+                </property>
+               </column>
+               <column>
+                <property name="text">
+                 <string>RegEx</string>
+                </property>
+               </column>
+               <column>
+                <property name="text">
+                 <string>CS</string>
+                </property>
+               </column>
+               <column>
+                <property name="text">
+                 <string>Sender</string>
+                </property>
+               </column>
+               <column>
+                <property name="text">
+                 <string>Channel</string>
+                </property>
+               </column>
+              </widget>
+             </item>
+             <item>
+              <layout class="QHBoxLayout" name="highlightButtonBarLayout">
+               <property name="topMargin">
+                <number>0</number>
+               </property>
+               <property name="bottomMargin">
+                <number>0</number>
+               </property>
+               <item>
+                <widget class="QPushButton" name="highlightAdd">
+                 <property name="text">
+                  <string>Add</string>
+                 </property>
+                </widget>
+               </item>
+               <item>
+                <widget class="QPushButton" name="highlightRemove">
+                 <property name="text">
+                  <string>Remove</string>
+                 </property>
+                </widget>
+               </item>
+               <item>
+                <spacer name="highlightButtonBarSpacer">
+                 <property name="orientation">
+                  <enum>Qt::Horizontal</enum>
+                 </property>
+                 <property name="sizeHint" stdset="0">
+                  <size>
+                   <width>40</width>
+                   <height>20</height>
+                  </size>
+                 </property>
+                </spacer>
+               </item>
+               <item>
+                <widget class="QPushButton" name="highlightImport">
+                 <property name="toolTip">
+                  <string>Import highlight rules configured in &lt;i&gt;Local Highlights&lt;/i&gt;</string>
+                 </property>
+                 <property name="text">
+                  <string>Import Local</string>
+                 </property>
+                </widget>
+               </item>
+              </layout>
+             </item>
+            </layout>
            </widget>
           </item>
            </widget>
           </item>
-          <item>
-           <spacer name="horizontalSpacer">
-            <property name="orientation">
-             <enum>Qt::Horizontal</enum>
-            </property>
-            <property name="sizeHint" stdset="0">
-             <size>
-              <width>40</width>
-              <height>20</height>
-             </size>
-            </property>
-           </spacer>
-          </item>
          </layout>
         </widget>
          </layout>
         </widget>
-       </item>
-       <item>
-        <widget class="QGroupBox" name="rulesBox">
-         <property name="title">
-          <string>Custom Highlights</string>
-         </property>
-         <layout class="QVBoxLayout" name="highlightLayout">
+        <widget class="QWidget" name="ignoredTab">
+         <attribute name="title">
+          <string>Highlight Ignore Rules</string>
+         </attribute>
+         <layout class="QVBoxLayout" name="verticalLayout_4">
           <item>
           <item>
-           <widget class="QTableWidget" name="highlightTable">
-            <property name="toolTip">
-             <string/>
-            </property>
-            <property name="styleSheet">
-             <string notr="true"/>
+           <widget class="QGroupBox" name="ignoresBox">
+            <property name="title">
+             <string>Never Highlight For</string>
             </property>
             </property>
-            <column>
-             <property name="text">
-              <string>Enabled</string>
-             </property>
-            </column>
-            <column>
-             <property name="text">
-              <string>Rule</string>
-             </property>
-            </column>
-            <column>
-             <property name="text">
-              <string>RegEx</string>
-             </property>
-            </column>
-            <column>
-             <property name="text">
-              <string>CS</string>
-             </property>
-            </column>
-            <column>
-             <property name="text">
-              <string>Sender</string>
-             </property>
-            </column>
-            <column>
-             <property name="text">
-              <string>Channel</string>
-             </property>
-            </column>
+            <layout class="QVBoxLayout" name="ignoredLayout">
+             <item>
+              <widget class="QTableWidget" name="ignoredTable">
+               <property name="toolTip">
+                <string/>
+               </property>
+               <property name="styleSheet">
+                <string notr="true"/>
+               </property>
+               <column>
+                <property name="text">
+                 <string>Enabled</string>
+                </property>
+               </column>
+               <column>
+                <property name="text">
+                 <string>Rule</string>
+                </property>
+               </column>
+               <column>
+                <property name="text">
+                 <string>RegEx</string>
+                </property>
+               </column>
+               <column>
+                <property name="text">
+                 <string>CS</string>
+                </property>
+               </column>
+               <column>
+                <property name="text">
+                 <string>Sender</string>
+                </property>
+               </column>
+               <column>
+                <property name="text">
+                 <string>Channel</string>
+                </property>
+               </column>
+              </widget>
+             </item>
+             <item>
+              <layout class="QHBoxLayout" name="ignoredButtonBarLayout">
+               <property name="topMargin">
+                <number>0</number>
+               </property>
+               <property name="bottomMargin">
+                <number>0</number>
+               </property>
+               <item>
+                <widget class="QPushButton" name="ignoredAdd">
+                 <property name="text">
+                  <string>Add</string>
+                 </property>
+                </widget>
+               </item>
+               <item>
+                <widget class="QPushButton" name="ignoredRemove">
+                 <property name="text">
+                  <string>Remove</string>
+                 </property>
+                </widget>
+               </item>
+               <item>
+                <spacer name="ignoredButtonBarSpacer">
+                 <property name="orientation">
+                  <enum>Qt::Horizontal</enum>
+                 </property>
+                 <property name="sizeHint" stdset="0">
+                  <size>
+                   <width>40</width>
+                   <height>20</height>
+                  </size>
+                 </property>
+                </spacer>
+               </item>
+              </layout>
+             </item>
+            </layout>
            </widget>
           </item>
            </widget>
           </item>
-          <item>
-           <layout class="QHBoxLayout" name="highlightButtonBarLayout">
-            <property name="topMargin">
-             <number>0</number>
-            </property>
-            <property name="bottomMargin">
-             <number>0</number>
-            </property>
-            <item>
-             <widget class="QPushButton" name="highlightAdd">
-              <property name="text">
-               <string>Add</string>
-              </property>
-             </widget>
-            </item>
-            <item>
-             <widget class="QPushButton" name="highlightRemove">
-              <property name="text">
-               <string>Remove</string>
-              </property>
-             </widget>
-            </item>
-            <item>
-             <spacer name="highlightButtonBarSpacer">
-              <property name="orientation">
-               <enum>Qt::Horizontal</enum>
-              </property>
-              <property name="sizeHint" stdset="0">
-               <size>
-                <width>40</width>
-                <height>20</height>
-               </size>
-              </property>
-             </spacer>
-            </item>
-            <item>
-             <widget class="QPushButton" name="highlightImport">
-              <property name="toolTip">
-               <string>Import highlight rules configured in &lt;i&gt;Local Highlights&lt;/i&gt;</string>
-              </property>
-              <property name="text">
-               <string>Import Local</string>
-              </property>
-             </widget>
-            </item>
-           </layout>
-          </item>
-         </layout>
-        </widget>
-       </item>
-      </layout>
-     </widget>
-     <widget class="QWidget" name="ignoredTab">
-      <attribute name="title">
-       <string>Highlight Ignore Rules</string>
-      </attribute>
-      <layout class="QVBoxLayout" name="verticalLayout_4">
-       <item>
-        <widget class="QGroupBox" name="ignoresBox">
-         <property name="title">
-          <string>Never Highlight For</string>
-         </property>
-         <layout class="QVBoxLayout" name="ignoredLayout">
-          <item>
-           <widget class="QTableWidget" name="ignoredTable">
-            <property name="toolTip">
-             <string/>
-            </property>
-            <property name="styleSheet">
-             <string notr="true"/>
-            </property>
-            <column>
-             <property name="text">
-              <string>Enabled</string>
-             </property>
-            </column>
-            <column>
-             <property name="text">
-              <string>Rule</string>
-             </property>
-            </column>
-            <column>
-             <property name="text">
-              <string>RegEx</string>
-             </property>
-            </column>
-            <column>
-             <property name="text">
-              <string>CS</string>
-             </property>
-            </column>
-            <column>
-             <property name="text">
-              <string>Sender</string>
-             </property>
-            </column>
-            <column>
-             <property name="text">
-              <string>Channel</string>
-             </property>
-            </column>
-           </widget>
-          </item>
-          <item>
-           <layout class="QHBoxLayout" name="ignoredButtonBarLayout">
-            <property name="topMargin">
-             <number>0</number>
-            </property>
-            <property name="bottomMargin">
-             <number>0</number>
-            </property>
-            <item>
-             <widget class="QPushButton" name="ignoredAdd">
-              <property name="text">
-               <string>Add</string>
-              </property>
-             </widget>
-            </item>
-            <item>
-             <widget class="QPushButton" name="ignoredRemove">
-              <property name="text">
-               <string>Remove</string>
-              </property>
-             </widget>
-            </item>
-            <item>
-             <spacer name="ignoredButtonBarSpacer">
-              <property name="orientation">
-               <enum>Qt::Horizontal</enum>
-              </property>
-              <property name="sizeHint" stdset="0">
-               <size>
-                <width>40</width>
-                <height>20</height>
-               </size>
-              </property>
-             </spacer>
-            </item>
-           </layout>
-          </item>
          </layout>
         </widget>
          </layout>
         </widget>
-       </item>
-      </layout>
-     </widget>
+       </widget>
+      </item>
+     </layout>
     </widget>
    </item>
   </layout>
     </widget>
    </item>
   </layout>