1 #ifndef _OPTW_HIGHLIGHTING_CPP_
2 #define _OPTW_HIGHLIGHTING_CPP_
3 //=============================================================================
4 //
5 // File : OptionsWidget_alertsAndHighlighting.cpp
6 // Creation date : Sat Nov 3 18:09:35 2001 GMT by Szymon Stefanek
7 //
8 // This file is part of the KVIrc IRC client distribution
9 // Copyright (C) 2001-2010 Szymon Stefanek (pragma at kvirc dot net)
10 //
11 // This program is FREE software. You can redistribute it and/or
12 // modify it under the terms of the GNU General Public License
13 // as published by the Free Software Foundation; either version 2
14 // of the License, or (at your option) any later version.
15 //
16 // This program is distributed in the HOPE that it will be USEFUL,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19 // See the GNU General Public License for more details.
20 //
21 // You should have received a copy of the GNU General Public License
22 // along with this program. If not, write to the Free Software Foundation,
23 // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24 //
25 //=============================================================================
26
27 #include "OptionsWidget_alertsAndHighlighting.h"
28 #include "KviOptions.h"
29 #include "KviLocale.h"
30
31 #include <QLayout>
32 #include <QLabel>
33 #include <QRadioButton>
34
35 #include "KviTalToolTip.h"
36
OptionsWidget_alertsAndHighlighting(QWidget * parent)37 OptionsWidget_alertsAndHighlighting::OptionsWidget_alertsAndHighlighting(QWidget * parent)
38 : KviOptionsWidget(parent)
39 {
40 setObjectName("highlighting_options_widget");
41 }
42
43 OptionsWidget_alertsAndHighlighting::~OptionsWidget_alertsAndHighlighting()
44 = default;
45
OptionsWidget_highlighting(QWidget * parent)46 OptionsWidget_highlighting::OptionsWidget_highlighting(QWidget * parent)
47 : KviOptionsWidget(parent)
48 {
49 setObjectName("highlighting_options_widget");
50 createLayout();
51
52 KviBoolSelector * b = addBoolSelector(0, 0, 0, 0, __tr2qs_ctx("Enable word highlighting", "options"), KviOption_boolUseWordHighlighting);
53 KviStringListSelector * sl = addStringListSelector(0, 1, 0, 1, __tr2qs_ctx("Words to Highlight", "options"), KviOption_stringlistHighlightWords,
54 KVI_OPTION_BOOL(KviOption_boolUseWordHighlighting));
55
56 connect(b, SIGNAL(toggled(bool)), sl, SLOT(setEnabled(bool)));
57
58 // This can be used even without Word highlighting
59 b = addBoolSelector(0, 2, 0, 2, __tr2qs_ctx("Highlight messages containing my nickname", "options"), KviOption_boolAlwaysHighlightNick);
60 mergeTip(b, __tr2qs_ctx("If this option is enabled, KVIrc will highlight any user message containing your current nickname.", "options"));
61
62 b = addBoolSelector(0, 3, 0, 3, __tr2qs_ctx("Words/Nick matching is case sensitive", "options"), KviOption_boolCaseSensitiveHighlighting);
63 mergeTip(b, __tr2qs_ctx("If this option is enabled, KVIrc will match your nick and/or the words you specified in a case sensitive manner.", "options"));
64
65 KviTalGroupBox * gbox = addGroupBox(0, 4, 0, 4, Qt::Horizontal, __tr2qs_ctx("Highlighting Method", "options"));
66
67 // note: KviTalGroupBox automatically deletes its previous layout on setLayout()
68 // note2: every QWidget will take ownership of its layout.
69 QGridLayout * g = new QGridLayout();
70 gbox->setLayout(g);
71
72 m_pHighlightAllOccurencesRadioButton = new QRadioButton(__tr2qs_ctx("Highlight every occurrence of a word inside text", "options"), gbox);
73 g->addWidget(m_pHighlightAllOccurencesRadioButton, 0, 0, 1, 2);
74 m_pHighlightAllOccurencesRadioButton->setChecked(KVI_OPTION_BOOL(KviOption_boolUseFullWordHighlighting));
75 KviTalToolTip::add(m_pHighlightAllOccurencesRadioButton, __tr2qs_ctx("This selection will cause KVIrc to search for the highlighted words or "
76 "nicknames inside the whole text. This will also highlight parts of words.<br>"
77 "(e.g. if your nickname is Mark then Markus will be highlighted too).", "options"));
78
79 m_pHighlightWholeWordsOnlyRadioButton = new QRadioButton(__tr2qs_ctx("Highlight only whole words splitting on space and on:", "options"), gbox);
80 g->addWidget(m_pHighlightWholeWordsOnlyRadioButton, 1, 0, 1, 1);
81 m_pHighlightWholeWordsOnlyRadioButton->setChecked(!KVI_OPTION_BOOL(KviOption_boolUseFullWordHighlighting));
82 KviTalToolTip::add(m_pHighlightWholeWordsOnlyRadioButton, __tr2qs_ctx("This selection will first split the string on the specified boundaries<br>"
83 "(including space) and then will compare all the parts with the highlighted words.", "options"));
84
85 m_pWordSplitterCharactersEdit = new QLineEdit(gbox);
86 m_pWordSplitterCharactersEdit->setText(KVI_OPTION_STRING(KviOption_stringWordSplitters));
87 m_pWordSplitterCharactersEdit->setEnabled(!KVI_OPTION_BOOL(KviOption_boolUseFullWordHighlighting));
88 g->addWidget(m_pWordSplitterCharactersEdit, 1, 1, 1, 1);
89
90 connect(m_pHighlightWholeWordsOnlyRadioButton, SIGNAL(toggled(bool)), m_pWordSplitterCharactersEdit, SLOT(setEnabled(bool)));
91
92 gbox = addGroupBox(0, 5, 0, 5, Qt::Horizontal, __tr2qs_ctx("Alert Options", "options"));
93
94 b = addBoolSelector(gbox, __tr2qs_ctx("Flash the system taskbar entry on highlighted messages", "options"),
95 KviOption_boolFlashWindowOnHighlightedMessages);
96 mergeTip(b, __tr2qs_ctx("If this option is enabled, KVIrc will (attempt to) flash the system taskbar entry when "
97 "a highlighted message is printed and KVIrc is not the active window.", "options"));
98
99 b = addBoolSelector(gbox, __tr2qs_ctx("Popup the notifier window on highlighted messages", "options"), KviOption_boolPopupNotifierOnHighlightedMessages);
100 mergeTip(b, __tr2qs_ctx("If this option is enabled, KVIrc will popup a little notifier window in the low right corner of your desktop when a highlighted message "
101 "is printed and KVIrc is not the active window.", "options"));
102
103 addRowSpacer(0, 6, 0, 6);
104 }
105
106 OptionsWidget_highlighting::~OptionsWidget_highlighting()
107 = default;
108
commit()109 void OptionsWidget_highlighting::commit()
110 {
111 KVI_OPTION_STRING(KviOption_stringWordSplitters) = m_pWordSplitterCharactersEdit->text().trimmed();
112 KVI_OPTION_BOOL(KviOption_boolUseFullWordHighlighting) = m_pHighlightAllOccurencesRadioButton->isChecked();
113
114 KviOptionsWidget::commit();
115 }
116
OptionsWidget_alerts(QWidget * parent)117 OptionsWidget_alerts::OptionsWidget_alerts(QWidget * parent)
118 : KviOptionsWidget(parent)
119 {
120 setObjectName("highlighting_options_widget");
121 createLayout();
122
123 KviTalGroupBox * g = addGroupBox(0, 0, 0, 0, Qt::Horizontal, __tr2qs_ctx("Alert Restrictions", "options"));
124 KviBoolSelector * b3 = addBoolSelector(g, __tr2qs_ctx("Restrict alert", "options"), KviOption_boolHighlightOnlyNormalMsg);
125 mergeTip(b3, __tr2qs_ctx("If this option is enabled, KVIrc will alert in the window list only if a normal message is received in a channel. "
126 "Actions like joins, parts and mode changes will be ignored.<br> This is useful if you are in channels with a high rate "
127 "of traffic and only want to be alerted for messages that are interesting to you.", "options"));
128
129 KviBoolSelector * b4 = addBoolSelector(g, __tr2qs_ctx("Alert for highlighted words", "options"), KviOption_boolHighlightOnlyNormalMsgHighlightInChanToo,
130 KVI_OPTION_BOOL(KviOption_boolHighlightOnlyNormalMsg));
131 mergeTip(b4, __tr2qs_ctx("If this option is enabled, the window list will also alert for messages which contain a word from the highlighted words list above.", "options"));
132
133 KviBoolSelector * b5 = addBoolSelector(g, __tr2qs_ctx("Alert for query messages", "options"), KviOption_boolHighlightOnlyNormalMsgQueryToo,
134 KVI_OPTION_BOOL(KviOption_boolHighlightOnlyNormalMsg));
135 mergeTip(b5, __tr2qs_ctx("If this option is enabled, the window list will also alert for messages which are shown in queries.", "options"));
136 connect(b3, SIGNAL(toggled(bool)), b4, SLOT(setEnabled(bool)));
137 connect(b3, SIGNAL(toggled(bool)), b5, SLOT(setEnabled(bool)));
138
139 KviBoolSelector * b6 = addBoolSelector(g, __tr2qs_ctx("Use custom alert level", "options"), KviOption_boolHighlightOnlyAtCostumHighlightLevel);
140 mergeTip(b6, __tr2qs_ctx("If this option is enabled, KVIrc will alert in the window list only if the specified alert level is reached.", "options"));
141
142 KviUIntSelector * b7 = addUIntSelector(g, __tr2qs_ctx("Minimum alert level:", "options"), KviOption_uintMinHighlightLevel, 1, KVI_MSGTYPE_MAXLEVEL, KVI_MSGTYPE_MAXLEVEL,
143 KVI_OPTION_BOOL(KviOption_boolHighlightOnlyAtCostumHighlightLevel));
144 b7->setEnabled(KVI_OPTION_BOOL(KviOption_boolHighlightOnlyAtCostumHighlightLevel));
145 mergeTip(b7, __tr2qs_ctx("This option sets the minimum alert level for the window list.", "options"));
146 connect(b6, SIGNAL(toggled(bool)), b7, SLOT(setEnabled(bool)));
147
148 addRowSpacer(0, 1, 0, 1);
149 }
150
151 OptionsWidget_alerts::~OptionsWidget_alerts()
152 = default;
153
154 #endif //_OPTW_HIGHLIGHTING_CPP_
155