author | harlekin <harlekin> | 2003-03-08 21:18:44 (UTC) |
---|---|---|
committer | harlekin <harlekin> | 2003-03-08 21:18:44 (UTC) |
commit | e0ee59855dfd924d33b4fcd98d5fa74a95437e71 (patch) (unidiff) | |
tree | 6a7094b8cd634958242cb767bf1bcb7a30dfd68d /noncore/settings/appearance2/appearance.cpp | |
parent | 803d651da2d61409029b12b378ea815a16109ce7 (diff) | |
download | opie-e0ee59855dfd924d33b4fcd98d5fa74a95437e71.zip opie-e0ee59855dfd924d33b4fcd98d5fa74a95437e71.tar.gz opie-e0ee59855dfd924d33b4fcd98d5fa74a95437e71.tar.bz2 |
use the wrench from inline
Diffstat (limited to 'noncore/settings/appearance2/appearance.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/appearance2/appearance.cpp | 72 |
1 files changed, 36 insertions, 36 deletions
diff --git a/noncore/settings/appearance2/appearance.cpp b/noncore/settings/appearance2/appearance.cpp index 2b35119..8dc70ee 100644 --- a/noncore/settings/appearance2/appearance.cpp +++ b/noncore/settings/appearance2/appearance.cpp | |||
@@ -411,32 +411,32 @@ Appearance::Appearance( QWidget* parent, const char* name, WFlags ) | |||
411 | 411 | ||
412 | Config config( "qpe" ); | 412 | Config config( "qpe" ); |
413 | config.setGroup( "Appearance" ); | 413 | config.setGroup( "Appearance" ); |
414 | 414 | ||
415 | QVBoxLayout *top = new QVBoxLayout ( this, 3, 3 ); | 415 | QVBoxLayout *top = new QVBoxLayout ( this, 3, 3 ); |
416 | 416 | ||
417 | m_sample = new SampleWindow ( this ); | 417 | m_sample = new SampleWindow ( this ); |
418 | m_sample-> setDecoration ( new DefaultWindowDecoration ( )); | 418 | m_sample-> setDecoration ( new DefaultWindowDecoration ( )); |
419 | QWhatsThis::add( m_sample, tr( "This is a preview window. Look here to see your new appearance as options are changed." ) ); | 419 | QWhatsThis::add( m_sample, tr( "This is a preview window. Look here to see your new appearance as options are changed." ) ); |
420 | 420 | ||
421 | OTabWidget* tw = new OTabWidget ( this, "tabwidget", OTabWidget::Global, OTabWidget::Bottom ); | 421 | OTabWidget* tw = new OTabWidget ( this, "tabwidget", OTabWidget::Global, OTabWidget::Bottom ); |
422 | QWidget *styletab; | 422 | QWidget *styletab; |
423 | 423 | ||
424 | m_color_list = 0; | 424 | m_color_list = 0; |
425 | 425 | ||
426 | tw-> addTab ( styletab = createStyleTab ( tw, config ), "appearance/style", tr( "Style" )); | 426 | tw-> addTab ( styletab = createStyleTab ( tw, config ), "appearance/style", tr( "Style" )); |
427 | tw-> addTab ( createFontTab ( tw, config ), "appearance/font", tr( "Font" )); | 427 | tw-> addTab ( createFontTab ( tw, config ), "appearance/font", tr( "Font" )); |
428 | tw-> addTab ( createColorTab ( tw, config ), "appearance/color", tr( "Colors" ) ); | 428 | tw-> addTab ( createColorTab ( tw, config ), "appearance/color", tr( "Colors" ) ); |
429 | tw-> addTab ( createDecoTab ( tw, config ), "appearance/deco", tr( "Windows" ) ); | 429 | tw-> addTab ( createDecoTab ( tw, config ), "appearance/deco", tr( "Windows" ) ); |
430 | tw-> addTab ( m_advtab = createAdvancedTab ( tw, config ), "appearance/advanced", tr( "Advanced" ) ); | 430 | tw-> addTab ( m_advtab = createAdvancedTab ( tw, config ), "SettingsIcon", tr( "Advanced" ) ); |
431 | 431 | ||
432 | top-> addWidget ( tw, 10 ); | 432 | top-> addWidget ( tw, 10 ); |
433 | top-> addWidget ( m_sample, 1 ); | 433 | top-> addWidget ( m_sample, 1 ); |
434 | 434 | ||
435 | tw-> setCurrentTab ( styletab ); | 435 | tw-> setCurrentTab ( styletab ); |
436 | connect ( tw, SIGNAL( currentChanged ( QWidget * )), this, SLOT( tabChanged ( QWidget * ))); | 436 | connect ( tw, SIGNAL( currentChanged ( QWidget * )), this, SLOT( tabChanged ( QWidget * ))); |
437 | 437 | ||
438 | m_style_changed = m_font_changed = m_color_changed = m_deco_changed = false; | 438 | m_style_changed = m_font_changed = m_color_changed = m_deco_changed = false; |
439 | } | 439 | } |
440 | 440 | ||
441 | Appearance::~Appearance() | 441 | Appearance::~Appearance() |
442 | { | 442 | { |
@@ -521,31 +521,31 @@ void Appearance::accept ( ) | |||
521 | 521 | ||
522 | void Appearance::done ( int r ) | 522 | void Appearance::done ( int r ) |
523 | { | 523 | { |
524 | QDialog::done ( r ); | 524 | QDialog::done ( r ); |
525 | close ( ); | 525 | close ( ); |
526 | } | 526 | } |
527 | 527 | ||
528 | 528 | ||
529 | void Appearance::styleClicked ( int index ) | 529 | void Appearance::styleClicked ( int index ) |
530 | { | 530 | { |
531 | StyleListItem *sli = (StyleListItem *) m_style_list-> item ( index ); | 531 | StyleListItem *sli = (StyleListItem *) m_style_list-> item ( index ); |
532 | m_style_settings-> setEnabled ( sli ? sli-> hasSettings ( ) : false ); | 532 | m_style_settings-> setEnabled ( sli ? sli-> hasSettings ( ) : false ); |
533 | 533 | ||
534 | if ( m_sample && sli && sli-> style ( )) { | 534 | if ( m_sample && sli && sli-> style ( )) { |
535 | int ci = m_color_list ? m_color_list-> currentItem ( ) : -1; | 535 | int ci = m_color_list ? m_color_list-> currentItem ( ) : -1; |
536 | 536 | ||
537 | m_sample-> setStyle2 ( sli-> style ( ), ci < 0 ? palette ( ) : ((ColorListItem *) m_color_list-> item ( ci ))-> palette ( )); | 537 | m_sample-> setStyle2 ( sli-> style ( ), ci < 0 ? palette ( ) : ((ColorListItem *) m_color_list-> item ( ci ))-> palette ( )); |
538 | } | 538 | } |
539 | 539 | ||
540 | m_style_changed |= ( index != m_original_style ); | 540 | m_style_changed |= ( index != m_original_style ); |
541 | } | 541 | } |
542 | 542 | ||
543 | void Appearance::styleSettingsClicked ( ) | 543 | void Appearance::styleSettingsClicked ( ) |
544 | { | 544 | { |
545 | StyleListItem *item = (StyleListItem *) m_style_list-> item ( m_style_list-> currentItem ( )); | 545 | StyleListItem *item = (StyleListItem *) m_style_list-> item ( m_style_list-> currentItem ( )); |
546 | 546 | ||
547 | if ( item && item-> hasSettings ( )) { | 547 | if ( item && item-> hasSettings ( )) { |
548 | QDialog *d = new QDialog ( this, "SETTINGS-DLG", true ); | 548 | QDialog *d = new QDialog ( this, "SETTINGS-DLG", true ); |
549 | QVBoxLayout *vbox = new QVBoxLayout ( d, 3, 0 ); | 549 | QVBoxLayout *vbox = new QVBoxLayout ( d, 3, 0 ); |
550 | 550 | ||
551 | QWidget *w = item-> settings ( d ); | 551 | QWidget *w = item-> settings ( d ); |
@@ -559,87 +559,87 @@ void Appearance::styleSettingsClicked ( ) | |||
559 | bool accepted = ( d-> exec ( ) == QDialog::Accepted ); | 559 | bool accepted = ( d-> exec ( ) == QDialog::Accepted ); |
560 | 560 | ||
561 | if ( item-> setSettings ( accepted )) | 561 | if ( item-> setSettings ( accepted )) |
562 | m_style_changed = true; | 562 | m_style_changed = true; |
563 | } | 563 | } |
564 | delete d; | 564 | delete d; |
565 | } | 565 | } |
566 | } | 566 | } |
567 | 567 | ||
568 | void Appearance::decoClicked ( int index ) | 568 | void Appearance::decoClicked ( int index ) |
569 | { | 569 | { |
570 | DecoListItem *dli = (DecoListItem *) m_deco_list-> item ( index ); | 570 | DecoListItem *dli = (DecoListItem *) m_deco_list-> item ( index ); |
571 | 571 | ||
572 | if ( m_sample ) { | 572 | if ( m_sample ) { |
573 | if ( dli && dli-> interface ( )) | 573 | if ( dli && dli-> interface ( )) |
574 | m_sample-> setDecoration ( dli-> interface ( )); | 574 | m_sample-> setDecoration ( dli-> interface ( )); |
575 | else | 575 | else |
576 | m_sample-> setDecoration ( new DefaultWindowDecoration ( )); | 576 | m_sample-> setDecoration ( new DefaultWindowDecoration ( )); |
577 | m_sample-> repaint ( ); | 577 | m_sample-> repaint ( ); |
578 | } | 578 | } |
579 | m_deco_changed |= ( index != m_original_deco ); | 579 | m_deco_changed |= ( index != m_original_deco ); |
580 | } | 580 | } |
581 | 581 | ||
582 | void Appearance::fontClicked ( const QFont &f ) | 582 | void Appearance::fontClicked ( const QFont &f ) |
583 | { | 583 | { |
584 | m_font_changed |= ( f != m_sample-> font ( )); | 584 | m_font_changed |= ( f != m_sample-> font ( )); |
585 | m_sample-> setFont ( f ); | 585 | m_sample-> setFont ( f ); |
586 | } | 586 | } |
587 | 587 | ||
588 | void Appearance::colorClicked ( int index ) | 588 | void Appearance::colorClicked ( int index ) |
589 | { | 589 | { |
590 | ColorListItem *item = (ColorListItem *) m_color_list-> item ( index ); | 590 | ColorListItem *item = (ColorListItem *) m_color_list-> item ( index ); |
591 | 591 | ||
592 | if ( item ) | 592 | if ( item ) |
593 | m_sample-> setPalette ( item-> palette ( )); | 593 | m_sample-> setPalette ( item-> palette ( )); |
594 | 594 | ||
595 | m_color_changed |= ( item-> palette ( ) != qApp-> palette ( )); | 595 | m_color_changed |= ( item-> palette ( ) != qApp-> palette ( )); |
596 | } | 596 | } |
597 | 597 | ||
598 | 598 | ||
599 | void Appearance::editSchemeClicked ( ) | 599 | void Appearance::editSchemeClicked ( ) |
600 | { | 600 | { |
601 | ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); | 601 | ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); |
602 | 602 | ||
603 | int cnt = 0; | 603 | int cnt = 0; |
604 | QString labels [QColorGroup::NColorRoles]; | 604 | QString labels [QColorGroup::NColorRoles]; |
605 | QColor colors [QColorGroup::NColorRoles]; | 605 | QColor colors [QColorGroup::NColorRoles]; |
606 | 606 | ||
607 | for ( QColorGroup::ColorRole role = (QColorGroup::ColorRole) 0; role != QColorGroup::NColorRoles; ((int) role )++ ) { | 607 | for ( QColorGroup::ColorRole role = (QColorGroup::ColorRole) 0; role != QColorGroup::NColorRoles; ((int) role )++ ) { |
608 | QColor col = item-> color ( role ); | 608 | QColor col = item-> color ( role ); |
609 | 609 | ||
610 | if ( col. isValid ( )) { | 610 | if ( col. isValid ( )) { |
611 | labels [cnt] = item-> label ( role ); | 611 | labels [cnt] = item-> label ( role ); |
612 | colors [cnt] = col; | 612 | colors [cnt] = col; |
613 | 613 | ||
614 | cnt++; | 614 | cnt++; |
615 | } | 615 | } |
616 | } | 616 | } |
617 | 617 | ||
618 | EditScheme* editdlg = new EditScheme( cnt, labels, colors, this, "editScheme", true ); | 618 | EditScheme* editdlg = new EditScheme( cnt, labels, colors, this, "editScheme", true ); |
619 | editdlg-> showMaximized ( ); | 619 | editdlg-> showMaximized ( ); |
620 | if ( editdlg-> exec ( ) == QDialog::Accepted ) { | 620 | if ( editdlg-> exec ( ) == QDialog::Accepted ) { |
621 | ColorListItem *citem = (ColorListItem *) m_color_list-> item ( 0 ); | 621 | ColorListItem *citem = (ColorListItem *) m_color_list-> item ( 0 ); |
622 | cnt = 0; | 622 | cnt = 0; |
623 | 623 | ||
624 | for ( QColorGroup::ColorRole role = (QColorGroup::ColorRole) 0; role != QColorGroup::NColorRoles; ((int) role )++ ) { | 624 | for ( QColorGroup::ColorRole role = (QColorGroup::ColorRole) 0; role != QColorGroup::NColorRoles; ((int) role )++ ) { |
625 | if ( item-> color ( role ). isValid ( )) { | 625 | if ( item-> color ( role ). isValid ( )) { |
626 | citem-> setColor ( role, colors [cnt] ); | 626 | citem-> setColor ( role, colors [cnt] ); |
627 | cnt++; | 627 | cnt++; |
628 | } | 628 | } |
629 | } | 629 | } |
630 | 630 | ||
631 | m_color_list-> setCurrentItem ( 0 ); | 631 | m_color_list-> setCurrentItem ( 0 ); |
632 | colorClicked ( 0 ); | 632 | colorClicked ( 0 ); |
633 | 633 | ||
634 | m_color_changed = true; | 634 | m_color_changed = true; |
635 | } | 635 | } |
636 | delete editdlg; | 636 | delete editdlg; |
637 | } | 637 | } |
638 | 638 | ||
639 | 639 | ||
640 | void Appearance::saveSchemeClicked() | 640 | void Appearance::saveSchemeClicked() |
641 | { | 641 | { |
642 | ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); | 642 | ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); |
643 | 643 | ||
644 | if ( !item ) | 644 | if ( !item ) |
645 | return; | 645 | return; |
@@ -649,34 +649,34 @@ void Appearance::saveSchemeClicked() | |||
649 | QLineEdit *ed = new QLineEdit ( d ); | 649 | QLineEdit *ed = new QLineEdit ( d ); |
650 | ( new QVBoxLayout ( d, 3, 3 ))-> addWidget ( ed ); | 650 | ( new QVBoxLayout ( d, 3, 3 ))-> addWidget ( ed ); |
651 | ed-> setFocus ( ); | 651 | ed-> setFocus ( ); |
652 | 652 | ||
653 | if ( d-> exec ( ) == QDialog::Accepted ) { | 653 | if ( d-> exec ( ) == QDialog::Accepted ) { |
654 | QString schemename = ed-> text ( ); | 654 | QString schemename = ed-> text ( ); |
655 | QString filestr = QPEApplication::qpeDir(); | 655 | QString filestr = QPEApplication::qpeDir(); |
656 | filestr.append( "/etc/colors/" ); | 656 | filestr.append( "/etc/colors/" ); |
657 | filestr.append( schemename ); | 657 | filestr.append( schemename ); |
658 | filestr.append( ".scheme" ); | 658 | filestr.append( ".scheme" ); |
659 | QFile file ( filestr ); | 659 | QFile file ( filestr ); |
660 | if ( !file. exists ( )) | 660 | if ( !file. exists ( )) |
661 | { | 661 | { |
662 | QPalette p = item-> palette ( ); | 662 | QPalette p = item-> palette ( ); |
663 | 663 | ||
664 | Config config ( file.name(), Config::File ); | 664 | Config config ( file.name(), Config::File ); |
665 | config. setGroup( "Colors" ); | 665 | config. setGroup( "Colors" ); |
666 | 666 | ||
667 | item-> save ( config ); | 667 | item-> save ( config ); |
668 | 668 | ||
669 | config. write ( ); // need to flush the config info first | 669 | config. write ( ); // need to flush the config info first |
670 | 670 | ||
671 | m_color_list-> insertItem ( new ColorListItem ( schemename, config )); | 671 | m_color_list-> insertItem ( new ColorListItem ( schemename, config )); |
672 | } | 672 | } |
673 | else | 673 | else |
674 | { | 674 | { |
675 | QMessageBox::information ( this, tr( "Save scheme" ), tr( "Scheme does already exist." )); | 675 | QMessageBox::information ( this, tr( "Save scheme" ), tr( "Scheme does already exist." )); |
676 | } | 676 | } |
677 | } | 677 | } |
678 | delete d; | 678 | delete d; |
679 | } | 679 | } |
680 | 680 | ||
681 | void Appearance::deleteSchemeClicked() | 681 | void Appearance::deleteSchemeClicked() |
682 | { | 682 | { |
@@ -713,84 +713,84 @@ void Appearance::addExcept ( ) | |||
713 | 713 | ||
714 | void Appearance::delExcept ( ) | 714 | void Appearance::delExcept ( ) |
715 | { | 715 | { |
716 | if ( m_except-> selectedItem ( )) { | 716 | if ( m_except-> selectedItem ( )) { |
717 | m_except-> setFocus ( ); | 717 | m_except-> setFocus ( ); |
718 | delete m_except-> selectedItem ( ); | 718 | delete m_except-> selectedItem ( ); |
719 | } | 719 | } |
720 | } | 720 | } |
721 | 721 | ||
722 | void Appearance::upExcept ( ) | 722 | void Appearance::upExcept ( ) |
723 | { | 723 | { |
724 | ExceptListItem *it = (ExceptListItem *) m_except-> selectedItem ( ); | 724 | ExceptListItem *it = (ExceptListItem *) m_except-> selectedItem ( ); |
725 | 725 | ||
726 | if ( it && it-> itemAbove ( )) | 726 | if ( it && it-> itemAbove ( )) |
727 | it-> itemAbove ( )-> moveItem ( it ); | 727 | it-> itemAbove ( )-> moveItem ( it ); |
728 | } | 728 | } |
729 | 729 | ||
730 | void Appearance::downExcept ( ) | 730 | void Appearance::downExcept ( ) |
731 | { | 731 | { |
732 | ExceptListItem *it = (ExceptListItem *) m_except-> selectedItem ( ); | 732 | ExceptListItem *it = (ExceptListItem *) m_except-> selectedItem ( ); |
733 | 733 | ||
734 | if ( it && it-> itemBelow ( )) | 734 | if ( it && it-> itemBelow ( )) |
735 | it-> moveItem ( it-> itemBelow ( )); | 735 | it-> moveItem ( it-> itemBelow ( )); |
736 | } | 736 | } |
737 | 737 | ||
738 | class ExEdit : public QLineEdit { | 738 | class ExEdit : public QLineEdit { |
739 | public: | 739 | public: |
740 | ExEdit ( ExceptListItem *item ) | 740 | ExEdit ( ExceptListItem *item ) |
741 | : QLineEdit ( item-> listView ( )-> viewport ( ), "exedit" ), it ( item ) | 741 | : QLineEdit ( item-> listView ( )-> viewport ( ), "exedit" ), it ( item ) |
742 | { | 742 | { |
743 | setFrame ( false ); | 743 | setFrame ( false ); |
744 | 744 | ||
745 | QRect r = it-> listView ( )-> itemRect ( it ); | 745 | QRect r = it-> listView ( )-> itemRect ( it ); |
746 | 746 | ||
747 | int x = it-> listView ( )-> header ( )-> cellPos ( 3 ) - 1; | 747 | int x = it-> listView ( )-> header ( )-> cellPos ( 3 ) - 1; |
748 | int y = r. y ( ); | 748 | int y = r. y ( ); |
749 | int w = it-> listView ( )-> viewport ( )-> width ( ) - x; | 749 | int w = it-> listView ( )-> viewport ( )-> width ( ) - x; |
750 | int h = r. height ( ); // + 2; | 750 | int h = r. height ( ); // + 2; |
751 | 751 | ||
752 | setText ( it-> pattern ( )); | 752 | setText ( it-> pattern ( )); |
753 | setGeometry ( x, y, w, h ); | 753 | setGeometry ( x, y, w, h ); |
754 | 754 | ||
755 | qDebug ( "ExEdit: [%s] at %d,%d %d,%d", it->text(2).latin1(),x,y,w,h); | 755 | qDebug ( "ExEdit: [%s] at %d,%d %d,%d", it->text(2).latin1(),x,y,w,h); |
756 | 756 | ||
757 | m_out = true; | 757 | m_out = true; |
758 | 758 | ||
759 | show ( ); | 759 | show ( ); |
760 | setFocus ( ); | 760 | setFocus ( ); |
761 | selectAll ( ); | 761 | selectAll ( ); |
762 | end ( true ); | 762 | end ( true ); |
763 | } | 763 | } |
764 | 764 | ||
765 | virtual void focusOutEvent ( QFocusEvent * ) | 765 | virtual void focusOutEvent ( QFocusEvent * ) |
766 | { | 766 | { |
767 | hide ( ); | 767 | hide ( ); |
768 | if ( m_out ) | 768 | if ( m_out ) |
769 | it-> setPattern ( text ( )); | 769 | it-> setPattern ( text ( )); |
770 | delete this; | 770 | delete this; |
771 | } | 771 | } |
772 | 772 | ||
773 | virtual void keyPressEvent ( QKeyEvent *e ) | 773 | virtual void keyPressEvent ( QKeyEvent *e ) |
774 | { | 774 | { |
775 | if ( e-> key ( ) == Key_Return ) | 775 | if ( e-> key ( ) == Key_Return ) |
776 | it-> listView ( )-> setFocus ( ); | 776 | it-> listView ( )-> setFocus ( ); |
777 | else if ( e-> key ( ) == Key_Escape ) { | 777 | else if ( e-> key ( ) == Key_Escape ) { |
778 | m_out = false; | 778 | m_out = false; |
779 | it-> listView ( )-> setFocus ( ); | 779 | it-> listView ( )-> setFocus ( ); |
780 | } | 780 | } |
781 | else | 781 | else |
782 | QLineEdit::keyPressEvent ( e ); | 782 | QLineEdit::keyPressEvent ( e ); |
783 | } | 783 | } |
784 | 784 | ||
785 | private: | 785 | private: |
786 | ExceptListItem *it; | 786 | ExceptListItem *it; |
787 | bool m_out; | 787 | bool m_out; |
788 | }; | 788 | }; |
789 | 789 | ||
790 | void Appearance::clickedExcept ( QListViewItem *item, const QPoint &, int c ) | 790 | void Appearance::clickedExcept ( QListViewItem *item, const QPoint &, int c ) |
791 | { | 791 | { |
792 | if ( !item || c < 0 || c > 3 ) | 792 | if ( !item || c < 0 || c > 3 ) |
793 | return; | 793 | return; |
794 | 794 | ||
795 | ExceptListItem *it = (ExceptListItem *) item; | 795 | ExceptListItem *it = (ExceptListItem *) item; |
796 | 796 | ||