-rw-r--r-- | noncore/settings/appearance2/appearance.cpp | 105 | ||||
-rw-r--r-- | noncore/settings/appearance2/colorlistitem.h | 95 | ||||
-rw-r--r-- | noncore/settings/appearance2/editScheme.cpp | 10 | ||||
-rw-r--r-- | noncore/settings/appearance2/editScheme.h | 8 | ||||
-rw-r--r-- | noncore/settings/appearance2/sample.cpp | 11 |
5 files changed, 152 insertions, 77 deletions
diff --git a/noncore/settings/appearance2/appearance.cpp b/noncore/settings/appearance2/appearance.cpp index 52c7125..cf3069e 100644 --- a/noncore/settings/appearance2/appearance.cpp +++ b/noncore/settings/appearance2/appearance.cpp | |||
@@ -102,40 +102,24 @@ public: | |||
102 | 102 | ||
103 | if ( *iface ) | 103 | if ( *iface ) |
104 | (*iface)->addRef(); | 104 | (*iface)->addRef(); |
105 | return QS_OK; | 105 | return QS_OK; |
106 | } | 106 | } |
107 | Q_REFCOUNT | 107 | Q_REFCOUNT |
108 | 108 | ||
109 | private: | 109 | private: |
110 | ulong ref; | 110 | ulong ref; |
111 | }; | 111 | }; |
112 | 112 | ||
113 | 113 | ||
114 | struct { | ||
115 | QColorGroup::ColorRole role; | ||
116 | const char *key; | ||
117 | const char *def; | ||
118 | } colorLUT [] = { | ||
119 | { QColorGroup::Base, "Base", "#FFFFFF" }, | ||
120 | { QColorGroup::Background, "Background", "#E5E1D5" }, | ||
121 | { QColorGroup::Button, "Button", "#D6CDBB" }, | ||
122 | { QColorGroup::ButtonText, "ButtonText", "#000000" }, | ||
123 | { QColorGroup::Highlight, "Highlight", "#800000" }, | ||
124 | { QColorGroup::HighlightedText, "HighlightedText", "#FFFFFF" }, | ||
125 | { QColorGroup::Text, "Text", "#000000" }, | ||
126 | |||
127 | { QColorGroup::NColorRoles, 0, 0 } | ||
128 | }; | ||
129 | |||
130 | 114 | ||
131 | void Appearance::loadStyles ( QListBox *list ) | 115 | void Appearance::loadStyles ( QListBox *list ) |
132 | { | 116 | { |
133 | #if QT_VERSION >= 300 | 117 | #if QT_VERSION >= 300 |
134 | list->insertStringList(QStyleFactory::styles()); | 118 | list->insertStringList(QStyleFactory::styles()); |
135 | #else | 119 | #else |
136 | list->insertItem( new StyleListItem ( "Windows", new QWindowsStyle ( ))); | 120 | list->insertItem( new StyleListItem ( "Windows", new QWindowsStyle ( ))); |
137 | list->insertItem( new StyleListItem ( "Light", new LightStyle ( ))); | 121 | list->insertItem( new StyleListItem ( "Light", new LightStyle ( ))); |
138 | #ifndef QT_NO_STYLE_MOTIF | 122 | #ifndef QT_NO_STYLE_MOTIF |
139 | list->insertItem( new StyleListItem ( "Motif", new QMotifStyle ( ))); | 123 | list->insertItem( new StyleListItem ( "Motif", new QMotifStyle ( ))); |
140 | #endif | 124 | #endif |
141 | #ifndef QT_NO_STYLE_MOTIFPLUS | 125 | #ifndef QT_NO_STYLE_MOTIFPLUS |
@@ -177,65 +161,43 @@ void Appearance::loadDecos ( QListBox *list ) | |||
177 | for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) { | 161 | for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) { |
178 | QLibrary *lib = new QLibrary ( path + "/" + *it ); | 162 | QLibrary *lib = new QLibrary ( path + "/" + *it ); |
179 | WindowDecorationInterface *iface; | 163 | WindowDecorationInterface *iface; |
180 | 164 | ||
181 | if ( lib-> queryInterface ( IID_WindowDecoration, (QUnknownInterface **) &iface ) == QS_OK ) | 165 | if ( lib-> queryInterface ( IID_WindowDecoration, (QUnknownInterface **) &iface ) == QS_OK ) |
182 | list-> insertItem ( new DecoListItem ( lib, iface )); | 166 | list-> insertItem ( new DecoListItem ( lib, iface )); |
183 | else | 167 | else |
184 | delete lib; | 168 | delete lib; |
185 | } | 169 | } |
186 | } | 170 | } |
187 | } | 171 | } |
188 | 172 | ||
189 | static QPalette readColorPalette ( Config &config ) | ||
190 | { | ||
191 | QColor bgcolor( config. readEntry( "Background", "#E5E1D5" ) ); | ||
192 | QColor btncolor( config. readEntry( "Button", "#D6CDBB" ) ); | ||
193 | QPalette pal( btncolor, bgcolor ); | ||
194 | |||
195 | QString color = config. readEntry( "Highlight", "#800000" ); | ||
196 | pal.setColor( QColorGroup::Highlight, QColor(color) ); | ||
197 | color = config. readEntry( "HighlightedText", "#FFFFFF" ); | ||
198 | pal.setColor( QColorGroup::HighlightedText, QColor(color) ); | ||
199 | color = config. readEntry( "Text", "#000000" ); | ||
200 | pal.setColor( QColorGroup::Text, QColor(color) ); | ||
201 | color = config. readEntry( "ButtonText", "#000000" ); | ||
202 | pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor(color) ); | ||
203 | color = config. readEntry( "Base", "#FFFFFF" ); | ||
204 | pal.setColor( QColorGroup::Base, QColor(color) ); | ||
205 | |||
206 | pal.setColor( QPalette::Disabled, QColorGroup::Text, pal.color(QPalette::Active, QColorGroup::Background).dark() ); | ||
207 | |||
208 | return pal; | ||
209 | } | ||
210 | |||
211 | void Appearance::loadColors ( QListBox *list ) | 173 | void Appearance::loadColors ( QListBox *list ) |
212 | { | 174 | { |
213 | list-> clear ( ); | 175 | list-> clear ( ); |
214 | { | 176 | { |
215 | Config config ( "qpe" ); | 177 | Config config ( "qpe" ); |
216 | config. setGroup ( "Appearance" ); | 178 | config. setGroup ( "Appearance" ); |
217 | 179 | ||
218 | list-> insertItem ( new ColorListItem ( tr( "Current scheme" ), readColorPalette ( config ))); | 180 | list-> insertItem ( new ColorListItem ( tr( "Current scheme" ), config )); |
219 | } | 181 | } |
220 | 182 | ||
221 | QString path = QPEApplication::qpeDir ( ) + "/etc/colors/"; | 183 | QString path = QPEApplication::qpeDir ( ) + "/etc/colors/"; |
222 | QStringList sl = QDir ( path ). entryList ( "*.scheme" ); | 184 | QStringList sl = QDir ( path ). entryList ( "*.scheme" ); |
223 | 185 | ||
224 | for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) { | 186 | for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) { |
225 | QString name = (*it). left ((*it). find ( ".scheme" )); | 187 | QString name = (*it). left ((*it). find ( ".scheme" )); |
226 | Config config ( path + *it, Config::File ); | 188 | Config config ( path + *it, Config::File ); |
227 | config. setGroup ( "Colors" ); | 189 | config. setGroup ( "Colors" ); |
228 | 190 | ||
229 | list-> insertItem ( new ColorListItem ( name, readColorPalette ( config ))); | 191 | list-> insertItem ( new ColorListItem ( name, config )); |
230 | } | 192 | } |
231 | } | 193 | } |
232 | 194 | ||
233 | void Appearance::loadFonts ( QListBox *list ) | 195 | void Appearance::loadFonts ( QListBox *list ) |
234 | { | 196 | { |
235 | FontDatabase fd; | 197 | FontDatabase fd; |
236 | QStringList f = fd. families ( ); | 198 | QStringList f = fd. families ( ); |
237 | 199 | ||
238 | for ( QStringList::ConstIterator it = f. begin ( ); it != f. end ( ); ++it ) | 200 | for ( QStringList::ConstIterator it = f. begin ( ); it != f. end ( ); ++it ) |
239 | list-> insertItem ( new FontListItem ( *it, fd. styles ( *it ), fd. pointSizes ( *it ))); | 201 | list-> insertItem ( new FontListItem ( *it, fd. styles ( *it ), fd. pointSizes ( *it ))); |
240 | } | 202 | } |
241 | 203 | ||
@@ -475,34 +437,33 @@ void Appearance::accept ( ) | |||
475 | config.writeEntry( "Style", item-> key ( )); | 437 | config.writeEntry( "Style", item-> key ( )); |
476 | } | 438 | } |
477 | if ( newtabstyle != m_original_tabstyle ) { | 439 | if ( newtabstyle != m_original_tabstyle ) { |
478 | config. writeEntry ( "TabStyle", newtabstyle ); | 440 | config. writeEntry ( "TabStyle", newtabstyle ); |
479 | } | 441 | } |
480 | 442 | ||
481 | if ( m_font_changed ) { | 443 | if ( m_font_changed ) { |
482 | config.writeEntry( "FontFamily", m_font_family_list-> text ( newfontfamily )); | 444 | config.writeEntry( "FontFamily", m_font_family_list-> text ( newfontfamily )); |
483 | config.writeEntry( "FontStyle", m_font_style_list-> text ( newfontstyle )); | 445 | config.writeEntry( "FontStyle", m_font_style_list-> text ( newfontstyle )); |
484 | config.writeEntry( "FontSize", m_font_size_list-> text ( newfontsize )); | 446 | config.writeEntry( "FontSize", m_font_size_list-> text ( newfontsize )); |
485 | } | 447 | } |
486 | 448 | ||
487 | /* | 449 | |
488 | if ( schemeChanged ) | 450 | if ( m_color_changed ) |
489 | { | 451 | { |
490 | int i; | 452 | ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); |
491 | for ( i = 0; i < MAX_CONTROL; i++ ) | 453 | |
492 | { | 454 | if ( item ) |
493 | config.writeEntry( controlList[i], controlColor[i] ); | 455 | item-> save ( config ); |
494 | } | ||
495 | } | 456 | } |
496 | */ | 457 | |
497 | config. write ( ); // need to flush the config info first | 458 | config. write ( ); // need to flush the config info first |
498 | Global::applyStyle ( ); | 459 | Global::applyStyle ( ); |
499 | 460 | ||
500 | if ( QMessageBox::warning ( this, tr( "Restart" ), tr( "Do you want to restart Opie now?" ), tr( "Yes" ), tr( "No" ), 0, 0, 1 ) == 0 ) { | 461 | if ( QMessageBox::warning ( this, tr( "Restart" ), tr( "Do you want to restart Opie now?" ), tr( "Yes" ), tr( "No" ), 0, 0, 1 ) == 0 ) { |
501 | QCopEnvelope e( "QPE/System", "restart()" ); | 462 | QCopEnvelope e( "QPE/System", "restart()" ); |
502 | } | 463 | } |
503 | 464 | ||
504 | QDialog::accept ( ); | 465 | QDialog::accept ( ); |
505 | } | 466 | } |
506 | 467 | ||
507 | void Appearance::done ( int r ) | 468 | void Appearance::done ( int r ) |
508 | { | 469 | { |
@@ -643,67 +604,85 @@ void Appearance::colorClicked ( int index ) | |||
643 | 604 | ||
644 | if ( item ) | 605 | if ( item ) |
645 | m_sample-> setPalette ( item-> palette ( )); | 606 | m_sample-> setPalette ( item-> palette ( )); |
646 | 607 | ||
647 | m_color_changed |= ( item-> palette ( ) != qApp-> palette ( )); | 608 | m_color_changed |= ( item-> palette ( ) != qApp-> palette ( )); |
648 | } | 609 | } |
649 | 610 | ||
650 | 611 | ||
651 | void Appearance::editSchemeClicked ( ) | 612 | void Appearance::editSchemeClicked ( ) |
652 | { | 613 | { |
653 | ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); | 614 | ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); |
654 | 615 | ||
655 | /* | 616 | int cnt = 0; |
656 | EditScheme* editdlg = new EditScheme( this, "editScheme", TRUE, 0, | 617 | QString controlLabel [QColorGroup::NColorRoles]; |
657 | 9, controlLabel, controlColor ); | 618 | QString controlColor [QColorGroup::NColorRoles]; |
658 | editdlg->showMaximized(); | 619 | |
659 | if ( editdlg->exec() == QDialog::Accepted ) | 620 | for ( QColorGroup::ColorRole role = (QColorGroup::ColorRole) 0; role != QColorGroup::NColorRoles; ((int) role )++ ) { |
660 | { | 621 | QColor col = item-> color ( role ); |
661 | int i; | 622 | |
662 | for ( i = 0; i < MAX_CONTROL; i++ ) | 623 | if ( col. isValid ( )) { |
663 | { | 624 | controlLabel [cnt] = item-> label ( role ); |
664 | controlColor[i] = editdlg->colorList[i]; | 625 | controlColor [cnt] = col. name ( ); |
626 | |||
627 | cnt++; | ||
628 | } | ||
629 | } | ||
630 | |||
631 | EditScheme* editdlg = new EditScheme( this, "editScheme", true, 0, cnt, controlLabel, controlColor ); | ||
632 | editdlg-> showMaximized ( ); | ||
633 | if ( editdlg-> exec ( ) == QDialog::Accepted ) { | ||
634 | ColorListItem *citem = (ColorListItem *) m_color_list-> item ( 0 ); | ||
635 | cnt = 0; | ||
636 | |||
637 | for ( QColorGroup::ColorRole role = (QColorGroup::ColorRole) 0; role != QColorGroup::NColorRoles; ((int) role )++ ) { | ||
638 | if ( item-> color ( role ). isValid ( )) { | ||
639 | citem-> setColor ( role, QColor ( controlColor [cnt] )); | ||
640 | cnt++; | ||
641 | } | ||
665 | } | 642 | } |
643 | |||
644 | m_color_list-> setCurrentItem ( 0 ); | ||
645 | colorClicked ( 0 ); | ||
646 | |||
666 | m_color_changed = true; | 647 | m_color_changed = true; |
667 | } | 648 | } |
668 | delete editdlg; | 649 | delete editdlg; |
669 | */ | ||
670 | } | 650 | } |
671 | 651 | ||
672 | 652 | ||
673 | void Appearance::saveSchemeClicked() | 653 | void Appearance::saveSchemeClicked() |
674 | { | 654 | { |
675 | ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); | 655 | ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); |
676 | 656 | ||
677 | if ( !item ) | 657 | if ( !item ) |
678 | return; | 658 | return; |
679 | 659 | ||
680 | QDialog *d = new QDialog ( this, 0, true ); | 660 | QDialog *d = new QDialog ( this, 0, true ); |
681 | d-> setCaption ( tr( "Save Scheme" )); | 661 | d-> setCaption ( tr( "Save Scheme" )); |
682 | QLineEdit *ed = new QLineEdit ( this ); | 662 | QLineEdit *ed = new QLineEdit ( this ); |
683 | ( new QVBoxLayout ( d, 4, 4 ))-> addWidget ( ed ); | 663 | ( new QVBoxLayout ( d, 4, 4 ))-> addWidget ( ed ); |
684 | 664 | ||
685 | if ( d-> exec ( ) == QDialog::Accepted ) { | 665 | if ( d-> exec ( ) == QDialog::Accepted ) { |
686 | QString schemename = ed-> text ( ); | 666 | QString schemename = ed-> text ( ); |
687 | QFile file ( QPEApplication::qpeDir() + "/etc/colors/" + schemename + ".scheme" ); | 667 | QFile file ( QPEApplication::qpeDir() + "/etc/colors/" + schemename + ".scheme" ); |
688 | if ( !file. exists ( )) | 668 | if ( !file. exists ( )) |
689 | { | 669 | { |
690 | QPalette p = item-> palette ( ); | 670 | QPalette p = item-> palette ( ); |
691 | 671 | ||
692 | Config config ( file.name(), Config::File ); | 672 | Config config ( file.name(), Config::File ); |
693 | config.setGroup( "Colors" ); | 673 | config. setGroup( "Colors" ); |
694 | 674 | ||
695 | for ( int i = 0; colorLUT [i]. role != QColorGroup::NColorRoles; i++ ) | 675 | item-> save ( config ); |
696 | config.writeEntry ( colorLUT [i]. key, p. color ( QPalette::Active, colorLUT [i]. role ). name ( )); | 676 | |
697 | |||
698 | config. write ( ); // need to flush the config info first | 677 | config. write ( ); // need to flush the config info first |
699 | loadColors ( m_color_list ); | 678 | loadColors ( m_color_list ); |
700 | } | 679 | } |
701 | else | 680 | else |
702 | { | 681 | { |
703 | QMessageBox::information ( this, tr( "Save scheme" ), tr( "Scheme does already exist." )); | 682 | QMessageBox::information ( this, tr( "Save scheme" ), tr( "Scheme does already exist." )); |
704 | } | 683 | } |
705 | } | 684 | } |
706 | delete d; | 685 | delete d; |
707 | } | 686 | } |
708 | 687 | ||
709 | void Appearance::deleteSchemeClicked() | 688 | void Appearance::deleteSchemeClicked() |
diff --git a/noncore/settings/appearance2/colorlistitem.h b/noncore/settings/appearance2/colorlistitem.h index c7318a6..1ff6ecc 100644 --- a/noncore/settings/appearance2/colorlistitem.h +++ b/noncore/settings/appearance2/colorlistitem.h | |||
@@ -1,28 +1,113 @@ | |||
1 | #ifndef COLORLISTITEM_H | 1 | #ifndef COLORLISTITEM_H |
2 | #define COLORLISTITEM_H | 2 | #define COLORLISTITEM_H |
3 | 3 | ||
4 | #include <qlistbox.h> | 4 | #include <qlistbox.h> |
5 | #include <qpalette.h> | 5 | #include <qpalette.h> |
6 | #include <qapplication.h> | ||
7 | |||
8 | #include <qpe/config.h> | ||
9 | |||
10 | class Appearance; | ||
6 | 11 | ||
7 | class ColorListItem : public QListBoxText { | 12 | class ColorListItem : public QListBoxText { |
8 | public: | 13 | public: |
9 | ColorListItem ( const QString &t, const QPalette &pal ) : QListBoxText ( t ) | 14 | ColorListItem ( const QString &t, Config &cfg ) : QListBoxText ( t ) |
10 | { | 15 | { |
11 | m_pal = pal; | 16 | m_colors = new QColor [s_colorcount]; |
17 | load ( cfg ); | ||
12 | } | 18 | } |
13 | 19 | ||
14 | virtual ~ColorListItem ( ) | 20 | virtual ~ColorListItem ( ) |
15 | { | 21 | { |
22 | delete [] m_colors; | ||
16 | } | 23 | } |
17 | 24 | ||
18 | QPalette palette ( ) | 25 | QPalette palette ( ) |
19 | { | 26 | { |
20 | return m_pal; | 27 | return m_palette; |
28 | } | ||
29 | |||
30 | bool load ( Config &cfg ) | ||
31 | { | ||
32 | for ( int i = 0; i < s_colorcount; i++ ) | ||
33 | m_colors [i] = QColor ( cfg. readEntry ( s_colorlut [i]. m_key, s_colorlut [i]. m_def )); | ||
34 | |||
35 | buildPalette ( ); | ||
36 | return true; | ||
37 | } | ||
38 | |||
39 | void buildPalette ( ) | ||
40 | { | ||
41 | m_palette = QPalette ( m_colors [r2i(QColorGroup::Button)], m_colors [r2i(QColorGroup::Background)] ); | ||
42 | m_palette. setColor ( QColorGroup::Highlight, m_colors [r2i(QColorGroup::Highlight)] ); | ||
43 | m_palette. setColor ( QColorGroup::HighlightedText, m_colors [r2i(QColorGroup::HighlightedText)] ); | ||
44 | m_palette. setColor ( QColorGroup::Text, m_colors [r2i(QColorGroup::Text)] ); | ||
45 | m_palette. setColor ( QPalette::Active, QColorGroup::ButtonText, m_colors [r2i(QColorGroup::ButtonText)] ); | ||
46 | m_palette. setColor ( QColorGroup::Base, m_colors [r2i(QColorGroup::Base)] ); | ||
47 | m_palette. setColor ( QPalette::Disabled, QColorGroup::Text, m_palette. color ( QPalette::Active, QColorGroup::Background ). dark ( )); | ||
21 | } | 48 | } |
22 | 49 | ||
50 | bool save ( Config &cfg ) | ||
51 | { | ||
52 | for ( int i = 0; i < s_colorcount; i++ ) | ||
53 | cfg. writeEntry ( s_colorlut [i]. m_key, m_colors [i]. name ( )); | ||
54 | return true; | ||
55 | } | ||
56 | |||
57 | QColor color ( QColorGroup::ColorRole role ) | ||
58 | { | ||
59 | int i = r2i ( role ); | ||
60 | return i >= 0 ? m_colors [i] : QColor ( ); | ||
61 | } | ||
62 | |||
63 | void setColor ( QColorGroup::ColorRole role, QColor c ) | ||
64 | { | ||
65 | int i = r2i ( role ); | ||
66 | if ( i >= 0 ) { | ||
67 | m_colors [i] = c; | ||
68 | buildPalette ( ); | ||
69 | } | ||
70 | } | ||
71 | |||
72 | QString label ( QColorGroup::ColorRole role ) | ||
73 | { | ||
74 | int i = r2i ( role ); | ||
75 | return i >= 0 ? qApp-> translate ( "Appearance", s_colorlut [i]. m_label ) : QString::null; | ||
76 | } | ||
77 | |||
23 | private: | 78 | private: |
24 | QPalette m_pal; | 79 | QPalette m_palette; |
80 | QColor *m_colors; | ||
81 | |||
82 | static struct colorlut { | ||
83 | QColorGroup::ColorRole m_role; | ||
84 | const char * m_key; | ||
85 | const char * m_def; | ||
86 | const char * m_label; | ||
87 | } const s_colorlut []; | ||
88 | static const int s_colorcount; | ||
89 | |||
90 | static int r2i ( QColorGroup::ColorRole role ) | ||
91 | { | ||
92 | for ( int i = 0; i < s_colorcount; i++ ) { | ||
93 | if ( s_colorlut [i]. m_role == role ) | ||
94 | return i; | ||
95 | } | ||
96 | return -1; | ||
97 | } | ||
25 | }; | 98 | }; |
26 | 99 | ||
100 | const ColorListItem::colorlut ColorListItem::s_colorlut [] = { | ||
101 | { QColorGroup::Base, "Base", "#FFFFFF", QT_TRANSLATE_NOOP( "Appearance", "Base" ) }, | ||
102 | { QColorGroup::Background, "Background", "#E5E1D5", QT_TRANSLATE_NOOP( "Appearance", "Background" ) }, | ||
103 | { QColorGroup::Button, "Button", "#D6CDBB", QT_TRANSLATE_NOOP( "Appearance", "Button" ) }, | ||
104 | { QColorGroup::ButtonText, "ButtonText", "#000000", QT_TRANSLATE_NOOP( "Appearance", "Button Text" ) }, | ||
105 | { QColorGroup::Highlight, "Highlight", "#800000", QT_TRANSLATE_NOOP( "Appearance", "Highlight" ) }, | ||
106 | { QColorGroup::HighlightedText, "HighlightedText", "#FFFFFF", QT_TRANSLATE_NOOP( "Appearance", "Highlighted Text" ) }, | ||
107 | { QColorGroup::Text, "Text", "#000000", QT_TRANSLATE_NOOP( "Appearance", "Text" ) } | ||
108 | }; | ||
109 | |||
110 | const int ColorListItem::s_colorcount = sizeof( s_colorlut ) / sizeof ( s_colorlut [0] ); | ||
111 | |||
27 | 112 | ||
28 | #endif | 113 | #endif |
diff --git a/noncore/settings/appearance2/editScheme.cpp b/noncore/settings/appearance2/editScheme.cpp index 2453c7b..4f2ac2c 100644 --- a/noncore/settings/appearance2/editScheme.cpp +++ b/noncore/settings/appearance2/editScheme.cpp | |||
@@ -20,56 +20,60 @@ | |||
20 | #include "editScheme.h" | 20 | #include "editScheme.h" |
21 | 21 | ||
22 | #include "opie/colorpopupmenu.h" | 22 | #include "opie/colorpopupmenu.h" |
23 | 23 | ||
24 | #include <qaction.h> | 24 | #include <qaction.h> |
25 | #include <qlabel.h> | 25 | #include <qlabel.h> |
26 | #include <qlayout.h> | 26 | #include <qlayout.h> |
27 | #include <qpopupmenu.h> | 27 | #include <qpopupmenu.h> |
28 | #include <qscrollview.h> | 28 | #include <qscrollview.h> |
29 | #include <qtoolbutton.h> | 29 | #include <qtoolbutton.h> |
30 | 30 | ||
31 | EditScheme::EditScheme( QWidget* parent, const char* name, bool modal, WFlags fl, | 31 | EditScheme::EditScheme( QWidget* parent, const char* name, bool modal, WFlags fl, |
32 | int max, QString list[], QString colors[] ) | 32 | int max, QString *list, QString *colors ) |
33 | : QDialog( parent, name, modal, fl ) | 33 | : QDialog( parent, name, modal, fl ) |
34 | { | 34 | { |
35 | setCaption( tr( "Edit scheme" ) ); | 35 | setCaption( tr( "Edit scheme" ) ); |
36 | QGridLayout* layout = new QGridLayout( this ); | 36 | QGridLayout* layout = new QGridLayout( this ); |
37 | layout->setSpacing( 4 ); | 37 | layout->setSpacing( 4 ); |
38 | layout->setMargin( 4 ); | 38 | layout->setMargin( 4 ); |
39 | 39 | ||
40 | 40 | ||
41 | maxCount = max; | 41 | maxCount = max; |
42 | colorList = colors; | ||
43 | surfaceList = list; | ||
44 | colorButtons = new QToolButton * [max]; | ||
42 | int i; | 45 | int i; |
43 | QLabel* label; | 46 | QLabel* label; |
44 | ColorPopupMenu* colorPopupMenu; | 47 | ColorPopupMenu* colorPopupMenu; |
45 | for ( i = 0; i < max; i++ ) | 48 | for ( i = 0; i < max; i++ ) |
46 | { | 49 | { |
47 | colorList[i] = colors[i]; | 50 | // colorList[i] = colors[i]; |
48 | surfaceList[i] = list[i]; | 51 | // surfaceList[i] = list[i]; |
49 | label = new QLabel( tr( surfaceList[i] ), this ); | 52 | label = new QLabel( tr( surfaceList[i] ), this ); |
50 | layout->addWidget( label, i, 0 ); | 53 | layout->addWidget( label, i, 0 ); |
51 | colorButtons[i] = new QToolButton( this, list[i] ); | 54 | colorButtons[i] = new QToolButton( this, list[i] ); |
52 | colorButtons[i]->setPalette( QPalette( QColor( colors[i] ) ) ); | 55 | colorButtons[i]->setPalette( QPalette( QColor( colors[i] ) ) ); |
53 | layout->addWidget( colorButtons[i], i, 1 ); | 56 | layout->addWidget( colorButtons[i], i, 1 ); |
54 | 57 | ||
55 | colorPopupMenu = new ColorPopupMenu( colors[i], 0, list[i] ); | 58 | colorPopupMenu = new ColorPopupMenu( colors[i], 0, list[i] ); |
56 | colorButtons[i]->setPopup( colorPopupMenu ); | 59 | colorButtons[i]->setPopup( colorPopupMenu ); |
57 | colorButtons[i]->setPopupDelay( 0 ); | 60 | colorButtons[i]->setPopupDelay( 0 ); |
58 | connect( colorPopupMenu, SIGNAL( colorSelected( const QColor& ) ), this, SLOT( changeColor( const QColor& ) ) ); | 61 | connect( colorPopupMenu, SIGNAL( colorSelected( const QColor& ) ), this, SLOT( changeColor( const QColor& ) ) ); |
59 | } | 62 | } |
60 | } | 63 | } |
61 | 64 | ||
62 | EditScheme::~EditScheme() | 65 | EditScheme::~EditScheme() |
63 | { | 66 | { |
67 | delete [] colorButtons; | ||
64 | } | 68 | } |
65 | 69 | ||
66 | void EditScheme::changeColor( const QColor& color ) | 70 | void EditScheme::changeColor( const QColor& color ) |
67 | { | 71 | { |
68 | QString name( sender()->name() ); | 72 | QString name( sender()->name() ); |
69 | int i; | 73 | int i; |
70 | 74 | ||
71 | for ( i = 0; i < maxCount; i++ ) | 75 | for ( i = 0; i < maxCount; i++ ) |
72 | { | 76 | { |
73 | if ( name == colorButtons[i]->name() ) | 77 | if ( name == colorButtons[i]->name() ) |
74 | { | 78 | { |
75 | break; | 79 | break; |
diff --git a/noncore/settings/appearance2/editScheme.h b/noncore/settings/appearance2/editScheme.h index cf238c6..583050f 100644 --- a/noncore/settings/appearance2/editScheme.h +++ b/noncore/settings/appearance2/editScheme.h | |||
@@ -22,27 +22,27 @@ | |||
22 | 22 | ||
23 | #include <qdialog.h> | 23 | #include <qdialog.h> |
24 | #include <qtoolbutton.h> | 24 | #include <qtoolbutton.h> |
25 | 25 | ||
26 | class QColor; | 26 | class QColor; |
27 | 27 | ||
28 | class EditScheme : public QDialog | 28 | class EditScheme : public QDialog |
29 | { | 29 | { |
30 | Q_OBJECT | 30 | Q_OBJECT |
31 | 31 | ||
32 | public: | 32 | public: |
33 | EditScheme( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0, | 33 | EditScheme( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0, |
34 | int = 0, QString[] = 0, QString[] = 0 ); | 34 | int = 0, QString * = 0, QString * = 0 ); |
35 | ~EditScheme(); | 35 | ~EditScheme(); |
36 | 36 | ||
37 | int maxCount; | 37 | int maxCount; |
38 | QString surfaceList[9]; | 38 | QString * surfaceList; |
39 | QString colorList[9]; | 39 | QString * colorList; |
40 | 40 | ||
41 | 41 | ||
42 | QToolButton* colorButtons[9]; | 42 | QToolButton** colorButtons; |
43 | 43 | ||
44 | protected slots: | 44 | protected slots: |
45 | void changeColor( const QColor& ); | 45 | void changeColor( const QColor& ); |
46 | }; | 46 | }; |
47 | 47 | ||
48 | #endif // EDITSCHEME_H | 48 | #endif // EDITSCHEME_H |
diff --git a/noncore/settings/appearance2/sample.cpp b/noncore/settings/appearance2/sample.cpp index ee27d60..e447002 100644 --- a/noncore/settings/appearance2/sample.cpp +++ b/noncore/settings/appearance2/sample.cpp | |||
@@ -1,24 +1,25 @@ | |||
1 | #include <qvbox.h> | 1 | #include <qvbox.h> |
2 | #include <qpopupmenu.h> | 2 | #include <qpopupmenu.h> |
3 | #include <qpainter.h> | 3 | #include <qpainter.h> |
4 | #include <qmenubar.h> | 4 | #include <qmenubar.h> |
5 | #include <qcheckbox.h> | 5 | #include <qcheckbox.h> |
6 | #include <qpushbutton.h> | 6 | #include <qpushbutton.h> |
7 | #include <qscrollbar.h> | 7 | #include <qscrollbar.h> |
8 | #include <qlayout.h> | 8 | #include <qlayout.h> |
9 | #include <qwhatsthis.h> | 9 | #include <qwhatsthis.h> |
10 | #include <qpixmapcache.h> | 10 | #include <qpixmapcache.h> |
11 | #include <qtimer.h> | 11 | #include <qtimer.h> |
12 | #include <qobjectlist.h> | 12 | #include <qobjectlist.h> |
13 | #include <qcommonstyle.h> | ||
13 | 14 | ||
14 | #include "sample.h" | 15 | #include "sample.h" |
15 | 16 | ||
16 | 17 | ||
17 | class SampleText : public QWidget | 18 | class SampleText : public QWidget |
18 | { | 19 | { |
19 | public: | 20 | public: |
20 | SampleText( const QString &t, bool h, QWidget *parent ) | 21 | SampleText( const QString &t, bool h, QWidget *parent ) |
21 | : QWidget( parent ), hl(h), text(t) | 22 | : QWidget( parent ), hl(h), text(t) |
22 | { | 23 | { |
23 | if ( hl ) | 24 | if ( hl ) |
24 | setBackgroundMode( PaletteHighlight ); | 25 | setBackgroundMode( PaletteHighlight ); |
@@ -58,43 +59,49 @@ QSize SampleWindow::sizeHint() const | |||
58 | return container->sizeHint() + QSize( 10, 35 ); | 59 | return container->sizeHint() + QSize( 10, 35 ); |
59 | } | 60 | } |
60 | 61 | ||
61 | void SampleWindow::setFont( const QFont &f ) | 62 | void SampleWindow::setFont( const QFont &f ) |
62 | { | 63 | { |
63 | QWidget::setFont( f ); | 64 | QWidget::setFont( f ); |
64 | popup->setFont( f ); | 65 | popup->setFont( f ); |
65 | QTimer::singleShot ( 0, this, SLOT( fixGeometry ( ))); | 66 | QTimer::singleShot ( 0, this, SLOT( fixGeometry ( ))); |
66 | } | 67 | } |
67 | 68 | ||
68 | static void setStyleRecursive ( QWidget *w, QStyle *s ) | 69 | static void setStyleRecursive ( QWidget *w, QStyle *s ) |
69 | { | 70 | { |
71 | w->setStyle( s ); | ||
70 | QObjectList *childObjects=(QObjectList*)w->children(); | 72 | QObjectList *childObjects=(QObjectList*)w->children(); |
71 | if ( childObjects ) { | 73 | if ( childObjects ) { |
72 | QObject * o; | 74 | QObject * o; |
73 | for(o=childObjects->first();o!=0;o=childObjects->next()) { | 75 | for(o=childObjects->first();o!=0;o=childObjects->next()) { |
74 | if( o->isWidgetType() ) { | 76 | if( o->isWidgetType() ) { |
75 | setStyleRecursive((QWidget *)o,s); | 77 | setStyleRecursive((QWidget *)o,s); |
76 | } | 78 | } |
77 | } | 79 | } |
78 | } | 80 | } |
79 | w->setStyle( s ); | ||
80 | } | 81 | } |
81 | 82 | ||
82 | 83 | ||
83 | void SampleWindow::setStyle2 ( QStyle *sty ) | 84 | void SampleWindow::setStyle2 ( QStyle *sty ) |
84 | { | 85 | { |
86 | typedef void (QStyle::*QDrawMenuBarItemImpl) (QPainter *, int, int, int, int, QMenuItem *, QColorGroup &, bool, bool); | ||
87 | |||
88 | extern QDrawMenuBarItemImpl qt_set_draw_menu_bar_impl(QDrawMenuBarItemImpl); | ||
89 | |||
85 | QPixmapCache::clear ( ); | 90 | QPixmapCache::clear ( ); |
86 | QPalette p = palette ( ); | 91 | QPalette p = palette ( ); |
87 | sty-> polish ( p ); | 92 | sty-> polish ( p ); |
93 | qt_set_draw_menu_bar_impl ( 0 ); | ||
88 | setStyleRecursive ( this, sty ); | 94 | setStyleRecursive ( this, sty ); |
95 | setPalette ( p ); | ||
89 | QTimer::singleShot ( 0, this, SLOT( fixGeometry ( ))); | 96 | QTimer::singleShot ( 0, this, SLOT( fixGeometry ( ))); |
90 | } | 97 | } |
91 | 98 | ||
92 | 99 | ||
93 | void SampleWindow::setDecoration( WindowDecorationInterface *i ) | 100 | void SampleWindow::setDecoration( WindowDecorationInterface *i ) |
94 | { | 101 | { |
95 | iface = i; | 102 | iface = i; |
96 | wd.rect = QRect( 0, 0, 150, 75 ); | 103 | wd.rect = QRect( 0, 0, 150, 75 ); |
97 | wd.caption = tr("Sample"); | 104 | wd.caption = tr("Sample"); |
98 | wd.palette = palette(); | 105 | wd.palette = palette(); |
99 | wd.flags = WindowDecorationInterface::WindowData::Dialog | | 106 | wd.flags = WindowDecorationInterface::WindowData::Dialog | |
100 | WindowDecorationInterface::WindowData::Active; | 107 | WindowDecorationInterface::WindowData::Active; |
@@ -197,30 +204,30 @@ bool SampleWindow::eventFilter( QObject *, QEvent *e ) | |||
197 | } | 204 | } |
198 | 205 | ||
199 | return FALSE; | 206 | return FALSE; |
200 | } | 207 | } |
201 | 208 | ||
202 | void SampleWindow::paletteChange( const QPalette &old ) | 209 | void SampleWindow::paletteChange( const QPalette &old ) |
203 | { | 210 | { |
204 | QWidget::paletteChange ( old ); | 211 | QWidget::paletteChange ( old ); |
205 | wd. palette = palette ( ); | 212 | wd. palette = palette ( ); |
206 | popup-> setPalette ( palette ( )); | 213 | popup-> setPalette ( palette ( )); |
207 | } | 214 | } |
208 | 215 | ||
216 | |||
209 | void SampleWindow::setPalette ( const QPalette &pal ) | 217 | void SampleWindow::setPalette ( const QPalette &pal ) |
210 | { | 218 | { |
211 | QPixmapCache::clear ( ); | 219 | QPixmapCache::clear ( ); |
212 | QPalette p = pal; | 220 | QPalette p = pal; |
213 | style ( ). polish ( p ); | 221 | style ( ). polish ( p ); |
214 | |||
215 | QWidget::setPalette ( p ); | 222 | QWidget::setPalette ( p ); |
216 | } | 223 | } |
217 | 224 | ||
218 | void SampleWindow::resizeEvent( QResizeEvent *re ) | 225 | void SampleWindow::resizeEvent( QResizeEvent *re ) |
219 | { | 226 | { |
220 | wd.rect = QRect( 0, 0, 150, 75 ); | 227 | wd.rect = QRect( 0, 0, 150, 75 ); |
221 | 228 | ||
222 | wd.rect.setX( 0 ); | 229 | wd.rect.setX( 0 ); |
223 | wd.rect.setWidth( width() - lb - rb ); | 230 | wd.rect.setWidth( width() - lb - rb ); |
224 | wd.rect.setY( 0 ); | 231 | wd.rect.setY( 0 ); |
225 | wd.rect.setHeight( height() - th - tb - bb ); | 232 | wd.rect.setHeight( height() - th - tb - bb ); |
226 | 233 | ||