Diffstat (limited to 'kaddressbook/views/configuretableviewdialog.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | kaddressbook/views/configuretableviewdialog.cpp | 155 |
1 files changed, 155 insertions, 0 deletions
diff --git a/kaddressbook/views/configuretableviewdialog.cpp b/kaddressbook/views/configuretableviewdialog.cpp new file mode 100644 index 0000000..e1cc63e --- a/dev/null +++ b/kaddressbook/views/configuretableviewdialog.cpp | |||
@@ -0,0 +1,155 @@ | |||
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
18 | |||
19 | As a special exception, permission is given to link this program | ||
20 | with any edition of Qt, and distribute the resulting executable, | ||
21 | without including the source code for Qt in the source distribution. | ||
22 | */ | ||
23 | |||
24 | #include <qstring.h> | ||
25 | #include <qwidget.h> | ||
26 | #include <qlayout.h> | ||
27 | #include <qradiobutton.h> | ||
28 | #include <qcheckbox.h> | ||
29 | #include <qvbox.h> | ||
30 | #include <qbuttongroup.h> | ||
31 | |||
32 | #include <kglobal.h> | ||
33 | #include <klocale.h> | ||
34 | #include <klineedit.h> | ||
35 | #include <kurlrequester.h> | ||
36 | #include <kiconloader.h> | ||
37 | |||
38 | #ifndef KAB_EMBEDDED | ||
39 | #include <kimageio.h> | ||
40 | #else //KAB_EMBEDDED | ||
41 | #endif //KAB_EMBEDDED | ||
42 | |||
43 | #include <kconfig.h> | ||
44 | |||
45 | #include "configuretableviewdialog.h" | ||
46 | |||
47 | ConfigureTableViewWidget::ConfigureTableViewWidget( KABC::AddressBook *ab, | ||
48 | QWidget *parent, | ||
49 | const char *name ) | ||
50 | : ViewConfigureWidget( ab, parent, name ) | ||
51 | { | ||
52 | QWidget *page = addPage( i18n( "Look & Feel" ), QString::null, | ||
53 | KGlobal::iconLoader()->loadIcon( "looknfeel", | ||
54 | KIcon::Panel ) ); | ||
55 | |||
56 | mPage = new LookAndFeelPage( page ); | ||
57 | } | ||
58 | |||
59 | ConfigureTableViewWidget::~ConfigureTableViewWidget() | ||
60 | { | ||
61 | } | ||
62 | |||
63 | void ConfigureTableViewWidget::restoreSettings( KConfig *config ) | ||
64 | { | ||
65 | ViewConfigureWidget::restoreSettings( config ); | ||
66 | |||
67 | mPage->restoreSettings( config ); | ||
68 | } | ||
69 | |||
70 | void ConfigureTableViewWidget::saveSettings( KConfig *config ) | ||
71 | { | ||
72 | ViewConfigureWidget::saveSettings( config ); | ||
73 | |||
74 | mPage->saveSettings( config ); | ||
75 | } | ||
76 | |||
77 | |||
78 | |||
79 | LookAndFeelPage::LookAndFeelPage(QWidget *parent, const char *name) | ||
80 | : QWidget(parent, name) | ||
81 | { | ||
82 | initGUI(); | ||
83 | |||
84 | // Set initial state | ||
85 | enableBackgroundToggled(mBackgroundBox->isChecked()); | ||
86 | } | ||
87 | |||
88 | void LookAndFeelPage::restoreSettings( KConfig *config ) | ||
89 | { | ||
90 | mAlternateButton->setChecked(config->readBoolEntry("ABackground", true)); | ||
91 | mLineButton->setChecked(config->readBoolEntry("SingleLine", false)); | ||
92 | mToolTipBox->setChecked(config->readBoolEntry("ToolTips", true)); | ||
93 | |||
94 | if (!mAlternateButton->isChecked() & !mLineButton->isChecked()) | ||
95 | mNoneButton->setChecked(true); | ||
96 | |||
97 | mBackgroundBox->setChecked(config->readBoolEntry("Background", false)); | ||
98 | mBackgroundName->lineEdit()->setText(config->readEntry("BackgroundName")); | ||
99 | } | ||
100 | |||
101 | void LookAndFeelPage::saveSettings( KConfig *config ) | ||
102 | { | ||
103 | config->writeEntry("ABackground", mAlternateButton->isChecked()); | ||
104 | config->writeEntry("SingleLine", mLineButton->isChecked()); | ||
105 | config->writeEntry("ToolTips", mToolTipBox->isChecked()); | ||
106 | config->writeEntry("Background", mBackgroundBox->isChecked()); | ||
107 | config->writeEntry("BackgroundName", mBackgroundName->lineEdit()->text()); | ||
108 | } | ||
109 | |||
110 | void LookAndFeelPage::initGUI() | ||
111 | { | ||
112 | QVBoxLayout *layout = new QVBoxLayout(this, 0, KDialogBase::spacingHint()); | ||
113 | |||
114 | QButtonGroup *group = new QButtonGroup(1, Qt::Horizontal, | ||
115 | i18n("Row Separator"), this); | ||
116 | layout->addWidget(group); | ||
117 | |||
118 | mAlternateButton = new QRadioButton(i18n("Alternating backgrounds"), | ||
119 | group, "mAlternateButton"); | ||
120 | mLineButton = new QRadioButton(i18n("Single line"), group, "mLineButton"); | ||
121 | mNoneButton = new QRadioButton(i18n("None"), group, "mNoneButton"); | ||
122 | |||
123 | // Background Checkbox/Selector | ||
124 | QHBoxLayout *backgroundLayout = new QHBoxLayout(); | ||
125 | layout->addLayout(backgroundLayout); | ||
126 | |||
127 | mBackgroundBox = new QCheckBox(i18n("Enable background image:"), this, | ||
128 | "mBackgroundBox"); | ||
129 | connect(mBackgroundBox, SIGNAL(toggled(bool)), | ||
130 | SLOT(enableBackgroundToggled(bool))); | ||
131 | backgroundLayout->addWidget(mBackgroundBox); | ||
132 | |||
133 | mBackgroundName = new KURLRequester(this, "mBackgroundName"); | ||
134 | #ifndef KAB_EMBEDDED | ||
135 | mBackgroundName->setMode(KFile::File | KFile::ExistingOnly | | ||
136 | KFile::LocalOnly); | ||
137 | mBackgroundName->setFilter(KImageIO::pattern(KImageIO::Reading)); | ||
138 | #endif //KAB_EMBEDDED | ||
139 | |||
140 | backgroundLayout->addWidget(mBackgroundName); | ||
141 | |||
142 | // ToolTip Checkbox | ||
143 | mToolTipBox = new QCheckBox(i18n("Enable contact tooltips"), this, | ||
144 | "mToolTipBox"); | ||
145 | layout->addWidget(mToolTipBox); | ||
146 | } | ||
147 | |||
148 | void LookAndFeelPage::enableBackgroundToggled(bool enabled) | ||
149 | { | ||
150 | mBackgroundName->setEnabled(enabled); | ||
151 | } | ||
152 | |||
153 | #ifndef KAB_EMBEDDED | ||
154 | #include "configuretableviewdialog.moc" | ||
155 | #endif //KAB_EMBEDDED | ||