kandyprefsdialog.cpp
00001 /* 00002 This file is part of Kandy. 00003 00004 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 00005 00006 This program is free software; you can redistribute it and/or modify 00007 it under the terms of the GNU General Public License as published by 00008 the Free Software Foundation; either version 2 of the License, or 00009 (at your option) any later version. 00010 00011 This program is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 GNU General Public License for more details. 00015 00016 You should have received a copy of the GNU General Public License 00017 along with this program; if not, write to the Free Software 00018 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00019 00020 As a special exception, permission is given to link this program 00021 with any edition of TQt, and distribute the resulting executable, 00022 without including the source code for TQt in the source distribution. 00023 */ 00024 00025 #include <tqlayout.h> 00026 #include <tqlabel.h> 00027 #include <tqgroupbox.h> 00028 #include <tqbuttongroup.h> 00029 #include <tqlineedit.h> 00030 #include <tqfont.h> 00031 #include <tqslider.h> 00032 #include <tqfile.h> 00033 #include <tqtextstream.h> 00034 #include <tqcombobox.h> 00035 #include <tqvbox.h> 00036 #include <tqhbox.h> 00037 #include <tqspinbox.h> 00038 #include <tqdatetime.h> 00039 00040 #include <tdeapplication.h> 00041 #include <kdebug.h> 00042 #include <tdelocale.h> 00043 #include <tdeglobal.h> 00044 #include <tdefontdialog.h> 00045 #include <kstandarddirs.h> 00046 #include <tdemessagebox.h> 00047 #include <kcolordialog.h> 00048 #include <kiconloader.h> 00049 #include <kiconeffect.h> 00050 00051 #include "kandyprefs.h" 00052 00053 #include "kandyprefsdialog.h" 00054 #include "kandyprefsdialog.moc" 00055 00056 00057 KandyPrefsDialog::KandyPrefsDialog(TQWidget *parent, char *name, bool modal) : 00058 KPrefsDialog(KandyPrefs::self(),parent,name,modal) 00059 { 00060 setupSerialTab(); 00061 setupAddressbookTab(); 00062 setupWindowsTab(); 00063 } 00064 00065 00066 KandyPrefsDialog::~KandyPrefsDialog() 00067 { 00068 delete serialDevice; 00069 delete lockDir; 00070 delete openOnStartup; 00071 delete startupTerminal; 00072 delete startupMobile; 00073 } 00074 00075 void KandyPrefsDialog::setupSerialTab() 00076 { 00077 TQFrame *topFrame = addPage(i18n("Serial Interface"),0, 00078 DesktopIcon("connect_no",TDEIcon::SizeMedium)); 00079 00080 TQGridLayout *topLayout = new TQGridLayout(topFrame,6,2); 00081 topLayout->setSpacing(spacingHint()); 00082 topLayout->setMargin(marginHint()); 00083 00084 // Define serial device 00085 serialDevice = addWidString( KandyPrefs::self()->serialDeviceItem(), 00086 topFrame ); 00087 topLayout->addWidget(serialDevice->label(),0,0); 00088 topLayout->addWidget(serialDevice->lineEdit(),0,1); 00089 00090 // Define baud rate 00091 baudRate = addWidString( KandyPrefs::self()->baudRateItem(), topFrame ); 00092 topLayout->addWidget( baudRate->label(), 1, 0 ); 00093 topLayout->addWidget( baudRate->lineEdit(), 1, 1 ); 00094 00095 // Define location of LOCK file 00096 lockDir = addWidString( KandyPrefs::self()->lockDirectoryItem(), 00097 topFrame ); 00098 topLayout->addWidget(lockDir->label(),2,0); 00099 topLayout->addWidget(lockDir->lineEdit(),2,1); 00100 00101 // Define startup modem behavior 00102 openOnStartup = addWidBool( KandyPrefs::self()->startupModemItem(), 00103 topFrame ); 00104 topLayout->addWidget(openOnStartup->checkBox(),3,0); 00105 00106 // Define clock setting hevahior 00107 autoSetClock = addWidBool( KandyPrefs::self()->autoSetClockItem(), 00108 topFrame ); 00109 topLayout->addWidget(autoSetClock->checkBox(),4,0); 00110 00111 topLayout->setRowStretch(5,1); 00112 } 00113 00114 void KandyPrefsDialog::setupAddressbookTab() 00115 { 00116 TQFrame *topFrame = addPage(i18n("Address Book"), 0, 00117 DesktopIcon("kaddressbook", TDEIcon::SizeMedium)); 00118 00119 TQGridLayout *topLayout = new TQGridLayout(topFrame, 13, 4); 00120 topLayout->setSpacing(spacingHint()); 00121 topLayout->setMargin(marginHint()); 00122 00123 excHome = addWidBool ( KandyPrefs::self()->excludeHomeItem(), topFrame ); 00124 topLayout->addWidget(excHome->checkBox(), 0, 0); 00125 00126 excWork = addWidBool ( KandyPrefs::self()->excludeWorkItem(), topFrame ); 00127 topLayout->addWidget(excWork->checkBox(), 1, 0); 00128 00129 excMsg = addWidBool ( KandyPrefs::self()->excludeMessagingItem(), topFrame ); 00130 topLayout->addWidget(excMsg->checkBox(), 2, 0); 00131 00132 excFax = addWidBool ( KandyPrefs::self()->excludeFaxItem(), topFrame ); 00133 topLayout->addWidget(excFax->checkBox(), 3, 0); 00134 00135 excCell = addWidBool ( KandyPrefs::self()->excludeCellItem(), topFrame ); 00136 topLayout->addWidget(excCell->checkBox(), 4, 0); 00137 00138 excVideo = addWidBool ( KandyPrefs::self()->excludeVideoItem(), topFrame ); 00139 topLayout->addWidget(excVideo->checkBox(), 5, 0); 00140 00141 excBbs = addWidBool ( KandyPrefs::self()->excludeMailboxItem(), topFrame ); 00142 topLayout->addWidget(excBbs->checkBox(), 6, 0); 00143 00144 excModem = addWidBool ( KandyPrefs::self()->excludeModemItem(), topFrame ); 00145 topLayout->addWidget(excModem->checkBox(), 7, 0); 00146 00147 excCar = addWidBool ( KandyPrefs::self()->excludeCarItem(), topFrame ); 00148 topLayout->addWidget(excCar->checkBox(), 8, 0); 00149 00150 excISDN = addWidBool ( KandyPrefs::self()->excludeISDNItem(), topFrame ); 00151 topLayout->addWidget(excISDN->checkBox(), 9, 0); 00152 00153 excPager = addWidBool ( KandyPrefs::self()->excludePagerItem(), topFrame ); 00154 topLayout->addWidget(excPager->checkBox(), 10, 0); 00155 00156 00157 useHomeSuff = addWidBool ( KandyPrefs::self()->useHomeSuffItem(), topFrame ); 00158 topLayout->addWidget(useHomeSuff->checkBox(), 0, 1); 00159 00160 useWorkSuff = addWidBool ( KandyPrefs::self()->useWorkSuffItem(), topFrame ); 00161 topLayout->addWidget(useWorkSuff->checkBox(), 1, 1); 00162 00163 useMessagingSuff = addWidBool ( KandyPrefs::self()->useMessagingSuffItem(), topFrame ); 00164 topLayout->addWidget(useMessagingSuff->checkBox(), 2, 1); 00165 00166 useFaxSuff = addWidBool ( KandyPrefs::self()->useFaxSuffItem(), topFrame ); 00167 topLayout->addWidget(useFaxSuff->checkBox(), 3, 1); 00168 00169 useCellSuff = addWidBool ( KandyPrefs::self()->useCellSuffItem(), topFrame ); 00170 topLayout->addWidget(useCellSuff->checkBox(), 4, 1); 00171 00172 useVideoSuff = addWidBool ( KandyPrefs::self()->useVideoSuffItem(), topFrame ); 00173 topLayout->addWidget(useVideoSuff->checkBox(), 5, 1); 00174 00175 useMailboxSuff = addWidBool ( KandyPrefs::self()->useMailboxSuffItem(), topFrame ); 00176 topLayout->addWidget(useMailboxSuff->checkBox(), 6, 1); 00177 00178 useModemSuff = addWidBool ( KandyPrefs::self()->useModemSuffItem(), topFrame ); 00179 topLayout->addWidget(useModemSuff->checkBox(), 7, 1); 00180 00181 useCarSuff = addWidBool ( KandyPrefs::self()->useCarSuffItem(), topFrame ); 00182 topLayout->addWidget(useCarSuff->checkBox(), 8, 1); 00183 00184 useISDNSuff = addWidBool ( KandyPrefs::self()->useISDNSuffItem(), topFrame ); 00185 topLayout->addWidget(useISDNSuff->checkBox(), 9, 1); 00186 00187 usePagerSuff = addWidBool ( KandyPrefs::self()->usePagerSuffItem(), topFrame ); 00188 topLayout->addWidget(usePagerSuff->checkBox(), 10, 1); 00189 00190 00191 HomeSuff = addWidString( KandyPrefs::self()->homeSuffItem(), topFrame ); 00192 topLayout->addWidget(HomeSuff->label(), 0, 2); 00193 topLayout->addWidget(HomeSuff->lineEdit(), 0, 3); 00194 00195 WorkSuff = addWidString( KandyPrefs::self()->workSuffItem(), topFrame ); 00196 topLayout->addWidget(WorkSuff->label(), 1, 2); 00197 topLayout->addWidget(WorkSuff->lineEdit(), 1, 3); 00198 00199 MessagingSuff = addWidString( KandyPrefs::self()->messagingSuffItem(), topFrame ); 00200 topLayout->addWidget(MessagingSuff->label(), 2, 2); 00201 topLayout->addWidget(MessagingSuff->lineEdit(), 2, 3); 00202 00203 FaxSuff = addWidString( KandyPrefs::self()->faxSuffItem(), topFrame ); 00204 topLayout->addWidget(FaxSuff->label(), 3, 2); 00205 topLayout->addWidget(FaxSuff->lineEdit(), 3, 3); 00206 00207 CellSuff = addWidString( KandyPrefs::self()->cellSuffItem(), topFrame ); 00208 topLayout->addWidget(CellSuff->label(), 4, 2); 00209 topLayout->addWidget(CellSuff->lineEdit(), 4, 3); 00210 00211 VideoSuff = addWidString( KandyPrefs::self()->videoSuffItem(), topFrame ); 00212 topLayout->addWidget(VideoSuff->label(), 5, 2); 00213 topLayout->addWidget(VideoSuff->lineEdit(), 5, 3); 00214 00215 MailboxSuff = addWidString( KandyPrefs::self()->mailboxSuffItem(), topFrame ); 00216 topLayout->addWidget(MailboxSuff->label(), 6, 2); 00217 topLayout->addWidget(MailboxSuff->lineEdit(), 6, 3); 00218 00219 ModemSuff = addWidString( KandyPrefs::self()->modemSuffItem(), topFrame ); 00220 topLayout->addWidget(ModemSuff->label(), 7, 2); 00221 topLayout->addWidget(ModemSuff->lineEdit(), 7, 3); 00222 00223 CarSuff = addWidString( KandyPrefs::self()->carSuffItem(), topFrame ); 00224 topLayout->addWidget(CarSuff->label(), 8, 2); 00225 topLayout->addWidget(CarSuff->lineEdit(), 8, 3); 00226 00227 ISDNSuff = addWidString( KandyPrefs::self()->iSDNSuffItem(), topFrame ); 00228 topLayout->addWidget(ISDNSuff->label(), 9, 2); 00229 topLayout->addWidget(ISDNSuff->lineEdit(), 9, 3); 00230 00231 PagerSuff = addWidString( KandyPrefs::self()->pagerSuffItem(), topFrame ); 00232 topLayout->addWidget(PagerSuff->label(), 10, 2); 00233 topLayout->addWidget(PagerSuff->lineEdit(), 10, 3); 00234 00235 00236 topLayout->setRowStretch(11, 1); 00237 00238 if ( !KandyPrefs::self()->useHomeSuff() ) 00239 { 00240 HomeSuff->lineEdit()->setEnabled( false ); 00241 HomeSuff->label()->setEnabled( false ); 00242 } 00243 if ( !KandyPrefs::self()->useWorkSuff() ) 00244 { 00245 WorkSuff->lineEdit()->setEnabled( false ); 00246 WorkSuff->label()->setEnabled( false ); 00247 } 00248 if ( !KandyPrefs::self()->useMessagingSuff() ) 00249 { 00250 MessagingSuff->lineEdit()->setEnabled( false ); 00251 MessagingSuff->label()->setEnabled( false ); 00252 } 00253 if ( !KandyPrefs::self()->useFaxSuff() ) 00254 { 00255 FaxSuff->lineEdit()->setEnabled( false ); 00256 FaxSuff->label()->setEnabled( false ); 00257 } 00258 if ( !KandyPrefs::self()->useCellSuff() ) 00259 { 00260 CellSuff->lineEdit()->setEnabled( false ); 00261 CellSuff->label()->setEnabled( false ); 00262 } 00263 if ( !KandyPrefs::self()->useVideoSuff() ) 00264 { 00265 VideoSuff->lineEdit()->setEnabled( false ); 00266 VideoSuff->label()->setEnabled( false ); 00267 } 00268 if ( !KandyPrefs::self()->useMailboxSuff() ) 00269 { 00270 MailboxSuff->lineEdit()->setEnabled( false ); 00271 MailboxSuff->label()->setEnabled( false ); 00272 } 00273 if ( !KandyPrefs::self()->useModemSuff() ) 00274 { 00275 ModemSuff->lineEdit()->setEnabled( false ); 00276 ModemSuff->label()->setEnabled( false ); 00277 } 00278 if ( !KandyPrefs::self()->useCarSuff() ) 00279 { 00280 CarSuff->lineEdit()->setEnabled( false ); 00281 CarSuff->label()->setEnabled( false ); 00282 } 00283 if ( !KandyPrefs::self()->useISDNSuff() ) 00284 { 00285 ISDNSuff->lineEdit()->setEnabled( false ); 00286 ISDNSuff->label()->setEnabled( false ); 00287 } 00288 if ( !KandyPrefs::self()->usePagerSuff() ) 00289 { 00290 PagerSuff->lineEdit()->setEnabled( false ); 00291 PagerSuff->label()->setEnabled( false ); 00292 } 00293 00294 00295 connect( useHomeSuff->checkBox(), TQT_SIGNAL(toggled(bool)), 00296 HomeSuff->lineEdit(), TQT_SLOT(setEnabled(bool)) ); 00297 connect( useHomeSuff->checkBox(), TQT_SIGNAL(toggled(bool)), 00298 HomeSuff->label(), TQT_SLOT(setEnabled(bool)) ); 00299 00300 connect( useWorkSuff->checkBox(), TQT_SIGNAL(toggled(bool)), 00301 WorkSuff->lineEdit(), TQT_SLOT(setEnabled(bool)) ); 00302 connect( useWorkSuff->checkBox(), TQT_SIGNAL(toggled(bool)), 00303 WorkSuff->label(), TQT_SLOT(setEnabled(bool)) ); 00304 00305 connect( useMessagingSuff->checkBox(), TQT_SIGNAL(toggled(bool)), 00306 MessagingSuff->lineEdit(), TQT_SLOT(setEnabled(bool)) ); 00307 connect( useMessagingSuff->checkBox(), TQT_SIGNAL(toggled(bool)), 00308 MessagingSuff->label(), TQT_SLOT(setEnabled(bool)) ); 00309 00310 connect( useFaxSuff->checkBox(), TQT_SIGNAL(toggled(bool)), 00311 FaxSuff->lineEdit(), TQT_SLOT(setEnabled(bool)) ); 00312 connect( useFaxSuff->checkBox(), TQT_SIGNAL(toggled(bool)), 00313 FaxSuff->label(), TQT_SLOT(setEnabled(bool)) ); 00314 00315 connect( useCellSuff->checkBox(), TQT_SIGNAL(toggled(bool)), 00316 CellSuff->lineEdit(), TQT_SLOT(setEnabled(bool)) ); 00317 connect( useCellSuff->checkBox(), TQT_SIGNAL(toggled(bool)), 00318 CellSuff->label(), TQT_SLOT(setEnabled(bool)) ); 00319 00320 connect( useVideoSuff->checkBox(), TQT_SIGNAL(toggled(bool)), 00321 VideoSuff->lineEdit(), TQT_SLOT(setEnabled(bool)) ); 00322 connect( useVideoSuff->checkBox(), TQT_SIGNAL(toggled(bool)), 00323 VideoSuff->label(), TQT_SLOT(setEnabled(bool)) ); 00324 00325 connect( useMailboxSuff->checkBox(), TQT_SIGNAL(toggled(bool)), 00326 MailboxSuff->lineEdit(), TQT_SLOT(setEnabled(bool)) ); 00327 connect( useMailboxSuff->checkBox(), TQT_SIGNAL(toggled(bool)), 00328 MailboxSuff->label(), TQT_SLOT(setEnabled(bool)) ); 00329 00330 connect( useModemSuff->checkBox(), TQT_SIGNAL(toggled(bool)), 00331 ModemSuff->lineEdit(), TQT_SLOT(setEnabled(bool)) ); 00332 connect( useModemSuff->checkBox(), TQT_SIGNAL(toggled(bool)), 00333 ModemSuff->label(), TQT_SLOT(setEnabled(bool)) ); 00334 00335 connect( useCarSuff->checkBox(), TQT_SIGNAL(toggled(bool)), 00336 CarSuff->lineEdit(), TQT_SLOT(setEnabled(bool)) ); 00337 connect( useCarSuff->checkBox(), TQT_SIGNAL(toggled(bool)), 00338 CarSuff->label(), TQT_SLOT(setEnabled(bool)) ); 00339 00340 connect( useISDNSuff->checkBox(), TQT_SIGNAL(toggled(bool)), 00341 ISDNSuff->lineEdit(), TQT_SLOT(setEnabled(bool)) ); 00342 connect( useISDNSuff->checkBox(), TQT_SIGNAL(toggled(bool)), 00343 ISDNSuff->label(), TQT_SLOT(setEnabled(bool)) ); 00344 00345 connect( usePagerSuff->checkBox(), TQT_SIGNAL(toggled(bool)), 00346 PagerSuff->lineEdit(), TQT_SLOT(setEnabled(bool)) ); 00347 connect( usePagerSuff->checkBox(), TQT_SIGNAL(toggled(bool)), 00348 PagerSuff->label(), TQT_SLOT(setEnabled(bool)) ); 00349 } 00350 00351 void KandyPrefsDialog::setupWindowsTab() 00352 { 00353 TQFrame *topFrame = addPage(i18n("Windows"),0, 00354 DesktopIcon("window_list",TDEIcon::SizeMedium)); 00355 00356 TQGridLayout *topLayout = new TQGridLayout(topFrame,6,2); 00357 topLayout->setSpacing(spacingHint()); 00358 topLayout->setMargin(marginHint()); 00359 00360 startupTerminal = addWidBool( KandyPrefs::self()->startupTerminalWinItem(), 00361 topFrame); 00362 topLayout->addWidget(startupTerminal->checkBox(),0,0); 00363 00364 startupMobile = addWidBool( KandyPrefs::self()->startupMobileWinItem(), 00365 topFrame ); 00366 topLayout->addWidget(startupMobile->checkBox(),1,0); 00367 00368 topLayout->setRowStretch(2, 1); 00369 }