client: Deprecate local highlight, migrate cleanup
authorShane Synan <digitalcircuit36939@gmail.com>
Sat, 20 Jun 2020 03:04:59 +0000 (23:04 -0400)
committerManuel Nickschas <sputnick@quassel-irc.org>
Sat, 3 Oct 2020 16:13:31 +0000 (18:13 +0200)
Deprecate "Local Highlights" for client and core setups, adapting the
name "Legacy Highlights" as used with monolithic installs.  Make the
legacy nature more prominent, but keep support enabled.  In the
future, legacy highlights should be disabled and invisible except when
connected to older cores.

Rename "Remote Highlights" to "Highlights" and place first in the
settings list.

When using the "Import Legacy" button, migrate nickname highlight
settings and offer to remove the old local highlight rules, avoiding
redundant highlight rules.

This should help reduce the cases where Highlight Ignore Rules are
configured, but don't seem to respond due to client highlights
overriding the core-side highlight ignore rules.

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

index 019216f..84246b8 100644 (file)
@@ -1527,8 +1527,15 @@ void MainWin::showSettingsDlg()
 #ifdef HAVE_SONNET
     dlg->registerSettingsPage(new SonnetSettingsPage(dlg));
 #endif
-    dlg->registerSettingsPage(new HighlightSettingsPage(dlg));
-    dlg->registerSettingsPage(new CoreHighlightSettingsPage(dlg));
+    auto coreHighlightsPage = new CoreHighlightSettingsPage(dlg);
+    auto localHighlightsPage = new HighlightSettingsPage(dlg);
+    // Let CoreHighlightSettingsPage reload HighlightSettingsPage after doing an import with
+    // cleaning up.  Otherwise, HighlightSettingsPage won't show that the local rules were deleted.
+    connect(coreHighlightsPage, &CoreHighlightSettingsPage::localHighlightsChanged,
+            localHighlightsPage, &HighlightSettingsPage::load);
+    // Put core-side highlights before local/legacy highlights
+    dlg->registerSettingsPage(coreHighlightsPage);
+    dlg->registerSettingsPage(localHighlightsPage);
     dlg->registerSettingsPage(new NotificationsSettingsPage(dlg));
     dlg->registerSettingsPage(new BacklogSettingsPage(dlg));
 
index 5a53b4a..b79e3e3 100644 (file)
@@ -32,9 +32,7 @@
 #include "util.h"
 
 CoreHighlightSettingsPage::CoreHighlightSettingsPage(QWidget* parent)
