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 <kglobal.h>
00033 #include <klocale.h>
00034 #include <klineedit.h>
00035 #include <kurlrequester.h>
00036 #include <kiconloader.h>
00037 #include <kimageio.h>
00038 #include <kconfig.h>
00039 
00040 #include "configuretableviewdialog.h"
00041 
00042 ConfigureTableViewWidget::ConfigureTableViewWidget( KABC::AddressBook *ab,
00043                                                     QWidget *parent, 
00044                                                     const char *name )
00045   : ViewConfigureWidget( ab, parent, name )
00046 {
00047   QWidget *page = addPage( i18n( "Look & Feel" ), QString::null,
00048                            KGlobal::iconLoader()->loadIcon( "looknfeel",
00049                            KIcon::Panel ) );
00050   
00051   mPage = new LookAndFeelPage( page );
00052 }
00053                                            
00054 ConfigureTableViewWidget::~ConfigureTableViewWidget()
00055 {
00056 }
00057 
00058 void ConfigureTableViewWidget::restoreSettings( KConfig *config )
00059 {
00060   ViewConfigureWidget::restoreSettings( config );
00061 
00062   mPage->restoreSettings( config );
00063 }
00064 
00065 void ConfigureTableViewWidget::saveSettings( KConfig *config )
00066 {
00067   ViewConfigureWidget::saveSettings( config );
00068 
00069   mPage->saveSettings( config );
00070 }
00071 
00072 
00073 
00074 LookAndFeelPage::LookAndFeelPage(QWidget *parent, const char *name)
00075   : QWidget(parent, name)
00076 {
00077   initGUI();
00078   
00079   // Set initial state
00080   enableBackgroundToggled(mBackgroundBox->isChecked());
00081 }
00082     
00083 void LookAndFeelPage::restoreSettings( KConfig *config )
00084 {
00085   mAlternateButton->setChecked(config->readBoolEntry("ABackground", true));
00086   mLineButton->setChecked(config->readBoolEntry("SingleLine", false));
00087   mToolTipBox->setChecked(config->readBoolEntry("ToolTips", true));
00088       
00089   if (!mAlternateButton->isChecked() & !mLineButton->isChecked())
00090     mNoneButton->setChecked(true);
00091   
00092   mBackgroundBox->setChecked(config->readBoolEntry("Background", false));
00093   mBackgroundName->lineEdit()->setText(config->readPathEntry("BackgroundName"));
00094 }
00095     
00096 void LookAndFeelPage::saveSettings( KConfig *config )
00097 {
00098   config->writeEntry("ABackground", mAlternateButton->isChecked());
00099   config->writeEntry("SingleLine", mLineButton->isChecked());
00100   config->writeEntry("ToolTips", mToolTipBox->isChecked());
00101   config->writeEntry("Background", mBackgroundBox->isChecked());
00102   config->writePathEntry("BackgroundName", mBackgroundName->lineEdit()->text());
00103 }
00104     
00105 void LookAndFeelPage::initGUI()
00106 {
00107   QVBoxLayout *layout = new QVBoxLayout(this, 0, KDialogBase::spacingHint());
00108       
00109   QButtonGroup *group = new QButtonGroup(1, Qt::Horizontal, 
00110                                          i18n("Row Separator"), this);
00111   layout->addWidget(group);
00112       
00113   mAlternateButton = new QRadioButton(i18n("Alternating backgrounds"),
00114                                       group, "mAlternateButton");
00115   mLineButton = new QRadioButton(i18n("Single line"), group, "mLineButton");
00116   mNoneButton = new QRadioButton(i18n("None"), group, "mNoneButton");
00117       
00118   // Background Checkbox/Selector
00119   QHBoxLayout *backgroundLayout = new QHBoxLayout();
00120   layout->addLayout(backgroundLayout);
00121       
00122   mBackgroundBox = new QCheckBox(i18n("Enable background image:"), this,
00123                                  "mBackgroundBox");
00124   connect(mBackgroundBox, SIGNAL(toggled(bool)),
00125           SLOT(enableBackgroundToggled(bool)));
00126   backgroundLayout->addWidget(mBackgroundBox);
00127   
00128   mBackgroundName = new KURLRequester(this, "mBackgroundName");
00129   mBackgroundName->setMode(KFile::File | KFile::ExistingOnly |
00130                            KFile::LocalOnly);
00131   mBackgroundName->setFilter(KImageIO::pattern(KImageIO::Reading));
00132   backgroundLayout->addWidget(mBackgroundName);
00133       
00134   // ToolTip Checkbox
00135   mToolTipBox = new QCheckBox(i18n("Enable contact tooltips"), this,
00136                               "mToolTipBox");
00137   layout->addWidget(mToolTipBox);
00138 }
00139 
00140 void LookAndFeelPage::enableBackgroundToggled(bool enabled)
00141 {
00142   mBackgroundName->setEnabled(enabled);
00143 }
00144     
00145 #include "configuretableviewdialog.moc"
KDE Logo
This file is part of the documentation for kaddressbook Library Version 3.2.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat May 1 11:38:50 2004 by doxygen 1.2.15 written by Dimitri van Heesch, © 1997-2003