From 63fc3ba0333a0555f6f04d49a45aa321b07d10ac Mon Sep 17 00:00:00 2001 From: Shane Synan Date: Thu, 1 Mar 2018 18:51:32 -0600 Subject: [PATCH] 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. --- .../corehighlightsettingspage.cpp | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) 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 { -- 2.20.1