-    : SettingsPage(tr("Interface"),
-                   // In Monolithic mode, local highlights are replaced by remote highlights
-                   Quassel::runMode() == Quassel::Monolithic ? tr("Highlights") : tr("Remote Highlights"),
+    : SettingsPage(tr("Interface"), tr("Highlights"),
                    parent)
 {
     ui.setupUi(this);
@@ -84,22 +82,12 @@ CoreHighlightSettingsPage::CoreHighlightSettingsPage(QWidget* parent)
     ui.coreUnsupportedIcon->setPixmap(icon::get("dialog-warning").pixmap(16));
 
     // Set up client/monolithic remote highlights information
-    if (Quassel::runMode() == Quassel::Monolithic) {
-        // We're running in Monolithic mode, local highlights are considered legacy
-        ui.highlightImport->setText(tr("Import Legacy"));
-        ui.highlightImport->setToolTip(
-            tr("Import highlight rules configured in <i>%1</i>.").arg(tr("Legacy Highlights").replace(" ", "&nbsp;")));
-        // Re-use translations of "Legacy Highlights" as this is a word-for-word reference, forcing
-        // all spaces to be non-breaking
-    }
-    else {
-        // We're running in client/split mode, local highlights are distinguished from remote
-        ui.highlightImport->setText(tr("Import Local"));
-        ui.highlightImport->setToolTip(
-            tr("Import highlight rules configured in <i>%1</i>.").arg(tr("Local Highlights").replace(" ", "&nbsp;")));
-        // Re-use translations of "Local Highlights" as this is a word-for-word reference, forcing
-        // all spaces to be non-breaking
-    }
+    // Local highlights are considered legacy
+    ui.highlightImport->setText(tr("Import Legacy"));
+    ui.highlightImport->setToolTip(
+        tr("Import highlight rules configured in <i>%1</i>.").arg(tr("Legacy Highlights").replace(" ", "&nbsp;")));
+    // Re-use translations of "Legacy Highlights" as this is a word-for-word reference, forcing
+    // all spaces to be non-breaking
 }
 
 void CoreHighlightSettingsPage::coreConnectionStateChanged(bool state)
@@ -681,9 +669,9 @@ void CoreHighlightSettingsPage::widgetHasChanged()
 
 void CoreHighlightSettingsPage::on_coreUnsupportedDetails_clicked()
 {
-    // Re-use translations of "Local Highlights" as this is a word-for-word reference, forcing all
+    // Re-use translations of "Legacy 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 localHighlightsName = tr("Legacy 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"),
@@ -704,13 +692,8 @@ void CoreHighlightSettingsPage::importRules()
 
     // Re-use translations of "Legacy/Local Highlights" as this is a word-for-word reference,
     // forcing all spaces to non-breaking
-    QString localHighlightsName;
-    if (Quassel::runMode() == Quassel::Monolithic) {
-        localHighlightsName = tr("Legacy Highlights").replace(" ", "&nbsp;");
-    }
-    else {
-        localHighlightsName = tr("Local Highlights").replace(" ", "&nbsp;");
-    }
+    // "Local Highlights" has been removed; it's always called "Legacy" now.
+    QString localHighlightsName = tr("Legacy Highlights").replace(" ", "&nbsp;");
 
     if (localHighlightList.count() == 0) {
         // No highlight rules exist to import, do nothing
@@ -750,14 +733,48 @@ void CoreHighlightSettingsPage::importRules()
                                        highlightRule["Channel"].toString());
     }
 
+    // Copy nickname highlighting settings
+    clonedManager.setNicksCaseSensitive(notificationSettings.nicksCaseSensitive());
+    if (notificationSettings.highlightNick() == NotificationSettings::HighlightNickType::AllNicks) {
+        clonedManager.setHighlightNick(HighlightRuleManager::HighlightNickType::AllNicks);
+    }
+    else if (notificationSettings.highlightNick() == NotificationSettings::HighlightNickType::CurrentNick) {
+       clonedManager.setHighlightNick(HighlightRuleManager::HighlightNickType::CurrentNick);
+    }
+    // else - Don't copy "NoNick", "NoNick" is now default and should be ignored
+
     Client::highlightRuleManager()->requestUpdate(clonedManager.toVariantMap());
     setChangedState(false);
     load();
 
-    // Give a heads-up that all succeeded
-    QMessageBox::information(this,
-                             tr("Imported highlights"),
-                             tr("%1 highlight rules successfully imported.").arg(QString::number(localHighlightList.count())));
+    // Give a heads-up that all succeeded, ask about removing old rules
+    //
+    // Hypothetically, someone might use a common set of highlight rules across multiple cores.
+    // This won't matter once client highlights are disabled entirely on newer cores.
+    //
+    // Remove this once client-side highlights are disabled for newer cores.
+    ret = QMessageBox::question(this, tr("Imported highlights"),
+                                QString("<p>%1</p></br><p>%2</p>").arg(
+                                    tr("%1 highlight rules successfully imported.").arg(QString::number(localHighlightList.count())),
+                                    tr("Clean up old, duplicate highlight rules?")),
+                                QMessageBox::Yes | QMessageBox::No,
+                                QMessageBox::Yes);
+
+    if (ret != QMessageBox::Yes) {
+        // Only two options, Yes or No, return if not Yes
+        return;
+    }
+
+    // Remove all local highlight rules
+    notificationSettings.setHighlightList({});
+    // Disable local nickname highlighting
+    notificationSettings.setHighlightNick(NotificationSettings::HighlightNickType::NoNick);
+    // Disable nickname sensitivity
+    // This isn't needed to disable local highlights, but it's part of appearing reset-to-default
+    notificationSettings.setNicksCaseSensitive(false);
+
+    // Refresh HighlightSettingsPage in case it was already loaded
+    emit localHighlightsChanged();
 }
 
 bool CoreHighlightSettingsPage::isSelectable() const
index d4db4f8..07a1cb1 100644 (file)
@@ -46,6 +46,15 @@ public slots:
     void revert();
     void clientConnected();
 
+signals:
+    /**
+     * Signals the local highlight settings have been changed as part of cleaning up after
+     * importing the rules locally.
+     *
+     * @see CoreHighlightSettingsPage::importRules()
+     */
+    void localHighlightsChanged();
+
 private slots:
     void coreConnectionStateChanged(bool state);
     void widgetHasChanged();
index bc0debe..4a9b11d 100644 (file)
@@ -31,9 +31,7 @@
 #include "uisettings.h"
 
 HighlightSettingsPage::HighlightSettingsPage(QWidget* parent)
