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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00018 00019 As a special exception, permission is given to link this program 00020 with any edition of TQt, and distribute the resulting executable, 00021 without including the source code for TQt in the source distribution. 00022 */ 00023 00024 #include <tqstring.h> 00025 #include <tqwidget.h> 00026 #include <tqlayout.h> 00027 #include <tqradiobutton.h> 00028 #include <tqcheckbox.h> 00029 #include <tqvbox.h> 00030 #include <tqbuttongroup.h> 00031 00032 #include <tdeversion.h> 00033 #include <tdeglobal.h> 00034 #include <tdelocale.h> 00035 #include <klineedit.h> 00036 #include <kurlrequester.h> 00037 #include <kiconloader.h> 00038 #include <kimageio.h> 00039 #include <tdeconfig.h> 00040 00041 #include "configuretableviewdialog.h" 00042 00043 ConfigureTableViewWidget::ConfigureTableViewWidget( TDEABC::AddressBook *ab, 00044 TQWidget *parent, 00045 const char *name ) 00046 : ViewConfigureWidget( ab, parent, name ) 00047 { 00048 TQWidget *page = addPage( i18n( "Look & Feel" ), TQString(), 00049 TDEGlobal::iconLoader()->loadIcon( "preferences-desktop", 00050 TDEIcon::Panel ) ); 00051 00052 mPage = new LookAndFeelPage( page ); 00053 } 00054 00055 ConfigureTableViewWidget::~ConfigureTableViewWidget() 00056 { 00057 } 00058 00059 void ConfigureTableViewWidget::restoreSettings( TDEConfig *config ) 00060 { 00061 ViewConfigureWidget::restoreSettings( config ); 00062 00063 mPage->restoreSettings( config ); 00064 } 00065 00066 void ConfigureTableViewWidget::saveSettings( TDEConfig *config ) 00067 { 00068 ViewConfigureWidget::saveSettings( config ); 00069 00070 mPage->saveSettings( config ); 00071 } 00072 00073 00074 00075 LookAndFeelPage::LookAndFeelPage(TQWidget *parent, const char *name) 00076 : TQWidget(parent, name) 00077 { 00078 initGUI(); 00079 00080 // Set initial state 00081 enableBackgroundToggled(mBackgroundBox->isChecked()); 00082 } 00083 00084 void LookAndFeelPage::restoreSettings( TDEConfig *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( TDEConfig *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 TQVBoxLayout *layout = new TQVBoxLayout(this, 0, KDialogBase::spacingHint()); 00115 00116 TQButtonGroup *group = new TQButtonGroup(1, Qt::Horizontal, 00117 i18n("Row Separator"), this); 00118 layout->addWidget(group); 00119 00120 mAlternateButton = new TQRadioButton(i18n("Alternating backgrounds"), 00121 group, "mAlternateButton"); 00122 mLineButton = new TQRadioButton(i18n("Single line"), group, "mLineButton"); 00123 mNoneButton = new TQRadioButton(i18n("None"), group, "mNoneButton"); 00124 00125 // Background Checkbox/Selector 00126 TQHBoxLayout *backgroundLayout = new TQHBoxLayout(); 00127 layout->addLayout(backgroundLayout); 00128 00129 mBackgroundBox = new TQCheckBox(i18n("Enable background image:"), this, 00130 "mBackgroundBox"); 00131 connect(mBackgroundBox, TQT_SIGNAL(toggled(bool)), 00132 TQT_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 TQCheckBox(i18n("Enable contact tooltips"), this, 00143 "mToolTipBox"); 00144 layout->addWidget(mToolTipBox); 00145 #if KDE_IS_VERSION(3,2,90) 00146 mIMPresenceBox = new TQCheckBox( 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"