X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fqtui%2Fsettingspages%2Fhighlightsettingspage.cpp;h=7a000e9b742a7d3e1dc1fd9f8cfb153eb429f5e1;hp=57bd526dbbeadf1ecd49bcde9f052c320cda0ec3;hb=95700544764698a7e2a417c3616d9a6ff30a2fd6;hpb=0a43227b8cd44625f4881cc1545d42c8c8a4876c diff --git a/src/qtui/settingspages/highlightsettingspage.cpp b/src/qtui/settingspages/highlightsettingspage.cpp index 57bd526d..7a000e9b 100644 --- a/src/qtui/settingspages/highlightsettingspage.cpp +++ b/src/qtui/settingspages/highlightsettingspage.cpp @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2005-2016 by the Quassel Project * + * Copyright (C) 2005-2018 by the Quassel Project * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * @@ -20,26 +20,46 @@ #include "highlightsettingspage.h" +#include "client.h" #include "qtui.h" #include "uisettings.h" #include +#include HighlightSettingsPage::HighlightSettingsPage(QWidget *parent) - : SettingsPage(tr("Interface"), tr("Highlight"), parent) + : SettingsPage(tr("Interface"), tr("Local Highlights"), parent) { ui.setupUi(this); ui.highlightTable->verticalHeader()->hide(); ui.highlightTable->setShowGrid(false); - ui.highlightTable->horizontalHeaderItem(HighlightSettingsPage::RegExColumn)->setToolTip("RegEx: This option determines if the highlight rule should be interpreted as a regular expression or just as a keyword."); - ui.highlightTable->horizontalHeaderItem(HighlightSettingsPage::RegExColumn)->setWhatsThis("RegEx: This option determines if the highlight rule should be interpreted as a regular expression or just as a keyword."); - - ui.highlightTable->horizontalHeaderItem(HighlightSettingsPage::CsColumn)->setToolTip("CS: This option determines if the highlight rule should be interpreted case sensitive."); - ui.highlightTable->horizontalHeaderItem(HighlightSettingsPage::CsColumn)->setWhatsThis("CS: This option determines if the highlight rule should be interpreted case sensitive."); - - ui.highlightTable->horizontalHeaderItem(HighlightSettingsPage::ChanColumn)->setToolTip("Channel: This regular expression determines for which channels the highlight rule works. Leave blank to match any channel. Put ! in the beginning to negate. Case insensitive."); - ui.highlightTable->horizontalHeaderItem(HighlightSettingsPage::ChanColumn)->setWhatsThis("Channel: This regular expression determines for which channels the highlight rule works. Leave blank to match any channel. Put ! in the beginning to negate. Case insensitive."); + ui.highlightTable->horizontalHeaderItem(HighlightSettingsPage::RegExColumn)->setToolTip( + tr("RegEx: This option determines if the highlight rule should be " + "interpreted as a regular expression or just as a keyword.")); + ui.highlightTable->horizontalHeaderItem(HighlightSettingsPage::RegExColumn)->setWhatsThis( + ui.highlightTable->horizontalHeaderItem(HighlightSettingsPage::RegExColumn)->toolTip()); + + ui.highlightTable->horizontalHeaderItem(HighlightSettingsPage::CsColumn)->setToolTip( + tr("CS: This option determines if the highlight rule should be interpreted " + "case sensitive.")); + ui.highlightTable->horizontalHeaderItem(HighlightSettingsPage::CsColumn)->setWhatsThis( + ui.highlightTable->horizontalHeaderItem(HighlightSettingsPage::CsColumn)->toolTip()); + + ui.highlightTable->horizontalHeaderItem(HighlightSettingsPage::ChanColumn)->setToolTip( + tr("

Channel: Semicolon separated list of channel names.

" + "

Example:
" + "#quassel*; #foobar; !#quasseldroid
" + "would match on #foobar and on any channel starting with #quassel except " + "for #quasseldroid
" + "

If only inverted names are specified, it will match anything except for " + "what's specified (implicit wildcard).

" + "

Example:
" + "!#quassel*; !#foobar
" + "would match anything except for #foobar or any channel starting with " + "#quassel

