kaddressbook

configuretableviewdialog.cpp
1 /*
2  This file is part of KAddressBook.
3  Copyright (c) 2002 Mike Pilone <mpilone@slac.com>
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program; if not, write to the Free Software
17  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 
19  As a special exception, permission is given to link this program
20  with any edition of TQt, and distribute the resulting executable,
21  without including the source code for TQt in the source distribution.
22 */
23 
24 #include <tqstring.h>
25 #include <tqwidget.h>
26 #include <tqlayout.h>
27 #include <tqradiobutton.h>
28 #include <tqcheckbox.h>
29 #include <tqvbox.h>
30 #include <tqbuttongroup.h>
31 
32 #include <tdeversion.h>
33 #include <tdeglobal.h>
34 #include <tdelocale.h>
35 #include <klineedit.h>
36 #include <kurlrequester.h>
37 #include <kiconloader.h>
38 #include <kimageio.h>
39 #include <tdeconfig.h>
40 
41 #include "configuretableviewdialog.h"
42 
43 ConfigureTableViewWidget::ConfigureTableViewWidget( TDEABC::AddressBook *ab,
44  TQWidget *parent,
45  const char *name )
46  : ViewConfigureWidget( ab, parent, name )
47 {
48  TQWidget *page = addPage( i18n( "Look & Feel" ), TQString(),
49  TDEGlobal::iconLoader()->loadIcon( "preferences-desktop",
50  TDEIcon::Panel ) );
51 
52  mPage = new LookAndFeelPage( page );
53 }
54 
55 ConfigureTableViewWidget::~ConfigureTableViewWidget()
56 {
57 }
58 
60 {
62 
63  mPage->restoreSettings( config );
64 }
65 
66 void ConfigureTableViewWidget::saveSettings( TDEConfig *config )
67 {
69 
70  mPage->saveSettings( config );
71 }
72 
73 
74 
75 LookAndFeelPage::LookAndFeelPage(TQWidget *parent, const char *name)
76  : TQWidget(parent, name)
77 {
78  initGUI();
79 
80  // Set initial state
81  enableBackgroundToggled(mBackgroundBox->isChecked());
82 }
83 
84 void LookAndFeelPage::restoreSettings( TDEConfig *config )
85 {
86  mAlternateButton->setChecked(config->readBoolEntry("ABackground", true));
87  mLineButton->setChecked(config->readBoolEntry("SingleLine", false));
88  mToolTipBox->setChecked(config->readBoolEntry("ToolTips", true));
89 
90  if (!mAlternateButton->isChecked() && !mLineButton->isChecked())
91  mNoneButton->setChecked(true);
92 
93  mBackgroundBox->setChecked(config->readBoolEntry("Background", false));
94  mBackgroundName->lineEdit()->setText(config->readPathEntry("BackgroundName"));
95 #if KDE_IS_VERSION(3,2,90)
96  mIMPresenceBox->setChecked( config->readBoolEntry( "InstantMessagingPresence", false ) );
97 #endif
98 }
99 
100 void LookAndFeelPage::saveSettings( TDEConfig *config )
101 {
102  config->writeEntry("ABackground", mAlternateButton->isChecked());
103  config->writeEntry("SingleLine", mLineButton->isChecked());
104  config->writeEntry("ToolTips", mToolTipBox->isChecked());
105  config->writeEntry("Background", mBackgroundBox->isChecked());
106  config->writePathEntry("BackgroundName", mBackgroundName->lineEdit()->text());
107 #if KDE_IS_VERSION(3,2,90)
108  config->writeEntry( "InstantMessagingPresence", mIMPresenceBox->isChecked() );
109 #endif
110 }
111 
112 void LookAndFeelPage::initGUI()
113 {
114  TQVBoxLayout *layout = new TQVBoxLayout(this, 0, KDialogBase::spacingHint());
115 
116  TQButtonGroup *group = new TQButtonGroup(1, TQt::Horizontal,
117  i18n("Row Separator"), this);
118  layout->addWidget(group);
119 
120  mAlternateButton = new TQRadioButton(i18n("Alternating backgrounds"),
121  group, "mAlternateButton");
122  mLineButton = new TQRadioButton(i18n("Single line"), group, "mLineButton");
123  mNoneButton = new TQRadioButton(i18n("None"), group, "mNoneButton");
124 
125  // Background Checkbox/Selector
126  TQHBoxLayout *backgroundLayout = new TQHBoxLayout();
127  layout->addLayout(backgroundLayout);
128 
129  mBackgroundBox = new TQCheckBox(i18n("Enable background image:"), this,
130  "mBackgroundBox");
131  connect(mBackgroundBox, TQ_SIGNAL(toggled(bool)),
132  TQ_SLOT(enableBackgroundToggled(bool)));
133  backgroundLayout->addWidget(mBackgroundBox);
134 
135  mBackgroundName = new KURLRequester(this, "mBackgroundName");
136  mBackgroundName->setMode(KFile::File | KFile::ExistingOnly |
137  KFile::LocalOnly);
138  mBackgroundName->setFilter(KImageIO::pattern(KImageIO::Reading));
139  backgroundLayout->addWidget(mBackgroundName);
140 
141  // ToolTip Checkbox
142  mToolTipBox = new TQCheckBox(i18n("Enable contact tooltips"), this,
143  "mToolTipBox");
144  layout->addWidget(mToolTipBox);
145 #if KDE_IS_VERSION(3,2,90)
146  mIMPresenceBox = new TQCheckBox( i18n( "Show instant messaging presence" ), this, "mIMPresenceBox" );
147  layout->addWidget( mIMPresenceBox );
148 #endif
149 }
150 
151 void LookAndFeelPage::enableBackgroundToggled(bool enabled)
152 {
153  mBackgroundName->setEnabled(enabled);
154 }
155 
156 #include "configuretableviewdialog.moc"
virtual void saveSettings(TDEConfig *)
Writes the configuration from the GUI to the config object.
virtual void restoreSettings(TDEConfig *)
Reads the configuration from the config object and sets the values in the GUI.
This widget is the base class for all view configuration widgets.
virtual void restoreSettings(TDEConfig *config)
Reads the configuration from the config object and sets the values in the GUI.
virtual void saveSettings(TDEConfig *config)
Writes the configuration from the GUI to the config object.