kandy

kandyprefsdialog.cpp
1/*
2 This file is part of Kandy.
3
4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
20 As a special exception, permission is given to link this program
21 with any edition of TQt, and distribute the resulting executable,
22 without including the source code for TQt in the source distribution.
23*/
24
25#include <tqlayout.h>
26#include <tqlabel.h>
27#include <tqgroupbox.h>
28#include <tqbuttongroup.h>
29#include <tqlineedit.h>
30#include <tqfont.h>
31#include <tqslider.h>
32#include <tqfile.h>
33#include <tqtextstream.h>
34#include <tqcombobox.h>
35#include <tqvbox.h>
36#include <tqhbox.h>
37#include <tqspinbox.h>
38#include <tqdatetime.h>
39
40#include <tdeapplication.h>
41#include <kdebug.h>
42#include <tdelocale.h>
43#include <tdeglobal.h>
44#include <tdefontdialog.h>
45#include <tdestandarddirs.h>
46#include <tdemessagebox.h>
47#include <kcolordialog.h>
48#include <kiconloader.h>
49#include <kiconeffect.h>
50
51#include "kandyprefs.h"
52
53#include "kandyprefsdialog.h"
54#include "kandyprefsdialog.moc"
55
56
57KandyPrefsDialog::KandyPrefsDialog(TQWidget *parent, char *name, bool modal) :
58 KPrefsDialog(KandyPrefs::self(),parent,name,modal)
59{
60 setupSerialTab();
61 setupAddressbookTab();
62 setupWindowsTab();
63}
64
65
66KandyPrefsDialog::~KandyPrefsDialog()
67{
68 delete serialDevice;
69 delete lockDir;
70 delete openOnStartup;
71 delete startupTerminal;
72 delete startupMobile;
73}
74
75void KandyPrefsDialog::setupSerialTab()
76{
77 TQFrame *topFrame = addPage(i18n("Serial Interface"),0,
78 DesktopIcon("connect_no",TDEIcon::SizeMedium));
79
80 TQGridLayout *topLayout = new TQGridLayout(topFrame,6,2);
81 topLayout->setSpacing(spacingHint());
82 topLayout->setMargin(marginHint());
83
84 // Define serial device
85 serialDevice = addWidString( KandyPrefs::self()->serialDeviceItem(),
86 topFrame );
87 topLayout->addWidget(serialDevice->label(),0,0);
88 topLayout->addWidget(serialDevice->lineEdit(),0,1);
89
90 // Define baud rate
91 baudRate = addWidString( KandyPrefs::self()->baudRateItem(), topFrame );
92 topLayout->addWidget( baudRate->label(), 1, 0 );
93 topLayout->addWidget( baudRate->lineEdit(), 1, 1 );
94
95 // Define location of LOCK file
96 lockDir = addWidString( KandyPrefs::self()->lockDirectoryItem(),
97 topFrame );
98 topLayout->addWidget(lockDir->label(),2,0);
99 topLayout->addWidget(lockDir->lineEdit(),2,1);
100
101 // Define startup modem behavior
102 openOnStartup = addWidBool( KandyPrefs::self()->startupModemItem(),
103 topFrame );
104 topLayout->addWidget(openOnStartup->checkBox(),3,0);
105
106 // Define clock setting hevahior
107 autoSetClock = addWidBool( KandyPrefs::self()->autoSetClockItem(),
108 topFrame );
109 topLayout->addWidget(autoSetClock->checkBox(),4,0);
110
111 topLayout->setRowStretch(5,1);
112}
113
114void KandyPrefsDialog::setupAddressbookTab()
115{
116 TQFrame *topFrame = addPage(i18n("Address Book"), 0,
117 DesktopIcon("kaddressbook", TDEIcon::SizeMedium));
118
119 TQGridLayout *topLayout = new TQGridLayout(topFrame, 13, 4);
120 topLayout->setSpacing(spacingHint());
121 topLayout->setMargin(marginHint());
122
123 excHome = addWidBool ( KandyPrefs::self()->excludeHomeItem(), topFrame );
124 topLayout->addWidget(excHome->checkBox(), 0, 0);
125
126 excWork = addWidBool ( KandyPrefs::self()->excludeWorkItem(), topFrame );
127 topLayout->addWidget(excWork->checkBox(), 1, 0);
128
129 excMsg = addWidBool ( KandyPrefs::self()->excludeMessagingItem(), topFrame );
130 topLayout->addWidget(excMsg->checkBox(), 2, 0);
131
132 excFax = addWidBool ( KandyPrefs::self()->excludeFaxItem(), topFrame );
133 topLayout->addWidget(excFax->checkBox(), 3, 0);
134
135 excCell = addWidBool ( KandyPrefs::self()->excludeCellItem(), topFrame );
136 topLayout->addWidget(excCell->checkBox(), 4, 0);
137
138 excVideo = addWidBool ( KandyPrefs::self()->excludeVideoItem(), topFrame );
139 topLayout->addWidget(excVideo->checkBox(), 5, 0);
140
141 excBbs = addWidBool ( KandyPrefs::self()->excludeMailboxItem(), topFrame );
142 topLayout->addWidget(excBbs->checkBox(), 6, 0);
143
144 excModem = addWidBool ( KandyPrefs::self()->excludeModemItem(), topFrame );
145 topLayout->addWidget(excModem->checkBox(), 7, 0);
146
147 excCar = addWidBool ( KandyPrefs::self()->excludeCarItem(), topFrame );
148 topLayout->addWidget(excCar->checkBox(), 8, 0);
149
150 excISDN = addWidBool ( KandyPrefs::self()->excludeISDNItem(), topFrame );
151 topLayout->addWidget(excISDN->checkBox(), 9, 0);
152
153 excPager = addWidBool ( KandyPrefs::self()->excludePagerItem(), topFrame );
154 topLayout->addWidget(excPager->checkBox(), 10, 0);
155
156
157 useHomeSuff = addWidBool ( KandyPrefs::self()->useHomeSuffItem(), topFrame );
158 topLayout->addWidget(useHomeSuff->checkBox(), 0, 1);
159
160 useWorkSuff = addWidBool ( KandyPrefs::self()->useWorkSuffItem(), topFrame );
161 topLayout->addWidget(useWorkSuff->checkBox(), 1, 1);
162
163 useMessagingSuff = addWidBool ( KandyPrefs::self()->useMessagingSuffItem(), topFrame );
164 topLayout->addWidget(useMessagingSuff->checkBox(), 2, 1);
165
166 useFaxSuff = addWidBool ( KandyPrefs::self()->useFaxSuffItem(), topFrame );
167 topLayout->addWidget(useFaxSuff->checkBox(), 3, 1);
168
169 useCellSuff = addWidBool ( KandyPrefs::self()->useCellSuffItem(), topFrame );
170 topLayout->addWidget(useCellSuff->checkBox(), 4, 1);
171
172 useVideoSuff = addWidBool ( KandyPrefs::self()->useVideoSuffItem(), topFrame );
173 topLayout->addWidget(useVideoSuff->checkBox(), 5, 1);
174
175 useMailboxSuff = addWidBool ( KandyPrefs::self()->useMailboxSuffItem(), topFrame );
176 topLayout->addWidget(useMailboxSuff->checkBox(), 6, 1);
177
178 useModemSuff = addWidBool ( KandyPrefs::self()->useModemSuffItem(), topFrame );
179 topLayout->addWidget(useModemSuff->checkBox(), 7, 1);
180
181 useCarSuff = addWidBool ( KandyPrefs::self()->useCarSuffItem(), topFrame );
182 topLayout->addWidget(useCarSuff->checkBox(), 8, 1);
183
184 useISDNSuff = addWidBool ( KandyPrefs::self()->useISDNSuffItem(), topFrame );
185 topLayout->addWidget(useISDNSuff->checkBox(), 9, 1);
186
187 usePagerSuff = addWidBool ( KandyPrefs::self()->usePagerSuffItem(), topFrame );
188 topLayout->addWidget(usePagerSuff->checkBox(), 10, 1);
189
190
191 HomeSuff = addWidString( KandyPrefs::self()->homeSuffItem(), topFrame );
192 topLayout->addWidget(HomeSuff->label(), 0, 2);
193 topLayout->addWidget(HomeSuff->lineEdit(), 0, 3);
194
195 WorkSuff = addWidString( KandyPrefs::self()->workSuffItem(), topFrame );
196 topLayout->addWidget(WorkSuff->label(), 1, 2);
197 topLayout->addWidget(WorkSuff->lineEdit(), 1, 3);
198
199 MessagingSuff = addWidString( KandyPrefs::self()->messagingSuffItem(), topFrame );
200 topLayout->addWidget(MessagingSuff->label(), 2, 2);
201 topLayout->addWidget(MessagingSuff->lineEdit(), 2, 3);
202
203 FaxSuff = addWidString( KandyPrefs::self()->faxSuffItem(), topFrame );
204 topLayout->addWidget(FaxSuff->label(), 3, 2);
205 topLayout->addWidget(FaxSuff->lineEdit(), 3, 3);
206
207 CellSuff = addWidString( KandyPrefs::self()->cellSuffItem(), topFrame );
208 topLayout->addWidget(CellSuff->label(), 4, 2);
209 topLayout->addWidget(CellSuff->lineEdit(), 4, 3);
210
211 VideoSuff = addWidString( KandyPrefs::self()->videoSuffItem(), topFrame );
212 topLayout->addWidget(VideoSuff->label(), 5, 2);
213 topLayout->addWidget(VideoSuff->lineEdit(), 5, 3);
214
215 MailboxSuff = addWidString( KandyPrefs::self()->mailboxSuffItem(), topFrame );
216 topLayout->addWidget(MailboxSuff->label(), 6, 2);
217 topLayout->addWidget(MailboxSuff->lineEdit(), 6, 3);
218
219 ModemSuff = addWidString( KandyPrefs::self()->modemSuffItem(), topFrame );
220 topLayout->addWidget(ModemSuff->label(), 7, 2);
221 topLayout->addWidget(ModemSuff->lineEdit(), 7, 3);
222
223 CarSuff = addWidString( KandyPrefs::self()->carSuffItem(), topFrame );
224 topLayout->addWidget(CarSuff->label(), 8, 2);
225 topLayout->addWidget(CarSuff->lineEdit(), 8, 3);
226
227 ISDNSuff = addWidString( KandyPrefs::self()->iSDNSuffItem(), topFrame );
228 topLayout->addWidget(ISDNSuff->label(), 9, 2);
229 topLayout->addWidget(ISDNSuff->lineEdit(), 9, 3);
230
231 PagerSuff = addWidString( KandyPrefs::self()->pagerSuffItem(), topFrame );
232 topLayout->addWidget(PagerSuff->label(), 10, 2);
233 topLayout->addWidget(PagerSuff->lineEdit(), 10, 3);
234
235
236 topLayout->setRowStretch(11, 1);
237
238 if ( !KandyPrefs::self()->useHomeSuff() )
239 {
240 HomeSuff->lineEdit()->setEnabled( false );
241 HomeSuff->label()->setEnabled( false );
242 }
243 if ( !KandyPrefs::self()->useWorkSuff() )
244 {
245 WorkSuff->lineEdit()->setEnabled( false );
246 WorkSuff->label()->setEnabled( false );
247 }
248 if ( !KandyPrefs::self()->useMessagingSuff() )
249 {
250 MessagingSuff->lineEdit()->setEnabled( false );
251 MessagingSuff->label()->setEnabled( false );
252 }
253 if ( !KandyPrefs::self()->useFaxSuff() )
254 {
255 FaxSuff->lineEdit()->setEnabled( false );
256 FaxSuff->label()->setEnabled( false );
257 }
258 if ( !KandyPrefs::self()->useCellSuff() )
259 {
260 CellSuff->lineEdit()->setEnabled( false );
261 CellSuff->label()->setEnabled( false );
262 }
263 if ( !KandyPrefs::self()->useVideoSuff() )
264 {
265 VideoSuff->lineEdit()->setEnabled( false );
266 VideoSuff->label()->setEnabled( false );
267 }
268 if ( !KandyPrefs::self()->useMailboxSuff() )
269 {
270 MailboxSuff->lineEdit()->setEnabled( false );
271 MailboxSuff->label()->setEnabled( false );
272 }
273 if ( !KandyPrefs::self()->useModemSuff() )
274 {
275 ModemSuff->lineEdit()->setEnabled( false );
276 ModemSuff->label()->setEnabled( false );
277 }
278 if ( !KandyPrefs::self()->useCarSuff() )
279 {
280 CarSuff->lineEdit()->setEnabled( false );
281 CarSuff->label()->setEnabled( false );
282 }
283 if ( !KandyPrefs::self()->useISDNSuff() )
284 {
285 ISDNSuff->lineEdit()->setEnabled( false );
286 ISDNSuff->label()->setEnabled( false );
287 }
288 if ( !KandyPrefs::self()->usePagerSuff() )
289 {
290 PagerSuff->lineEdit()->setEnabled( false );
291 PagerSuff->label()->setEnabled( false );
292 }
293
294
295 connect( useHomeSuff->checkBox(), TQ_SIGNAL(toggled(bool)),
296 HomeSuff->lineEdit(), TQ_SLOT(setEnabled(bool)) );
297 connect( useHomeSuff->checkBox(), TQ_SIGNAL(toggled(bool)),
298 HomeSuff->label(), TQ_SLOT(setEnabled(bool)) );
299
300 connect( useWorkSuff->checkBox(), TQ_SIGNAL(toggled(bool)),
301 WorkSuff->lineEdit(), TQ_SLOT(setEnabled(bool)) );
302 connect( useWorkSuff->checkBox(), TQ_SIGNAL(toggled(bool)),
303 WorkSuff->label(), TQ_SLOT(setEnabled(bool)) );
304
305 connect( useMessagingSuff->checkBox(), TQ_SIGNAL(toggled(bool)),
306 MessagingSuff->lineEdit(), TQ_SLOT(setEnabled(bool)) );
307 connect( useMessagingSuff->checkBox(), TQ_SIGNAL(toggled(bool)),
308 MessagingSuff->label(), TQ_SLOT(setEnabled(bool)) );
309
310 connect( useFaxSuff->checkBox(), TQ_SIGNAL(toggled(bool)),
311 FaxSuff->lineEdit(), TQ_SLOT(setEnabled(bool)) );
312 connect( useFaxSuff->checkBox(), TQ_SIGNAL(toggled(bool)),
313 FaxSuff->label(), TQ_SLOT(setEnabled(bool)) );
314
315 connect( useCellSuff->checkBox(), TQ_SIGNAL(toggled(bool)),
316 CellSuff->lineEdit(), TQ_SLOT(setEnabled(bool)) );
317 connect( useCellSuff->checkBox(), TQ_SIGNAL(toggled(bool)),
318 CellSuff->label(), TQ_SLOT(setEnabled(bool)) );
319
320 connect( useVideoSuff->checkBox(), TQ_SIGNAL(toggled(bool)),
321 VideoSuff->lineEdit(), TQ_SLOT(setEnabled(bool)) );
322 connect( useVideoSuff->checkBox(), TQ_SIGNAL(toggled(bool)),
323 VideoSuff->label(), TQ_SLOT(setEnabled(bool)) );
324
325 connect( useMailboxSuff->checkBox(), TQ_SIGNAL(toggled(bool)),
326 MailboxSuff->lineEdit(), TQ_SLOT(setEnabled(bool)) );
327 connect( useMailboxSuff->checkBox(), TQ_SIGNAL(toggled(bool)),
328 MailboxSuff->label(), TQ_SLOT(setEnabled(bool)) );
329
330 connect( useModemSuff->checkBox(), TQ_SIGNAL(toggled(bool)),
331 ModemSuff->lineEdit(), TQ_SLOT(setEnabled(bool)) );
332 connect( useModemSuff->checkBox(), TQ_SIGNAL(toggled(bool)),
333 ModemSuff->label(), TQ_SLOT(setEnabled(bool)) );
334
335 connect( useCarSuff->checkBox(), TQ_SIGNAL(toggled(bool)),
336 CarSuff->lineEdit(), TQ_SLOT(setEnabled(bool)) );
337 connect( useCarSuff->checkBox(), TQ_SIGNAL(toggled(bool)),
338 CarSuff->label(), TQ_SLOT(setEnabled(bool)) );
339
340 connect( useISDNSuff->checkBox(), TQ_SIGNAL(toggled(bool)),
341 ISDNSuff->lineEdit(), TQ_SLOT(setEnabled(bool)) );
342 connect( useISDNSuff->checkBox(), TQ_SIGNAL(toggled(bool)),
343 ISDNSuff->label(), TQ_SLOT(setEnabled(bool)) );
344
345 connect( usePagerSuff->checkBox(), TQ_SIGNAL(toggled(bool)),
346 PagerSuff->lineEdit(), TQ_SLOT(setEnabled(bool)) );
347 connect( usePagerSuff->checkBox(), TQ_SIGNAL(toggled(bool)),
348 PagerSuff->label(), TQ_SLOT(setEnabled(bool)) );
349}
350
351void KandyPrefsDialog::setupWindowsTab()
352{
353 TQFrame *topFrame = addPage(i18n("Windows"),0,
354 DesktopIcon("window_duplicate",TDEIcon::SizeMedium));
355
356 TQGridLayout *topLayout = new TQGridLayout(topFrame,6,2);
357 topLayout->setSpacing(spacingHint());
358 topLayout->setMargin(marginHint());
359
360 startupTerminal = addWidBool( KandyPrefs::self()->startupTerminalWinItem(),
361 topFrame);
362 topLayout->addWidget(startupTerminal->checkBox(),0,0);
363
364 startupMobile = addWidBool( KandyPrefs::self()->startupMobileWinItem(),
365 topFrame );
366 topLayout->addWidget(startupMobile->checkBox(),1,0);
367
368 topLayout->setRowStretch(2, 1);
369}
KandyPrefsDialog(TQWidget *parent=0, char *name=0, bool modal=false)
Initialize dialog and pages.