X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fsettingspages%2Fcorehighlightsettingspage.cpp;h=e07c87d90d476904afa18cf6b443d09498564d9e;hp=9707c70b144a11c16d449854650dcdc78893e4d3;hb=HEAD;hpb=cc6e7c08709c4e761e2fd9c2e322751015497003 diff --git a/src/qtui/settingspages/corehighlightsettingspage.cpp b/src/qtui/settingspages/corehighlightsettingspage.cpp index 9707c70b..cb134899 100644 --- a/src/qtui/settingspages/corehighlightsettingspage.cpp +++ b/src/qtui/settingspages/corehighlightsettingspage.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-2019 by the Quassel Project * + * Copyright (C) 2005-2022 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -20,6 +20,8 @@ #include "corehighlightsettingspage.h" +#include + #include #include #include @@ -30,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); @@ -54,7 +54,7 @@ CoreHighlightSettingsPage::CoreHighlightSettingsPage(QWidget* parent) connect(ui.ignoredAdd, &QAbstractButton::clicked, this, [this]() { addNewIgnoredRow(); }); connect(ui.ignoredRemove, &QAbstractButton::clicked, this, &CoreHighlightSettingsPage::removeSelectedIgnoredRows); - // TODO: search for a better signal (one that emits everytime a selection has been changed for one item) + // TODO: search for a better signal (one that emits every time a selection has been changed for one item) connect(ui.highlightTable, &QTableWidget::itemClicked, this, &CoreHighlightSettingsPage::selectHighlightRow); connect(ui.ignoredTable, &QTableWidget::itemClicked, this, &CoreHighlightSettingsPage::selectIgnoredRow); @@ -79,25 +79,15 @@ CoreHighlightSettingsPage::CoreHighlightSettingsPage(QWidget* parent) connect(Client::instance(), &Client::connected, this, &CoreHighlightSettingsPage::clientConnected); // Warning icon - ui.coreUnsupportedIcon->setPixmap(icon::get("dialog-warning").pixmap(16)); + ui.coreUnsupportedIcon->setPixmap(icon::get({"emblem-unavailable", "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 %1.").arg(tr("Legacy Highlights").replace(" ", " "))); - // 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 %1.").arg(tr("Local Highlights").replace(" ", " "))); - // 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 %1.").arg(tr("Legacy Highlights").replace(" ", " "))); + // 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) @@ -420,7 +410,7 @@ void CoreHighlightSettingsPage::removeSelectedHighlightRows() for (auto selectedItem : selectedItemList) { selectedRows.append(selectedItem->row()); } - qSort(selectedRows.begin(), selectedRows.end(), qGreater()); + std::sort(selectedRows.begin(), selectedRows.end(), std::greater<>()); int lastRow = -1; for (auto row : selectedRows) { if (row != lastRow) { @@ -438,7 +428,7 @@ void CoreHighlightSettingsPage::removeSelectedIgnoredRows() for (auto selectedItem : selectedItemList) { selectedRows.append(selectedItem->row()); } - qSort(selectedRows.begin(), selectedRows.end(), qGreater()); + std::sort(selectedRows.begin(), selectedRows.end(), std::greater<>()); int lastRow = -1; for (auto row : selectedRows) { if (row != lastRow) { @@ -618,7 +608,7 @@ void CoreHighlightSettingsPage::save() if (ruleManager == nullptr) return; - auto clonedManager = HighlightRuleManager(); + HighlightRuleManager clonedManager; clonedManager.fromVariantMap(ruleManager->toVariantMap()); clonedManager.clear(); @@ -679,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(" ", " "); + const QString localHighlightsName = tr("Legacy Highlights").replace(" ", " "); const QString remoteHighlightsMsgText = QString("

%1


%2


%3

") .arg(tr("Your Quassel core is too old to support remote highlights"), @@ -702,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(" ", " "); - } - else { - localHighlightsName = tr("Local Highlights").replace(" ", " "); - } + // "Local Highlights" has been removed; it's always called "Legacy" now. + QString localHighlightsName = tr("Legacy Highlights").replace(" ", " "); if (localHighlightList.count() == 0) { // No highlight rules exist to import, do nothing @@ -732,7 +717,7 @@ void CoreHighlightSettingsPage::importRules() save(); } - auto clonedManager = HighlightRuleManager(); + HighlightRuleManager clonedManager; clonedManager.fromVariantMap(Client::highlightRuleManager()->toVariantMap()); for (const auto& variant : notificationSettings.highlightList()) { @@ -748,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("

%1


%2

").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