summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/appearance2/appearance.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/noncore/settings/appearance2/appearance.cpp b/noncore/settings/appearance2/appearance.cpp
index 4132b30..303e0b9 100644
--- a/noncore/settings/appearance2/appearance.cpp
+++ b/noncore/settings/appearance2/appearance.cpp
@@ -255,270 +255,271 @@ QWidget *Appearance::createDecoTab ( QWidget *parent )
255 255
256 return tab; 256 return tab;
257} 257}
258 258
259QWidget *Appearance::createFontTab ( QWidget *parent ) 259QWidget *Appearance::createFontTab ( QWidget *parent )
260{ 260{
261 Config config ( "qpe" ); 261 Config config ( "qpe" );
262 config. setGroup ( "Appearance" ); 262 config. setGroup ( "Appearance" );
263 263
264 QString familyStr = config.readEntry( "FontFamily", "Helvetica" ); 264 QString familyStr = config.readEntry( "FontFamily", "Helvetica" );
265 QString styleStr = config.readEntry( "FontStyle", "Regular" ); 265 QString styleStr = config.readEntry( "FontStyle", "Regular" );
266 int size = config.readNumEntry( "FontSize", 10 ); 266 int size = config.readNumEntry( "FontSize", 10 );
267 267
268 m_fontselect = new OFontSelector ( false, parent, "FontTab" ); 268 m_fontselect = new OFontSelector ( false, parent, "FontTab" );
269 m_fontselect-> setSelectedFont ( familyStr, styleStr, size ); 269 m_fontselect-> setSelectedFont ( familyStr, styleStr, size );
270 270
271 connect( m_fontselect, SIGNAL( fontSelected ( const QFont & )), 271 connect( m_fontselect, SIGNAL( fontSelected ( const QFont & )),
272 this, SLOT( fontClicked ( const QFont & ))); 272 this, SLOT( fontClicked ( const QFont & )));
273 273
274 return m_fontselect; 274 return m_fontselect;
275} 275}
276 276
277QWidget *Appearance::createColorTab ( QWidget *parent ) 277QWidget *Appearance::createColorTab ( QWidget *parent )
278{ 278{
279 Config config ( "qpe" ); 279 Config config ( "qpe" );
280 config. setGroup ( "Appearance" ); 280 config. setGroup ( "Appearance" );
281 281
282 282
283 QWidget *tab = new QWidget( parent, "ColorTab" ); 283 QWidget *tab = new QWidget( parent, "ColorTab" );
284 QGridLayout *gridLayout = new QGridLayout( tab, 0, 0, 4, 4 ); 284 QGridLayout *gridLayout = new QGridLayout( tab, 0, 0, 4, 4 );
285 gridLayout->setRowStretch ( 3, 10 ); 285 gridLayout->setRowStretch ( 3, 10 );
286 286
287 m_color_list = new QListBox ( tab ); 287 m_color_list = new QListBox ( tab );
288 gridLayout->addMultiCellWidget ( m_color_list, 0, 3, 0, 0 ); 288 gridLayout->addMultiCellWidget ( m_color_list, 0, 3, 0, 0 );
289 connect( m_color_list, SIGNAL( highlighted( int ) ), this, SLOT( colorClicked( int ) ) ); 289 connect( m_color_list, SIGNAL( highlighted( int ) ), this, SLOT( colorClicked( int ) ) );
290 290
291 loadColors ( m_color_list ); 291 loadColors ( m_color_list );
292 m_color_list-> setCurrentItem ( 0 ); 292 m_color_list-> setCurrentItem ( 0 );
293 293
294 QPushButton* tempButton = new QPushButton( tab, "editSchemeButton" ); 294 QPushButton* tempButton = new QPushButton( tab, "editSchemeButton" );
295 tempButton->setText( tr( "Edit..." ) ); 295 tempButton->setText( tr( "Edit..." ) );
296 connect( tempButton, SIGNAL( clicked() ), this, SLOT( editSchemeClicked() ) ); 296 connect( tempButton, SIGNAL( clicked() ), this, SLOT( editSchemeClicked() ) );
297 gridLayout->addWidget( tempButton, 0, 1 ); 297 gridLayout->addWidget( tempButton, 0, 1 );
298 298
299 tempButton = new QPushButton( tab, "deleteSchemeButton" ); 299 tempButton = new QPushButton( tab, "deleteSchemeButton" );
300 tempButton->setText( tr( "Delete" ) ); 300 tempButton->setText( tr( "Delete" ) );
301 connect( tempButton, SIGNAL( clicked() ), this, SLOT( deleteSchemeClicked() ) ); 301 connect( tempButton, SIGNAL( clicked() ), this, SLOT( deleteSchemeClicked() ) );
302 gridLayout->addWidget( tempButton, 1, 1 ); 302 gridLayout->addWidget( tempButton, 1, 1 );
303 303
304 tempButton = new QPushButton( tab, "saveSchemeButton" ); 304 tempButton = new QPushButton( tab, "saveSchemeButton" );
305 tempButton->setText( tr( "Save" ) ); 305 tempButton->setText( tr( "Save" ) );
306 connect( tempButton, SIGNAL( clicked() ), this, SLOT( saveSchemeClicked() ) ); 306 connect( tempButton, SIGNAL( clicked() ), this, SLOT( saveSchemeClicked() ) );
307 gridLayout->addWidget( tempButton, 2, 1 ); 307 gridLayout->addWidget( tempButton, 2, 1 );
308 308
309 return tab; 309 return tab;
310} 310}
311 311
312QWidget *Appearance::createGuiTab ( QWidget *parent ) 312QWidget *Appearance::createGuiTab ( QWidget *parent )
313{ 313{
314 Config config ( "qpe" ); 314 Config config ( "qpe" );
315 config. setGroup ( "Appearance" ); 315 config. setGroup ( "Appearance" );
316 316
317 QWidget *tab = new QWidget( parent, "AdvancedTab" ); 317 QWidget *tab = new QWidget( parent, "AdvancedTab" );
318 QVBoxLayout *vertLayout = new QVBoxLayout( tab, 4, 4 ); 318 QVBoxLayout *vertLayout = new QVBoxLayout( tab, 4, 4 );
319 319
320 QGridLayout* gridLayout = new QGridLayout ( vertLayout ); 320 QGridLayout* gridLayout = new QGridLayout ( vertLayout );
321 321
322 int style = config. readNumEntry ( "TabStyle", 2 ) - 1; 322 int style = config. readNumEntry ( "TabStyle", 2 ) - 1;
323 bool tabtop = ( config. readEntry ( "TabPosition", "Top" ) == "Top" ); 323 bool tabtop = ( config. readEntry ( "TabPosition", "Top" ) == "Top" );
324 324
325 QLabel* label = new QLabel( tr( "Tab style:" ), tab ); 325 QLabel* label = new QLabel( tr( "Tab style:" ), tab );
326 gridLayout-> addWidget ( label, 0, 0 ); 326 gridLayout-> addWidget ( label, 0, 0 );
327 QButtonGroup* btngrp = new QButtonGroup( tab, "buttongroup" ); 327 QButtonGroup* btngrp = new QButtonGroup( tab, "buttongroup" );
328 btngrp-> hide ( ); 328 btngrp-> hide ( );
329 btngrp-> setExclusive ( true ); 329 btngrp-> setExclusive ( true );
330 330
331 m_tabstyle_list = new QComboBox ( false, tab, "tabstyle" ); 331 m_tabstyle_list = new QComboBox ( false, tab, "tabstyle" );
332 m_tabstyle_list-> insertItem ( tr( "Tabs" )); 332 m_tabstyle_list-> insertItem ( tr( "Tabs" ));
333 m_tabstyle_list-> insertItem ( tr( "Tabs w/icons" )); 333 m_tabstyle_list-> insertItem ( tr( "Tabs w/icons" ));
334 m_tabstyle_list-> insertItem ( tr( "Drop down list" )); 334 m_tabstyle_list-> insertItem ( tr( "Drop down list" ));
335 m_tabstyle_list-> insertItem ( tr( "Drop down list w/icons" )); 335 m_tabstyle_list-> insertItem ( tr( "Drop down list w/icons" ));
336 m_tabstyle_list-> setCurrentItem ( style ); 336 m_tabstyle_list-> setCurrentItem ( style );
337 gridLayout-> addMultiCellWidget ( m_tabstyle_list, 0, 0, 1, 2 ); 337 gridLayout-> addMultiCellWidget ( m_tabstyle_list, 0, 0, 1, 2 );
338 338
339 m_tabstyle_top = new QRadioButton( tr( "Top" ), tab, "tabpostop" ); 339 m_tabstyle_top = new QRadioButton( tr( "Top" ), tab, "tabpostop" );
340 btngrp-> insert ( m_tabstyle_top ); 340 btngrp-> insert ( m_tabstyle_top );
341 gridLayout-> addWidget( m_tabstyle_top, 1, 1 ); 341 gridLayout-> addWidget( m_tabstyle_top, 1, 1 );
342 342
343 m_tabstyle_bottom = new QRadioButton( tr( "Bottom" ), tab, "tabposbottom" ); 343 m_tabstyle_bottom = new QRadioButton( tr( "Bottom" ), tab, "tabposbottom" );
344 btngrp-> insert ( m_tabstyle_bottom ); 344 btngrp-> insert ( m_tabstyle_bottom );
345 gridLayout-> addWidget( m_tabstyle_bottom, 1, 2 ); 345 gridLayout-> addWidget( m_tabstyle_bottom, 1, 2 );
346 346
347 m_tabstyle_top-> setChecked ( tabtop ); 347 m_tabstyle_top-> setChecked ( tabtop );
348 m_tabstyle_bottom-> setChecked ( !tabtop ); 348 m_tabstyle_bottom-> setChecked ( !tabtop );
349 349
350 m_original_tabstyle = style; 350 m_original_tabstyle = style;
351 m_original_tabpos = tabtop; 351 m_original_tabpos = tabtop;
352 352
353 return tab; 353 return tab;
354} 354}
355 355
356 356
357Appearance::Appearance( QWidget* parent, const char* name, WFlags ) 357Appearance::Appearance( QWidget* parent, const char* name, WFlags )
358 : QDialog ( parent, name, true ) 358 : QDialog ( parent, name, true )
359{ 359{
360 setCaption( tr( "Appearance" ) ); 360 setCaption( tr( "Appearance" ) );
361 361
362 Config config( "qpe" ); 362 Config config( "qpe" );
363 config.setGroup( "Appearance" ); 363 config.setGroup( "Appearance" );
364 364
365 QVBoxLayout *top = new QVBoxLayout ( this, 4, 4 ); 365 QVBoxLayout *top = new QVBoxLayout ( this, 4, 4 );
366 366
367 m_sample = new SampleWindow ( this ); 367 m_sample = new SampleWindow ( this );
368 m_sample-> setDecoration ( new DefaultWindowDecoration ( )); 368 m_sample-> setDecoration ( new DefaultWindowDecoration ( ));
369 369
370 OTabWidget* tw = new OTabWidget ( this, "tabwidget", OTabWidget::Global, OTabWidget::Bottom ); 370 OTabWidget* tw = new OTabWidget ( this, "tabwidget", OTabWidget::Global, OTabWidget::Bottom );
371 QWidget *styletab; 371 QWidget *styletab;
372 372
373 tw-> addTab ( styletab = createStyleTab ( tw ), "appearance/styletabicon.png", tr( "Style" )); 373 tw-> addTab ( styletab = createStyleTab ( tw ), "appearance/styletabicon.png", tr( "Style" ));
374 tw-> addTab ( createFontTab ( tw ), "appearance/fonttabicon.png", tr( "Font" )); 374 tw-> addTab ( createFontTab ( tw ), "appearance/fonttabicon.png", tr( "Font" ));
375 tw-> addTab ( createColorTab ( tw ), "appearance/colorstabicon.png", tr( "Colors" ) ); 375 tw-> addTab ( createColorTab ( tw ), "appearance/colorstabicon.png", tr( "Colors" ) );
376 tw-> addTab ( createDecoTab ( tw ), "appearance/decotabicon.png", tr( "Windows" ) ); 376 tw-> addTab ( createDecoTab ( tw ), "appearance/decotabicon.png", tr( "Windows" ) );
377 tw-> addTab ( createGuiTab ( tw ), "appearance/advancedtabicon.png", tr( "Gui" ) ); 377 tw-> addTab ( createGuiTab ( tw ), "appearance/advancedtabicon.png", tr( "Gui" ) );
378 378
379 top-> addWidget ( tw, 10 ); 379 top-> addWidget ( tw, 10 );
380 top-> addWidget ( m_sample, 1 ); 380 top-> addWidget ( m_sample, 1 );
381 381
382 tw-> setCurrentTab ( styletab ); 382 tw-> setCurrentTab ( styletab );
383
384 m_style_changed = m_font_changed = m_color_changed = m_deco_changed = false;
383} 385}
384 386
385Appearance::~Appearance() 387Appearance::~Appearance()
386{ 388{
387} 389}
388 390
389void Appearance::accept ( ) 391void Appearance::accept ( )
390{ 392{
391 Config config("qpe");
392 config.setGroup( "Appearance" );
393
394 int newtabstyle = m_tabstyle_list-> currentItem ( );
395 bool newtabpos = m_tabstyle_top-> isChecked ( ); 393 bool newtabpos = m_tabstyle_top-> isChecked ( );
394 int newtabstyle = m_tabstyle_list-> currentItem ( );
396 395
396 Config config ( "qpe" );
397 config. setGroup ( "Appearance" );
397 398
398 if ( m_style_changed ) { 399 if ( m_style_changed ) {
399 StyleListItem *item = (StyleListItem *) m_style_list-> item ( m_style_list-> currentItem ( )); 400 StyleListItem *item = (StyleListItem *) m_style_list-> item ( m_style_list-> currentItem ( ));
400 if ( item ) 401 if ( item )
401 config.writeEntry( "Style", item-> key ( )); 402 config.writeEntry( "Style", item-> key ( ));
402 } 403 }
403 404
404 if ( m_deco_changed ) { 405 if ( m_deco_changed ) {
405 DecoListItem *item = (DecoListItem *) m_deco_list-> item ( m_deco_list-> currentItem ( )); 406 DecoListItem *item = (DecoListItem *) m_deco_list-> item ( m_deco_list-> currentItem ( ));
406 if ( item ) 407 if ( item )
407 config.writeEntry( "Decoration", item-> key ( )); 408 config.writeEntry( "Decoration", item-> key ( ));
408 } 409 }
409 410
410 if (( newtabstyle != m_original_tabstyle ) || ( newtabpos != m_original_tabpos )) { 411 if (( newtabstyle != m_original_tabstyle ) || ( newtabpos != m_original_tabpos )) {
411 config. writeEntry ( "TabStyle", newtabstyle + 1 ); 412 config. writeEntry ( "TabStyle", newtabstyle + 1 );
412 config. writeEntry ( "TabPosition", newtabpos ? "Top" : "Bottom" ); 413 config. writeEntry ( "TabPosition", newtabpos ? "Top" : "Bottom" );
413 } 414 }
414 415
415 if ( m_font_changed ) { 416 if ( m_font_changed ) {
416 config. writeEntry ( "FontFamily", m_fontselect-> fontFamily ( )); 417 config. writeEntry ( "FontFamily", m_fontselect-> fontFamily ( ));
417 config. writeEntry ( "FontStyle", m_fontselect-> fontStyle ( )); 418 config. writeEntry ( "FontStyle", m_fontselect-> fontStyle ( ));
418 config. writeEntry ( "FontSize", m_fontselect-> fontSize ( )); 419 config. writeEntry ( "FontSize", m_fontselect-> fontSize ( ));
419 } 420 }
420 421
421 422
422 if ( m_color_changed ) 423 if ( m_color_changed )
423 { 424 {
424 ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); 425 ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( ));
425 426
426 if ( item ) 427 if ( item )
427 item-> save ( config ); 428 item-> save ( config );
428 } 429 }
429 430
430 config. write ( ); // need to flush the config info first 431 config. write ( ); // need to flush the config info first
431 Global::applyStyle ( ); 432 Global::applyStyle ( );
432 433
433 if ( QMessageBox::warning ( this, tr( "Restart" ), tr( "Do you want to restart Opie now?" ), tr( "Yes" ), tr( "No" ), 0, 0, 1 ) == 0 ) { 434 if ( QMessageBox::warning ( this, tr( "Restart" ), tr( "Do you want to restart Opie now?" ), tr( "Yes" ), tr( "No" ), 0, 0, 1 ) == 0 ) {
434 QCopEnvelope e( "QPE/System", "restart()" ); 435 QCopEnvelope e( "QPE/System", "restart()" );
435 } 436 }
436 437
437 QDialog::accept ( ); 438 QDialog::accept ( );
438} 439}
439 440
440void Appearance::done ( int r ) 441void Appearance::done ( int r )
441{ 442{
442 QDialog::done ( r ); 443 QDialog::done ( r );
443 close ( ); 444 close ( );
444} 445}
445 446
446 447
447void Appearance::styleClicked ( int index ) 448void Appearance::styleClicked ( int index )
448{ 449{
449 StyleListItem *sli = (StyleListItem *) m_style_list-> item ( index ); 450 StyleListItem *sli = (StyleListItem *) m_style_list-> item ( index );
450 m_style_settings-> setEnabled ( sli ? sli-> hasSettings ( ) : false ); 451 m_style_settings-> setEnabled ( sli ? sli-> hasSettings ( ) : false );
451 452
452 if ( m_sample && sli && sli-> style ( )) 453 if ( m_sample && sli && sli-> style ( ))
453 m_sample-> setStyle2 ( sli-> style ( )); 454 m_sample-> setStyle2 ( sli-> style ( ));
454 455
455 m_style_changed |= ( index != m_original_style ); 456 m_style_changed |= ( index != m_original_style );
456} 457}
457 458
458void Appearance::styleSettingsClicked ( ) 459void Appearance::styleSettingsClicked ( )
459{ 460{
460 StyleListItem *item = (StyleListItem *) m_style_list-> item ( m_style_list-> currentItem ( )); 461 StyleListItem *item = (StyleListItem *) m_style_list-> item ( m_style_list-> currentItem ( ));
461 462
462 if ( item && item-> hasSettings ( )) { 463 if ( item && item-> hasSettings ( )) {
463 QDialog *d = new QDialog ( this, "SETTINGS-DLG", true ); 464 QDialog *d = new QDialog ( this, "SETTINGS-DLG", true );
464 QVBoxLayout *vbox = new QVBoxLayout ( d, 4, 0 ); 465 QVBoxLayout *vbox = new QVBoxLayout ( d, 4, 0 );
465 466
466 QWidget *w = item-> settings ( d ); 467 QWidget *w = item-> settings ( d );
467 468
468 if ( w ) { 469 if ( w ) {
469 vbox-> addWidget ( w ); 470 vbox-> addWidget ( w );
470 471
471 d-> setCaption ( w-> caption ( )); 472 d-> setCaption ( w-> caption ( ));
472 473
473 d-> showMaximized ( ); 474 d-> showMaximized ( );
474 bool accepted = ( d-> exec ( ) == QDialog::Accepted ); 475 bool accepted = ( d-> exec ( ) == QDialog::Accepted );
475 476
476 if ( item-> setSettings ( accepted )) 477 if ( item-> setSettings ( accepted ))
477 m_style_changed = true; 478 m_style_changed = true;
478 } 479 }
479 delete d; 480 delete d;
480 } 481 }
481} 482}
482 483
483void Appearance::decoClicked ( int index ) 484void Appearance::decoClicked ( int index )
484{ 485{
485 DecoListItem *dli = (DecoListItem *) m_deco_list-> item ( index ); 486 DecoListItem *dli = (DecoListItem *) m_deco_list-> item ( index );
486 487
487 if ( m_sample ) { 488 if ( m_sample ) {
488 if ( dli && dli-> interface ( )) 489 if ( dli && dli-> interface ( ))
489 m_sample-> setDecoration ( dli-> interface ( )); 490 m_sample-> setDecoration ( dli-> interface ( ));
490 else 491 else
491 m_sample-> setDecoration ( new DefaultWindowDecoration ( )); 492 m_sample-> setDecoration ( new DefaultWindowDecoration ( ));
492 m_sample-> repaint ( ); 493 m_sample-> repaint ( );
493 } 494 }
494 m_deco_changed |= ( index != m_original_deco ); 495 m_deco_changed |= ( index != m_original_deco );
495} 496}
496 497
497void Appearance::fontClicked ( const QFont &f ) 498void Appearance::fontClicked ( const QFont &f )
498{ 499{
499 m_font_changed |= ( f != m_sample-> font ( )); 500 m_font_changed |= ( f != m_sample-> font ( ));
500 m_sample-> setFont ( f ); 501 m_sample-> setFont ( f );
501} 502}
502 503
503void Appearance::colorClicked ( int index ) 504void Appearance::colorClicked ( int index )
504{ 505{
505 ColorListItem *item = (ColorListItem *) m_color_list-> item ( index ); 506 ColorListItem *item = (ColorListItem *) m_color_list-> item ( index );
506 507
507 if ( item ) 508 if ( item )
508 m_sample-> setPalette ( item-> palette ( )); 509 m_sample-> setPalette ( item-> palette ( ));
509 510
510 m_color_changed |= ( item-> palette ( ) != qApp-> palette ( )); 511 m_color_changed |= ( item-> palette ( ) != qApp-> palette ( ));
511} 512}
512 513
513 514
514void Appearance::editSchemeClicked ( ) 515void Appearance::editSchemeClicked ( )
515{ 516{
516 ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); 517 ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( ));
517 518
518 int cnt = 0; 519 int cnt = 0;
519 QString labels [QColorGroup::NColorRoles]; 520 QString labels [QColorGroup::NColorRoles];
520 QColor colors [QColorGroup::NColorRoles]; 521 QColor colors [QColorGroup::NColorRoles];
521 522
522 for ( QColorGroup::ColorRole role = (QColorGroup::ColorRole) 0; role != QColorGroup::NColorRoles; ((int) role )++ ) { 523 for ( QColorGroup::ColorRole role = (QColorGroup::ColorRole) 0; role != QColorGroup::NColorRoles; ((int) role )++ ) {
523 QColor col = item-> color ( role ); 524 QColor col = item-> color ( role );
524 525