author | Michael Krelin <hacker@klever.net> | 2007-07-04 11:23:42 (UTC) |
---|---|---|
committer | Michael Krelin <hacker@klever.net> | 2007-07-04 11:23:42 (UTC) |
commit | a08aff328d4393031d5ba7d622c2b05705a89d73 (patch) (unidiff) | |
tree | 8ee90d686081c52e7c69b5ce946e9b1a7d690001 /libkdepim/kprefsdialog.cpp | |
parent | 11edc920afe4f274c0964436633aa632c8288a40 (diff) | |
download | kdepimpi-p1.zip kdepimpi-p1.tar.gz kdepimpi-p1.tar.bz2 |
initial public commit of qt4 portp1
-rw-r--r-- | libkdepim/kprefsdialog.cpp | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/libkdepim/kprefsdialog.cpp b/libkdepim/kprefsdialog.cpp index 6dc741d..358acbd 100644 --- a/libkdepim/kprefsdialog.cpp +++ b/libkdepim/kprefsdialog.cpp | |||
@@ -1,323 +1,324 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 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 | 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 | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 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 | 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. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | // $Id$ | 24 | // $Id$ |
25 | 25 | ||
26 | #include <qlayout.h> | 26 | #include <qlayout.h> |
27 | #include <qlabel.h> | 27 | #include <qlabel.h> |
28 | #include <qgroupbox.h> | 28 | #include <q3groupbox.h> |
29 | #include <qbuttongroup.h> | 29 | #include <q3buttongroup.h> |
30 | #include <qlineedit.h> | 30 | #include <qlineedit.h> |
31 | #include <qfont.h> | 31 | #include <qfont.h> |
32 | #include <qslider.h> | 32 | #include <qslider.h> |
33 | #include <qfile.h> | 33 | #include <qfile.h> |
34 | #include <qtextstream.h> | 34 | #include <q3textstream.h> |
35 | #include <qvbox.h> | 35 | #include <q3vbox.h> |
36 | #include <qhbox.h> | 36 | #include <q3hbox.h> |
37 | #include <qspinbox.h> | 37 | #include <qspinbox.h> |
38 | #include <qdatetime.h> | 38 | #include <qdatetime.h> |
39 | #include <qframe.h> | 39 | #include <q3frame.h> |
40 | #include <qcombobox.h> | 40 | #include <qcombobox.h> |
41 | #include <qcheckbox.h> | 41 | #include <qcheckbox.h> |
42 | #include <qradiobutton.h> | 42 | #include <qradiobutton.h> |
43 | #include <qpushbutton.h> | 43 | #include <qpushbutton.h> |
44 | #include <qapplication.h> | 44 | #include <qapplication.h> |
45 | #include <QDesktopWidget> | ||
45 | 46 | ||
46 | #include <kcolorbutton.h> | 47 | #include <kcolorbutton.h> |
47 | #include <kdebug.h> | 48 | #include <kdebug.h> |
48 | #include <klocale.h> | 49 | #include <klocale.h> |
49 | #include <kglobal.h> | 50 | #include <kglobal.h> |
50 | #include <kglobalsettings.h> | 51 | #include <kglobalsettings.h> |
51 | #include <kfontdialog.h> | 52 | #include <kfontdialog.h> |
52 | #include <kmessagebox.h> | 53 | #include <kmessagebox.h> |
53 | #include <kcolordialog.h> | 54 | #include <kcolordialog.h> |
54 | #include <kiconloader.h> | 55 | #include <kiconloader.h> |
55 | 56 | ||
56 | #include "kprefs.h" | 57 | #include "kprefs.h" |
57 | #include "kpimglobalprefs.h" | 58 | #include "kpimglobalprefs.h" |
58 | 59 | ||
59 | #include "kprefsdialog.h" | 60 | #include "kprefsdialog.h" |
60 | //#include "kprefsdialog.moc" | 61 | //#include "kprefsdialog.moc" |
61 | 62 | ||
62 | KPrefsDialogWidBool::KPrefsDialogWidBool(const QString &text,bool *reference, | 63 | KPrefsDialogWidBool::KPrefsDialogWidBool(const QString &text,bool *reference, |
63 | QWidget *parent) | 64 | QWidget *parent) |
64 | { | 65 | { |
65 | mReference = reference; | 66 | mReference = reference; |
66 | 67 | ||
67 | mCheck = new QCheckBox(text,parent); | 68 | mCheck = new QCheckBox(text,parent); |
68 | } | 69 | } |
69 | 70 | ||
70 | void KPrefsDialogWidBool::readConfig() | 71 | void KPrefsDialogWidBool::readConfig() |
71 | { | 72 | { |
72 | mCheck->setChecked(*mReference); | 73 | mCheck->setChecked(*mReference); |
73 | } | 74 | } |
74 | 75 | ||
75 | void KPrefsDialogWidBool::writeConfig() | 76 | void KPrefsDialogWidBool::writeConfig() |
76 | { | 77 | { |
77 | *mReference = mCheck->isChecked(); | 78 | *mReference = mCheck->isChecked(); |
78 | } | 79 | } |
79 | 80 | ||
80 | QCheckBox *KPrefsDialogWidBool::checkBox() | 81 | QCheckBox *KPrefsDialogWidBool::checkBox() |
81 | { | 82 | { |
82 | return mCheck; | 83 | return mCheck; |
83 | } | 84 | } |
84 | 85 | ||
85 | 86 | ||
86 | KPrefsDialogWidColor::KPrefsDialogWidColor(const QString &text,QColor *reference, | 87 | KPrefsDialogWidColor::KPrefsDialogWidColor(const QString &text,QColor *reference, |
87 | QWidget *parent) | 88 | QWidget *parent) |
88 | { | 89 | { |
89 | mReference = reference; | 90 | mReference = reference; |
90 | 91 | ||
91 | mButton = new KColorButton(parent); | 92 | mButton = new KColorButton(parent); |
92 | mLabel = new QLabel(mButton, text, parent); | 93 | mLabel = new QLabel(mButton, text, parent); |
93 | mButton->setColor( *mReference ); | 94 | mButton->setColor( *mReference ); |
94 | mButton->setColor( Qt::red ); | 95 | mButton->setColor( Qt::red ); |
95 | 96 | ||
96 | } | 97 | } |
97 | 98 | ||
98 | KPrefsDialogWidColor::~KPrefsDialogWidColor() | 99 | KPrefsDialogWidColor::~KPrefsDialogWidColor() |
99 | { | 100 | { |
100 | // kdDebug(5300) << "KPrefsDialogWidColor::~KPrefsDialogWidColor()" << endl; | 101 | // kdDebug(5300) << "KPrefsDialogWidColor::~KPrefsDialogWidColor()" << endl; |
101 | } | 102 | } |
102 | 103 | ||
103 | void KPrefsDialogWidColor::readConfig() | 104 | void KPrefsDialogWidColor::readConfig() |
104 | { | 105 | { |
105 | mButton->setColor(*mReference); | 106 | mButton->setColor(*mReference); |
106 | } | 107 | } |
107 | 108 | ||
108 | void KPrefsDialogWidColor::writeConfig() | 109 | void KPrefsDialogWidColor::writeConfig() |
109 | { | 110 | { |
110 | *mReference = mButton->color(); | 111 | *mReference = mButton->color(); |
111 | } | 112 | } |
112 | 113 | ||
113 | QLabel *KPrefsDialogWidColor::label() | 114 | QLabel *KPrefsDialogWidColor::label() |
114 | { | 115 | { |
115 | return mLabel; | 116 | return mLabel; |
116 | } | 117 | } |
117 | 118 | ||
118 | KColorButton *KPrefsDialogWidColor::button() | 119 | KColorButton *KPrefsDialogWidColor::button() |
119 | { | 120 | { |
120 | return mButton; | 121 | return mButton; |
121 | } | 122 | } |
122 | 123 | ||
123 | KPrefsDialogWidFont::KPrefsDialogWidFont(const QString &sampleText,const QString &labelText, | 124 | KPrefsDialogWidFont::KPrefsDialogWidFont(const QString &sampleText,const QString &labelText, |
124 | QFont *reference,QWidget *parent) | 125 | QFont *reference,QWidget *parent) |
125 | { | 126 | { |
126 | mReference = reference; | 127 | mReference = reference; |
127 | 128 | ||
128 | mLabel = new QLabel(labelText, parent); | 129 | mLabel = new QLabel(labelText, parent); |
129 | 130 | ||
130 | mPreview = new QLabel(sampleText,parent); | 131 | mPreview = new QLabel(sampleText,parent); |
131 | mPreview->setFrameStyle(QFrame::Panel|QFrame::Sunken); | 132 | mPreview->setFrameStyle(Q3Frame::Panel|Q3Frame::Sunken); |
132 | 133 | ||
133 | mButton = new QPushButton(i18n("Choose..."), parent); | 134 | mButton = new QPushButton(i18n("Choose..."), parent); |
134 | connect(mButton,SIGNAL(clicked()),SLOT(selectFont())); | 135 | connect(mButton,SIGNAL(clicked()),SLOT(selectFont())); |
135 | mPreview->setMaximumHeight( QApplication::desktop()->height() / 12 ); | 136 | mPreview->setMaximumHeight( QApplication::desktop()->height() / 12 ); |
136 | mPreview->setMaximumWidth( (QApplication::desktop()->width() / 2)-10 ); | 137 | mPreview->setMaximumWidth( (QApplication::desktop()->width() / 2)-10 ); |
137 | } | 138 | } |
138 | 139 | ||
139 | KPrefsDialogWidFont::~KPrefsDialogWidFont() | 140 | KPrefsDialogWidFont::~KPrefsDialogWidFont() |
140 | { | 141 | { |
141 | } | 142 | } |
142 | 143 | ||
143 | void KPrefsDialogWidFont::readConfig() | 144 | void KPrefsDialogWidFont::readConfig() |
144 | { | 145 | { |
145 | mPreview->setFont(*mReference); | 146 | mPreview->setFont(*mReference); |
146 | } | 147 | } |
147 | 148 | ||
148 | void KPrefsDialogWidFont::writeConfig() | 149 | void KPrefsDialogWidFont::writeConfig() |
149 | { | 150 | { |
150 | *mReference = mPreview->font(); | 151 | *mReference = mPreview->font(); |
151 | } | 152 | } |
152 | 153 | ||
153 | QLabel *KPrefsDialogWidFont::label() | 154 | QLabel *KPrefsDialogWidFont::label() |
154 | { | 155 | { |
155 | return mLabel; | 156 | return mLabel; |
156 | } | 157 | } |
157 | 158 | ||
158 | QLabel *KPrefsDialogWidFont::preview() | 159 | QLabel *KPrefsDialogWidFont::preview() |
159 | { | 160 | { |
160 | return mPreview; | 161 | return mPreview; |
161 | } | 162 | } |
162 | 163 | ||
163 | QPushButton *KPrefsDialogWidFont::button() | 164 | QPushButton *KPrefsDialogWidFont::button() |
164 | { | 165 | { |
165 | return mButton; | 166 | return mButton; |
166 | } | 167 | } |
167 | 168 | ||
168 | void KPrefsDialogWidFont::selectFont() | 169 | void KPrefsDialogWidFont::selectFont() |
169 | { | 170 | { |
170 | QFont myFont(mPreview->font()); | 171 | QFont myFont(mPreview->font()); |
171 | bool ok; | 172 | bool ok; |
172 | myFont = KFontDialog::getFont(myFont, ok); | 173 | myFont = KFontDialog::getFont(myFont, ok); |
173 | if ( ok ) { | 174 | if ( ok ) { |
174 | mPreview->setFont(myFont); | 175 | mPreview->setFont(myFont); |
175 | } | 176 | } |
176 | } | 177 | } |
177 | 178 | ||
178 | 179 | ||
179 | KPrefsDialogWidTime::KPrefsDialogWidTime(const QString &text,int *reference, | 180 | KPrefsDialogWidTime::KPrefsDialogWidTime(const QString &text,int *reference, |
180 | QWidget *parent) | 181 | QWidget *parent) |
181 | { | 182 | { |
182 | mReference = reference; | 183 | mReference = reference; |
183 | 184 | ||
184 | mLabel = new QLabel(text,parent); | 185 | mLabel = new QLabel(text,parent); |
185 | mSpin = new QSpinBox(0,23,1,parent); | 186 | mSpin = new QSpinBox(0,23,1,parent); |
186 | mSpin->setSuffix(":00"); | 187 | mSpin->setSuffix(":00"); |
187 | } | 188 | } |
188 | 189 | ||
189 | void KPrefsDialogWidTime::readConfig() | 190 | void KPrefsDialogWidTime::readConfig() |
190 | { | 191 | { |
191 | mSpin->setValue(*mReference); | 192 | mSpin->setValue(*mReference); |
192 | } | 193 | } |
193 | 194 | ||
194 | void KPrefsDialogWidTime::writeConfig() | 195 | void KPrefsDialogWidTime::writeConfig() |
195 | { | 196 | { |
196 | *mReference = mSpin->value(); | 197 | *mReference = mSpin->value(); |
197 | } | 198 | } |
198 | 199 | ||
199 | QLabel *KPrefsDialogWidTime::label() | 200 | QLabel *KPrefsDialogWidTime::label() |
200 | { | 201 | { |
201 | return mLabel; | 202 | return mLabel; |
202 | } | 203 | } |
203 | 204 | ||
204 | QSpinBox *KPrefsDialogWidTime::spinBox() | 205 | QSpinBox *KPrefsDialogWidTime::spinBox() |
205 | { | 206 | { |
206 | return mSpin; | 207 | return mSpin; |
207 | } | 208 | } |
208 | 209 | ||
209 | 210 | ||
210 | KPrefsDialogWidRadios::KPrefsDialogWidRadios(const QString &text,int *reference, | 211 | KPrefsDialogWidRadios::KPrefsDialogWidRadios(const QString &text,int *reference, |
211 | QWidget *parent) | 212 | QWidget *parent) |
212 | { | 213 | { |
213 | mReference = reference; | 214 | mReference = reference; |
214 | 215 | ||
215 | mBox = new QButtonGroup(1,Qt::Horizontal,text,parent); | 216 | mBox = new Q3ButtonGroup(1,Qt::Horizontal,text,parent); |
216 | } | 217 | } |
217 | 218 | ||
218 | KPrefsDialogWidRadios::~KPrefsDialogWidRadios() | 219 | KPrefsDialogWidRadios::~KPrefsDialogWidRadios() |
219 | { | 220 | { |
220 | } | 221 | } |
221 | 222 | ||
222 | void KPrefsDialogWidRadios::addRadio(const QString &text) | 223 | void KPrefsDialogWidRadios::addRadio(const QString &text) |
223 | { | 224 | { |
224 | new QRadioButton(text,mBox); | 225 | new QRadioButton(text,mBox); |
225 | } | 226 | } |
226 | 227 | ||
227 | QButtonGroup *KPrefsDialogWidRadios::groupBox() | 228 | Q3ButtonGroup *KPrefsDialogWidRadios::groupBox() |
228 | { | 229 | { |
229 | return mBox; | 230 | return mBox; |
230 | } | 231 | } |
231 | 232 | ||
232 | void KPrefsDialogWidRadios::readConfig() | 233 | void KPrefsDialogWidRadios::readConfig() |
233 | { | 234 | { |
234 | mBox->setButton(*mReference); | 235 | mBox->setButton(*mReference); |
235 | } | 236 | } |
236 | 237 | ||
237 | void KPrefsDialogWidRadios::writeConfig() | 238 | void KPrefsDialogWidRadios::writeConfig() |
238 | { | 239 | { |
239 | *mReference = mBox->id(mBox->selected()); | 240 | *mReference = mBox->id(mBox->selected()); |
240 | } | 241 | } |
241 | 242 | ||
242 | 243 | ||
243 | KPrefsDialogWidString::KPrefsDialogWidString(const QString &text,QString *reference, | 244 | KPrefsDialogWidString::KPrefsDialogWidString(const QString &text,QString *reference, |
244 | QWidget *parent, QLineEdit::EchoMode echomode) | 245 | QWidget *parent, QLineEdit::EchoMode echomode) |
245 | { | 246 | { |
246 | mReference = reference; | 247 | mReference = reference; |
247 | 248 | ||
248 | mLabel = new QLabel(text,parent); | 249 | mLabel = new QLabel(text,parent); |
249 | mEdit = new QLineEdit(parent); | 250 | mEdit = new QLineEdit(parent); |
250 | mEdit->setEchoMode( echomode ); | 251 | mEdit->setEchoMode( echomode ); |
251 | } | 252 | } |
252 | 253 | ||
253 | KPrefsDialogWidString::~KPrefsDialogWidString() | 254 | KPrefsDialogWidString::~KPrefsDialogWidString() |
254 | { | 255 | { |
255 | } | 256 | } |
256 | 257 | ||
257 | void KPrefsDialogWidString::readConfig() | 258 | void KPrefsDialogWidString::readConfig() |
258 | { | 259 | { |
259 | mEdit->setText(*mReference); | 260 | mEdit->setText(*mReference); |
260 | } | 261 | } |
261 | 262 | ||
262 | void KPrefsDialogWidString::writeConfig() | 263 | void KPrefsDialogWidString::writeConfig() |
263 | { | 264 | { |
264 | *mReference = mEdit->text(); | 265 | *mReference = mEdit->text(); |
265 | } | 266 | } |
266 | 267 | ||
267 | QLabel *KPrefsDialogWidString::label() | 268 | QLabel *KPrefsDialogWidString::label() |
268 | { | 269 | { |
269 | return mLabel; | 270 | return mLabel; |
270 | } | 271 | } |
271 | 272 | ||
272 | QLineEdit *KPrefsDialogWidString::lineEdit() | 273 | QLineEdit *KPrefsDialogWidString::lineEdit() |
273 | { | 274 | { |
274 | return mEdit; | 275 | return mEdit; |
275 | } | 276 | } |
276 | 277 | ||
277 | 278 | ||
278 | KPrefsDialog::KPrefsDialog(KPrefs *prefs,QWidget *parent,char *name,bool modal) : | 279 | KPrefsDialog::KPrefsDialog(KPrefs *prefs,QWidget *parent,char *name,bool modal) : |
279 | KDialogBase(IconList,i18n("Preferences"),Ok|Cancel|Default,Ok,parent, | 280 | KDialogBase(IconList,i18n("Preferences"),Ok|Cancel|Default,Ok,parent, |
280 | name,modal,true) | 281 | name,modal,true) |
281 | { | 282 | { |
282 | mPrefs = prefs; | 283 | mPrefs = prefs; |
283 | 284 | ||
284 | // This seems to cause a crash on exit. Investigate later. | 285 | // This seems to cause a crash on exit. Investigate later. |
285 | mPrefsWids.setAutoDelete(true); | 286 | mPrefsWids.setAutoDelete(true); |
286 | 287 | ||
287 | connect(this,SIGNAL(defaultClicked()),SLOT(slotDefault())); | 288 | connect(this,SIGNAL(defaultClicked()),SLOT(slotDefault())); |
288 | //connect(this,SIGNAL(cancelClicked()),SLOT(slotDefault())); | 289 | //connect(this,SIGNAL(cancelClicked()),SLOT(slotDefault())); |
289 | //connect(this,SIGNAL(cancelClicked()),SLOT(reject())); | 290 | //connect(this,SIGNAL(cancelClicked()),SLOT(reject())); |
290 | } | 291 | } |
291 | 292 | ||
292 | KPrefsDialog::~KPrefsDialog() | 293 | KPrefsDialog::~KPrefsDialog() |
293 | { | 294 | { |
294 | } | 295 | } |
295 | 296 | ||
296 | void KPrefsDialog::addWid(KPrefsDialogWid *wid) | 297 | void KPrefsDialog::addWid(KPrefsDialogWid *wid) |
297 | { | 298 | { |
298 | mPrefsWids.append(wid); | 299 | mPrefsWids.append(wid); |
299 | } | 300 | } |
300 | 301 | ||
301 | KPrefsDialogWidBool *KPrefsDialog::addWidBool(const QString &text,bool *reference,QWidget *parent) | 302 | KPrefsDialogWidBool *KPrefsDialog::addWidBool(const QString &text,bool *reference,QWidget *parent) |
302 | { | 303 | { |
303 | KPrefsDialogWidBool *w = new KPrefsDialogWidBool(text,reference,parent); | 304 | KPrefsDialogWidBool *w = new KPrefsDialogWidBool(text,reference,parent); |
304 | addWid(w); | 305 | addWid(w); |
305 | return w; | 306 | return w; |
306 | } | 307 | } |
307 | 308 | ||
308 | KPrefsDialogWidTime *KPrefsDialog::addWidTime(const QString &text,int *reference,QWidget *parent) | 309 | KPrefsDialogWidTime *KPrefsDialog::addWidTime(const QString &text,int *reference,QWidget *parent) |
309 | { | 310 | { |
310 | KPrefsDialogWidTime *w = new KPrefsDialogWidTime(text,reference,parent); | 311 | KPrefsDialogWidTime *w = new KPrefsDialogWidTime(text,reference,parent); |
311 | addWid(w); | 312 | addWid(w); |
312 | return w; | 313 | return w; |
313 | } | 314 | } |
314 | 315 | ||
315 | KPrefsDialogWidColor *KPrefsDialog::addWidColor(const QString &text,QColor *reference,QWidget *parent) | 316 | KPrefsDialogWidColor *KPrefsDialog::addWidColor(const QString &text,QColor *reference,QWidget *parent) |
316 | { | 317 | { |
317 | KPrefsDialogWidColor *w = new KPrefsDialogWidColor(text,reference,parent); | 318 | KPrefsDialogWidColor *w = new KPrefsDialogWidColor(text,reference,parent); |
318 | addWid(w); | 319 | addWid(w); |
319 | return w; | 320 | return w; |
320 | } | 321 | } |
321 | 322 | ||
322 | KPrefsDialogWidRadios *KPrefsDialog::addWidRadios(const QString &text,int *reference,QWidget *parent) | 323 | KPrefsDialogWidRadios *KPrefsDialog::addWidRadios(const QString &text,int *reference,QWidget *parent) |
323 | { | 324 | { |