Diffstat (limited to 'noncore/settings/appearance2/appearance.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/appearance2/appearance.cpp | 174 |
1 files changed, 25 insertions, 149 deletions
diff --git a/noncore/settings/appearance2/appearance.cpp b/noncore/settings/appearance2/appearance.cpp index cf3069e..23630c5 100644 --- a/noncore/settings/appearance2/appearance.cpp +++ b/noncore/settings/appearance2/appearance.cpp | |||
@@ -47,62 +47,54 @@ | |||
47 | #include <qlayout.h> | 47 | #include <qlayout.h> |
48 | #include <qlineedit.h> | 48 | #include <qlineedit.h> |
49 | #include <qlistbox.h> | 49 | #include <qlistbox.h> |
50 | #include <qmessagebox.h> | 50 | #include <qmessagebox.h> |
51 | #include <qmultilineedit.h> | 51 | #include <qmultilineedit.h> |
52 | #include <qpopupmenu.h> | 52 | #include <qpopupmenu.h> |
53 | #include <qpushbutton.h> | 53 | #include <qpushbutton.h> |
54 | #include <qradiobutton.h> | 54 | #include <qradiobutton.h> |
55 | #if QT_VERSION >= 300 | 55 | #if QT_VERSION >= 300 |
56 | #include <qstylefactory.h> | 56 | #include <qstylefactory.h> |
57 | #else | 57 | #else |
58 | #include <qwindowsstyle.h> | 58 | #include <qwindowsstyle.h> |
59 | #include <qpe/qpestyle.h> | 59 | #include <qpe/qpestyle.h> |
60 | #include <qpe/lightstyle.h> | 60 | #include <qpe/lightstyle.h> |
61 | #include <qpe/qlibrary.h> | 61 | #include <qpe/qlibrary.h> |
62 | #include <qpe/styleinterface.h> | 62 | #include <qpe/styleinterface.h> |
63 | #endif | 63 | #endif |
64 | #include <qtabwidget.h> | 64 | #include <qtabwidget.h> |
65 | #include <qtoolbutton.h> | 65 | #include <qtoolbutton.h> |
66 | #include <qvgroupbox.h> | 66 | #include <qvgroupbox.h> |
67 | #include <qwidget.h> | 67 | #include <qwidget.h> |
68 | 68 | ||
69 | #include "stylelistitem.h" | 69 | #include "stylelistitem.h" |
70 | #include "decolistitem.h" | 70 | #include "decolistitem.h" |
71 | #include "fontlistitem.h" | ||
72 | #include "colorlistitem.h" | 71 | #include "colorlistitem.h" |
73 | 72 | ||
74 | #include "sample.h" | 73 | #include "sample.h" |
75 | 74 | ||
75 | #include <opie/ofontselector.h> | ||
76 | 76 | ||
77 | static int findItemCB ( QComboBox *box, const QString &str ) | ||
78 | { | ||
79 | for ( int i = 0; i < box-> count ( ); i++ ) { | ||
80 | if ( box-> text ( i ) == str ) | ||
81 | return i; | ||
82 | } | ||
83 | return -1; | ||
84 | } | ||
85 | 77 | ||
86 | class DefaultWindowDecoration : public WindowDecorationInterface | 78 | class DefaultWindowDecoration : public WindowDecorationInterface |
87 | { | 79 | { |
88 | public: | 80 | public: |
89 | DefaultWindowDecoration() : ref(0) {} | 81 | DefaultWindowDecoration() : ref(0) {} |
90 | QString name() const { | 82 | QString name() const { |
91 | return "Default"; | 83 | return "Default"; |
92 | } | 84 | } |
93 | QPixmap icon() const { | 85 | QPixmap icon() const { |
94 | return QPixmap(); | 86 | return QPixmap(); |
95 | } | 87 | } |
96 | QRESULT queryInterface( const QUuid &uuid, QUnknownInterface **iface ) { | 88 | QRESULT queryInterface( const QUuid &uuid, QUnknownInterface **iface ) { |
97 | *iface = 0; | 89 | *iface = 0; |
98 | if ( uuid == IID_QUnknown ) | 90 | if ( uuid == IID_QUnknown ) |
99 | *iface = this; | 91 | *iface = this; |
100 | else if ( uuid == IID_WindowDecoration ) | 92 | else if ( uuid == IID_WindowDecoration ) |
101 | *iface = this; | 93 | *iface = this; |
102 | 94 | ||
103 | if ( *iface ) | 95 | if ( *iface ) |
104 | (*iface)->addRef(); | 96 | (*iface)->addRef(); |
105 | return QS_OK; | 97 | return QS_OK; |
106 | } | 98 | } |
107 | Q_REFCOUNT | 99 | Q_REFCOUNT |
108 | 100 | ||
@@ -171,57 +163,48 @@ void Appearance::loadDecos ( QListBox *list ) | |||
171 | } | 163 | } |
172 | 164 | ||
173 | void Appearance::loadColors ( QListBox *list ) | 165 | void Appearance::loadColors ( QListBox *list ) |
174 | { | 166 | { |
175 | list-> clear ( ); | 167 | list-> clear ( ); |
176 | { | 168 | { |
177 | Config config ( "qpe" ); | 169 | Config config ( "qpe" ); |
178 | config. setGroup ( "Appearance" ); | 170 | config. setGroup ( "Appearance" ); |
179 | 171 | ||
180 | list-> insertItem ( new ColorListItem ( tr( "Current scheme" ), config )); | 172 | list-> insertItem ( new ColorListItem ( tr( "Current scheme" ), config )); |
181 | } | 173 | } |
182 | 174 | ||
183 | QString path = QPEApplication::qpeDir ( ) + "/etc/colors/"; | 175 | QString path = QPEApplication::qpeDir ( ) + "/etc/colors/"; |
184 | QStringList sl = QDir ( path ). entryList ( "*.scheme" ); | 176 | QStringList sl = QDir ( path ). entryList ( "*.scheme" ); |
185 | 177 | ||
186 | for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) { | 178 | for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) { |
187 | QString name = (*it). left ((*it). find ( ".scheme" )); | 179 | QString name = (*it). left ((*it). find ( ".scheme" )); |
188 | Config config ( path + *it, Config::File ); | 180 | Config config ( path + *it, Config::File ); |
189 | config. setGroup ( "Colors" ); | 181 | config. setGroup ( "Colors" ); |
190 | 182 | ||
191 | list-> insertItem ( new ColorListItem ( name, config )); | 183 | list-> insertItem ( new ColorListItem ( name, config )); |
192 | } | 184 | } |
193 | } | 185 | } |
194 | 186 | ||
195 | void Appearance::loadFonts ( QListBox *list ) | ||
196 | { | ||
197 | FontDatabase fd; | ||
198 | QStringList f = fd. families ( ); | ||
199 | |||
200 | for ( QStringList::ConstIterator it = f. begin ( ); it != f. end ( ); ++it ) | ||
201 | list-> insertItem ( new FontListItem ( *it, fd. styles ( *it ), fd. pointSizes ( *it ))); | ||
202 | } | ||
203 | |||
204 | 187 | ||
205 | QWidget *Appearance::createStyleTab ( QWidget *parent ) | 188 | QWidget *Appearance::createStyleTab ( QWidget *parent ) |
206 | { | 189 | { |
207 | Config config ( "qpe" ); | 190 | Config config ( "qpe" ); |
208 | config. setGroup ( "Appearance" ); | 191 | config. setGroup ( "Appearance" ); |
209 | 192 | ||
210 | QWidget* tab = new QWidget( parent, "StyleTab" ); | 193 | QWidget* tab = new QWidget( parent, "StyleTab" ); |
211 | QVBoxLayout* vertLayout = new QVBoxLayout( tab, 4, 4 ); | 194 | QVBoxLayout* vertLayout = new QVBoxLayout( tab, 4, 4 ); |
212 | 195 | ||
213 | m_style_list = new QListBox( tab, "m_style_list" ); | 196 | m_style_list = new QListBox( tab, "m_style_list" ); |
214 | vertLayout->addWidget( m_style_list ); | 197 | vertLayout->addWidget( m_style_list ); |
215 | 198 | ||
216 | m_style_settings = new QPushButton ( tr( "Settings..." ), tab ); | 199 | m_style_settings = new QPushButton ( tr( "Settings..." ), tab ); |
217 | connect ( m_style_settings, SIGNAL( clicked ( )), this, SLOT( styleSettingsClicked ( ))); | 200 | connect ( m_style_settings, SIGNAL( clicked ( )), this, SLOT( styleSettingsClicked ( ))); |
218 | vertLayout-> addWidget ( m_style_settings ); | 201 | vertLayout-> addWidget ( m_style_settings ); |
219 | 202 | ||
220 | loadStyles ( m_style_list ); | 203 | loadStyles ( m_style_list ); |
221 | 204 | ||
222 | QString s = config. readEntry ( "Style", "Light" ); | 205 | QString s = config. readEntry ( "Style", "Light" ); |
223 | m_style_list-> setCurrentItem ( m_style_list-> findItem ( s )); | 206 | m_style_list-> setCurrentItem ( m_style_list-> findItem ( s )); |
224 | m_original_style = m_style_list-> currentItem ( ); | 207 | m_original_style = m_style_list-> currentItem ( ); |
225 | styleClicked ( m_original_style ); | 208 | styleClicked ( m_original_style ); |
226 | 209 | ||
227 | connect( m_style_list, SIGNAL( highlighted( int ) ), this, SLOT( styleClicked( int ) ) ); | 210 | connect( m_style_list, SIGNAL( highlighted( int ) ), this, SLOT( styleClicked( int ) ) ); |
@@ -238,233 +221,197 @@ QWidget *Appearance::createDecoTab ( QWidget *parent ) | |||
238 | QVBoxLayout* vertLayout = new QVBoxLayout( tab, 4, 4 ); | 221 | QVBoxLayout* vertLayout = new QVBoxLayout( tab, 4, 4 ); |
239 | 222 | ||
240 | m_deco_list = new QListBox( tab, "m_deco_list" ); | 223 | m_deco_list = new QListBox( tab, "m_deco_list" ); |
241 | vertLayout->addWidget( m_deco_list ); | 224 | vertLayout->addWidget( m_deco_list ); |
242 | 225 | ||
243 | loadDecos ( m_deco_list ); | 226 | loadDecos ( m_deco_list ); |
244 | 227 | ||
245 | QString s = config. readEntry ( "Decoration" ); | 228 | QString s = config. readEntry ( "Decoration" ); |
246 | m_deco_list-> setCurrentItem ( m_deco_list-> findItem ( s )); | 229 | m_deco_list-> setCurrentItem ( m_deco_list-> findItem ( s )); |
247 | m_original_deco = m_deco_list-> currentItem ( ); | 230 | m_original_deco = m_deco_list-> currentItem ( ); |
248 | if ( m_deco_list-> currentItem ( ) < 0 ) | 231 | if ( m_deco_list-> currentItem ( ) < 0 ) |
249 | m_deco_list-> setCurrentItem ( 0 ); | 232 | m_deco_list-> setCurrentItem ( 0 ); |
250 | decoClicked ( m_original_deco ); | 233 | decoClicked ( m_original_deco ); |
251 | 234 | ||
252 | connect( m_deco_list, SIGNAL( highlighted( int ) ), this, SLOT( decoClicked( int ) ) ); | 235 | connect( m_deco_list, SIGNAL( highlighted( int ) ), this, SLOT( decoClicked( int ) ) ); |
253 | 236 | ||
254 | return tab; | 237 | return tab; |
255 | } | 238 | } |
256 | 239 | ||
257 | QWidget *Appearance::createFontTab ( QWidget *parent ) | 240 | QWidget *Appearance::createFontTab ( QWidget *parent ) |
258 | { | 241 | { |
259 | Config config ( "qpe" ); | 242 | Config config ( "qpe" ); |
260 | config. setGroup ( "Appearance" ); | 243 | config. setGroup ( "Appearance" ); |
261 | 244 | ||
262 | |||
263 | QWidget *tab = new QWidget( parent, "FontTab" ); | ||
264 | QGridLayout *gridLayout = new QGridLayout ( tab, 0, 0, 4, 4 ); | ||
265 | gridLayout->setRowStretch ( 4, 10 ); | ||
266 | |||
267 | m_font_family_list = new QListBox( tab, "FontListBox" ); | ||
268 | gridLayout->addMultiCellWidget( m_font_family_list, 0, 4, 0, 0 ); | ||
269 | connect( m_font_family_list, SIGNAL( highlighted( int ) ), this, SLOT( fontFamilyClicked( int ) ) ); | ||
270 | |||
271 | QLabel *label = new QLabel( tr( "Style" ), tab ); | ||
272 | gridLayout->addWidget( label, 0, 1 ); | ||
273 | |||
274 | m_font_style_list = new QComboBox( tab, "StyleListBox" ); | ||
275 | connect( m_font_style_list, SIGNAL( activated( int ) ), this, SLOT( fontStyleClicked( int ) ) ); | ||
276 | gridLayout->addWidget( m_font_style_list, 1, 1 ); | ||
277 | |||
278 | label = new QLabel( tr( "Size" ), tab ); | ||
279 | gridLayout->addWidget( label, 2, 1 ); | ||
280 | |||
281 | m_font_size_list = new QComboBox( tab, "SizeListBox" ); | ||
282 | connect( m_font_size_list, SIGNAL( activated( int ) ), | ||
283 | this, SLOT( fontSizeClicked( int ) ) ); | ||
284 | gridLayout->addWidget( m_font_size_list, 3, 1 ); | ||
285 | |||
286 | loadFonts ( m_font_family_list ); | ||
287 | |||
288 | QString familyStr = config.readEntry( "FontFamily", "Helvetica" ); | 245 | QString familyStr = config.readEntry( "FontFamily", "Helvetica" ); |
289 | QString styleStr = config.readEntry( "FontStyle", "Regular" ); | 246 | QString styleStr = config.readEntry( "FontStyle", "Regular" ); |
290 | QString sizeStr = config.readEntry( "FontSize", "10" ); | 247 | int size = config.readNumEntry( "FontSize", 10 ); |
291 | 248 | ||
292 | m_font_family_list-> setCurrentItem ( m_font_family_list-> findItem ( familyStr )); | 249 | m_fontselect = new OFontSelector ( parent, "FontTab" ); |
293 | m_original_fontfamily = m_font_family_list-> currentItem ( ); | 250 | m_fontselect-> setSelectedFont ( familyStr, styleStr, size ); |
294 | if ( m_font_family_list-> currentItem ( ) < 0 ) | ||
295 | m_font_family_list-> setCurrentItem ( 0 ); | ||
296 | 251 | ||
297 | fontFamilyClicked ( m_original_fontfamily ); | 252 | connect( m_fontselect, SIGNAL( fontSelected ( const QFont & )), |
253 | this, SLOT( fontClicked ( const QFont & ))); | ||
298 | 254 | ||
299 | m_font_style_list-> setCurrentItem ( findItemCB ( m_font_style_list, styleStr )); | 255 | return m_fontselect; |
300 | m_original_fontstyle = m_font_style_list-> currentItem ( ); | ||
301 | fontStyleClicked ( m_original_fontstyle ); | ||
302 | |||
303 | m_font_size_list-> setCurrentItem ( findItemCB ( m_font_size_list, sizeStr )); | ||
304 | m_original_fontsize = m_font_size_list-> currentItem ( ); | ||
305 | fontSizeClicked ( m_original_fontsize ); | ||
306 | |||
307 | return tab; | ||
308 | } | 256 | } |
309 | 257 | ||
310 | QWidget *Appearance::createColorTab ( QWidget *parent ) | 258 | QWidget *Appearance::createColorTab ( QWidget *parent ) |
311 | { | 259 | { |
312 | Config config ( "qpe" ); | 260 | Config config ( "qpe" ); |
313 | config. setGroup ( "Appearance" ); | 261 | config. setGroup ( "Appearance" ); |
314 | 262 | ||
315 | 263 | ||
316 | QWidget *tab = new QWidget( parent, "ColorTab" ); | 264 | QWidget *tab = new QWidget( parent, "ColorTab" ); |
317 | QGridLayout *gridLayout = new QGridLayout( tab, 0, 0, 4, 4 ); | 265 | QGridLayout *gridLayout = new QGridLayout( tab, 0, 0, 4, 4 ); |
318 | gridLayout->setRowStretch ( 3, 10 ); | 266 | gridLayout->setRowStretch ( 3, 10 ); |
319 | 267 | ||
320 | m_color_list = new QListBox ( tab ); | 268 | m_color_list = new QListBox ( tab ); |
321 | gridLayout->addMultiCellWidget ( m_color_list, 0, 3, 0, 0 ); | 269 | gridLayout->addMultiCellWidget ( m_color_list, 0, 3, 0, 0 ); |
322 | connect( m_color_list, SIGNAL( highlighted( int ) ), this, SLOT( colorClicked( int ) ) ); | 270 | connect( m_color_list, SIGNAL( highlighted( int ) ), this, SLOT( colorClicked( int ) ) ); |
323 | 271 | ||
324 | loadColors ( m_color_list ); | 272 | loadColors ( m_color_list ); |
325 | m_color_list-> setCurrentItem ( 0 ); | 273 | m_color_list-> setCurrentItem ( 0 ); |
326 | 274 | ||
327 | QPushButton* tempButton = new QPushButton( tab, "editSchemeButton" ); | 275 | QPushButton* tempButton = new QPushButton( tab, "editSchemeButton" ); |
328 | tempButton->setText( tr( "Edit..." ) ); | 276 | tempButton->setText( tr( "Edit..." ) ); |
329 | connect( tempButton, SIGNAL( clicked() ), this, SLOT( editSchemeClicked() ) ); | 277 | connect( tempButton, SIGNAL( clicked() ), this, SLOT( editSchemeClicked() ) ); |
330 | gridLayout->addWidget( tempButton, 0, 1 ); | 278 | gridLayout->addWidget( tempButton, 0, 1 ); |
331 | 279 | ||
332 | tempButton = new QPushButton( tab, "deleteSchemeButton" ); | 280 | tempButton = new QPushButton( tab, "deleteSchemeButton" ); |
333 | tempButton->setText( tr( "Delete" ) ); | 281 | tempButton->setText( tr( "Delete" ) ); |
334 | connect( tempButton, SIGNAL( clicked() ), this, SLOT( deleteSchemeClicked() ) ); | 282 | connect( tempButton, SIGNAL( clicked() ), this, SLOT( deleteSchemeClicked() ) ); |
335 | gridLayout->addWidget( tempButton, 1, 1 ); | 283 | gridLayout->addWidget( tempButton, 1, 1 ); |
336 | 284 | ||
337 | tempButton = new QPushButton( tab, "saveSchemeButton" ); | 285 | tempButton = new QPushButton( tab, "saveSchemeButton" ); |
338 | tempButton->setText( tr( "Save" ) ); | 286 | tempButton->setText( tr( "Save" ) ); |
339 | connect( tempButton, SIGNAL( clicked() ), this, SLOT( saveSchemeClicked() ) ); | 287 | connect( tempButton, SIGNAL( clicked() ), this, SLOT( saveSchemeClicked() ) ); |
340 | gridLayout->addWidget( tempButton, 2, 1 ); | 288 | gridLayout->addWidget( tempButton, 2, 1 ); |
341 | 289 | ||
342 | return tab; | 290 | return tab; |
343 | } | 291 | } |
344 | 292 | ||
345 | QWidget *Appearance::createGuiTab ( QWidget *parent ) | 293 | QWidget *Appearance::createGuiTab ( QWidget *parent ) |
346 | { | 294 | { |
347 | Config config ( "qpe" ); | 295 | Config config ( "qpe" ); |
348 | config. setGroup ( "Appearance" ); | 296 | config. setGroup ( "Appearance" ); |
349 | 297 | ||
350 | QWidget *tab = new QWidget( parent, "AdvancedTab" ); | 298 | QWidget *tab = new QWidget( parent, "AdvancedTab" ); |
351 | QVBoxLayout *vertLayout = new QVBoxLayout( tab, 4, 4 ); | 299 | QVBoxLayout *vertLayout = new QVBoxLayout( tab, 4, 4 ); |
352 | 300 | ||
353 | QGridLayout* gridLayout = new QGridLayout ( vertLayout ); | 301 | QGridLayout* gridLayout = new QGridLayout ( vertLayout ); |
354 | 302 | ||
355 | int style = config. readNumEntry ( "TabStyle", 2 ); | 303 | int style = config. readNumEntry ( "TabStyle", 2 ) - 1; |
304 | bool tabtop = ( config. readEntry ( "TabPosition", "Top" ) == "Top" ); | ||
356 | 305 | ||
357 | QLabel* label = new QLabel( tr( "Tab style:" ), tab ); | 306 | QLabel* label = new QLabel( tr( "Tab style:" ), tab ); |
358 | gridLayout-> addWidget ( label, 0, 0 ); | 307 | gridLayout-> addWidget ( label, 0, 0 ); |
359 | QButtonGroup* btngrp = new QButtonGroup( tab, "buttongroup" ); | 308 | QButtonGroup* btngrp = new QButtonGroup( tab, "buttongroup" ); |
360 | btngrp-> hide ( ); | 309 | btngrp-> hide ( ); |
361 | btngrp-> setExclusive ( true ); | 310 | btngrp-> setExclusive ( true ); |
362 | 311 | ||
363 | m_tabstyle_list = new QComboBox ( false, tab, "tabstyle" ); | 312 | m_tabstyle_list = new QComboBox ( false, tab, "tabstyle" ); |
364 | m_tabstyle_list-> insertItem ( tr( "Tabs" )); | 313 | m_tabstyle_list-> insertItem ( tr( "Tabs" )); |
365 | m_tabstyle_list-> insertItem ( tr( "Tabs w/icons" )); | 314 | m_tabstyle_list-> insertItem ( tr( "Tabs w/icons" )); |
366 | m_tabstyle_list-> insertItem ( tr( "Drop down list" )); | 315 | m_tabstyle_list-> insertItem ( tr( "Drop down list" )); |
367 | m_tabstyle_list-> insertItem ( tr( "Drop down list w/icons" )); | 316 | m_tabstyle_list-> insertItem ( tr( "Drop down list w/icons" )); |
368 | m_tabstyle_list-> setCurrentItem ( style & 0xff ); | 317 | m_tabstyle_list-> setCurrentItem ( style ); |
369 | gridLayout-> addMultiCellWidget ( m_tabstyle_list, 0, 0, 1, 2 ); | 318 | gridLayout-> addMultiCellWidget ( m_tabstyle_list, 0, 0, 1, 2 ); |
370 | 319 | ||
371 | m_tabstyle_top = new QRadioButton( tr( "Top" ), tab, "tabpostop" ); | 320 | m_tabstyle_top = new QRadioButton( tr( "Top" ), tab, "tabpostop" ); |
372 | btngrp-> insert ( m_tabstyle_top ); | 321 | btngrp-> insert ( m_tabstyle_top ); |
373 | gridLayout-> addWidget( m_tabstyle_top, 1, 1 ); | 322 | gridLayout-> addWidget( m_tabstyle_top, 1, 1 ); |
374 | 323 | ||
375 | m_tabstyle_bottom = new QRadioButton( tr( "Bottom" ), tab, "tabposbottom" ); | 324 | m_tabstyle_bottom = new QRadioButton( tr( "Bottom" ), tab, "tabposbottom" ); |
376 | btngrp-> insert ( m_tabstyle_top ); | 325 | btngrp-> insert ( m_tabstyle_bottom ); |
377 | gridLayout-> addWidget( m_tabstyle_bottom, 1, 2 ); | 326 | gridLayout-> addWidget( m_tabstyle_bottom, 1, 2 ); |
378 | 327 | ||
379 | bool tabtop = ( style & 0xff00 ) == 0; | ||
380 | m_tabstyle_top-> setChecked ( tabtop ); | 328 | m_tabstyle_top-> setChecked ( tabtop ); |
381 | m_tabstyle_bottom-> setChecked ( !tabtop ); | 329 | m_tabstyle_bottom-> setChecked ( !tabtop ); |
382 | 330 | ||
383 | m_original_tabstyle = style; | 331 | m_original_tabstyle = style; |
332 | m_original_tabpos = tabtop; | ||
384 | 333 | ||
385 | return tab; | 334 | return tab; |
386 | } | 335 | } |
387 | 336 | ||
388 | 337 | ||
389 | Appearance::Appearance( QWidget* parent, const char* name, WFlags ) | 338 | Appearance::Appearance( QWidget* parent, const char* name, WFlags ) |
390 | : QDialog ( parent, name, true ) | 339 | : QDialog ( parent, name, true ) |
391 | { | 340 | { |
392 | setCaption( tr( "Appearance" ) ); | 341 | setCaption( tr( "Appearance" ) ); |
393 | 342 | ||
394 | Config config( "qpe" ); | 343 | Config config( "qpe" ); |
395 | config.setGroup( "Appearance" ); | 344 | config.setGroup( "Appearance" ); |
396 | 345 | ||
397 | QVBoxLayout *top = new QVBoxLayout ( this, 4, 4 ); | 346 | QVBoxLayout *top = new QVBoxLayout ( this, 4, 4 ); |
398 | 347 | ||
399 | m_sample = new SampleWindow ( this ); | 348 | m_sample = new SampleWindow ( this ); |
400 | m_sample-> setDecoration ( new DefaultWindowDecoration ( )); | 349 | m_sample-> setDecoration ( new DefaultWindowDecoration ( )); |
401 | 350 | ||
402 | OTabWidget* tw = new OTabWidget ( this, "tabwidget", OTabWidget::Global, OTabWidget::Bottom ); | 351 | OTabWidget* tw = new OTabWidget ( this, "tabwidget", OTabWidget::Global, OTabWidget::Bottom ); |
403 | QWidget *styletab; | 352 | QWidget *styletab; |
404 | 353 | ||
405 | tw-> addTab ( styletab = createStyleTab ( tw ), "appearance/styletabicon.png", tr( "Style" )); | 354 | tw-> addTab ( styletab = createStyleTab ( tw ), "appearance/styletabicon.png", tr( "Style" )); |
406 | tw-> addTab ( createFontTab ( tw ), "appearance/fonttabicon.png", tr( "Font" )); | 355 | tw-> addTab ( createFontTab ( tw ), "appearance/fonttabicon.png", tr( "Font" )); |
407 | tw-> addTab ( createColorTab ( tw ), "appearance/colorstabicon.png", tr( "Colors" ) ); | 356 | tw-> addTab ( createColorTab ( tw ), "appearance/colorstabicon.png", tr( "Colors" ) ); |
408 | tw-> addTab ( createDecoTab ( tw ), "appearance/styletabicon.png", tr( "Windows" ) ); | 357 | tw-> addTab ( createDecoTab ( tw ), "appearance/styletabicon.png", tr( "Windows" ) ); |
409 | tw-> addTab ( createGuiTab ( tw ), "appearance/backgroundtabicon.png", tr( "Gui" ) ); | 358 | tw-> addTab ( createGuiTab ( tw ), "appearance/backgroundtabicon.png", tr( "Gui" ) ); |
410 | 359 | ||
411 | top-> addWidget ( tw, 10 ); | 360 | top-> addWidget ( tw, 10 ); |
412 | top-> addWidget ( m_sample, 1 ); | 361 | top-> addWidget ( m_sample, 1 ); |
413 | 362 | ||
414 | tw-> setCurrentTab ( styletab ); | 363 | tw-> setCurrentTab ( styletab ); |
415 | } | 364 | } |
416 | 365 | ||
417 | Appearance::~Appearance() | 366 | Appearance::~Appearance() |
418 | { | 367 | { |
419 | } | 368 | } |
420 | 369 | ||
421 | void Appearance::accept ( ) | 370 | void Appearance::accept ( ) |
422 | { | 371 | { |
423 | Config config("qpe"); | 372 | Config config("qpe"); |
424 | config.setGroup( "Appearance" ); | 373 | config.setGroup( "Appearance" ); |
425 | 374 | ||
426 | int newstyle = m_style_list-> currentItem ( ); | 375 | int newtabstyle = m_tabstyle_list-> currentItem ( ); |
427 | int newtabstyle = ( m_tabstyle_list-> currentItem ( ) & 0xff ) | \ | 376 | bool newtabpos = m_tabstyle_top-> isChecked ( ); |
428 | ( m_tabstyle_top-> isChecked ( ) ? 0x000 : 0x100 ); | ||
429 | int newfontfamily = m_font_family_list-> currentItem ( ); | ||
430 | int newfontstyle = m_font_style_list-> currentItem ( ); | ||
431 | int newfontsize = m_font_size_list-> currentItem ( ); | ||
432 | 377 | ||
433 | 378 | ||
434 | if ( m_style_changed ) { | 379 | if ( m_style_changed ) { |
435 | StyleListItem *item = (StyleListItem *) m_style_list-> item ( newstyle ); | 380 | StyleListItem *item = (StyleListItem *) m_style_list-> item ( m_style_list-> currentItem ( )); |
436 | if ( item ) | 381 | if ( item ) |
437 | config.writeEntry( "Style", item-> key ( )); | 382 | config.writeEntry( "Style", item-> key ( )); |
438 | } | 383 | } |
439 | if ( newtabstyle != m_original_tabstyle ) { | 384 | |
440 | config. writeEntry ( "TabStyle", newtabstyle ); | 385 | if (( newtabstyle != m_original_tabstyle ) || ( newtabpos != m_original_tabpos )) { |
386 | config. writeEntry ( "TabStyle", newtabstyle + 1 ); | ||
387 | config. writeEntry ( "TabPosition", newtabpos ? "Top" : "Bottom" ); | ||
441 | } | 388 | } |
442 | 389 | ||
443 | if ( m_font_changed ) { | 390 | if ( m_font_changed ) { |
444 | config.writeEntry( "FontFamily", m_font_family_list-> text ( newfontfamily )); | 391 | config. writeEntry ( "FontFamily", m_fontselect-> fontFamily ( )); |
445 | config.writeEntry( "FontStyle", m_font_style_list-> text ( newfontstyle )); | 392 | config. writeEntry ( "FontStyle", m_fontselect-> fontStyle ( )); |
446 | config.writeEntry( "FontSize", m_font_size_list-> text ( newfontsize )); | 393 | config. writeEntry ( "FontSize", m_fontselect-> fontSize ( )); |
447 | } | 394 | } |
448 | 395 | ||
449 | 396 | ||
450 | if ( m_color_changed ) | 397 | if ( m_color_changed ) |
451 | { | 398 | { |
452 | ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); | 399 | ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); |
453 | 400 | ||
454 | if ( item ) | 401 | if ( item ) |
455 | item-> save ( config ); | 402 | item-> save ( config ); |
456 | } | 403 | } |
457 | 404 | ||
458 | config. write ( ); // need to flush the config info first | 405 | config. write ( ); // need to flush the config info first |
459 | Global::applyStyle ( ); | 406 | Global::applyStyle ( ); |
460 | 407 | ||
461 | if ( QMessageBox::warning ( this, tr( "Restart" ), tr( "Do you want to restart Opie now?" ), tr( "Yes" ), tr( "No" ), 0, 0, 1 ) == 0 ) { | 408 | if ( QMessageBox::warning ( this, tr( "Restart" ), tr( "Do you want to restart Opie now?" ), tr( "Yes" ), tr( "No" ), 0, 0, 1 ) == 0 ) { |
462 | QCopEnvelope e( "QPE/System", "restart()" ); | 409 | QCopEnvelope e( "QPE/System", "restart()" ); |
463 | } | 410 | } |
464 | 411 | ||
465 | QDialog::accept ( ); | 412 | QDialog::accept ( ); |
466 | } | 413 | } |
467 | 414 | ||
468 | void Appearance::done ( int r ) | 415 | void Appearance::done ( int r ) |
469 | { | 416 | { |
470 | QDialog::done ( r ); | 417 | QDialog::done ( r ); |
@@ -500,123 +447,52 @@ void Appearance::styleSettingsClicked ( ) | |||
500 | 447 | ||
501 | d-> showMaximized ( ); | 448 | d-> showMaximized ( ); |
502 | bool accepted = ( d-> exec ( ) == QDialog::Accepted ); | 449 | bool accepted = ( d-> exec ( ) == QDialog::Accepted ); |
503 | 450 | ||
504 | if ( item-> setSettings ( accepted )) | 451 | if ( item-> setSettings ( accepted )) |
505 | m_style_changed = true; | 452 | m_style_changed = true; |
506 | } | 453 | } |
507 | delete d; | 454 | delete d; |
508 | } | 455 | } |
509 | } | 456 | } |
510 | 457 | ||
511 | void Appearance::decoClicked ( int index ) | 458 | void Appearance::decoClicked ( int index ) |
512 | { | 459 | { |
513 | DecoListItem *dli = (DecoListItem *) m_deco_list-> item ( index ); | 460 | DecoListItem *dli = (DecoListItem *) m_deco_list-> item ( index ); |
514 | 461 | ||
515 | if ( m_sample ) { | 462 | if ( m_sample ) { |
516 | if ( dli && dli-> interface ( )) | 463 | if ( dli && dli-> interface ( )) |
517 | m_sample-> setDecoration ( dli-> interface ( )); | 464 | m_sample-> setDecoration ( dli-> interface ( )); |
518 | else | 465 | else |
519 | m_sample-> setDecoration ( new DefaultWindowDecoration ( )); | 466 | m_sample-> setDecoration ( new DefaultWindowDecoration ( )); |
520 | } | 467 | } |
521 | m_deco_changed |= ( index != m_original_deco ); | 468 | m_deco_changed |= ( index != m_original_deco ); |
522 | } | 469 | } |
523 | 470 | ||
524 | void Appearance::fontFamilyClicked ( int index ) | 471 | void Appearance::fontClicked ( const QFont &f ) |
525 | { | 472 | { |
526 | QString oldstyle = m_font_style_list-> currentText ( ); | 473 | m_font_changed |= ( f != m_sample-> font ( )); |
527 | QString oldsize = m_font_size_list-> currentText ( ); | 474 | m_sample-> setFont ( f ); |
528 | |||
529 | FontListItem *fli = (FontListItem *) m_font_family_list-> item ( index ); | ||
530 | |||
531 | m_font_style_list-> clear ( ); | ||
532 | m_font_style_list-> insertStringList ( fli-> styles ( )); | ||
533 | m_font_style_list-> setEnabled ( !fli-> styles ( ). isEmpty ( )); | ||
534 | |||
535 | int i; | ||
536 | |||
537 | i = findItemCB ( m_font_style_list, oldstyle ); | ||
538 | if ( i < 0 ) | ||
539 | i = findItemCB ( m_font_style_list, "Regular" ); | ||
540 | if (( i < 0 ) && ( m_font_style_list-> count ( ) > 0 )) | ||
541 | i = 0; | ||
542 | |||
543 | if ( i >= 0 ) { | ||
544 | m_font_style_list-> setCurrentItem ( i ); | ||
545 | fontStyleClicked ( i ); | ||
546 | } | ||
547 | |||
548 | m_font_size_list-> clear ( ); | ||
549 | QValueList<int> sl = fli-> sizes ( ); | ||
550 | |||
551 | for ( QValueList<int>::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) | ||
552 | m_font_size_list-> insertItem ( QString::number ( *it )); | ||
553 | |||
554 | i = findItemCB ( m_font_size_list, oldsize ); | ||
555 | if ( i < 0 ) | ||
556 | i = findItemCB ( m_font_size_list, "10" ); | ||
557 | if (( i < 0 ) && ( m_font_size_list-> count ( ) > 0 )) | ||
558 | i = 0; | ||
559 | |||
560 | if ( i >= 0 ) { | ||
561 | m_font_size_list-> setCurrentItem ( i ); | ||
562 | fontSizeClicked ( i ); | ||
563 | } | ||
564 | changeText ( ); | ||
565 | |||
566 | m_font_changed |= ( index != m_original_fontfamily ); | ||
567 | } | ||
568 | |||
569 | void Appearance::fontStyleClicked ( int index ) | ||
570 | { | ||
571 | changeText ( ); | ||
572 | |||
573 | m_font_changed |= ( index != m_original_fontstyle ); | ||
574 | } | ||
575 | |||
576 | void Appearance::fontSizeClicked ( int index ) | ||
577 | { | ||
578 | changeText ( ); | ||
579 | |||
580 | m_font_changed |= ( index != m_original_fontsize ); | ||
581 | } | ||
582 | |||
583 | void Appearance::changeText ( ) | ||
584 | { | ||
585 | int ffa = m_font_family_list-> currentItem ( ); | ||
586 | int fst = m_font_style_list-> currentItem ( ); | ||
587 | int fsi = m_font_size_list-> currentItem ( ); | ||
588 | |||
589 | FontListItem *fli = (FontListItem *) m_font_family_list-> item ( ffa ); | ||
590 | |||
591 | if ( fli ) { | ||
592 | FontDatabase fdb; | ||
593 | |||
594 | m_sample-> setFont ( fdb. font ( fli-> family ( ), \ | ||
595 | fst >= 0 ? fli-> styles ( ) [fst] : QString::null, \ | ||
596 | fsi >= 0 ? fli-> sizes ( ) [fsi] : 10, \ | ||
597 | fdb. charSets ( fli-> family ( )) [0] )); | ||
598 | } | ||
599 | } | 475 | } |
600 | 476 | ||
601 | void Appearance::colorClicked ( int index ) | 477 | void Appearance::colorClicked ( int index ) |
602 | { | 478 | { |
603 | ColorListItem *item = (ColorListItem *) m_color_list-> item ( index ); | 479 | ColorListItem *item = (ColorListItem *) m_color_list-> item ( index ); |
604 | 480 | ||
605 | if ( item ) | 481 | if ( item ) |
606 | m_sample-> setPalette ( item-> palette ( )); | 482 | m_sample-> setPalette ( item-> palette ( )); |
607 | 483 | ||
608 | m_color_changed |= ( item-> palette ( ) != qApp-> palette ( )); | 484 | m_color_changed |= ( item-> palette ( ) != qApp-> palette ( )); |
609 | } | 485 | } |
610 | 486 | ||
611 | 487 | ||
612 | void Appearance::editSchemeClicked ( ) | 488 | void Appearance::editSchemeClicked ( ) |
613 | { | 489 | { |
614 | ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); | 490 | ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); |
615 | 491 | ||
616 | int cnt = 0; | 492 | int cnt = 0; |
617 | QString controlLabel [QColorGroup::NColorRoles]; | 493 | QString controlLabel [QColorGroup::NColorRoles]; |
618 | QString controlColor [QColorGroup::NColorRoles]; | 494 | QString controlColor [QColorGroup::NColorRoles]; |
619 | 495 | ||
620 | for ( QColorGroup::ColorRole role = (QColorGroup::ColorRole) 0; role != QColorGroup::NColorRoles; ((int) role )++ ) { | 496 | for ( QColorGroup::ColorRole role = (QColorGroup::ColorRole) 0; role != QColorGroup::NColorRoles; ((int) role )++ ) { |
621 | QColor col = item-> color ( role ); | 497 | QColor col = item-> color ( role ); |
622 | 498 | ||