From: Shane Synan Date: Fri, 2 Mar 2018 00:51:32 +0000 (-0600) Subject: client: Show feedback for Local Highlights import X-Git-Tag: travis-deploy-test~90 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=63fc3ba0333a0555f6f04d49a45aa321b07d10ac client: Show feedback for Local Highlights import Prompt before importing local highlight rules to guard against accidental clicks. Show a success message at the end indicating how many highlight rules were imported. Show an information message if no local highlight rules exist to import. --- diff --git a/src/qtui/settingspages/corehighlightsettingspage.cpp b/src/qtui/settingspages/corehighlightsettingspage.cpp index 644a9020..68d60176 100644 --- a/src/qtui/settingspages/corehighlightsettingspage.cpp +++ b/src/qtui/settingspages/corehighlightsettingspage.cpp @@ -591,6 +591,33 @@ void CoreHighlightSettingsPage::on_coreUnsupportedDetails_clicked() void CoreHighlightSettingsPage::importRules() { NotificationSettings notificationSettings; + const auto localHighlightList = notificationSettings.highlightList(); + + // 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(" ", " "); + + if (localHighlightList.count() == 0) { + // No highlight rules exist to import, do nothing + QMessageBox::information(this, + tr("No local highlights"), + tr("No highlight rules in %1." + ).arg(localHighlightsName)); + return; + } + + int ret = QMessageBox::question(this, + tr("Import local highlights?"), + tr("Import all highlight rules from %1?" + ).arg(localHighlightsName), + QMessageBox::Yes|QMessageBox::No, + QMessageBox::No); + + if (ret == QMessageBox::No) { + // Only two options, Yes or No, just return if No + return; + } + auto clonedManager = HighlightRuleManager(); clonedManager.fromVariantMap(Client::highlightRuleManager()->toVariantMap()); @@ -611,6 +638,12 @@ void CoreHighlightSettingsPage::importRules() { Client::highlightRuleManager()->requestUpdate(clonedManager.toVariantMap()); setChangedState(false); load(); + + // Give a heads-up that all succeeded + QMessageBox::information(this, + tr("Imported local highlights"), + tr("%1 highlight rules successfully imported." + ).arg(QString::number(localHighlightList.count()))); } bool CoreHighlightSettingsPage::isSelectable() const {