| 1 | #include "opt_chat.h"
|
|---|
| 2 | #include "common.h"
|
|---|
| 3 | #include "iconwidget.h"
|
|---|
| 4 |
|
|---|
| 5 | #include <qwhatsthis.h>
|
|---|
| 6 | #include <qcheckbox.h>
|
|---|
| 7 | #include <qcombobox.h>
|
|---|
| 8 | #include <qbuttongroup.h>
|
|---|
| 9 | #include <qradiobutton.h>
|
|---|
| 10 |
|
|---|
| 11 | #include "opt_chat-ui.h"
|
|---|
| 12 |
|
|---|
| 13 | //----------------------------------------------------------------------------
|
|---|
| 14 | // OptionsTabChat
|
|---|
| 15 | //----------------------------------------------------------------------------
|
|---|
| 16 |
|
|---|
| 17 | OptionsTabChat::OptionsTabChat(QObject *parent)
|
|---|
| 18 | : OptionsTab(parent, "chat", "", tr("Chat"), tr("Configure the chat dialog"), "psi/start-chat")
|
|---|
| 19 | {
|
|---|
| 20 | w = 0;
|
|---|
| 21 | bg_delChats = bg_defAct = 0;
|
|---|
| 22 | }
|
|---|
| 23 |
|
|---|
| 24 | OptionsTabChat::~OptionsTabChat()
|
|---|
| 25 | {
|
|---|
| 26 | if ( bg_defAct )
|
|---|
| 27 | delete bg_defAct;
|
|---|
| 28 | if ( bg_delChats )
|
|---|
| 29 | delete bg_delChats;
|
|---|
| 30 | }
|
|---|
| 31 |
|
|---|
| 32 | QWidget *OptionsTabChat::widget()
|
|---|
| 33 | {
|
|---|
| 34 | if ( w )
|
|---|
| 35 | return 0;
|
|---|
| 36 |
|
|---|
| 37 | w = new OptChatUI();
|
|---|
| 38 | OptChatUI *d = (OptChatUI *)w;
|
|---|
| 39 |
|
|---|
| 40 | bg_defAct = new QButtonGroup;
|
|---|
| 41 | bg_defAct->setRadioButtonExclusive( true );
|
|---|
| 42 | bg_defAct->insert( d->rb_defActMsg, 0 );
|
|---|
| 43 | bg_defAct->insert( d->rb_defActChat, 1 );
|
|---|
| 44 |
|
|---|
| 45 | bg_delChats = new QButtonGroup;
|
|---|
| 46 | bg_delChats->setRadioButtonExclusive( true );
|
|---|
| 47 | bg_delChats->insert( d->rb_delChatsClose, 0 );
|
|---|
| 48 | bg_delChats->insert( d->rb_delChatsHour, 1 );
|
|---|
| 49 | bg_delChats->insert( d->rb_delChatsDay, 2 );
|
|---|
| 50 | bg_delChats->insert( d->rb_delChatsNever, 3 );
|
|---|
| 51 |
|
|---|
| 52 | QWhatsThis::add(d->rb_defActMsg,
|
|---|
| 53 | tr("Make the default action open a normal message window."));
|
|---|
| 54 | QWhatsThis::add(d->rb_defActChat,
|
|---|
| 55 | tr("Make the default action open a chat window."));
|
|---|
| 56 | QWhatsThis::add(d->ck_chatSays,
|
|---|
| 57 | tr("<P>Changes the normal chat style from:</P>"
|
|---|
| 58 | "<P>[01:23:45] <MyName> Hi</P>"
|
|---|
| 59 | "<P>[01:23:56] <YourName> How are you?</P>"
|
|---|
| 60 | "<P>to:</P>"
|
|---|
| 61 | "<P>[01:23:45] MyName says:</P>"
|
|---|
| 62 | "<P>Hi</P>"
|
|---|
| 63 | "<P>[01:23:56] YourName says:</P>"
|
|---|
| 64 | "<P>How are you?</P>"));
|
|---|
| 65 | QWhatsThis::add(d->ck_chatSoftReturn,
|
|---|
| 66 | tr("<P>When checked, pressing Enter in a chat window will send your message."
|
|---|
| 67 | " You must use Shift+Enter in order to create a newline in the chat message."
|
|---|
| 68 | " If unchecked, messages are sent by pressing Alt-S or Control-Enter, just as they are with regular messages.</P>"));
|
|---|
| 69 | QWhatsThis::add(d->ck_alertOpenChats,
|
|---|
| 70 | tr("Normally, Psi will not alert you when a new chat message"
|
|---|
| 71 | " is received in a chat window that is already open."
|
|---|
| 72 | " Check this option if you want to receive these alerts anyway."));
|
|---|
| 73 | QWhatsThis::add(d->ck_raiseChatWindow,
|
|---|
| 74 | tr("Makes Psi bring an open chat window to the front of your screen when you receive a new message."
|
|---|
| 75 | " It does not take the keyboard focus, so it will not interfere with your work."));
|
|---|
| 76 | QWhatsThis::add(d->ck_smallChats,
|
|---|
| 77 | tr("Makes Psi open chat windows in compact mode."));
|
|---|
| 78 | QWhatsThis::add(d->ck_tabChats,
|
|---|
| 79 | tr("Makes Psi open chats in a tabbed window."));
|
|---|
| 80 | QString s = tr("<P>Controls how long the chat log will be kept in memory after the"
|
|---|
| 81 | " chat window is closed.</P>");
|
|---|
| 82 | QWhatsThis::add(d->rb_delChatsClose, s +
|
|---|
| 83 | tr("<P>This option does not keep the chat log in memory.</P>"));
|
|---|
| 84 | QWhatsThis::add(d->rb_delChatsHour, s +
|
|---|
| 85 | tr("<P>This option keeps the chat log for 1 hour before deleting it.</P>"));
|
|---|
| 86 | QWhatsThis::add(d->rb_delChatsDay, s +
|
|---|
| 87 | tr("<P>This option keeps the chat log for 1 day before deleting it.</P>"));
|
|---|
| 88 | QWhatsThis::add(d->rb_delChatsNever, s +
|
|---|
| 89 | tr("<P>This options keeps the chat log forever.</P>"));
|
|---|
| 90 |
|
|---|
| 91 | return w;
|
|---|
| 92 | }
|
|---|
| 93 |
|
|---|
| 94 | void OptionsTabChat::applyOptions(Options *opt)
|
|---|
| 95 | {
|
|---|
| 96 | if ( !w )
|
|---|
| 97 | return;
|
|---|
| 98 |
|
|---|
| 99 | OptChatUI *d = (OptChatUI *)w;
|
|---|
| 100 |
|
|---|
| 101 | opt->defaultAction = bg_defAct->id(bg_defAct->selected());
|
|---|
| 102 | opt->chatSays = d->ck_chatSays->isChecked();
|
|---|
| 103 | opt->chatSoftReturn = d->ck_chatSoftReturn->isChecked();
|
|---|
| 104 | opt->alertOpenChats = d->ck_alertOpenChats->isChecked();
|
|---|
| 105 | opt->raiseChatWindow = d->ck_raiseChatWindow->isChecked();
|
|---|
| 106 | opt->oldSmallChats = opt->smallChats;
|
|---|
| 107 | opt->smallChats = d->ck_smallChats->isChecked();
|
|---|
| 108 | opt->delChats = bg_delChats->id( bg_delChats->selected() );
|
|---|
| 109 | opt->useTabs = d->ck_tabChats->isChecked();
|
|---|
| 110 | opt->chatLineEdit = d->ck_autoResize->isChecked();
|
|---|
| 111 | }
|
|---|
| 112 |
|
|---|
| 113 | void OptionsTabChat::restoreOptions(const Options *opt)
|
|---|
| 114 | {
|
|---|
| 115 | if ( !w )
|
|---|
| 116 | return;
|
|---|
| 117 |
|
|---|
| 118 | OptChatUI *d = (OptChatUI *)w;
|
|---|
| 119 |
|
|---|
| 120 | bg_defAct->setButton( opt->defaultAction );
|
|---|
| 121 | d->ck_chatSays->setChecked( opt->chatSays );
|
|---|
| 122 | d->ck_chatSoftReturn->setChecked( opt->chatSoftReturn );
|
|---|
| 123 | d->ck_alertOpenChats->setChecked( opt->alertOpenChats );
|
|---|
| 124 | d->ck_raiseChatWindow->setChecked( opt->raiseChatWindow );
|
|---|
| 125 | d->ck_smallChats->setChecked( opt->smallChats );
|
|---|
| 126 | d->ck_tabChats->setChecked( opt->useTabs );
|
|---|
| 127 | d->ck_autoResize->setChecked( opt->chatLineEdit );
|
|---|
| 128 | bg_delChats->setButton( opt->delChats );
|
|---|
| 129 | }
|
|---|