1 /***************************************************************************
2 * Copyright (C) 2005-2020 by the Quassel Project *
3 * devel@quassel-irc.org *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) version 3. *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
19 ***************************************************************************/
23 #include <QTableWidgetItem>
24 #include <QVariantList>
26 #include "highlightrulemanager.h"
27 #include "settingspage.h"
29 #include "ui_corehighlightsettingspage.h"
31 class CoreHighlightSettingsPage : public SettingsPage
36 explicit CoreHighlightSettingsPage(QWidget* parent = nullptr);
38 bool hasDefaults() const override;
40 bool isSelectable() const override;
43 void save() final override;
44 void load() final override;
45 void defaults() final override;
47 void clientConnected();
51 * Signals the local highlight settings have been changed as part of cleaning up after
52 * importing the rules locally.
54 * @see CoreHighlightSettingsPage::importRules()
56 void localHighlightsChanged();
59 void coreConnectionStateChanged(bool state);
60 void widgetHasChanged();
61 void addNewHighlightRow(bool enable = true,
63 const QString& name = tr("highlight rule"),
66 const QString& sender = "",
67 const QString& chanName = "",
69 void addNewIgnoredRow(bool enable = true,
71 const QString& name = tr("highlight rule"),
74 const QString& sender = "",
75 const QString& chanName = "",
77 void removeSelectedHighlightRows();
78 void removeSelectedIgnoredRows();
79 void highlightNicksChanged(int index);
80 void selectHighlightRow(QTableWidgetItem* item);
81 void selectIgnoredRow(QTableWidgetItem* item);
82 void highlightTableChanged(QTableWidgetItem* item);
83 void ignoredTableChanged(QTableWidgetItem* item);
85 /** Import local Highlight rules into the Core Highlight rules
87 * Iterates through all local highlight rules, converting each into core-side highlight rules.
92 * Event handler for core unspported Details button
94 void on_coreUnsupportedDetails_clicked();
97 Ui::CoreHighlightSettingsPage ui;
99 HighlightRuleManager::HighlightRuleList highlightList;
100 HighlightRuleManager::HighlightRuleList ignoredList;
113 void emptyHighlightTable();
114 void emptyIgnoredTable();
116 void setupRuleTable(QTableWidget* highlightTable) const;
119 * Get tooltip for the specified rule table column
121 * @param tableColumn Column to retrieve tooltip
122 * @return Translated tooltip for the specified column
124 QString getTableTooltip(column tableColumn) const;
127 * Setup tooltips and "What's this?" prompts for table entries
129 * @param enableWidget Enabled checkbox
130 * @param nameWidget Rule name
131 * @param regExWidget RegEx enabled
132 * @param csWidget Case-sensitive
133 * @param senderWidget Sender name
134 * @param chanWidget Channel name
136 void setupTableTooltips(
137 QWidget* enableWidget, QWidget* nameWidget, QWidget* regExWidget, QWidget* csWidget, QWidget* senderWidget, QWidget* chanWidget) const;
140 * Setup tooltips and "What's this?" prompts for table entries
142 * @param enableWidget Enabled checkbox
143 * @param nameWidget Rule name
144 * @param regExWidget RegEx enabled
145 * @param csWidget Case-sensitive
146 * @param senderWidget Sender name
147 * @param chanWidget Channel name
149 void setupTableTooltips(QTableWidgetItem* enableWidget,
150 QTableWidgetItem* nameWidget,
151 QTableWidgetItem* regExWidget,
152 QTableWidgetItem* csWidget,
153 QTableWidgetItem* senderWidget,
154 QTableWidgetItem* chanWidget) const;
156 /** Update the UI to show core support for highlights
158 * Shows or hides the UI warnings around core-side highlights according to core connection and
159 * core feature support.
161 * @param state True if connected to core, otherwise false
163 void updateCoreSupportStatus(bool state);