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 <tdeglobal.h>
33#include <tdelocale.h>
34#include <klineedit.h>
35#include <kurlrequester.h>
36#include <kiconloader.h>
37#include <kimageio.h>
38#include <tdeconfig.h>
39
40#include "configuretableviewdialog.h"
41
42ConfigureTableViewWidget::ConfigureTableViewWidget( TDEABC::AddressBook *ab,
43 TQWidget *parent,
44 const char *name )
45 : ViewConfigureWidget( ab, parent, name )
46{
47 TQWidget *page = addPage( i18n( "Look & Feel" ), TQString(),
48 TDEGlobal::iconLoader()->loadIcon( "preferences-desktop",
49 TDEIcon::Panel ) );
50
51 mPage = new LookAndFeelPage( page );
52}
53
54ConfigureTableViewWidget::~ConfigureTableViewWidget()
55{
56}
57
59{
61
62 mPage->restoreSettings( config );
63}
64
66{
68
69 mPage->saveSettings( config );
70}
71
72
73
74LookAndFeelPage::LookAndFeelPage(TQWidget *parent, const char *name)
75 : TQWidget(parent, name)
76{
77 initGUI();
78
79 // Set initial state
80 enableBackgroundToggled(mBackgroundBox->isChecked());
81}
82
83void LookAndFeelPage::restoreSettings( TDEConfig *config )
84{
85 mAlternateButton->setChecked(config->readBoolEntry("ABackground", true));
86 mLineButton->setChecked(config->readBoolEntry("SingleLine", false));
87 mToolTipBox->setChecked(config->readBoolEntry("ToolTips", true));
88
89 if (!mAlternateButton->isChecked() && !mLineButton->isChecked())
90 mNoneButton->setChecked(true);
91
92 mBackgroundBox->setChecked(config->readBoolEntry("Background", false));
93 mBackgroundName->lineEdit()->setText(config->readPathEntry("BackgroundName"));
94 mIMPresenceBox->setChecked( config->readBoolEntry( "InstantMessagingPresence", false ) );
95}
96
97void LookAndFeelPage::saveSettings( TDEConfig *config )
98{
99 config->writeEntry("ABackground", mAlternateButton->isChecked());
100 config->writeEntry("SingleLine", mLineButton->isChecked());
101 config->writeEntry("ToolTips", mToolTipBox->isChecked());
102 config->writeEntry("Background", mBackgroundBox->isChecked());
103 config->writePathEntry("BackgroundName", mBackgroundName->lineEdit()->text());
104 config->writeEntry( "InstantMessagingPresence", mIMPresenceBox->isChecked() );
105}
106
107void LookAndFeelPage::initGUI()
108{
109 TQVBoxLayout *layout = new TQVBoxLayout(this, 0, KDialogBase::spacingHint());
110
111 TQButtonGroup *group = new TQButtonGroup(1, TQt::Horizontal,
112 i18n("Row Separator"), this);
113 layout->addWidget(group);
114
115 mAlternateButton = new TQRadioButton(i18n("Alternating backgrounds"),
116 group, "mAlternateButton");
117 mLineButton = new TQRadioButton(i18n("Single line"), group, "mLineButton");
118 mNoneButton = new TQRadioButton(i18n("None"), group, "mNoneButton");
119
120 // Background Checkbox/Selector
121 TQHBoxLayout *backgroundLayout = new TQHBoxLayout();
122 layout->addLayout(backgroundLayout);
123
124 mBackgroundBox = new TQCheckBox(i18n("Enable background image:"), this,
125 "mBackgroundBox");
126 connect(mBackgroundBox, TQ_SIGNAL(toggled(bool)),
127 TQ_SLOT(enableBackgroundToggled(bool)));
128 backgroundLayout->addWidget(mBackgroundBox);
129
130 mBackgroundName = new KURLRequester(this, "mBackgroundName");
131 mBackgroundName->setMode(KFile::File | KFile::ExistingOnly |
132 KFile::LocalOnly);
133 mBackgroundName->setFilter(KImageIO::pattern(KImageIO::Reading));
134 backgroundLayout->addWidget(mBackgroundName);
135
136 // ToolTip Checkbox
137 mToolTipBox = new TQCheckBox(i18n("Enable contact tooltips"), this,
138 "mToolTipBox");
139 layout->addWidget(mToolTipBox);
140 mIMPresenceBox = new TQCheckBox( i18n( "Show instant messaging presence" ), this, "mIMPresenceBox" );
141 layout->addWidget( mIMPresenceBox );
142}
143
144void LookAndFeelPage::enableBackgroundToggled(bool enabled)
145{
146 mBackgroundName->setEnabled(enabled);
147}
148
149#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.