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., 675 Mass Ave, Cambridge, MA 02139, 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 "configuretableviewdialog.h"
00025 
00026 #include <qstring.h>
00027 #include <qwidget.h>
00028 #include <qlayout.h>
00029 #include <qradiobutton.h>
00030 #include <qcheckbox.h>
00031 #include <qvbox.h>
00032 #include <qbuttongroup.h>
00033 
00034 #include <kglobal.h>
00035 #include <klocale.h>
00036 #include <klineedit.h>
00037 #include <kurlrequester.h>
00038 #include <kiconloader.h>
00039 #include <kconfig.h>
00040 
00042 // Look and feel page
00043 LookAndFeelPage::LookAndFeelPage(QWidget *parent, const char *name)
00044   : QWidget(parent, name)
00045 {
00046   initGUI();
00047   
00048   // Set initial state
00049   enableBackgroundToggled(mBackgroundBox->isChecked());
00050 }
00051     
00052 void LookAndFeelPage::readConfig(KConfig *config)
00053 {
00054   mAlternateButton->setChecked(config->readBoolEntry("ABackground", true));
00055   mLineButton->setChecked(config->readBoolEntry("SingleLine", false));
00056   mToolTipBox->setChecked(config->readBoolEntry("ToolTips", true));
00057       
00058   if (!mAlternateButton->isChecked() & !mLineButton->isChecked())
00059     mNoneButton->setChecked(true);
00060   
00061   mBackgroundBox->setChecked(config->readBoolEntry("Background", false));
00062   mBackgroundName->lineEdit()->setText(config->readEntry("BackgroundName"));
00063 }
00064     
00065 void LookAndFeelPage::writeConfig(KConfig *config)
00066 {
00067   config->writeEntry("ABackground", mAlternateButton->isChecked());
00068   config->writeEntry("SingleLine", mLineButton->isChecked());
00069   config->writeEntry("ToolTips", mToolTipBox->isChecked());
00070   config->writeEntry("Background", mBackgroundBox->isChecked());
00071   config->writeEntry("BackgroundName", mBackgroundName->lineEdit()->text());
00072 }
00073     
00074 void LookAndFeelPage::initGUI()
00075 {
00076   QVBoxLayout *layout = new QVBoxLayout(this);
00077   layout->setSpacing(KDialog::spacingHint());
00078   layout->setMargin(KDialog::marginHint());
00079       
00080   QButtonGroup *group = new QButtonGroup(1, Qt::Horizontal, 
00081                                          i18n("Row Separator"), this);
00082   layout->addWidget(group);
00083       
00084   mAlternateButton = new QRadioButton(i18n("Alternating backgrounds"),
00085                                       group, "mAlternateButton");
00086   mLineButton = new QRadioButton(i18n("Single line"), group, "mLineButton");
00087   mNoneButton = new QRadioButton(i18n("None"), group, "mNoneButton");
00088       
00089   // Background Checkbox/Selector
00090   QHBoxLayout *backgroundLayout = new QHBoxLayout();
00091   layout->addLayout(backgroundLayout);
00092       
00093   mBackgroundBox = new QCheckBox(i18n("Enable background image:"), this,
00094                                  "mBackgroundBox");
00095   connect(mBackgroundBox, SIGNAL(toggled(bool)),
00096           SLOT(enableBackgroundToggled(bool)));
00097   backgroundLayout->addWidget(mBackgroundBox);
00098   
00099   mBackgroundName = new KURLRequester(this, "mBackgroundName");
00100   mBackgroundName->setMode(KFile::File | KFile::ExistingOnly |
00101                            KFile::LocalOnly);
00102   mBackgroundName->setFilter(i18n("*.png *.jpg *.xpm|Image Files\n*|All Files"));
00103   backgroundLayout->addWidget(mBackgroundName);
00104       
00105   // ToolTip Checkbox
00106   mToolTipBox = new QCheckBox(i18n("Enable contact tooltips"), this,
00107                               "mToolTipBox");
00108   layout->addWidget(mToolTipBox);
00109 }
00110 
00111 void LookAndFeelPage::enableBackgroundToggled(bool enabled)
00112 {
00113   mBackgroundName->setEnabled(enabled);
00114 }
00115 
00117 // ConfigureTableViewDialog
00118 
00119 ConfigureTableViewDialog::ConfigureTableViewDialog(const QString &viewName, 
00120                                                    KABC::AddressBook *doc,
00121                                                    QWidget *parent, 
00122                                                    const char *name)
00123   : ConfigureViewDialog(viewName, doc, parent, name)
00124 {
00125   initGUI();
00126 }
00127                                            
00128 ConfigureTableViewDialog::~ConfigureTableViewDialog()
00129 {
00130 }
00131     
00132 void ConfigureTableViewDialog::readConfig(KConfig *config)
00133 {
00134   ConfigureViewDialog::readConfig(config);
00135   
00136   mPage->readConfig(config);
00137 }
00138 
00139 void ConfigureTableViewDialog::writeConfig(KConfig *config)
00140 {
00141   ConfigureViewDialog::writeConfig(config);
00142   
00143   mPage->writeConfig(config);
00144 }
00145     
00146 void ConfigureTableViewDialog::initGUI()
00147 {
00148   QWidget *page = addVBoxPage(i18n("Look & Feel"), QString::null,
00149                               KGlobal::iconLoader()->loadIcon("looknfeel",
00150                                                             KIcon::Desktop));
00151   
00152   mPage = new LookAndFeelPage(page, "mLookAndFeelPage");
00153 }
00154 
00155 #include "configuretableviewdialog.moc"
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.4.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Sat Oct 18 02:47:09 2003 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001