From: Shane Synan Date: Fri, 2 Mar 2018 16:20:12 +0000 (-0600) Subject: client: Show when Remote Highlights unsupported X-Git-Tag: travis-deploy-test~92 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=b627af388d570f48a03fd22ab024c07e82e0d503 client: Show when Remote Highlights unsupported 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. --- diff --git a/src/qtui/settingspages/corehighlightsettingspage.cpp b/src/qtui/settingspages/corehighlightsettingspage.cpp index 55266d05..644a9020 100644 --- a/src/qtui/settingspages/corehighlightsettingspage.cpp +++ b/src/qtui/settingspages/corehighlightsettingspage.cpp @@ -19,6 +19,7 @@ ***************************************************************************/ #include +#include #include #include "client.h" @@ -83,10 +84,14 @@ CoreHighlightSettingsPage::CoreHighlightSettingsPage(QWidget *parent) 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) { + updateCoreSupportStatus(state); setEnabled(state); if (state) { load(); @@ -142,6 +147,21 @@ void CoreHighlightSettingsPage::setupRuleTable(QTableWidget *table) const #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())); @@ -549,6 +569,25 @@ void CoreHighlightSettingsPage::widgetHasChanged() 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(" ", " "); + + const QString remoteHighlightsMsgText = + QString("

%1


%2


%3

" + ).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 " + "%1.").arg(localHighlightsName)); + + QMessageBox::warning(this, + tr("Remote Highlights unsupported"), + remoteHighlightsMsgText); +} + void CoreHighlightSettingsPage::importRules() { NotificationSettings notificationSettings; @@ -575,5 +614,7 @@ void CoreHighlightSettingsPage::importRules() { } 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. } diff --git a/src/qtui/settingspages/corehighlightsettingspage.h b/src/qtui/settingspages/corehighlightsettingspage.h index 5859d00c..1a0ea711 100644 --- a/src/qtui/settingspages/corehighlightsettingspage.h +++ b/src/qtui/settingspages/corehighlightsettingspage.h @@ -68,6 +68,11 @@ private slots: */ void importRules(); + /** + * Event handler for core unspported Details button + */ + void on_coreUnsupportedDetails_clicked(); + private: Ui::CoreHighlightSettingsPage ui; @@ -89,5 +94,14 @@ private: 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; }; diff --git a/src/qtui/settingspages/corehighlightsettingspage.ui b/src/qtui/settingspages/corehighlightsettingspage.ui index 1c102bf3..19dae1eb 100644 --- a/src/qtui/settingspages/corehighlightsettingspage.ui +++ b/src/qtui/settingspages/corehighlightsettingspage.ui @@ -15,260 +15,332 @@ - - + + + QFrame::NoFrame + + + QFrame::Plain + + 0 - - - Highlight Rules - - - - - - Highlight Nicks - - + + + 0 + + + 0 + + + 0 + + + 0 + + + + + [icon] + + + + + + + + 0 + 0 + + + + Your Quassel core is too old to support remote highlights + + + + + + + Details... + + + + + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + 0 + + + + Highlight Rules + + - - - - 0 - 0 - - - - - 0 - 0 - - - - -1 - - - QComboBox::AdjustToContents + + + Highlight Nicks + + + + + + 0 + 0 + + + + + 0 + 0 + + + + -1 + + + QComboBox::AdjustToContents + + + + + + + Case sensitive + + + true + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + - - - Case sensitive - - - true + + + Custom Highlights + + + + + + + + + + + + Enabled + + + + + Rule + + + + + RegEx + + + + + CS + + + + + Sender + + + + + Channel + + + + + + + + 0 + + + 0 + + + + + Add + + + + + + + Remove + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Import highlight rules configured in <i>Local Highlights</i> + + + Import Local + + + + + + - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - Custom Highlights - - + + + Highlight Ignore Rules + + - - - - - - + + + Never Highlight For - - - Enabled - - - - - Rule - - - - - RegEx - - - - - CS - - - - - Sender - - - - - Channel - - + + + + + + + + + + + + Enabled + + + + + Rule + + + + + RegEx + + + + + CS + + + + + Sender + + + + + Channel + + + + + + + + 0 + + + 0 + + + + + Add + + + + + + + Remove + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + - - - - 0 - - - 0 - - - - - Add - - - - - - - Remove - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Import highlight rules configured in <i>Local Highlights</i> - - - Import Local - - - - - - - - - - - - - Highlight Ignore Rules - - - - - - Never Highlight For - - - - - - - - - - - - - Enabled - - - - - Rule - - - - - RegEx - - - - - CS - - - - - Sender - - - - - Channel - - - - - - - - 0 - - - 0 - - - - - Add - - - - - - - Remove - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - + + +