You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tdepim/kandy/src/kandyprefsdialog.cpp

370 lines
14 KiB

/*
This file is part of Kandy.
Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
As a special exception, permission is given to link this program
with any edition of TQt, and distribute the resulting executable,
without including the source code for TQt in the source distribution.
*/
#include <tqlayout.h>
#include <tqlabel.h>
#include <tqgroupbox.h>
#include <tqbuttongroup.h>
#include <tqlineedit.h>
#include <tqfont.h>
#include <tqslider.h>
#include <tqfile.h>
#include <tqtextstream.h>
#include <tqcombobox.h>
#include <tqvbox.h>
#include <tqhbox.h>
#include <tqspinbox.h>
#include <tqdatetime.h>
#include <tdeapplication.h>
#include <kdebug.h>
#include <tdelocale.h>
#include <tdeglobal.h>
#include <tdefontdialog.h>
#include <kstandarddirs.h>
#include <tdemessagebox.h>
#include <kcolordialog.h>
#include <kiconloader.h>
#include <kiconeffect.h>
#include "kandyprefs.h"
#include "kandyprefsdialog.h"
#include "kandyprefsdialog.moc"
KandyPrefsDialog::KandyPrefsDialog(TQWidget *parent, char *name, bool modal) :
KPrefsDialog(KandyPrefs::self(),parent,name,modal)
{
setupSerialTab();
setupAddressbookTab();
setupWindowsTab();
}
KandyPrefsDialog::~KandyPrefsDialog()
{
delete serialDevice;
delete lockDir;
delete openOnStartup;
delete startupTerminal;
delete startupMobile;
}
void KandyPrefsDialog::setupSerialTab()
{
TQFrame *topFrame = addPage(i18n("Serial Interface"),0,
DesktopIcon("connect_no",TDEIcon::SizeMedium));
TQGridLayout *topLayout = new TQGridLayout(topFrame,6,2);
topLayout->setSpacing(spacingHint());
topLayout->setMargin(marginHint());
// Define serial device
serialDevice = addWidString( KandyPrefs::self()->serialDeviceItem(),
topFrame );
topLayout->addWidget(serialDevice->label(),0,0);
topLayout->addWidget(serialDevice->lineEdit(),0,1);
// Define baud rate
baudRate = addWidString( KandyPrefs::self()->baudRateItem(), topFrame );
topLayout->addWidget( baudRate->label(), 1, 0 );
topLayout->addWidget( baudRate->lineEdit(), 1, 1 );
// Define location of LOCK file
lockDir = addWidString( KandyPrefs::self()->lockDirectoryItem(),
topFrame );
topLayout->addWidget(lockDir->label(),2,0);
topLayout->addWidget(lockDir->lineEdit(),2,1);
// Define startup modem behavior
openOnStartup = addWidBool( KandyPrefs::self()->startupModemItem(),
topFrame );
topLayout->addWidget(openOnStartup->checkBox(),3,0);
// Define clock setting hevahior
autoSetClock = addWidBool( KandyPrefs::self()->autoSetClockItem(),
topFrame );
topLayout->addWidget(autoSetClock->checkBox(),4,0);
topLayout->setRowStretch(5,1);
}
void KandyPrefsDialog::setupAddressbookTab()
{
TQFrame *topFrame = addPage(i18n("Address Book"), 0,
DesktopIcon("kaddressbook", TDEIcon::SizeMedium));
TQGridLayout *topLayout = new TQGridLayout(topFrame, 13, 4);
topLayout->setSpacing(spacingHint());
topLayout->setMargin(marginHint());
excHome = addWidBool ( KandyPrefs::self()->excludeHomeItem(), topFrame );
topLayout->addWidget(excHome->checkBox(), 0, 0);
excWork = addWidBool ( KandyPrefs::self()->excludeWorkItem(), topFrame );
topLayout->addWidget(excWork->checkBox(), 1, 0);
excMsg = addWidBool ( KandyPrefs::self()->excludeMessagingItem(), topFrame );
topLayout->addWidget(excMsg->checkBox(), 2, 0);
excFax = addWidBool ( KandyPrefs::self()->excludeFaxItem(), topFrame );
topLayout->addWidget(excFax->checkBox(), 3, 0);
excCell = addWidBool ( KandyPrefs::self()->excludeCellItem(), topFrame );
topLayout->addWidget(excCell->checkBox(), 4, 0);
excVideo = addWidBool ( KandyPrefs::self()->excludeVideoItem(), topFrame );
topLayout->addWidget(excVideo->checkBox(), 5, 0);
excBbs = addWidBool ( KandyPrefs::self()->excludeMailboxItem(), topFrame );
topLayout->addWidget(excBbs->checkBox(), 6, 0);
excModem = addWidBool ( KandyPrefs::self()->excludeModemItem(), topFrame );
topLayout->addWidget(excModem->checkBox(), 7, 0);
excCar = addWidBool ( KandyPrefs::self()->excludeCarItem(), topFrame );
topLayout->addWidget(excCar->checkBox(), 8, 0);
excISDN = addWidBool ( KandyPrefs::self()->excludeISDNItem(), topFrame );
topLayout->addWidget(excISDN->checkBox(), 9, 0);
excPager = addWidBool ( KandyPrefs::self()->excludePagerItem(), topFrame );
topLayout->addWidget(excPager->checkBox(), 10, 0);
useHomeSuff = addWidBool ( KandyPrefs::self()->useHomeSuffItem(), topFrame );
topLayout->addWidget(useHomeSuff->checkBox(), 0, 1);
useWorkSuff = addWidBool ( KandyPrefs::self()->useWorkSuffItem(), topFrame );
topLayout->addWidget(useWorkSuff->checkBox(), 1, 1);
useMessagingSuff = addWidBool ( KandyPrefs::self()->useMessagingSuffItem(), topFrame );
topLayout->addWidget(useMessagingSuff->checkBox(), 2, 1);
useFaxSuff = addWidBool ( KandyPrefs::self()->useFaxSuffItem(), topFrame );
topLayout->addWidget(useFaxSuff->checkBox(), 3, 1);
useCellSuff = addWidBool ( KandyPrefs::self()->useCellSuffItem(), topFrame );
topLayout->addWidget(useCellSuff->checkBox(), 4, 1);
useVideoSuff = addWidBool ( KandyPrefs::self()->useVideoSuffItem(), topFrame );
topLayout->addWidget(useVideoSuff->checkBox(), 5, 1);
useMailboxSuff = addWidBool ( KandyPrefs::self()->useMailboxSuffItem(), topFrame );
topLayout->addWidget(useMailboxSuff->checkBox(), 6, 1);
useModemSuff = addWidBool ( KandyPrefs::self()->useModemSuffItem(), topFrame );
topLayout->addWidget(useModemSuff->checkBox(), 7, 1);
useCarSuff = addWidBool ( KandyPrefs::self()->useCarSuffItem(), topFrame );
topLayout->addWidget(useCarSuff->checkBox(), 8, 1);
useISDNSuff = addWidBool ( KandyPrefs::self()->useISDNSuffItem(), topFrame );
topLayout->addWidget(useISDNSuff->checkBox(), 9, 1);
usePagerSuff = addWidBool ( KandyPrefs::self()->usePagerSuffItem(), topFrame );
topLayout->addWidget(usePagerSuff->checkBox(), 10, 1);
HomeSuff = addWidString( KandyPrefs::self()->homeSuffItem(), topFrame );
topLayout->addWidget(HomeSuff->label(), 0, 2);
topLayout->addWidget(HomeSuff->lineEdit(), 0, 3);
WorkSuff = addWidString( KandyPrefs::self()->workSuffItem(), topFrame );
topLayout->addWidget(WorkSuff->label(), 1, 2);
topLayout->addWidget(WorkSuff->lineEdit(), 1, 3);
MessagingSuff = addWidString( KandyPrefs::self()->messagingSuffItem(), topFrame );
topLayout->addWidget(MessagingSuff->label(), 2, 2);
topLayout->addWidget(MessagingSuff->lineEdit(), 2, 3);
FaxSuff = addWidString( KandyPrefs::self()->faxSuffItem(), topFrame );
topLayout->addWidget(FaxSuff->label(), 3, 2);
topLayout->addWidget(FaxSuff->lineEdit(), 3, 3);
CellSuff = addWidString( KandyPrefs::self()->cellSuffItem(), topFrame );
topLayout->addWidget(CellSuff->label(), 4, 2);
topLayout->addWidget(CellSuff->lineEdit(), 4, 3);
VideoSuff = addWidString( KandyPrefs::self()->videoSuffItem(), topFrame );
topLayout->addWidget(VideoSuff->label(), 5, 2);
topLayout->addWidget(VideoSuff->lineEdit(), 5, 3);
MailboxSuff = addWidString( KandyPrefs::self()->mailboxSuffItem(), topFrame );
topLayout->addWidget(MailboxSuff->label(), 6, 2);
topLayout->addWidget(MailboxSuff->lineEdit(), 6, 3);
ModemSuff = addWidString( KandyPrefs::self()->modemSuffItem(), topFrame );
topLayout->addWidget(ModemSuff->label(), 7, 2);
topLayout->addWidget(ModemSuff->lineEdit(), 7, 3);
CarSuff = addWidString( KandyPrefs::self()->carSuffItem(), topFrame );
topLayout->addWidget(CarSuff->label(), 8, 2);
topLayout->addWidget(CarSuff->lineEdit(), 8, 3);
ISDNSuff = addWidString( KandyPrefs::self()->iSDNSuffItem(), topFrame );
topLayout->addWidget(ISDNSuff->label(), 9, 2);
topLayout->addWidget(ISDNSuff->lineEdit(), 9, 3);
PagerSuff = addWidString( KandyPrefs::self()->pagerSuffItem(), topFrame );
topLayout->addWidget(PagerSuff->label(), 10, 2);
topLayout->addWidget(PagerSuff->lineEdit(), 10, 3);
topLayout->setRowStretch(11, 1);
if ( !KandyPrefs::self()->useHomeSuff() )
{
HomeSuff->lineEdit()->setEnabled( false );
HomeSuff->label()->setEnabled( false );
}
if ( !KandyPrefs::self()->useWorkSuff() )
{
WorkSuff->lineEdit()->setEnabled( false );
WorkSuff->label()->setEnabled( false );
}
if ( !KandyPrefs::self()->useMessagingSuff() )
{
MessagingSuff->lineEdit()->setEnabled( false );
MessagingSuff->label()->setEnabled( false );
}
if ( !KandyPrefs::self()->useFaxSuff() )
{
FaxSuff->lineEdit()->setEnabled( false );
FaxSuff->label()->setEnabled( false );
}
if ( !KandyPrefs::self()->useCellSuff() )
{
CellSuff->lineEdit()->setEnabled( false );
CellSuff->label()->setEnabled( false );
}
if ( !KandyPrefs::self()->useVideoSuff() )
{
VideoSuff->lineEdit()->setEnabled( false );
VideoSuff->label()->setEnabled( false );
}
if ( !KandyPrefs::self()->useMailboxSuff() )
{
MailboxSuff->lineEdit()->setEnabled( false );
MailboxSuff->label()->setEnabled( false );
}
if ( !KandyPrefs::self()->useModemSuff() )
{
ModemSuff->lineEdit()->setEnabled( false );
ModemSuff->label()->setEnabled( false );
}
if ( !KandyPrefs::self()->useCarSuff() )
{
CarSuff->lineEdit()->setEnabled( false );
CarSuff->label()->setEnabled( false );
}
if ( !KandyPrefs::self()->useISDNSuff() )
{
ISDNSuff->lineEdit()->setEnabled( false );
ISDNSuff->label()->setEnabled( false );
}
if ( !KandyPrefs::self()->usePagerSuff() )
{
PagerSuff->lineEdit()->setEnabled( false );
PagerSuff->label()->setEnabled( false );
}
connect( useHomeSuff->checkBox(), TQT_SIGNAL(toggled(bool)),
HomeSuff->lineEdit(), TQT_SLOT(setEnabled(bool)) );
connect( useHomeSuff->checkBox(), TQT_SIGNAL(toggled(bool)),
HomeSuff->label(), TQT_SLOT(setEnabled(bool)) );
connect( useWorkSuff->checkBox(), TQT_SIGNAL(toggled(bool)),
WorkSuff->lineEdit(), TQT_SLOT(setEnabled(bool)) );
connect( useWorkSuff->checkBox(), TQT_SIGNAL(toggled(bool)),
WorkSuff->label(), TQT_SLOT(setEnabled(bool)) );
connect( useMessagingSuff->checkBox(), TQT_SIGNAL(toggled(bool)),
MessagingSuff->lineEdit(), TQT_SLOT(setEnabled(bool)) );
connect( useMessagingSuff->checkBox(), TQT_SIGNAL(toggled(bool)),
MessagingSuff->label(), TQT_SLOT(setEnabled(bool)) );
connect( useFaxSuff->checkBox(), TQT_SIGNAL(toggled(bool)),
FaxSuff->lineEdit(), TQT_SLOT(setEnabled(bool)) );
connect( useFaxSuff->checkBox(), TQT_SIGNAL(toggled(bool)),
FaxSuff->label(), TQT_SLOT(setEnabled(bool)) );
connect( useCellSuff->checkBox(), TQT_SIGNAL(toggled(bool)),
CellSuff->lineEdit(), TQT_SLOT(setEnabled(bool)) );
connect( useCellSuff->checkBox(), TQT_SIGNAL(toggled(bool)),
CellSuff->label(), TQT_SLOT(setEnabled(bool)) );
connect( useVideoSuff->checkBox(), TQT_SIGNAL(toggled(bool)),
VideoSuff->lineEdit(), TQT_SLOT(setEnabled(bool)) );
connect( useVideoSuff->checkBox(), TQT_SIGNAL(toggled(bool)),
VideoSuff->label(), TQT_SLOT(setEnabled(bool)) );
connect( useMailboxSuff->checkBox(), TQT_SIGNAL(toggled(bool)),
MailboxSuff->lineEdit(), TQT_SLOT(setEnabled(bool)) );
connect( useMailboxSuff->checkBox(), TQT_SIGNAL(toggled(bool)),
MailboxSuff->label(), TQT_SLOT(setEnabled(bool)) );
connect( useModemSuff->checkBox(), TQT_SIGNAL(toggled(bool)),
ModemSuff->lineEdit(), TQT_SLOT(setEnabled(bool)) );
connect( useModemSuff->checkBox(), TQT_SIGNAL(toggled(bool)),
ModemSuff->label(), TQT_SLOT(setEnabled(bool)) );
connect( useCarSuff->checkBox(), TQT_SIGNAL(toggled(bool)),
CarSuff->lineEdit(), TQT_SLOT(setEnabled(bool)) );
connect( useCarSuff->checkBox(), TQT_SIGNAL(toggled(bool)),
CarSuff->label(), TQT_SLOT(setEnabled(bool)) );
connect( useISDNSuff->checkBox(), TQT_SIGNAL(toggled(bool)),
ISDNSuff->lineEdit(), TQT_SLOT(setEnabled(bool)) );
connect( useISDNSuff->checkBox(), TQT_SIGNAL(toggled(bool)),
ISDNSuff->label(), TQT_SLOT(setEnabled(bool)) );
connect( usePagerSuff->checkBox(), TQT_SIGNAL(toggled(bool)),
PagerSuff->lineEdit(), TQT_SLOT(setEnabled(bool)) );
connect( usePagerSuff->checkBox(), TQT_SIGNAL(toggled(bool)),
PagerSuff->label(), TQT_SLOT(setEnabled(bool)) );
}
void KandyPrefsDialog::setupWindowsTab()
{
TQFrame *topFrame = addPage(i18n("Windows"),0,
DesktopIcon("window_duplicate",TDEIcon::SizeMedium));
TQGridLayout *topLayout = new TQGridLayout(topFrame,6,2);
topLayout->setSpacing(spacingHint());
topLayout->setMargin(marginHint());
startupTerminal = addWidBool( KandyPrefs::self()->startupTerminalWinItem(),
topFrame);
topLayout->addWidget(startupTerminal->checkBox(),0,0);
startupMobile = addWidBool( KandyPrefs::self()->startupMobileWinItem(),
topFrame );
topLayout->addWidget(startupMobile->checkBox(),1,0);
topLayout->setRowStretch(2, 1);
}