Diffstat (limited to 'noncore/settings/appearance2/colorlistitem.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/appearance2/colorlistitem.h | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/noncore/settings/appearance2/colorlistitem.h b/noncore/settings/appearance2/colorlistitem.h index 10e4468..f8d5c45 100644 --- a/noncore/settings/appearance2/colorlistitem.h +++ b/noncore/settings/appearance2/colorlistitem.h | |||
@@ -31,110 +31,111 @@ | |||
31 | #include <qlistbox.h> | 31 | #include <qlistbox.h> |
32 | #include <qpalette.h> | 32 | #include <qpalette.h> |
33 | #include <qapplication.h> | 33 | #include <qapplication.h> |
34 | 34 | ||
35 | #include <qpe/config.h> | 35 | #include <qpe/config.h> |
36 | 36 | ||
37 | class Appearance; | 37 | class Appearance; |
38 | 38 | ||
39 | class ColorListItem : public QListBoxText { | 39 | class ColorListItem : public QListBoxText { |
40 | public: | 40 | public: |
41 | ColorListItem ( const QString &t, Config &cfg ) : QListBoxText ( t ) | 41 | ColorListItem ( const QString &t, Config &cfg ) : QListBoxText ( t ) |
42 | { | 42 | { |
43 | m_colors = new QColor [s_colorcount]; | 43 | m_colors = new QColor [s_colorcount]; |
44 | load ( cfg ); | 44 | load ( cfg ); |
45 | } | 45 | } |
46 | 46 | ||
47 | virtual ~ColorListItem ( ) | 47 | virtual ~ColorListItem ( ) |
48 | { | 48 | { |
49 | delete [] m_colors; | 49 | delete [] m_colors; |
50 | } | 50 | } |
51 | 51 | ||
52 | QPalette palette ( ) | 52 | QPalette palette ( ) |
53 | { | 53 | { |
54 | return m_palette; | 54 | return m_palette; |
55 | } | 55 | } |
56 | 56 | ||
57 | bool load ( Config &cfg ) | 57 | bool load ( Config &cfg ) |
58 | { | 58 | { |
59 | for ( int i = 0; i < s_colorcount; i++ ) | 59 | for ( int i = 0; i < s_colorcount; i++ ) |
60 | m_colors [i] = QColor ( cfg. readEntry ( s_colorlut [i]. m_key, s_colorlut [i]. m_def )); | 60 | m_colors [i] = QColor ( cfg. readEntry ( s_colorlut [i]. m_key, s_colorlut [i]. m_def )); |
61 | 61 | ||
62 | buildPalette ( ); | 62 | buildPalette ( ); |
63 | return true; | 63 | return true; |
64 | } | 64 | } |
65 | 65 | ||
66 | void buildPalette ( ) | 66 | void buildPalette ( ) |
67 | { | 67 | { |
68 | m_palette = QPalette ( m_colors [r2i(QColorGroup::Button)], m_colors [r2i(QColorGroup::Background)] ); | 68 | m_palette = QPalette ( m_colors [r2i(QColorGroup::Button)], m_colors [r2i(QColorGroup::Background)] ); |
69 | m_palette. setColor ( QColorGroup::Highlight, m_colors [r2i(QColorGroup::Highlight)] ); | 69 | m_palette. setColor ( QColorGroup::Highlight, m_colors [r2i(QColorGroup::Highlight)] ); |
70 | m_palette. setColor ( QColorGroup::HighlightedText, m_colors [r2i(QColorGroup::HighlightedText)] ); | 70 | m_palette. setColor ( QColorGroup::HighlightedText, m_colors [r2i(QColorGroup::HighlightedText)] ); |
71 | m_palette. setColor ( QColorGroup::Text, m_colors [r2i(QColorGroup::Text)] ); | 71 | m_palette. setColor ( QColorGroup::Text, m_colors [r2i(QColorGroup::Text)] ); |
72 | m_palette. setColor ( QPalette::Active, QColorGroup::ButtonText, m_colors [r2i(QColorGroup::ButtonText)] ); | 72 | m_palette. setColor ( QPalette::Active, QColorGroup::ButtonText, m_colors [r2i(QColorGroup::ButtonText)] ); |
73 | m_palette. setColor ( QColorGroup::Base, m_colors [r2i(QColorGroup::Base)] ); | 73 | m_palette. setColor ( QColorGroup::Base, m_colors [r2i(QColorGroup::Base)] ); |
74 | m_palette. setColor ( QPalette::Disabled, QColorGroup::Text, m_palette. color ( QPalette::Active, QColorGroup::Background ). dark ( )); | 74 | m_palette. setColor ( QPalette::Disabled, QColorGroup::Text, m_palette. color ( QPalette::Active, QColorGroup::Background ). dark ( )); |
75 | } | 75 | } |
76 | 76 | ||
77 | bool save ( Config &cfg ) | 77 | bool save ( Config &cfg ) |
78 | { | 78 | { |
79 | for ( int i = 0; i < s_colorcount; i++ ) | 79 | for ( int i = 0; i < s_colorcount; i++ ) |
80 | cfg. writeEntry ( s_colorlut [i]. m_key, m_colors [i]. name ( )); | 80 | cfg. writeEntry ( s_colorlut [i]. m_key, m_colors [i]. name ( )); |
81 | return true; | 81 | return true; |
82 | } | 82 | } |
83 | 83 | ||
84 | QColor color ( QColorGroup::ColorRole role ) | 84 | QColor color ( QColorGroup::ColorRole role ) |
85 | { | 85 | { |
86 | int i = r2i ( role ); | 86 | int i = r2i ( role ); |
87 | return i >= 0 ? m_colors [i] : QColor ( ); | 87 | return i >= 0 ? m_colors [i] : QColor ( ); |
88 | } | 88 | } |
89 | 89 | ||
90 | void setColor ( QColorGroup::ColorRole role, QColor c ) | 90 | void setColor ( QColorGroup::ColorRole role, QColor c ) |
91 | { | 91 | { |
92 | int i = r2i ( role ); | 92 | int i = r2i ( role ); |
93 | if ( i >= 0 ) { | 93 | if ( i >= 0 ) { |
94 | m_colors [i] = c; | 94 | m_colors [i] = c; |
95 | buildPalette ( ); | 95 | buildPalette ( ); |
96 | } | 96 | } |
97 | } | 97 | } |
98 | 98 | ||
99 | QString label ( QColorGroup::ColorRole role ) | 99 | QString label ( QColorGroup::ColorRole role ) |
100 | { | 100 | { |
101 | int i = r2i ( role ); | 101 | int i = r2i ( role ); |
102 | return i >= 0 ? qApp-> translate ( "Appearance", s_colorlut [i]. m_label ) : QString::null; | 102 | return i >= 0 ? qApp-> translate ( "Appearance", s_colorlut [i]. m_label ) : QString::null; |
103 | } | 103 | } |
104 | 104 | ||
105 | private: | 105 | private: |
106 | QPalette m_palette; | 106 | QPalette m_palette; |
107 | QColor *m_colors; | 107 | QColor *m_colors; |
108 | 108 | ||
109 | static struct colorlut { | 109 | static struct colorlut { |
110 | QColorGroup::ColorRole m_role; | 110 | QColorGroup::ColorRole m_role; |
111 | const char * m_key; | 111 | const char * m_key; |
112 | const char * m_def; | 112 | const char * m_def; |
113 | const char * m_label; | 113 | const char * m_label; |
114 | } const s_colorlut []; | 114 | } const s_colorlut []; |
115 | static const int s_colorcount; | 115 | static const int s_colorcount; |
116 | 116 | ||
117 | static int r2i ( QColorGroup::ColorRole role ) | 117 | static int r2i ( QColorGroup::ColorRole role ) |
118 | { | 118 | { |
119 | for ( int i = 0; i < s_colorcount; i++ ) { | 119 | for ( int i = 0; i < s_colorcount; i++ ) { |
120 | if ( s_colorlut [i]. m_role == role ) | 120 | if ( s_colorlut [i]. m_role == role ) |
121 | return i; | 121 | return i; |
122 | } | 122 | } |
123 | return -1; | 123 | return -1; |
124 | } | 124 | } |
125 | }; | 125 | }; |
126 | 126 | ||
127 | // from etc/colors/Liquid.scheme | ||
127 | const ColorListItem::colorlut ColorListItem::s_colorlut [] = { | 128 | const ColorListItem::colorlut ColorListItem::s_colorlut [] = { |
128 | { QColorGroup::Base, "Base", "#FFFFFF", QT_TRANSLATE_NOOP( "Appearance", "Base" ) }, | 129 | { QColorGroup::Base, "Base", "#FFFFFF", QT_TRANSLATE_NOOP( "Appearance", "Base" ) }, |
129 | { QColorGroup::Background, "Background", "#E5E1D5", QT_TRANSLATE_NOOP( "Appearance", "Background" ) }, | 130 | { QColorGroup::Background, "Background", "#E0E0E0", QT_TRANSLATE_NOOP( "Appearance", "Background" ) }, |
130 | { QColorGroup::Button, "Button", "#D6CDBB", QT_TRANSLATE_NOOP( "Appearance", "Button" ) }, | 131 | { QColorGroup::Button, "Button", "#96c8fa", QT_TRANSLATE_NOOP( "Appearance", "Button" ) }, |
131 | { QColorGroup::ButtonText, "ButtonText", "#000000", QT_TRANSLATE_NOOP( "Appearance", "Button Text" ) }, | 132 | { QColorGroup::ButtonText, "ButtonText", "#000000", QT_TRANSLATE_NOOP( "Appearance", "Button Text" ) }, |
132 | { QColorGroup::Highlight, "Highlight", "#800000", QT_TRANSLATE_NOOP( "Appearance", "Highlight" ) }, | 133 | { QColorGroup::Highlight, "Highlight", "#73adef", QT_TRANSLATE_NOOP( "Appearance", "Highlight" ) }, |
133 | { QColorGroup::HighlightedText, "HighlightedText", "#FFFFFF", QT_TRANSLATE_NOOP( "Appearance", "Highlighted Text" ) }, | 134 | { QColorGroup::HighlightedText, "HighlightedText", "#FFFFFF", QT_TRANSLATE_NOOP( "Appearance", "Highlighted Text" ) }, |
134 | { QColorGroup::Text, "Text", "#000000", QT_TRANSLATE_NOOP( "Appearance", "Text" ) } | 135 | { QColorGroup::Text, "Text", "#000000", QT_TRANSLATE_NOOP( "Appearance", "Text" ) } |
135 | }; | 136 | }; |
136 | 137 | ||
137 | const int ColorListItem::s_colorcount = sizeof( s_colorlut ) / sizeof ( s_colorlut [0] ); | 138 | const int ColorListItem::s_colorcount = sizeof( s_colorlut ) / sizeof ( s_colorlut [0] ); |
138 | 139 | ||
139 | 140 | ||
140 | #endif | 141 | #endif |