source: psi/trunk/src/options/opt_application.cpp

Last change on this file was 19, checked in by dmik, 19 years ago

UI: Misc changes:

  • Added OS/2-related definitions.
  • On all platforms but Mac, the main (roster) window will be minimized (instead of closing) when Esc is pressed, but the doclet window is disabled.
File size: 7.4 KB
Line 
1#include "opt_application.h"
2#include "common.h"
3#include "iconwidget.h"
4
5#include <qwhatsthis.h>
6#include <qcheckbox.h>
7#include <qcombobox.h>
8#include <qlineedit.h>
9#include <qgroupbox.h>
10
11#include "opt_application-ui.h"
12
13//----------------------------------------------------------------------------
14// OptionsTabApplication
15//----------------------------------------------------------------------------
16
17OptionsTabApplication::OptionsTabApplication(QObject *parent)
18: OptionsTab(parent, "application", "", tr("Application"), tr("General application options"), "psi/psi16")
19{
20 w = 0;
21}
22
23OptionsTabApplication::~OptionsTabApplication()
24{
25}
26
27QWidget *OptionsTabApplication::widget()
28{
29 if ( w )
30 return 0;
31
32 w = new OptApplicationUI();
33 OptApplicationUI *d = (OptApplicationUI *)w;
34
35 QWhatsThis::add(d->ck_alwaysOnTop,
36 tr("Makes the main Psi window always be in front of other windows."));
37 QWhatsThis::add(d->ck_autoRosterSize,
38 tr("Makes the main Psi window resize automatically to fit all contacts."));
39 QWhatsThis::add(d->ck_keepSizes,
40 tr("Makes Psi remember window size and positions for chats and messages."
41 " If disabled, the windows will always appear in their default positions and sizes."));
42 QWhatsThis::add(d->ck_useleft,
43 tr("Normally, right-clicking with the mouse on a contact will activate the context-menu."
44 " Check this option if you'd rather use a left-click."));
45 QWhatsThis::add(d->ck_hideMenubar,
46 tr("Hides the menubar in the application window."));
47 connect(d->ck_hideMenubar, SIGNAL(toggled(bool)), this, SLOT(hideMenubarToggled(bool)));
48
49 // links
50 QWhatsThis::add(d->cb_link,
51 tr("Selects what applications to use for handling URLs and e-mail addresses."
52 " You can choose between the system default and custom applications."));
53
54 QString s = tr("Enter the path to the application's executable and choose \"Custom\" in the list above.");
55 QWhatsThis::add(d->le_linkBrowser,
56 tr("Specify what custom browser application to use for handling URLs here.") + " " + s);
57 QWhatsThis::add(d->le_linkMailer,
58 tr("Specify what custom mailer application to use for handling e-mail addresses here.") + " " + s);
59
60 // docklet
61 QWhatsThis::add(d->ck_docklet,
62 tr("Makes Psi use a docklet icon, also known as system tray icon."));
63 QWhatsThis::add(d->ck_dockDCstyle,
64 tr("Normally, single-clicking on the Psi docklet icon brings the main window to"
65 " the foreground. Check this option if you would rather use a double-click."));
66 QWhatsThis::add(d->ck_dockHideMW,
67 tr("Starts Psi with only the docklet icon visible."));
68 QWhatsThis::add(d->ck_dockToolMW,
69 tr("Prevents Psi from taking up a slot on the taskbar and makes the main "
70 "window use a small titlebar."));
71 QWhatsThis::add(d->ck_dockUseWM,
72 tr("If checked, Psi will use the Window Maker docklet instead of FreeDesktop one."));
73
74#ifdef Q_WS_MAC
75 d->ck_alwaysOnTop->hide();
76 d->ck_hideMenubar->hide();
77 d->gb_links->hide();
78 d->ck_docklet->hide();
79 d->gb_docklet->hide();
80#endif
81#ifdef Q_WS_PM
82 /// @todo (dmik) disable "always on top" until implemented in Qt/2
83 d->ck_alwaysOnTop->hide();
84 /// @todo (dmik) disable the docklet until the xCenter plugin is implemented
85 d->ck_docklet->hide();
86 d->gb_docklet->hide();
87#endif
88#ifndef Q_WS_X11
89 d->ck_dockUseWM->hide();
90#endif
91
92 return w;
93}
94
95#ifdef Q_WS_X11
96static int om_x11browse[] = { 0, 2, 1 };
97#endif
98
99void OptionsTabApplication::applyOptions(Options *opt)
100{
101 if ( !w )
102 return;
103
104 OptApplicationUI *d = (OptApplicationUI *)w;
105
106 opt->alwaysOnTop = d->ck_alwaysOnTop->isChecked();
107 opt->autoRosterSize = d->ck_autoRosterSize->isChecked();
108 opt->keepSizes = d->ck_keepSizes->isChecked();
109 opt->useleft = d->ck_useleft->isChecked();
110 opt->hideMenubar = d->ck_hideMenubar->isChecked();
111
112 // links
113#ifdef Q_WS_X11
114 opt->browser = om_x11browse[ d->cb_link->currentItem() ];
115#else
116 opt->browser = d->cb_link->currentItem();
117#endif
118 opt->customBrowser = d->le_linkBrowser->text();
119 opt->customMailer = d->le_linkMailer->text();
120
121 // docklet
122 opt->useDock = d->ck_docklet->isChecked();
123 opt->dockDCstyle = d->ck_dockDCstyle->isChecked();
124 opt->dockHideMW = d->ck_dockHideMW->isChecked();
125 opt->dockToolMW = d->ck_dockToolMW->isChecked();
126 opt->isWMDock = d->ck_dockUseWM->isChecked();
127
128 // data transfer
129 opt->dtPort = d->le_dtPort->text().toInt();
130 opt->dtExternal = d->le_dtExternal->text();
131}
132
133void OptionsTabApplication::restoreOptions(const Options *opt)
134{
135 if ( !w )
136 return;
137
138 OptApplicationUI *d = (OptApplicationUI *)w;
139
140 d->ck_alwaysOnTop->setChecked( opt->alwaysOnTop );
141 d->ck_autoRosterSize->setChecked( opt->autoRosterSize );
142 d->ck_keepSizes->setChecked( opt->keepSizes );
143 d->ck_hideMenubar->setChecked( opt->hideMenubar );
144 d->ck_useleft->setChecked( opt->useleft );
145
146 // links
147 connect(d->cb_link, SIGNAL(activated(int)), SLOT(selectBrowser(int)));
148#ifdef Q_WS_WIN
149 d->cb_link->insertItem(tr("Windows Default Browser/Mail"));
150 d->cb_link->insertItem(tr("Custom"));
151 d->cb_link->setCurrentItem( opt->browser );
152 selectBrowser( opt->browser );
153#endif
154#ifdef Q_WS_PM
155 d->cb_link->insertItem(tr("PM Default Browser/Mail"));
156 d->cb_link->insertItem(tr("Custom"));
157 d->cb_link->setCurrentItem( opt->browser );
158 selectBrowser( opt->browser );
159#endif
160#ifdef Q_WS_X11
161 d->cb_link->insertItem(tr("KDE Default Browser/Mail"));
162 d->cb_link->insertItem(tr("GNOME2 Default Browser/Mail"));
163 d->cb_link->insertItem(tr("Custom"));
164 int rbi = om_x11browse[ opt->browser ];
165 d->cb_link->setCurrentItem( rbi );
166 selectBrowser( rbi );
167#endif
168#ifdef Q_WS_MAC
169 d->cb_link->insertItem(tr("Mac OS Default Browser/Mail"));
170 d->cb_link->setCurrentItem( opt->browser );
171 selectBrowser( opt->browser );
172#endif
173 d->le_linkBrowser->setText( opt->customBrowser );
174 d->le_linkMailer->setText( opt->customMailer );
175
176 // docklet
177 d->ck_docklet->setChecked( opt->useDock );
178 d->ck_dockDCstyle->setChecked( opt->dockDCstyle );
179 d->ck_dockHideMW->setChecked( opt->dockHideMW );
180 d->ck_dockToolMW->setChecked( opt->dockToolMW );
181 d->ck_dockUseWM->setChecked( opt->isWMDock );
182
183 // data transfer
184 d->le_dtPort->setText( QString::number(opt->dtPort) );
185 d->le_dtExternal->setText( opt->dtExternal );
186}
187
188void OptionsTabApplication::selectBrowser(int x)
189{
190 if ( !w )
191 return;
192
193 bool enableCustom = TRUE;
194
195#ifdef Q_WS_WIN
196 if(x == 0)
197 enableCustom = FALSE;
198#endif
199#ifdef Q_WS_PM
200 if(x == 0)
201 enableCustom = FALSE;
202#endif
203#ifdef Q_WS_X11
204 if(x == 0 || x == 1)
205 enableCustom = FALSE;
206#endif
207#ifdef Q_WS_MAC
208 if(x == 0)
209 enableCustom = FALSE;
210#endif
211
212 OptApplicationUI *d = (OptApplicationUI *)w;
213 d->gb_linkCustom->setEnabled(enableCustom);
214}
215
216#ifndef Q_WS_MAC
217void OptionsTabApplication::hideMenubarToggled(bool toggle)
218{
219 if (toggle == true) {
220 // check if all toolbars are disabled
221 bool toolbarsVisible = false;
222 QValueList<Options::ToolbarPrefs>::ConstIterator it = option.toolbars["mainWin"].begin();
223 for ( ; it != option.toolbars["mainWin"].end() && !toolbarsVisible; ++it) {
224 toolbarsVisible = toolbarsVisible || (*it).on;
225 }
226
227 // Check whether it is legal to disable the menubar
228 if ( !toolbarsVisible ) {
229 QMessageBox::warning(0, tr("Warning"),
230 tr("You can not disable <i>all</i> toolbars <i>and</i> the menubar. If you do so, you will be unable to enable them back, when you'll change your mind.\n"
231 "<br><br>\n"
232 "If you really-really want to disable all toolbars and the menubar, you need to edit the config.xml file by hand."),
233 tr("I understand"));
234 ((OptApplicationUI *)w)->ck_hideMenubar->setChecked(false);
235 }
236 }
237}
238#else
239void OptionsTabApplication::hideMenubarToggled(bool)
240{
241}
242#endif
Note: See TracBrowser for help on using the repository browser.