kaddressbook Library API Documentation

configuretableviewdialog.cpp

00001 /* 00002 This file is part of KAddressBook. 00003 Copyright (c) 2002 Mike Pilone <mpilone@slac.com> 00004 00005 This program is free software; you can redistribute it and/or modify 00006 it under the terms of the GNU General Public License as published by 00007 the Free Software Foundation; either version 2 of the License, or 00008 (at your option) any later version. 00009 00010 This program is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 GNU General Public License for more details. 00014 00015 You should have received a copy of the GNU General Public License 00016 along with this program; if not, write to the Free Software 00017 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00018 00019 As a special exception, permission is given to link this program 00020 with any edition of Qt, and distribute the resulting executable, 00021 without including the source code for Qt in the source distribution. 00022 */ 00023 00024 #include <qstring.h> 00025 #include <qwidget.h> 00026 #include <qlayout.h> 00027 #include <qradiobutton.h> 00028 #include <qcheckbox.h> 00029 #include <qvbox.h> 00030 #include <qbuttongroup.h> 00031 00032 #include <kdeversion.h> 00033 #include <kglobal.h> 00034 #include <klocale.h> 00035 #include <klineedit.h> 00036 #include <kurlrequester.h> 00037 #include <kiconloader.h> 00038 #include <kimageio.h> 00039 #include <kconfig.h> 00040 00041 #include "configuretableviewdialog.h" 00042 00043 ConfigureTableViewWidget::ConfigureTableViewWidget( KABC::AddressBook *ab, 00044 QWidget *parent, 00045 const char *name ) 00046 : ViewConfigureWidget( ab, parent, name ) 00047 { 00048 QWidget *page = addPage( i18n( "Look & Feel" ), QString::null, 00049 KGlobal::iconLoader()->loadIcon( "looknfeel", 00050 KIcon::Panel ) ); 00051 00052 mPage = new LookAndFeelPage( page ); 00053 } 00054 00055 ConfigureTableViewWidget::~ConfigureTableViewWidget() 00056 { 00057 } 00058 00059 void ConfigureTableViewWidget::restoreSettings( KConfig *config ) 00060 { 00061 ViewConfigureWidget::restoreSettings( config ); 00062 00063 mPage->restoreSettings( config ); 00064 } 00065 00066 void ConfigureTableViewWidget::saveSettings( KConfig *config ) 00067 { 00068 ViewConfigureWidget::saveSettings( config ); 00069 00070 mPage->saveSettings( config ); 00071 } 00072 00073 00074 00075 LookAndFeelPage::LookAndFeelPage(QWidget *parent, const char *name) 00076 : QWidget(parent, name) 00077 { 00078 initGUI(); 00079 00080 // Set initial state 00081 enableBackgroundToggled(mBackgroundBox->isChecked()); 00082 } 00083 00084 void LookAndFeelPage::restoreSettings( KConfig *config ) 00085 { 00086 mAlternateButton->setChecked(config->readBoolEntry("ABackground", true)); 00087 mLineButton->setChecked(config->readBoolEntry("SingleLine", false)); 00088 mToolTipBox->setChecked(config->readBoolEntry("ToolTips", true)); 00089 00090 if (!mAlternateButton->isChecked() & !mLineButton->isChecked()) 00091 mNoneButton->setChecked(true); 00092 00093 mBackgroundBox->setChecked(config->readBoolEntry("Background", false)); 00094 mBackgroundName->lineEdit()->setText(config->readPathEntry("BackgroundName")); 00095 #if KDE_IS_VERSION(3,2,90) 00096 mIMPresenceBox->setChecked( config->readBoolEntry( "InstantMessagingPresence", false ) ); 00097 #endif 00098 } 00099 00100 void LookAndFeelPage::saveSettings( KConfig *config ) 00101 { 00102 config->writeEntry("ABackground", mAlternateButton->isChecked()); 00103 config->writeEntry("SingleLine", mLineButton->isChecked()); 00104 config->writeEntry("ToolTips", mToolTipBox->isChecked()); 00105 config->writeEntry("Background", mBackgroundBox->isChecked()); 00106 config->writePathEntry("BackgroundName", mBackgroundName->lineEdit()->text()); 00107 #if KDE_IS_VERSION(3,2,90) 00108 config->writeEntry( "InstantMessagingPresence", mIMPresenceBox->isChecked() ); 00109 #endif 00110 } 00111 00112 void LookAndFeelPage::initGUI() 00113 { 00114 QVBoxLayout *layout = new QVBoxLayout(this, 0, KDialogBase::spacingHint()); 00115 00116 QButtonGroup *group = new QButtonGroup(1, Qt::Horizontal, 00117 i18n("Row Separator"), this); 00118 layout->addWidget(group); 00119 00120 mAlternateButton = new QRadioButton(i18n("Alternating backgrounds"), 00121 group, "mAlternateButton"); 00122 mLineButton = new QRadioButton(i18n("Single line"), group, "mLineButton"); 00123 mNoneButton = new QRadioButton(i18n("None"), group, "mNoneButton"); 00124 00125 // Background Checkbox/Selector 00126 QHBoxLayout *backgroundLayout = new QHBoxLayout(); 00127 layout->addLayout(backgroundLayout); 00128 00129 mBackgroundBox = new QCheckBox(i18n("Enable background image:"), this, 00130 "mBackgroundBox"); 00131 connect(mBackgroundBox, SIGNAL(toggled(bool)), 00132 SLOT(enableBackgroundToggled(bool))); 00133 backgroundLayout->addWidget(mBackgroundBox); 00134 00135 mBackgroundName = new KURLRequester(this, "mBackgroundName"); 00136 mBackgroundName->setMode(KFile::File | KFile::ExistingOnly | 00137 KFile::LocalOnly); 00138 mBackgroundName->setFilter(KImageIO::pattern(KImageIO::Reading)); 00139 backgroundLayout->addWidget(mBackgroundName); 00140 00141 // ToolTip Checkbox 00142 mToolTipBox = new QCheckBox(i18n("Enable contact tooltips"), this, 00143 "mToolTipBox"); 00144 layout->addWidget(mToolTipBox); 00145 #if KDE_IS_VERSION(3,2,90) 00146 mIMPresenceBox = new QCheckBox( i18n( "Show instant messaging presence" ), this, "mIMPresenceBox" ); 00147 layout->addWidget( mIMPresenceBox ); 00148 #endif 00149 } 00150 00151 void LookAndFeelPage::enableBackgroundToggled(bool enabled) 00152 { 00153 mBackgroundName->setEnabled(enabled); 00154 } 00155 00156 #include "configuretableviewdialog.moc"
KDE Logo
This file is part of the documentation for kaddressbook Library Version 3.3.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Fri Aug 27 12:51:11 2004 by doxygen 1.3.8 written by Dimitri van Heesch, © 1997-2003