")); + ui.highlightTable->horizontalHeaderItem(HighlightSettingsPage::ChanColumn)->setWhatsThis( + ui.highlightTable->horizontalHeaderItem(HighlightSettingsPage::ChanColumn)->toolTip()); #if QT_VERSION < 0x050000 ui.highlightTable->horizontalHeader()->setResizeMode(HighlightSettingsPage::NameColumn, QHeaderView::Stretch); @@ -55,6 +75,20 @@ HighlightSettingsPage::HighlightSettingsPage(QWidget *parent) ui.highlightTable->horizontalHeader()->setSectionResizeMode(HighlightSettingsPage::ChanColumn, QHeaderView::ResizeToContents); #endif + // Information icon + ui.localHighlightsIcon->setPixmap(QIcon::fromTheme("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 highlights as it's identical to setting remote highlights. + ui.localHighlightsLabel->setText( + tr("Local Highlights are replaced by Remote 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, SIGNAL(clicked(bool)), this, SLOT(addNewRow())); connect(ui.remove, SIGNAL(clicked(bool)), this, SLOT(removeSelectedRows())); //TODO: search for a better signal (one that emits everytime a selection has been changed for one item) @@ -78,7 +112,7 @@ bool HighlightSettingsPage::hasDefaults() const void HighlightSettingsPage::defaults() { - ui.highlightCurrentNick->setChecked(true); + ui.highlightNoNick->setChecked(true); ui.nicksCaseSensitive->setChecked(false); emptyTable(); @@ -90,6 +124,13 @@ void HighlightSettingsPage::addNewRow(QString name, bool regex, bool cs, bool en { ui.highlightTable->setRowCount(ui.highlightTable->rowCount()+1); + QTableWidgetItem *enableItem = new QTableWidgetItem(""); + if (enable) + enableItem->setCheckState(Qt::Checked); + else + enableItem->setCheckState(Qt::Unchecked); + enableItem->setFlags(Qt::ItemIsUserCheckable|Qt::ItemIsEnabled|Qt::ItemIsSelectable); + QTableWidgetItem *nameItem = new QTableWidgetItem(name); QTableWidgetItem *regexItem = new QTableWidgetItem(""); @@ -106,20 +147,34 @@ void HighlightSettingsPage::addNewRow(QString name, bool regex, bool cs, bool en csItem->setCheckState(Qt::Unchecked); csItem->setFlags(Qt::ItemIsUserCheckable|Qt::ItemIsEnabled|Qt::ItemIsSelectable); - QTableWidgetItem *enableItem = new QTableWidgetItem(""); - if (enable) - enableItem->setCheckState(Qt::Checked); - else - enableItem->setCheckState(Qt::Unchecked); - enableItem->setFlags(Qt::ItemIsUserCheckable|Qt::ItemIsEnabled|Qt::ItemIsSelectable); - QTableWidgetItem *chanNameItem = new QTableWidgetItem(chanName); + enableItem->setToolTip(tr("Enable/disable this rule")); + nameItem->setToolTip(tr("Phrase to match")); + regexItem->setToolTip( + tr("RegEx: This option determines if the highlight rule should be " + "interpreted as a regular expression or just as a keyword.")); + csItem->setToolTip( + tr("CS: This option determines if the highlight rule should be interpreted " + "case sensitive.")); + chanNameItem->setToolTip( + tr("

Channel: Semicolon separated list of channel names.

" + "

Example:
" + "#quassel*; #foobar; !#quasseldroid
" + "would match on #foobar and on any channel starting with #quassel except " + "for #quasseldroid
" + "

If only inverted names are specified, it will match anything except for " + "what's specified (implicit wildcard).

" + "

Example:
" + "!#quassel*; !#foobar
" + "would match anything except for #foobar or any channel starting with " + "#quassel

")); + int lastRow = ui.highlightTable->rowCount()-1; + ui.highlightTable->setItem(lastRow, HighlightSettingsPage::EnableColumn, enableItem); ui.highlightTable->setItem(lastRow, HighlightSettingsPage::NameColumn, nameItem); ui.highlightTable->setItem(lastRow, HighlightSettingsPage::RegExColumn, regexItem); ui.highlightTable->setItem(lastRow, HighlightSettingsPage::CsColumn, csItem); - ui.highlightTable->setItem(lastRow, HighlightSettingsPage::EnableColumn, enableItem); ui.highlightTable->setItem(lastRow, HighlightSettingsPage::ChanColumn, chanNameItem); if (!self) @@ -187,6 +242,9 @@ void HighlightSettingsPage::tableChanged(QTableWidgetItem *item) switch (item->column()) { + case HighlightSettingsPage::EnableColumn: + highlightRule["Enable"] = (item->checkState() == Qt::Checked); + break; case HighlightSettingsPage::NameColumn: if (item->text() == "") item->setText(tr("this shouldn't be empty")); @@ -198,9 +256,6 @@ void HighlightSettingsPage::tableChanged(QTableWidgetItem *item) case HighlightSettingsPage::CsColumn: highlightRule["CS"] = (item->checkState() == Qt::Checked); break; - case HighlightSettingsPage::EnableColumn: - highlightRule["Enable"] = (item->checkState() == Qt::Checked); - break; case HighlightSettingsPage::ChanColumn: if (!item->text().isEmpty() && item->text().trimmed().isEmpty()) item->setText(""); @@ -212,6 +267,41 @@ void HighlightSettingsPage::tableChanged(QTableWidgetItem *item) } +void HighlightSettingsPage::on_localHighlightsDetails_clicked() +{ + // Re-use translations of "Remote Highlights" as this is a word-for-word reference, forcing all + // spaces to non-breaking + const QString remoteHighlightsName = tr("Remote Highlights").replace(" ", " "); + QString localHighlightsMsgText; + + // 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 highlights as it's identical to setting remote highlights. + localHighlightsMsgText = + QString("

%1


%2


%3

" + ).arg(tr("Local Highlights are replaced by Remote 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 " + "%1.").arg(remoteHighlightsName)); + } else { + // We're running in client/split mode, allow for splitting the details. + localHighlightsMsgText = + QString("

%1


%2


%3

" + ).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 " + "%1.").arg(remoteHighlightsName)); + } + + QMessageBox::information(this, + tr("Local Highlights vs. Remote Highlights"), + localHighlightsMsgText); +} + + void HighlightSettingsPage::load() { NotificationSettings notificationSettings;