-    : SettingsPage(tr("Interface"),
-                   // In Monolithic mode, local highlights are replaced by remote highlights
-                   Quassel::runMode() == Quassel::Monolithic ? tr("Legacy Highlights") : tr("Local Highlights"),
+    : SettingsPage(tr("Interface"), tr("Legacy Highlights"),
                    parent)
 {
     ui.setupUi(this);
@@ -85,17 +83,6 @@ HighlightSettingsPage::HighlightSettingsPage(QWidget* parent)
     // Information icon
     ui.localHighlightsIcon->setPixmap(icon::get("dialog-information").pixmap(16));
 
-    // Set up client/monolithic local highlights information
-    if (Quassel::runMode() == Quassel::Monolithic) {
-        // We're running in Monolithic mode, core/client version in total sync.  Discourage the use
-        // of local (legacy) highlights as it's identical to setting remote highlights.
-        ui.localHighlightsLabel->setText(tr("Legacy Highlights are replaced by Highlights"));
-    }
-    else {
-        // We're running in client/split mode, allow for splitting the details.
-        ui.localHighlightsLabel->setText(tr("Local Highlights apply to this device only"));
-    }
-
     connect(ui.add, &QAbstractButton::clicked, this, [this]() { addNewRow(); });
     connect(ui.remove, &QAbstractButton::clicked, this, &HighlightSettingsPage::removeSelectedRows);
     // TODO: search for a better signal (one that emits everytime a selection has been changed for one item)
@@ -265,34 +252,16 @@ void HighlightSettingsPage::tableChanged(QTableWidgetItem* item)
 
 void HighlightSettingsPage::on_localHighlightsDetails_clicked()
 {
-    // Show information specific to client/monolithic differences
-    if (Quassel::runMode() == Quassel::Monolithic) {
-        // We're running in Monolithic mode, core/client version in total sync.  Discourage the use
-        // of local (legacy) highlights as it's identical to setting remote highlights.
-        QMessageBox::information(this,
-                                 tr("Legacy Highlights vs. Highlights"),
-                                 QString("<p><b>%1</b></p></br><p>%2</p></br><p>%3</p>")
-                                     .arg(tr("Legacy Highlights are replaced by Highlights"),
-                                          tr("These highlights will keep working for now, but you should move to "
-                                             "the improved highlight rules when you can."),
-                                          tr("Configure the new style of highlights in "
-                                             "<i>%1</i>.")
-                                              .arg(tr("Highlights"))));
-    }
-    else {
-        // We're running in client/split mode, allow for splitting the details.
-        QMessageBox::information(this,
-                                 tr("Local Highlights vs. Remote Highlights"),
-                                 QString("<p><b>%1</b></p></br><p>%2</p></br><p>%3</p>")
-                                     .arg(tr("Local Highlights apply to this device only"),
-                                          tr("Highlights configured on this page only apply to your current "
-                                             "device."),
-                                          tr("Configure highlights for all of your devices in "
-                                             "<i>%1</i>.")
-                                              .arg(tr("Remote Highlights").replace(" ", "&nbsp;"))));
-        // Re-use translations of "Remote Highlights" as this is a word-for-word reference, forcing
-        // all spaces to be non-breaking
-    }
+    // Discourage the use of local (legacy) highlights.  When not running in Monolithic mode, they
+    // need to be kept around for pre-0.13 cores.
+    QMessageBox::information(this,
+                             tr("Legacy Highlights vs. Highlights"),
+                             QString("<p><b>%1</b></p></br><p>%2</p></br><p>%3</p>")
+                             .arg(tr("Legacy Highlights are replaced by Highlights"),
+                                  tr("These highlights will keep working for now, but you should move to "
+                                     "the improved highlight rules when you can."),
+                                  tr("Configure the new style of highlights in <i>%1</i>.")
+                                  .arg(tr("Highlights"))));
 }
 
 void HighlightSettingsPage::load()
index 70922c0..8c4a803 100644 (file)
    <string>Form</string>
   </property>
   <layout class="QVBoxLayout">
+   <item>
+    <layout class="QHBoxLayout">
+     <item>
+      <widget class="QLabel" name="localHighlightsIcon">
+       <property name="text">
+        <string notr="true">[icon]</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QLabel" name="localHighlightsLabel">
+       <property name="sizePolicy">
+        <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
+         <horstretch>0</horstretch>
+         <verstretch>0</verstretch>
+        </sizepolicy>
+       </property>
+       <property name="text">
+        <string>Legacy Highlights are replaced by Highlights</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QPushButton" name="localHighlightsDetails">
+       <property name="text">
+        <string>Details...</string>
+       </property>
+      </widget>
+     </item>
+    </layout>
+   </item>
    <item>
     <widget class="QGroupBox" name="groupBox">
      <property name="title">
      </layout>
     </widget>
    </item>
-   <item>
-    <layout class="QHBoxLayout">
-     <item>
-      <widget class="QLabel" name="localHighlightsIcon">
-       <property name="text">
-        <string notr="true">[icon]</string>
-       </property>
-      </widget>
-     </item>
-     <item>
-      <widget class="QLabel" name="localHighlightsLabel">
-       <property name="sizePolicy">
-        <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
-         <horstretch>0</horstretch>
-         <verstretch>0</verstretch>
-        </sizepolicy>
-       </property>
-       <property name="text">
-        <string>Local Highlights apply to this device only</string>
-       </property>
-      </widget>
-     </item>
-     <item>
-      <widget class="QPushButton" name="localHighlightsDetails">
-       <property name="text">
-        <string>Details...</string>
-       </property>
-      </widget>
-     </item>
-    </layout>
-   </item>
   </layout>
  </widget>
  <resources/>