kaddressbook Library API Documentation

prefsdialog.cpp

00001 #include <qlayout.h>
00002 #include <qframe.h>
00003 #include <qvbox.h>
00004 #include <qcheckbox.h>
00005 
00006 #include <kapplication.h>
00007 #include <klocale.h>
00008 #include <kconfig.h>
00009 #include <kglobal.h>
00010 #include <kiconloader.h>
00011 #include <klistview.h>
00012 
00013 #include "ldapoptionswidget.h"
00014 #include "kabprefs.h"
00015 
00016 #include "prefsdialog.h"
00017 
00018 PrefsDialog::PrefsDialog( QWidget *parent )
00019   : KDialogBase( IconList, i18n( "Preferences" ), Apply | Ok | Cancel, Ok,
00020                  parent, 0, false, true )
00021 {
00022   setupLdapPage();
00023 
00024   readConfig();
00025 }
00026 
00027 void PrefsDialog::setupLdapPage()
00028 {
00030   // Views
00031   QFrame *page = addPage( i18n("Views"), i18n("Views"),
00032                           KGlobal::iconLoader()->loadIcon( "view_remove", KIcon::Desktop ) );
00033 
00034   QVBoxLayout *topLayout = new QVBoxLayout( page, spacingHint(), marginHint() );
00035   topLayout->setAutoAdd( true );
00036 
00037   mViewsSingleClickBox = new QCheckBox( i18n( "Honor KDE single click" ), page );
00038 
00039   new QWidget( page ); // spacer
00040 
00042   // LDAP
00043   page = addPage( i18n("LDAP"), i18n("LDAP"),
00044                   KGlobal::iconLoader()->loadIcon( "find", KIcon::Desktop ) );
00045 
00046   topLayout = new QVBoxLayout( page, 0, 0 );
00047 
00048   mLdapWidget = new LDAPOptionsWidget( page );
00049   topLayout->addWidget( mLdapWidget );
00050 }
00051 
00052 void PrefsDialog::readConfig()
00053 {
00054   mLdapWidget->restoreSettings();
00055   mViewsSingleClickBox->setChecked( KABPrefs::instance()->mHonorSingleClick );
00056 }
00057 
00058 void PrefsDialog::writeConfig()
00059 {
00060   mLdapWidget->saveSettings();
00061 
00062   KABPrefs::instance()->mHonorSingleClick = mViewsSingleClickBox->isChecked();
00063   KABPrefs::instance()->writeConfig();
00064 }
00065 
00066 void PrefsDialog::slotApply()
00067 {
00068   writeConfig();
00069 
00070   emit configChanged();
00071 }
00072 
00073 void PrefsDialog::slotOk()
00074 {
00075   slotApply();
00076   accept();
00077 }
00078 
00079 #include "prefsdialog.moc"
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Sun Feb 15 11:40:37 2004 by doxygen 1.3.5 written by Dimitri van Heesch, © 1997-2001