1 | #include "opt_general.h"
|
---|
2 | #include "common.h"
|
---|
3 | #include "iconwidget.h"
|
---|
4 |
|
---|
5 | #include <qbuttongroup.h>
|
---|
6 | #include <qwhatsthis.h>
|
---|
7 | #include <qcheckbox.h>
|
---|
8 | #include <qradiobutton.h>
|
---|
9 | #include <qcombobox.h>
|
---|
10 | #include <qlineedit.h>
|
---|
11 | #include <qsignalmapper.h>
|
---|
12 | #include <qpixmap.h>
|
---|
13 | #include <qpainter.h>
|
---|
14 | #include <qcolordialog.h>
|
---|
15 |
|
---|
16 | #include "opt_general_roster.h"
|
---|
17 | #include "opt_general_docking.h"
|
---|
18 | #include "opt_general_misc.h"
|
---|
19 | #include "opt_general_notify.h"
|
---|
20 | #include "opt_general_groupchat.h"
|
---|
21 |
|
---|
22 | //----------------------------------------------------------------------------
|
---|
23 | // OptionsTabGeneral
|
---|
24 | //----------------------------------------------------------------------------
|
---|
25 |
|
---|
26 | OptionsTabGeneral::OptionsTabGeneral(QObject *parent)
|
---|
27 | : MetaOptionsTab(parent, "general", "", tr("General"), tr("General options"), "psi/psi16")
|
---|
28 | {
|
---|
29 | addTab( new OptionsTabGeneralRoster(this) );
|
---|
30 | addTab( new OptionsTabGeneralDocking(this) );
|
---|
31 | addTab( new OptionsTabGeneralMisc(this) );
|
---|
32 | addTab( new OptionsTabGeneralNotifications(this) );
|
---|
33 | addTab( new OptionsTabGeneralGroupchat(this) );
|
---|
34 | }
|
---|
35 |
|
---|
36 | //----------------------------------------------------------------------------
|
---|
37 | // OptionsTabGeneralRoster
|
---|
38 | //----------------------------------------------------------------------------
|
---|
39 |
|
---|
40 | OptionsTabGeneralRoster::OptionsTabGeneralRoster(QObject *parent)
|
---|
41 | : OptionsTab(parent, "general_roster", "general", tr("Roster"), tr("Configure your roster"))
|
---|
42 | {
|
---|
43 | w = 0;
|
---|
44 | bg_defAct = 0;
|
---|
45 | }
|
---|
46 |
|
---|
47 | OptionsTabGeneralRoster::~OptionsTabGeneralRoster()
|
---|
48 | {
|
---|
49 | if ( bg_defAct )
|
---|
50 | delete bg_defAct;
|
---|
51 | }
|
---|
52 |
|
---|
53 | QWidget *OptionsTabGeneralRoster::widget()
|
---|
54 | {
|
---|
55 | if ( w )
|
---|
56 | return 0;
|
---|
57 |
|
---|
58 | w = new GeneralRosterUI();
|
---|
59 | GeneralRosterUI *d = (GeneralRosterUI *)w;
|
---|
60 |
|
---|
61 | bg_defAct = new QButtonGroup;
|
---|
62 | bg_defAct->setRadioButtonExclusive( true );
|
---|
63 | bg_defAct->insert( d->rb_defActMsg, 0 );
|
---|
64 | bg_defAct->insert( d->rb_defActChat, 1 );
|
---|
65 |
|
---|
66 | QWhatsThis::add(d->ck_useleft,
|
---|
67 | tr("Normally, right-clicking with the mouse on a contact will activate the context-menu."
|
---|
68 | " Check this option if you'd rather use a left-click."));
|
---|
69 | QWhatsThis::add(d->ck_singleclick,
|
---|
70 | tr("Normally, a double-click on a contact will invoke the default action."
|
---|
71 | " Check this option if you'd rather invoke with a single-click."));
|
---|
72 |
|
---|
73 | QWhatsThis::add(d->rb_defActMsg,
|
---|
74 | tr("Make the default action open a chat window."));
|
---|
75 | QWhatsThis::add(d->rb_defActChat,
|
---|
76 | tr("Make the default action open a normal message window."));
|
---|
77 |
|
---|
78 | QWhatsThis::add(d->ck_showself,
|
---|
79 | tr("If checked, always show the self-contact in roster, "
|
---|
80 | "otherwise it is shown only when multiple resources are connected to your account."));
|
---|
81 |
|
---|
82 | return w;
|
---|
83 | }
|
---|
84 |
|
---|
85 | void OptionsTabGeneralRoster::applyOptions(Options *opt)
|
---|
86 | {
|
---|
87 | if ( !w )
|
---|
88 | return;
|
---|
89 |
|
---|
90 | GeneralRosterUI *d = (GeneralRosterUI *)w;
|
---|
91 | opt->useleft = d->ck_useleft->isChecked();
|
---|
92 | opt->singleclick = d->ck_singleclick->isChecked();
|
---|
93 | opt->defaultAction = bg_defAct->id(bg_defAct->selected());
|
---|
94 | opt->alwaysShowSelf = d->ck_showself->isChecked();
|
---|
95 | }
|
---|
96 |
|
---|
97 | void OptionsTabGeneralRoster::restoreOptions(const Options *opt)
|
---|
98 | {
|
---|
99 | if ( !w )
|
---|
100 | return;
|
---|
101 |
|
---|
102 | GeneralRosterUI *d = (GeneralRosterUI *)w;
|
---|
103 | d->ck_useleft->setChecked( opt->useleft );
|
---|
104 | d->ck_singleclick->setChecked( opt->singleclick );
|
---|
105 | bg_defAct->setButton( opt->defaultAction );
|
---|
106 | d->ck_showself->setChecked( opt->alwaysShowSelf );
|
---|
107 | }
|
---|
108 |
|
---|
109 | //----------------------------------------------------------------------------
|
---|
110 | // OptionsTabGeneralDocking
|
---|
111 | //----------------------------------------------------------------------------
|
---|
112 |
|
---|
113 | OptionsTabGeneralDocking::OptionsTabGeneralDocking(QObject *parent)
|
---|
114 | : OptionsTab(parent, "general_docking", "general", tr("Docking"), tr("Configure the Psi docklet"))
|
---|
115 | {
|
---|
116 | w = 0;
|
---|
117 | }
|
---|
118 |
|
---|
119 | QWidget *OptionsTabGeneralDocking::widget()
|
---|
120 | {
|
---|
121 | if ( w )
|
---|
122 | return 0;
|
---|
123 |
|
---|
124 | w = new GeneralDockingUI();
|
---|
125 | GeneralDockingUI *d = (GeneralDockingUI *)w;
|
---|
126 |
|
---|
127 | connect(d->ck_docklet, SIGNAL(toggled(bool)), d->ck_dockDCstyle, SLOT(setEnabled(bool)));
|
---|
128 | connect(d->ck_docklet, SIGNAL(toggled(bool)), d->ck_dockHideMW, SLOT(setEnabled(bool)));
|
---|
129 | connect(d->ck_docklet, SIGNAL(toggled(bool)), d->ck_dockToolMW, SLOT(setEnabled(bool)));
|
---|
130 |
|
---|
131 | QWhatsThis::add(d->ck_docklet,
|
---|
132 | tr("Makes Psi use a docklet icon, also known as system tray icon."));
|
---|
133 | QWhatsThis::add(d->ck_dockDCstyle,
|
---|
134 | tr("Normally, single-clicking on the Psi docklet icon brings the main window to"
|
---|
135 | " the foreground. Check this option if you would rather use a double-click."));
|
---|
136 | QWhatsThis::add(d->ck_dockHideMW,
|
---|
137 | tr("Starts Psi with only the docklet icon visible."));
|
---|
138 | QWhatsThis::add(d->ck_dockToolMW,
|
---|
139 | tr("Prevents Psi from taking up a slot on the taskbar and makes the main "
|
---|
140 | "window use a small titlebar."));
|
---|
141 |
|
---|
142 | return w;
|
---|
143 | }
|
---|
144 |
|
---|
145 | void OptionsTabGeneralDocking::applyOptions(Options *opt)
|
---|
146 | {
|
---|
147 | if ( !w )
|
---|
148 | return;
|
---|
149 |
|
---|
150 | GeneralDockingUI *d = (GeneralDockingUI *)w;
|
---|
151 | opt->useDock = d->ck_docklet->isChecked();
|
---|
152 | opt->dockDCstyle = d->ck_dockDCstyle->isChecked();
|
---|
153 | opt->dockHideMW = d->ck_dockHideMW->isChecked();
|
---|
154 | opt->dockToolMW = d->ck_dockToolMW->isChecked();
|
---|
155 | }
|
---|
156 |
|
---|
157 | void OptionsTabGeneralDocking::restoreOptions(const Options *opt)
|
---|
158 | {
|
---|
159 | if ( !w )
|
---|
160 | return;
|
---|
161 |
|
---|
162 | GeneralDockingUI *d = (GeneralDockingUI *)w;
|
---|
163 | d->ck_docklet->setChecked( opt->useDock );
|
---|
164 | d->ck_dockDCstyle->setChecked( opt->dockDCstyle );
|
---|
165 | d->ck_dockHideMW->setChecked( opt->dockHideMW );
|
---|
166 | d->ck_dockToolMW->setChecked( opt->dockToolMW );
|
---|
167 |
|
---|
168 | if( !d->ck_docklet->isChecked() ) {
|
---|
169 | d->ck_dockDCstyle->setEnabled(false);
|
---|
170 | d->ck_dockHideMW->setEnabled(false);
|
---|
171 | d->ck_dockToolMW->setEnabled(false);
|
---|
172 | }
|
---|
173 | }
|
---|
174 |
|
---|
175 | //----------------------------------------------------------------------------
|
---|
176 | // OptionsTabGeneralMisc
|
---|
177 | //----------------------------------------------------------------------------
|
---|
178 |
|
---|
179 | OptionsTabGeneralMisc::OptionsTabGeneralMisc(QObject *parent)
|
---|
180 | : OptionsTab(parent, "general_misc", "general", tr("Misc"), tr("Miscellaneous settings"))
|
---|
181 | {
|
---|
182 | w = 0;
|
---|
183 | bg_delChats = 0;
|
---|
184 | }
|
---|
185 |
|
---|
186 | OptionsTabGeneralMisc::~OptionsTabGeneralMisc()
|
---|
187 | {
|
---|
188 | if ( bg_delChats )
|
---|
189 | delete bg_delChats;
|
---|
190 | }
|
---|
191 |
|
---|
192 | QWidget *OptionsTabGeneralMisc::widget()
|
---|
193 | {
|
---|
194 | if ( w )
|
---|
195 | return 0;
|
---|
196 |
|
---|
197 | w = new GeneralMiscUI();
|
---|
198 | GeneralMiscUI *d = (GeneralMiscUI *)w;
|
---|
199 |
|
---|
200 | // chat
|
---|
201 | QWhatsThis::add(d->ck_chatSays,
|
---|
202 | tr("<P>Changes the normal chat style from:</P>"
|
---|
203 | "<P>[01:23:45] <MyName> Hi</P>"
|
---|
204 | "<P>[01:23:56] <YourName> How are you?</P>"
|
---|
205 | "<P>to:</P>"
|
---|
206 | "<P>[01:23:45] MyName says:</P>"
|
---|
207 | "<P>Hi</P>"
|
---|
208 | "<P>[01:23:56] YourName says:</P>"
|
---|
209 | "<P>How are you?</P>"));
|
---|
210 | QWhatsThis::add(d->ck_chatSoftReturn,
|
---|
211 | tr("<P>When checked, pressing Enter in a chat window will send your message."
|
---|
212 | " You must use Shift+Enter in order to create a newline in the chat message."
|
---|
213 | " If unchecked, messages are sent by pressing Alt-S or Control-Enter, just as they are with regular messages.</P>"));
|
---|
214 |
|
---|
215 | // misc
|
---|
216 | bg_delChats = new QButtonGroup;
|
---|
217 | bg_delChats->setRadioButtonExclusive( true );
|
---|
218 | bg_delChats->insert( d->rb_delChatsClose, 0 );
|
---|
219 | bg_delChats->insert( d->rb_delChatsHour, 1 );
|
---|
220 | bg_delChats->insert( d->rb_delChatsDay, 2 );
|
---|
221 | bg_delChats->insert( d->rb_delChatsNever, 3 );
|
---|
222 |
|
---|
223 | QWhatsThis::add(d->ck_alwaysOnTop,
|
---|
224 | tr("Makes the main Psi window always be in front of other windows."));
|
---|
225 | QWhatsThis::add(d->ck_keepSizes,
|
---|
226 | tr("Makes Psi remember window size and positions for chats and messages."
|
---|
227 | " If disabled, the windows will always appear in their default positions and sizes."));
|
---|
228 | QWhatsThis::add(d->ck_jidComplete,
|
---|
229 | tr("Enables as-you-type JID autocompletion in message dialog."));
|
---|
230 | QWhatsThis::add(d->ck_grabUrls,
|
---|
231 | tr("Automatically attaches URLs from clipboard to the messages when enabled"));
|
---|
232 |
|
---|
233 | QString s = tr("<P>Controls how long the chat log will be kept in memory after the"
|
---|
234 | " chat window is closed.</P>");
|
---|
235 | QWhatsThis::add(d->rb_delChatsClose, s +
|
---|
236 | tr("<P>This option does not keep the chat log in memory.</P>"));
|
---|
237 | QWhatsThis::add(d->rb_delChatsHour, s +
|
---|
238 | tr("<P>This option keeps the chat log for 1 hour before deleting it.</P>"));
|
---|
239 | QWhatsThis::add(d->rb_delChatsDay, s +
|
---|
240 | tr("<P>This option keeps the chat log for 1 day before deleting it.</P>"));
|
---|
241 | QWhatsThis::add(d->rb_delChatsNever, s +
|
---|
242 | tr("<P>This options keeps the chat log forever.</P>"));
|
---|
243 |
|
---|
244 | // links
|
---|
245 | QWhatsThis::add(d->cb_link,
|
---|
246 | tr("Selects what applications to use for handling URLs and e-mail addresses."
|
---|
247 | " You can choose between the system default and custom applications."));
|
---|
248 |
|
---|
249 | s = tr("Enter the path to the application's executable and choose \"Custom\" in the list above.");
|
---|
250 | QWhatsThis::add(d->le_linkBrowser,
|
---|
251 | tr("Specify what custom browser application to use for handling URLs here.") + " " + s);
|
---|
252 | QWhatsThis::add(d->le_linkMailer,
|
---|
253 | tr("Specify what custom mailer application to use for handling e-mail addresses here.") + " " + s);
|
---|
254 |
|
---|
255 | return w;
|
---|
256 | }
|
---|
257 |
|
---|
258 | static int om_x11browse[] = { 0, 2, 1 };
|
---|
259 |
|
---|
260 | void OptionsTabGeneralMisc::applyOptions(Options *opt)
|
---|
261 | {
|
---|
262 | if ( !w )
|
---|
263 | return;
|
---|
264 |
|
---|
265 | GeneralMiscUI *d = (GeneralMiscUI *)w;
|
---|
266 |
|
---|
267 | // chat
|
---|
268 | opt->chatSays = d->ck_chatSays->isChecked();
|
---|
269 | opt->chatSoftReturn = d->ck_chatSoftReturn->isChecked();
|
---|
270 |
|
---|
271 | // misc
|
---|
272 | opt->alwaysOnTop = d->ck_alwaysOnTop->isChecked();
|
---|
273 | opt->keepSizes = d->ck_keepSizes->isChecked();
|
---|
274 | opt->jidComplete = d->ck_jidComplete->isChecked();
|
---|
275 | opt->grabUrls = d->ck_grabUrls->isChecked();
|
---|
276 | opt->delChats = bg_delChats->id( bg_delChats->selected() );
|
---|
277 |
|
---|
278 | // links
|
---|
279 | #ifdef Q_WS_X11
|
---|
280 | opt->browser = om_x11browse[ d->cb_link->currentItem() ];
|
---|
281 | #else
|
---|
282 | opt->browser = d->cb_link->currentItem();
|
---|
283 | #endif
|
---|
284 | opt->customBrowser = d->le_linkBrowser->text();
|
---|
285 | opt->customMailer = d->le_linkMailer->text();
|
---|
286 | }
|
---|
287 |
|
---|
288 | void OptionsTabGeneralMisc::restoreOptions(const Options *opt)
|
---|
289 | {
|
---|
290 | if ( !w )
|
---|
291 | return;
|
---|
292 |
|
---|
293 | GeneralMiscUI *d = (GeneralMiscUI *)w;
|
---|
294 |
|
---|
295 | // chat
|
---|
296 | d->ck_chatSays->setChecked( opt->chatSays );
|
---|
297 | d->ck_chatSoftReturn->setChecked( opt->chatSoftReturn );
|
---|
298 |
|
---|
299 | // misc
|
---|
300 | #ifdef Q_WS_MAC
|
---|
301 | d->ck_alwaysOnTop->setEnabled( false );
|
---|
302 | #else
|
---|
303 | d->ck_alwaysOnTop->setChecked( opt->alwaysOnTop );
|
---|
304 | #endif
|
---|
305 | d->ck_keepSizes->setChecked( opt->keepSizes );
|
---|
306 | d->ck_jidComplete->setChecked( opt->jidComplete );
|
---|
307 | d->ck_grabUrls->setChecked( opt->grabUrls );
|
---|
308 |
|
---|
309 | bg_delChats->setButton( opt->delChats );
|
---|
310 |
|
---|
311 | // links
|
---|
312 | connect(d->cb_link, SIGNAL(activated(int)), SLOT(selectBrowser(int)));
|
---|
313 | #ifdef Q_WS_WIN
|
---|
314 | d->cb_link->insertItem(tr("Windows Default Browser/Mail"));
|
---|
315 | d->cb_link->insertItem(tr("Custom"));
|
---|
316 | d->cb_link->setCurrentItem( opt->browser );
|
---|
317 | selectBrowser( opt->browser );
|
---|
318 | #endif
|
---|
319 | #ifdef Q_WS_PM
|
---|
320 | d->cb_link->insertItem(tr("PM Default Browser/Mail"));
|
---|
321 | d->cb_link->insertItem(tr("Custom"));
|
---|
322 | d->cb_link->setCurrentItem( opt->browser );
|
---|
323 | selectBrowser( opt->browser );
|
---|
324 | #endif
|
---|
325 | #ifdef Q_WS_X11
|
---|
326 | d->cb_link->insertItem(tr("KDE Default Browser/Mail"));
|
---|
327 | d->cb_link->insertItem(tr("GNOME2 Default Browser/Mail"));
|
---|
328 | d->cb_link->insertItem(tr("Custom"));
|
---|
329 | int rbi = om_x11browse[ opt->browser ];
|
---|
330 | d->cb_link->setCurrentItem( rbi );
|
---|
331 | selectBrowser( rbi );
|
---|
332 | #endif
|
---|
333 | #ifdef Q_WS_MAC
|
---|
334 | d->cb_link->insertItem(tr("MacOS Default Browser/Mail"));
|
---|
335 | d->cb_link->setCurrentItem( opt->browser );
|
---|
336 | selectBrowser( opt->browser );
|
---|
337 | #endif
|
---|
338 | d->le_linkBrowser->setText( opt->customBrowser );
|
---|
339 | d->le_linkMailer->setText( opt->customMailer );
|
---|
340 | }
|
---|
341 |
|
---|
342 | void OptionsTabGeneralMisc::selectBrowser(int x)
|
---|
343 | {
|
---|
344 | if ( !w )
|
---|
345 | return;
|
---|
346 |
|
---|
347 | bool enableCustom = TRUE;
|
---|
348 |
|
---|
349 | #ifdef Q_WS_WIN
|
---|
350 | if(x == 0)
|
---|
351 | enableCustom = FALSE;
|
---|
352 | #endif
|
---|
353 | #ifdef Q_WS_PM
|
---|
354 | if(x == 0)
|
---|
355 | enableCustom = FALSE;
|
---|
356 | #endif
|
---|
357 | #ifdef Q_WS_X11
|
---|
358 | if(x == 0 || x == 1)
|
---|
359 | enableCustom = FALSE;
|
---|
360 | #endif
|
---|
361 | #ifdef Q_WS_MAC
|
---|
362 | if(x == 0)
|
---|
363 | enableCustom = FALSE;
|
---|
364 | #endif
|
---|
365 |
|
---|
366 | GeneralMiscUI *d = (GeneralMiscUI *)w;
|
---|
367 | d->gb_linkCustom->setEnabled(enableCustom);
|
---|
368 | }
|
---|
369 |
|
---|
370 | //----------------------------------------------------------------------------
|
---|
371 | // OptionsTabGeneralNotifications
|
---|
372 | //----------------------------------------------------------------------------
|
---|
373 |
|
---|
374 | OptionsTabGeneralNotifications::OptionsTabGeneralNotifications(QObject *parent)
|
---|
375 | : OptionsTab(parent, "general_notifications", "general", tr("Notifications"), tr("Configure the popup notifications"))
|
---|
376 | {
|
---|
377 | w = 0;
|
---|
378 | }
|
---|
379 |
|
---|
380 | QWidget *OptionsTabGeneralNotifications::widget()
|
---|
381 | {
|
---|
382 | if ( w )
|
---|
383 | return 0;
|
---|
384 |
|
---|
385 | w = new GeneralNotifyUI();
|
---|
386 | //GeneralNotifyUI *d = (GeneralNotifyUI *)w;
|
---|
387 |
|
---|
388 | // TODO: add QWhatsThis for all controls on widget
|
---|
389 |
|
---|
390 | return w;
|
---|
391 | }
|
---|
392 |
|
---|
393 | void OptionsTabGeneralNotifications::applyOptions(Options *opt)
|
---|
394 | {
|
---|
395 | if ( !w )
|
---|
396 | return;
|
---|
397 |
|
---|
398 | GeneralNotifyUI *d = (GeneralNotifyUI *)w;
|
---|
399 | opt->ppIsOn = d->ck_popupOn->isChecked();
|
---|
400 | opt->ppMessage = d->ck_popupOnMessage->isChecked();
|
---|
401 | opt->ppChat = d->ck_popupOnChat->isChecked();
|
---|
402 | opt->ppHeadline = d->ck_popupOnHeadline->isChecked();
|
---|
403 | opt->ppFile = d->ck_popupOnFile->isChecked();
|
---|
404 | opt->ppStatus = d->ck_popupOnStatus->isChecked();
|
---|
405 | opt->ppOnline = d->ck_popupOnOnline->isChecked();
|
---|
406 | opt->ppOffline = d->ck_popupOnOffline->isChecked();
|
---|
407 | }
|
---|
408 |
|
---|
409 | void OptionsTabGeneralNotifications::restoreOptions(const Options *opt)
|
---|
410 | {
|
---|
411 | if ( !w )
|
---|
412 | return;
|
---|
413 |
|
---|
414 | GeneralNotifyUI *d = (GeneralNotifyUI *)w;
|
---|
415 | d->ck_popupOn->setChecked( true );
|
---|
416 | d->ck_popupOn->setChecked( opt->ppIsOn );
|
---|
417 | d->ck_popupOnMessage->setChecked( opt->ppMessage );
|
---|
418 | d->ck_popupOnChat->setChecked( opt->ppChat );
|
---|
419 | d->ck_popupOnHeadline->setChecked( opt->ppHeadline );
|
---|
420 | d->ck_popupOnFile->setChecked( opt->ppFile );
|
---|
421 | d->ck_popupOnStatus->setChecked( opt->ppStatus );
|
---|
422 | d->ck_popupOnOnline->setChecked( opt->ppOnline );
|
---|
423 | d->ck_popupOnOffline->setChecked( opt->ppOffline );
|
---|
424 | }
|
---|
425 |
|
---|
426 | //----------------------------------------------------------------------------
|
---|
427 | // OptionsTabGeneralGroupchat -- TODO: simplify the code
|
---|
428 | //----------------------------------------------------------------------------
|
---|
429 |
|
---|
430 | OptionsTabGeneralGroupchat::OptionsTabGeneralGroupchat(QObject *parent)
|
---|
431 | : OptionsTab(parent, "general_groupchat", "general", tr("Groupchat"), tr("Configure the groupchat"))
|
---|
432 | {
|
---|
433 | w = 0;
|
---|
434 | }
|
---|
435 |
|
---|
436 | void OptionsTabGeneralGroupchat::setData(PsiCon *, QWidget *_dlg)
|
---|
437 | {
|
---|
438 | dlg = _dlg;
|
---|
439 | }
|
---|
440 |
|
---|
441 | QWidget *OptionsTabGeneralGroupchat::widget()
|
---|
442 | {
|
---|
443 | if ( w )
|
---|
444 | return 0;
|
---|
445 |
|
---|
446 | w = new GeneralGroupchatUI();
|
---|
447 | GeneralGroupchatUI *d = (GeneralGroupchatUI *)w;
|
---|
448 |
|
---|
449 | connect(d->pb_nickColor, SIGNAL(clicked()), SLOT(chooseGCNickColor()));
|
---|
450 | connect(d->lb_nickColors, SIGNAL(highlighted(int)), SLOT(selectedGCNickColor()));
|
---|
451 |
|
---|
452 | connect(d->pb_addHighlightWord, SIGNAL(clicked()), SLOT(addGCHighlight()));
|
---|
453 | connect(d->pb_removeHighlightWord, SIGNAL(clicked()), SLOT(removeGCHighlight()));
|
---|
454 |
|
---|
455 | connect(d->pb_addNickColor, SIGNAL(clicked()), SLOT(addGCNickColor()));
|
---|
456 | connect(d->pb_removeNickColor, SIGNAL(clicked()), SLOT(removeGCNickColor()));
|
---|
457 |
|
---|
458 | // TODO: add QWhatsThis for all controls on widget
|
---|
459 |
|
---|
460 | return w;
|
---|
461 | }
|
---|
462 |
|
---|
463 | void OptionsTabGeneralGroupchat::applyOptions(Options *opt)
|
---|
464 | {
|
---|
465 | if ( !w )
|
---|
466 | return;
|
---|
467 |
|
---|
468 | GeneralGroupchatUI *d = (GeneralGroupchatUI *)w;
|
---|
469 | opt->gcHighlighting = d->ck_gcHighlights->isChecked();
|
---|
470 | opt->gcNickColoring = d->ck_gcNickColoring->isChecked();
|
---|
471 |
|
---|
472 | QStringList highlight;
|
---|
473 | int i;
|
---|
474 | for (i = 0; i < (int)d->lb_highlightWords->count(); i++)
|
---|
475 | highlight << d->lb_highlightWords->item(i)->text();
|
---|
476 | opt->gcHighlights = highlight;
|
---|
477 |
|
---|
478 | QStringList colors;
|
---|
479 | for (i = 0; i < (int)d->lb_nickColors->count(); i++)
|
---|
480 | colors << d->lb_nickColors->item(i)->text();
|
---|
481 | opt->gcNickColors = colors;
|
---|
482 | }
|
---|
483 |
|
---|
484 | void OptionsTabGeneralGroupchat::restoreOptions(const Options *opt)
|
---|
485 | {
|
---|
486 | if ( !w )
|
---|
487 | return;
|
---|
488 |
|
---|
489 | GeneralGroupchatUI *d = (GeneralGroupchatUI *)w;
|
---|
490 |
|
---|
491 | // no need to call dataChanged() when these widgets are modified
|
---|
492 | disconnect(d->le_newNickColor, SIGNAL(textChanged(const QString &)), 0, 0);
|
---|
493 | disconnect(d->le_newHighlightWord, SIGNAL(textChanged(const QString &)), 0, 0);
|
---|
494 | connect(d->le_newNickColor, SIGNAL(textChanged(const QString &)), SLOT(displayGCNickColor()));
|
---|
495 |
|
---|
496 | d->ck_gcHighlights->setChecked( true );
|
---|
497 | d->ck_gcHighlights->setChecked( opt->gcHighlighting );
|
---|
498 | d->ck_gcNickColoring->setChecked( true );
|
---|
499 | d->ck_gcNickColoring->setChecked( opt->gcNickColoring );
|
---|
500 | d->lb_highlightWords->clear();
|
---|
501 | d->lb_highlightWords->insertStringList( opt->gcHighlights );
|
---|
502 | d->lb_nickColors->clear();
|
---|
503 |
|
---|
504 | QStringList::ConstIterator it = opt->gcNickColors.begin();
|
---|
505 | for ( ; it != opt->gcNickColors.end(); ++it)
|
---|
506 | addNickColor( *it );
|
---|
507 |
|
---|
508 | d->le_newHighlightWord->setText("");
|
---|
509 | d->le_newNickColor->setText("#FFFFFF");
|
---|
510 | }
|
---|
511 |
|
---|
512 | static QPixmap name2color(QString name)
|
---|
513 | {
|
---|
514 | QColor c(name);
|
---|
515 | QPixmap pix(16, 16);
|
---|
516 | QPainter p(&pix);
|
---|
517 |
|
---|
518 | p.fillRect(0, 0, pix.width(), pix.height(), QBrush(c));
|
---|
519 | p.setPen( QColor(0, 0, 0) );
|
---|
520 | p.drawRect(0, 0, pix.width(), pix.height());
|
---|
521 | p.end();
|
---|
522 |
|
---|
523 | return pix;
|
---|
524 | }
|
---|
525 |
|
---|
526 | void OptionsTabGeneralGroupchat::addNickColor(QString name)
|
---|
527 | {
|
---|
528 | GeneralGroupchatUI *d = (GeneralGroupchatUI *)w;
|
---|
529 | d->lb_nickColors->insertItem(name2color(name), name);
|
---|
530 | }
|
---|
531 |
|
---|
532 | void OptionsTabGeneralGroupchat::addGCHighlight()
|
---|
533 | {
|
---|
534 | GeneralGroupchatUI *d = (GeneralGroupchatUI *)w;
|
---|
535 | if ( d->le_newHighlightWord->text().isEmpty() )
|
---|
536 | return;
|
---|
537 |
|
---|
538 | d->lb_highlightWords->insertItem( d->le_newHighlightWord->text() );
|
---|
539 | d->le_newHighlightWord->setFocus();
|
---|
540 | d->le_newHighlightWord->setText("");
|
---|
541 |
|
---|
542 | emit dataChanged();
|
---|
543 | }
|
---|
544 |
|
---|
545 | void OptionsTabGeneralGroupchat::removeGCHighlight()
|
---|
546 | {
|
---|
547 | GeneralGroupchatUI *d = (GeneralGroupchatUI *)w;
|
---|
548 | int id = d->lb_highlightWords->currentItem();
|
---|
549 | if ( id == -1 )
|
---|
550 | return;
|
---|
551 |
|
---|
552 | d->lb_highlightWords->removeItem(id);
|
---|
553 |
|
---|
554 | emit dataChanged();
|
---|
555 | }
|
---|
556 |
|
---|
557 | void OptionsTabGeneralGroupchat::addGCNickColor()
|
---|
558 | {
|
---|
559 | GeneralGroupchatUI *d = (GeneralGroupchatUI *)w;
|
---|
560 | if ( d->le_newNickColor->text().isEmpty() )
|
---|
561 | return;
|
---|
562 |
|
---|
563 | addNickColor( d->le_newNickColor->text() );
|
---|
564 | d->le_newNickColor->setFocus();
|
---|
565 | d->le_newNickColor->setText("");
|
---|
566 |
|
---|
567 | emit dataChanged();
|
---|
568 | }
|
---|
569 |
|
---|
570 | void OptionsTabGeneralGroupchat::removeGCNickColor()
|
---|
571 | {
|
---|
572 | GeneralGroupchatUI *d = (GeneralGroupchatUI *)w;
|
---|
573 | int id = d->lb_nickColors->currentItem();
|
---|
574 | if ( id == -1 )
|
---|
575 | return;
|
---|
576 |
|
---|
577 | d->lb_nickColors->removeItem(id);
|
---|
578 |
|
---|
579 | emit dataChanged();
|
---|
580 | }
|
---|
581 |
|
---|
582 | void OptionsTabGeneralGroupchat::chooseGCNickColor()
|
---|
583 | {
|
---|
584 | GeneralGroupchatUI *d = (GeneralGroupchatUI *)w;
|
---|
585 | QColor c = QColorDialog::getColor(QColor(d->le_newNickColor->text()), dlg);
|
---|
586 | if ( c.isValid() ) {
|
---|
587 | QString cs = c.name();
|
---|
588 | d->le_newNickColor->setText(cs);
|
---|
589 | }
|
---|
590 | }
|
---|
591 |
|
---|
592 | void OptionsTabGeneralGroupchat::selectedGCNickColor()
|
---|
593 | {
|
---|
594 | GeneralGroupchatUI *d = (GeneralGroupchatUI *)w;
|
---|
595 | int id = d->lb_nickColors->currentItem();
|
---|
596 | if ( id == -1 )
|
---|
597 | return;
|
---|
598 |
|
---|
599 | d->le_newNickColor->setText( d->lb_nickColors->text(id) );
|
---|
600 | }
|
---|
601 |
|
---|
602 | void OptionsTabGeneralGroupchat::displayGCNickColor()
|
---|
603 | {
|
---|
604 | GeneralGroupchatUI *d = (GeneralGroupchatUI *)w;
|
---|
605 | d->pb_nickColor->setPixmap( name2color(d->le_newNickColor->text()) );
|
---|
606 | }
|
---|