author | sandman <sandman> | 2002-09-24 23:53:23 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-09-24 23:53:23 (UTC) |
commit | 5ae62a1def1d21c4827560607b208033d6054ed0 (patch) (unidiff) | |
tree | 445b34a539ec9f377d36ba9fb1587c72dafa46b0 | |
parent | a390040768072b4b2b931ec0bcdaaa55daae0b4c (diff) | |
download | opie-5ae62a1def1d21c4827560607b208033d6054ed0.zip opie-5ae62a1def1d21c4827560607b208033d6054ed0.tar.gz opie-5ae62a1def1d21c4827560607b208033d6054ed0.tar.bz2 |
- updated all copyright headers
- use new OColorButton
- rearranged editScheme a bit
-rw-r--r-- | noncore/settings/appearance2/appearance.cpp | 62 | ||||
-rw-r--r-- | noncore/settings/appearance2/appearance.h | 50 | ||||
-rw-r--r-- | noncore/settings/appearance2/colorlistitem.h | 28 | ||||
-rw-r--r-- | noncore/settings/appearance2/decolistitem.h | 27 | ||||
-rw-r--r-- | noncore/settings/appearance2/editScheme.cpp | 116 | ||||
-rw-r--r-- | noncore/settings/appearance2/editScheme.h | 73 | ||||
-rw-r--r-- | noncore/settings/appearance2/main.cpp | 46 | ||||
-rw-r--r-- | noncore/settings/appearance2/sample.cpp | 29 | ||||
-rw-r--r-- | noncore/settings/appearance2/sample.h | 29 | ||||
-rw-r--r-- | noncore/settings/appearance2/stylelistitem.h | 28 |
10 files changed, 318 insertions, 170 deletions
diff --git a/noncore/settings/appearance2/appearance.cpp b/noncore/settings/appearance2/appearance.cpp index 23630c5..66cf2c3 100644 --- a/noncore/settings/appearance2/appearance.cpp +++ b/noncore/settings/appearance2/appearance.cpp | |||
@@ -1,584 +1,588 @@ | |||
1 | /********************************************************************** | 1 | /* |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | =. This file is part of the OPIE Project |
3 | ** | 3 | .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> |
4 | ** This file is part of the Qtopia Environment. | 4 | .>+-= |
5 | ** | 5 | _;:, .> :=|. This library is free software; you can |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | .> <`_, > . <= redistribute it and/or modify it under |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | .="- .-=="i, .._ License as published by the Free Software |
9 | ** packaging of this file. | 9 | - . .-<_> .<> Foundation; either version 2 of the License, |
10 | ** | 10 | ._= =} : or (at your option) any later version. |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | .%`+i> _;_. |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | .i_,=:_. -<s. This library is distributed in the hope that |
13 | ** | 13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | : .. .:, . . . without even the implied warranty of |
15 | ** | 15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
17 | ** not clear to you. | 17 | ..}^=.= = ; Library General Public License for more |
18 | ** | 18 | ++= -. .` .: details. |
19 | *********************************************************************** | 19 | : = ...= . :.=- |
20 | ** | 20 | -. .:....=;==+<; You should have received a copy of the GNU |
21 | ** Enhancements by: Dan Williams, <williamsdr@acm.org> | 21 | -_. . . )=. = Library General Public License along with |
22 | ** | 22 | -- :-=` this library; see the file COPYING.LIB. |
23 | **********************************************************************/ | 23 | If not, write to the Free Software Foundation, |
24 | Inc., 59 Temple Place - Suite 330, | ||
25 | Boston, MA 02111-1307, USA. | ||
26 | |||
27 | */ | ||
24 | 28 | ||
25 | #include "appearance.h" | 29 | #include "appearance.h" |
26 | #include "editScheme.h" | 30 | #include "editScheme.h" |
27 | 31 | ||
28 | #include <opie/ofiledialog.h> | 32 | #include <opie/ofiledialog.h> |
29 | #include <opie/otabwidget.h> | 33 | #include <opie/otabwidget.h> |
30 | 34 | ||
31 | #include <qpe/applnk.h> | 35 | #include <qpe/applnk.h> |
32 | #include <qpe/config.h> | 36 | #include <qpe/config.h> |
33 | #include <qpe/global.h> | 37 | #include <qpe/global.h> |
34 | #include <qpe/resource.h> | 38 | #include <qpe/resource.h> |
35 | #include <qpe/qpeapplication.h> | 39 | #include <qpe/qpeapplication.h> |
36 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 40 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
37 | #include <qpe/qcopenvelope_qws.h> | 41 | #include <qpe/qcopenvelope_qws.h> |
38 | #endif | 42 | #endif |
39 | 43 | ||
40 | #include <qaction.h> | 44 | #include <qaction.h> |
41 | #include <qbuttongroup.h> | 45 | #include <qbuttongroup.h> |
42 | #include <qcheckbox.h> | 46 | #include <qcheckbox.h> |
43 | #include <qcombobox.h> | 47 | #include <qcombobox.h> |
44 | #include <qdialog.h> | 48 | #include <qdialog.h> |
45 | #include <qdir.h> | 49 | #include <qdir.h> |
46 | #include <qlabel.h> | 50 | #include <qlabel.h> |
47 | #include <qlayout.h> | 51 | #include <qlayout.h> |
48 | #include <qlineedit.h> | 52 | #include <qlineedit.h> |
49 | #include <qlistbox.h> | 53 | #include <qlistbox.h> |
50 | #include <qmessagebox.h> | 54 | #include <qmessagebox.h> |
51 | #include <qmultilineedit.h> | 55 | #include <qmultilineedit.h> |
52 | #include <qpopupmenu.h> | 56 | #include <qpopupmenu.h> |
53 | #include <qpushbutton.h> | 57 | #include <qpushbutton.h> |
54 | #include <qradiobutton.h> | 58 | #include <qradiobutton.h> |
55 | #if QT_VERSION >= 300 | 59 | #if QT_VERSION >= 300 |
56 | #include <qstylefactory.h> | 60 | #include <qstylefactory.h> |
57 | #else | 61 | #else |
58 | #include <qwindowsstyle.h> | 62 | #include <qwindowsstyle.h> |
59 | #include <qpe/qpestyle.h> | 63 | #include <qpe/qpestyle.h> |
60 | #include <qpe/lightstyle.h> | 64 | #include <qpe/lightstyle.h> |
61 | #include <qpe/qlibrary.h> | 65 | #include <qpe/qlibrary.h> |
62 | #include <qpe/styleinterface.h> | 66 | #include <qpe/styleinterface.h> |
63 | #endif | 67 | #endif |
64 | #include <qtabwidget.h> | 68 | #include <qtabwidget.h> |
65 | #include <qtoolbutton.h> | 69 | #include <qtoolbutton.h> |
66 | #include <qvgroupbox.h> | 70 | #include <qvgroupbox.h> |
67 | #include <qwidget.h> | 71 | #include <qwidget.h> |
68 | 72 | ||
69 | #include "stylelistitem.h" | 73 | #include "stylelistitem.h" |
70 | #include "decolistitem.h" | 74 | #include "decolistitem.h" |
71 | #include "colorlistitem.h" | 75 | #include "colorlistitem.h" |
72 | 76 | ||
73 | #include "sample.h" | 77 | #include "sample.h" |
74 | 78 | ||
75 | #include <opie/ofontselector.h> | 79 | #include <opie/ofontselector.h> |
76 | 80 | ||
77 | 81 | ||
78 | class DefaultWindowDecoration : public WindowDecorationInterface | 82 | class DefaultWindowDecoration : public WindowDecorationInterface |
79 | { | 83 | { |
80 | public: | 84 | public: |
81 | DefaultWindowDecoration() : ref(0) {} | 85 | DefaultWindowDecoration() : ref(0) {} |
82 | QString name() const { | 86 | QString name() const { |
83 | return "Default"; | 87 | return "Default"; |
84 | } | 88 | } |
85 | QPixmap icon() const { | 89 | QPixmap icon() const { |
86 | return QPixmap(); | 90 | return QPixmap(); |
87 | } | 91 | } |
88 | QRESULT queryInterface( const QUuid &uuid, QUnknownInterface **iface ) { | 92 | QRESULT queryInterface( const QUuid &uuid, QUnknownInterface **iface ) { |
89 | *iface = 0; | 93 | *iface = 0; |
90 | if ( uuid == IID_QUnknown ) | 94 | if ( uuid == IID_QUnknown ) |
91 | *iface = this; | 95 | *iface = this; |
92 | else if ( uuid == IID_WindowDecoration ) | 96 | else if ( uuid == IID_WindowDecoration ) |
93 | *iface = this; | 97 | *iface = this; |
94 | 98 | ||
95 | if ( *iface ) | 99 | if ( *iface ) |
96 | (*iface)->addRef(); | 100 | (*iface)->addRef(); |
97 | return QS_OK; | 101 | return QS_OK; |
98 | } | 102 | } |
99 | Q_REFCOUNT | 103 | Q_REFCOUNT |
100 | 104 | ||
101 | private: | 105 | private: |
102 | ulong ref; | 106 | ulong ref; |
103 | }; | 107 | }; |
104 | 108 | ||
105 | 109 | ||
106 | 110 | ||
107 | void Appearance::loadStyles ( QListBox *list ) | 111 | void Appearance::loadStyles ( QListBox *list ) |
108 | { | 112 | { |
109 | #if QT_VERSION >= 300 | 113 | #if QT_VERSION >= 300 |
110 | list->insertStringList(QStyleFactory::styles()); | 114 | list->insertStringList(QStyleFactory::styles()); |
111 | #else | 115 | #else |
112 | list->insertItem( new StyleListItem ( "Windows", new QWindowsStyle ( ))); | 116 | list->insertItem( new StyleListItem ( "Windows", new QWindowsStyle ( ))); |
113 | list->insertItem( new StyleListItem ( "Light", new LightStyle ( ))); | 117 | list->insertItem( new StyleListItem ( "Light", new LightStyle ( ))); |
114 | #ifndef QT_NO_STYLE_MOTIF | 118 | #ifndef QT_NO_STYLE_MOTIF |
115 | list->insertItem( new StyleListItem ( "Motif", new QMotifStyle ( ))); | 119 | list->insertItem( new StyleListItem ( "Motif", new QMotifStyle ( ))); |
116 | #endif | 120 | #endif |
117 | #ifndef QT_NO_STYLE_MOTIFPLUS | 121 | #ifndef QT_NO_STYLE_MOTIFPLUS |
118 | list->insertItem( new StyleListItem ( "MotifPlus", new QMotifPlusStyle ( ))); | 122 | list->insertItem( new StyleListItem ( "MotifPlus", new QMotifPlusStyle ( ))); |
119 | #endif | 123 | #endif |
120 | #ifndef QT_NO_STYLE_PLATINUM | 124 | #ifndef QT_NO_STYLE_PLATINUM |
121 | list->insertItem( new StyleListItem ( "Platinum", new QPlatinumStyle ( ))); | 125 | list->insertItem( new StyleListItem ( "Platinum", new QPlatinumStyle ( ))); |
122 | #endif | 126 | #endif |
123 | #endif | 127 | #endif |
124 | list->insertItem( new StyleListItem ( "QPE", new QPEStyle ( ))); | 128 | list->insertItem( new StyleListItem ( "QPE", new QPEStyle ( ))); |
125 | 129 | ||
126 | #if QT_VERSION < 300 | 130 | #if QT_VERSION < 300 |
127 | { | 131 | { |
128 | QString path = QPEApplication::qpeDir() + "/plugins/styles/"; | 132 | QString path = QPEApplication::qpeDir() + "/plugins/styles/"; |
129 | QStringList sl = QDir ( path, "lib*.so" ). entryList ( ); | 133 | QStringList sl = QDir ( path, "lib*.so" ). entryList ( ); |
130 | 134 | ||
131 | for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) { | 135 | for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) { |
132 | QLibrary *lib = new QLibrary ( path + "/" + *it ); | 136 | QLibrary *lib = new QLibrary ( path + "/" + *it ); |
133 | StyleInterface *iface; | 137 | StyleInterface *iface; |
134 | 138 | ||
135 | if ( lib-> queryInterface ( IID_Style, (QUnknownInterface **) &iface ) == QS_OK ) | 139 | if ( lib-> queryInterface ( IID_Style, (QUnknownInterface **) &iface ) == QS_OK ) |
136 | list-> insertItem ( new StyleListItem ( lib, iface )); | 140 | list-> insertItem ( new StyleListItem ( lib, iface )); |
137 | else | 141 | else |
138 | delete lib; | 142 | delete lib; |
139 | } | 143 | } |
140 | } | 144 | } |
141 | 145 | ||
142 | #endif | 146 | #endif |
143 | } | 147 | } |
144 | 148 | ||
145 | void Appearance::loadDecos ( QListBox *list ) | 149 | void Appearance::loadDecos ( QListBox *list ) |
146 | { | 150 | { |
147 | list-> insertItem ( new DecoListItem ( tr( "Default" ))); | 151 | list-> insertItem ( new DecoListItem ( tr( "Default" ))); |
148 | 152 | ||
149 | { | 153 | { |
150 | QString path = QPEApplication::qpeDir() + "/plugins/decorations/"; | 154 | QString path = QPEApplication::qpeDir() + "/plugins/decorations/"; |
151 | QStringList sl = QDir ( path, "lib*.so" ). entryList ( ); | 155 | QStringList sl = QDir ( path, "lib*.so" ). entryList ( ); |
152 | 156 | ||
153 | for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) { | 157 | for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) { |
154 | QLibrary *lib = new QLibrary ( path + "/" + *it ); | 158 | QLibrary *lib = new QLibrary ( path + "/" + *it ); |
155 | WindowDecorationInterface *iface; | 159 | WindowDecorationInterface *iface; |
156 | 160 | ||
157 | if ( lib-> queryInterface ( IID_WindowDecoration, (QUnknownInterface **) &iface ) == QS_OK ) | 161 | if ( lib-> queryInterface ( IID_WindowDecoration, (QUnknownInterface **) &iface ) == QS_OK ) |
158 | list-> insertItem ( new DecoListItem ( lib, iface )); | 162 | list-> insertItem ( new DecoListItem ( lib, iface )); |
159 | else | 163 | else |
160 | delete lib; | 164 | delete lib; |
161 | } | 165 | } |
162 | } | 166 | } |
163 | } | 167 | } |
164 | 168 | ||
165 | void Appearance::loadColors ( QListBox *list ) | 169 | void Appearance::loadColors ( QListBox *list ) |
166 | { | 170 | { |
167 | list-> clear ( ); | 171 | list-> clear ( ); |
168 | { | 172 | { |
169 | Config config ( "qpe" ); | 173 | Config config ( "qpe" ); |
170 | config. setGroup ( "Appearance" ); | 174 | config. setGroup ( "Appearance" ); |
171 | 175 | ||
172 | list-> insertItem ( new ColorListItem ( tr( "Current scheme" ), config )); | 176 | list-> insertItem ( new ColorListItem ( tr( "Current scheme" ), config )); |
173 | } | 177 | } |
174 | 178 | ||
175 | QString path = QPEApplication::qpeDir ( ) + "/etc/colors/"; | 179 | QString path = QPEApplication::qpeDir ( ) + "/etc/colors/"; |
176 | QStringList sl = QDir ( path ). entryList ( "*.scheme" ); | 180 | QStringList sl = QDir ( path ). entryList ( "*.scheme" ); |
177 | 181 | ||
178 | for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) { | 182 | for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) { |
179 | QString name = (*it). left ((*it). find ( ".scheme" )); | 183 | QString name = (*it). left ((*it). find ( ".scheme" )); |
180 | Config config ( path + *it, Config::File ); | 184 | Config config ( path + *it, Config::File ); |
181 | config. setGroup ( "Colors" ); | 185 | config. setGroup ( "Colors" ); |
182 | 186 | ||
183 | list-> insertItem ( new ColorListItem ( name, config )); | 187 | list-> insertItem ( new ColorListItem ( name, config )); |
184 | } | 188 | } |
185 | } | 189 | } |
186 | 190 | ||
187 | 191 | ||
188 | QWidget *Appearance::createStyleTab ( QWidget *parent ) | 192 | QWidget *Appearance::createStyleTab ( QWidget *parent ) |
189 | { | 193 | { |
190 | Config config ( "qpe" ); | 194 | Config config ( "qpe" ); |
191 | config. setGroup ( "Appearance" ); | 195 | config. setGroup ( "Appearance" ); |
192 | 196 | ||
193 | QWidget* tab = new QWidget( parent, "StyleTab" ); | 197 | QWidget* tab = new QWidget( parent, "StyleTab" ); |
194 | QVBoxLayout* vertLayout = new QVBoxLayout( tab, 4, 4 ); | 198 | QVBoxLayout* vertLayout = new QVBoxLayout( tab, 4, 4 ); |
195 | 199 | ||
196 | m_style_list = new QListBox( tab, "m_style_list" ); | 200 | m_style_list = new QListBox( tab, "m_style_list" ); |
197 | vertLayout->addWidget( m_style_list ); | 201 | vertLayout->addWidget( m_style_list ); |
198 | 202 | ||
199 | m_style_settings = new QPushButton ( tr( "Settings..." ), tab ); | 203 | m_style_settings = new QPushButton ( tr( "Settings..." ), tab ); |
200 | connect ( m_style_settings, SIGNAL( clicked ( )), this, SLOT( styleSettingsClicked ( ))); | 204 | connect ( m_style_settings, SIGNAL( clicked ( )), this, SLOT( styleSettingsClicked ( ))); |
201 | vertLayout-> addWidget ( m_style_settings ); | 205 | vertLayout-> addWidget ( m_style_settings ); |
202 | 206 | ||
203 | loadStyles ( m_style_list ); | 207 | loadStyles ( m_style_list ); |
204 | 208 | ||
205 | QString s = config. readEntry ( "Style", "Light" ); | 209 | QString s = config. readEntry ( "Style", "Light" ); |
206 | m_style_list-> setCurrentItem ( m_style_list-> findItem ( s )); | 210 | m_style_list-> setCurrentItem ( m_style_list-> findItem ( s )); |
207 | m_original_style = m_style_list-> currentItem ( ); | 211 | m_original_style = m_style_list-> currentItem ( ); |
208 | styleClicked ( m_original_style ); | 212 | styleClicked ( m_original_style ); |
209 | 213 | ||
210 | connect( m_style_list, SIGNAL( highlighted( int ) ), this, SLOT( styleClicked( int ) ) ); | 214 | connect( m_style_list, SIGNAL( highlighted( int ) ), this, SLOT( styleClicked( int ) ) ); |
211 | 215 | ||
212 | return tab; | 216 | return tab; |
213 | } | 217 | } |
214 | 218 | ||
215 | QWidget *Appearance::createDecoTab ( QWidget *parent ) | 219 | QWidget *Appearance::createDecoTab ( QWidget *parent ) |
216 | { | 220 | { |
217 | Config config ( "qpe" ); | 221 | Config config ( "qpe" ); |
218 | config. setGroup ( "Appearance" ); | 222 | config. setGroup ( "Appearance" ); |
219 | 223 | ||
220 | QWidget* tab = new QWidget( parent, "DecoTab" ); | 224 | QWidget* tab = new QWidget( parent, "DecoTab" ); |
221 | QVBoxLayout* vertLayout = new QVBoxLayout( tab, 4, 4 ); | 225 | QVBoxLayout* vertLayout = new QVBoxLayout( tab, 4, 4 ); |
222 | 226 | ||
223 | m_deco_list = new QListBox( tab, "m_deco_list" ); | 227 | m_deco_list = new QListBox( tab, "m_deco_list" ); |
224 | vertLayout->addWidget( m_deco_list ); | 228 | vertLayout->addWidget( m_deco_list ); |
225 | 229 | ||
226 | loadDecos ( m_deco_list ); | 230 | loadDecos ( m_deco_list ); |
227 | 231 | ||
228 | QString s = config. readEntry ( "Decoration" ); | 232 | QString s = config. readEntry ( "Decoration" ); |
229 | m_deco_list-> setCurrentItem ( m_deco_list-> findItem ( s )); | 233 | m_deco_list-> setCurrentItem ( m_deco_list-> findItem ( s )); |
230 | m_original_deco = m_deco_list-> currentItem ( ); | 234 | m_original_deco = m_deco_list-> currentItem ( ); |
231 | if ( m_deco_list-> currentItem ( ) < 0 ) | 235 | if ( m_deco_list-> currentItem ( ) < 0 ) |
232 | m_deco_list-> setCurrentItem ( 0 ); | 236 | m_deco_list-> setCurrentItem ( 0 ); |
233 | decoClicked ( m_original_deco ); | 237 | decoClicked ( m_original_deco ); |
234 | 238 | ||
235 | connect( m_deco_list, SIGNAL( highlighted( int ) ), this, SLOT( decoClicked( int ) ) ); | 239 | connect( m_deco_list, SIGNAL( highlighted( int ) ), this, SLOT( decoClicked( int ) ) ); |
236 | 240 | ||
237 | return tab; | 241 | return tab; |
238 | } | 242 | } |
239 | 243 | ||
240 | QWidget *Appearance::createFontTab ( QWidget *parent ) | 244 | QWidget *Appearance::createFontTab ( QWidget *parent ) |
241 | { | 245 | { |
242 | Config config ( "qpe" ); | 246 | Config config ( "qpe" ); |
243 | config. setGroup ( "Appearance" ); | 247 | config. setGroup ( "Appearance" ); |
244 | 248 | ||
245 | QString familyStr = config.readEntry( "FontFamily", "Helvetica" ); | 249 | QString familyStr = config.readEntry( "FontFamily", "Helvetica" ); |
246 | QString styleStr = config.readEntry( "FontStyle", "Regular" ); | 250 | QString styleStr = config.readEntry( "FontStyle", "Regular" ); |
247 | int size = config.readNumEntry( "FontSize", 10 ); | 251 | int size = config.readNumEntry( "FontSize", 10 ); |
248 | 252 | ||
249 | m_fontselect = new OFontSelector ( parent, "FontTab" ); | 253 | m_fontselect = new OFontSelector ( parent, "FontTab" ); |
250 | m_fontselect-> setSelectedFont ( familyStr, styleStr, size ); | 254 | m_fontselect-> setSelectedFont ( familyStr, styleStr, size ); |
251 | 255 | ||
252 | connect( m_fontselect, SIGNAL( fontSelected ( const QFont & )), | 256 | connect( m_fontselect, SIGNAL( fontSelected ( const QFont & )), |
253 | this, SLOT( fontClicked ( const QFont & ))); | 257 | this, SLOT( fontClicked ( const QFont & ))); |
254 | 258 | ||
255 | return m_fontselect; | 259 | return m_fontselect; |
256 | } | 260 | } |
257 | 261 | ||
258 | QWidget *Appearance::createColorTab ( QWidget *parent ) | 262 | QWidget *Appearance::createColorTab ( QWidget *parent ) |
259 | { | 263 | { |
260 | Config config ( "qpe" ); | 264 | Config config ( "qpe" ); |
261 | config. setGroup ( "Appearance" ); | 265 | config. setGroup ( "Appearance" ); |
262 | 266 | ||
263 | 267 | ||
264 | QWidget *tab = new QWidget( parent, "ColorTab" ); | 268 | QWidget *tab = new QWidget( parent, "ColorTab" ); |
265 | QGridLayout *gridLayout = new QGridLayout( tab, 0, 0, 4, 4 ); | 269 | QGridLayout *gridLayout = new QGridLayout( tab, 0, 0, 4, 4 ); |
266 | gridLayout->setRowStretch ( 3, 10 ); | 270 | gridLayout->setRowStretch ( 3, 10 ); |
267 | 271 | ||
268 | m_color_list = new QListBox ( tab ); | 272 | m_color_list = new QListBox ( tab ); |
269 | gridLayout->addMultiCellWidget ( m_color_list, 0, 3, 0, 0 ); | 273 | gridLayout->addMultiCellWidget ( m_color_list, 0, 3, 0, 0 ); |
270 | connect( m_color_list, SIGNAL( highlighted( int ) ), this, SLOT( colorClicked( int ) ) ); | 274 | connect( m_color_list, SIGNAL( highlighted( int ) ), this, SLOT( colorClicked( int ) ) ); |
271 | 275 | ||
272 | loadColors ( m_color_list ); | 276 | loadColors ( m_color_list ); |
273 | m_color_list-> setCurrentItem ( 0 ); | 277 | m_color_list-> setCurrentItem ( 0 ); |
274 | 278 | ||
275 | QPushButton* tempButton = new QPushButton( tab, "editSchemeButton" ); | 279 | QPushButton* tempButton = new QPushButton( tab, "editSchemeButton" ); |
276 | tempButton->setText( tr( "Edit..." ) ); | 280 | tempButton->setText( tr( "Edit..." ) ); |
277 | connect( tempButton, SIGNAL( clicked() ), this, SLOT( editSchemeClicked() ) ); | 281 | connect( tempButton, SIGNAL( clicked() ), this, SLOT( editSchemeClicked() ) ); |
278 | gridLayout->addWidget( tempButton, 0, 1 ); | 282 | gridLayout->addWidget( tempButton, 0, 1 ); |
279 | 283 | ||
280 | tempButton = new QPushButton( tab, "deleteSchemeButton" ); | 284 | tempButton = new QPushButton( tab, "deleteSchemeButton" ); |
281 | tempButton->setText( tr( "Delete" ) ); | 285 | tempButton->setText( tr( "Delete" ) ); |
282 | connect( tempButton, SIGNAL( clicked() ), this, SLOT( deleteSchemeClicked() ) ); | 286 | connect( tempButton, SIGNAL( clicked() ), this, SLOT( deleteSchemeClicked() ) ); |
283 | gridLayout->addWidget( tempButton, 1, 1 ); | 287 | gridLayout->addWidget( tempButton, 1, 1 ); |
284 | 288 | ||
285 | tempButton = new QPushButton( tab, "saveSchemeButton" ); | 289 | tempButton = new QPushButton( tab, "saveSchemeButton" ); |
286 | tempButton->setText( tr( "Save" ) ); | 290 | tempButton->setText( tr( "Save" ) ); |
287 | connect( tempButton, SIGNAL( clicked() ), this, SLOT( saveSchemeClicked() ) ); | 291 | connect( tempButton, SIGNAL( clicked() ), this, SLOT( saveSchemeClicked() ) ); |
288 | gridLayout->addWidget( tempButton, 2, 1 ); | 292 | gridLayout->addWidget( tempButton, 2, 1 ); |
289 | 293 | ||
290 | return tab; | 294 | return tab; |
291 | } | 295 | } |
292 | 296 | ||
293 | QWidget *Appearance::createGuiTab ( QWidget *parent ) | 297 | QWidget *Appearance::createGuiTab ( QWidget *parent ) |
294 | { | 298 | { |
295 | Config config ( "qpe" ); | 299 | Config config ( "qpe" ); |
296 | config. setGroup ( "Appearance" ); | 300 | config. setGroup ( "Appearance" ); |
297 | 301 | ||
298 | QWidget *tab = new QWidget( parent, "AdvancedTab" ); | 302 | QWidget *tab = new QWidget( parent, "AdvancedTab" ); |
299 | QVBoxLayout *vertLayout = new QVBoxLayout( tab, 4, 4 ); | 303 | QVBoxLayout *vertLayout = new QVBoxLayout( tab, 4, 4 ); |
300 | 304 | ||
301 | QGridLayout* gridLayout = new QGridLayout ( vertLayout ); | 305 | QGridLayout* gridLayout = new QGridLayout ( vertLayout ); |
302 | 306 | ||
303 | int style = config. readNumEntry ( "TabStyle", 2 ) - 1; | 307 | int style = config. readNumEntry ( "TabStyle", 2 ) - 1; |
304 | bool tabtop = ( config. readEntry ( "TabPosition", "Top" ) == "Top" ); | 308 | bool tabtop = ( config. readEntry ( "TabPosition", "Top" ) == "Top" ); |
305 | 309 | ||
306 | QLabel* label = new QLabel( tr( "Tab style:" ), tab ); | 310 | QLabel* label = new QLabel( tr( "Tab style:" ), tab ); |
307 | gridLayout-> addWidget ( label, 0, 0 ); | 311 | gridLayout-> addWidget ( label, 0, 0 ); |
308 | QButtonGroup* btngrp = new QButtonGroup( tab, "buttongroup" ); | 312 | QButtonGroup* btngrp = new QButtonGroup( tab, "buttongroup" ); |
309 | btngrp-> hide ( ); | 313 | btngrp-> hide ( ); |
310 | btngrp-> setExclusive ( true ); | 314 | btngrp-> setExclusive ( true ); |
311 | 315 | ||
312 | m_tabstyle_list = new QComboBox ( false, tab, "tabstyle" ); | 316 | m_tabstyle_list = new QComboBox ( false, tab, "tabstyle" ); |
313 | m_tabstyle_list-> insertItem ( tr( "Tabs" )); | 317 | m_tabstyle_list-> insertItem ( tr( "Tabs" )); |
314 | m_tabstyle_list-> insertItem ( tr( "Tabs w/icons" )); | 318 | m_tabstyle_list-> insertItem ( tr( "Tabs w/icons" )); |
315 | m_tabstyle_list-> insertItem ( tr( "Drop down list" )); | 319 | m_tabstyle_list-> insertItem ( tr( "Drop down list" )); |
316 | m_tabstyle_list-> insertItem ( tr( "Drop down list w/icons" )); | 320 | m_tabstyle_list-> insertItem ( tr( "Drop down list w/icons" )); |
317 | m_tabstyle_list-> setCurrentItem ( style ); | 321 | m_tabstyle_list-> setCurrentItem ( style ); |
318 | gridLayout-> addMultiCellWidget ( m_tabstyle_list, 0, 0, 1, 2 ); | 322 | gridLayout-> addMultiCellWidget ( m_tabstyle_list, 0, 0, 1, 2 ); |
319 | 323 | ||
320 | m_tabstyle_top = new QRadioButton( tr( "Top" ), tab, "tabpostop" ); | 324 | m_tabstyle_top = new QRadioButton( tr( "Top" ), tab, "tabpostop" ); |
321 | btngrp-> insert ( m_tabstyle_top ); | 325 | btngrp-> insert ( m_tabstyle_top ); |
322 | gridLayout-> addWidget( m_tabstyle_top, 1, 1 ); | 326 | gridLayout-> addWidget( m_tabstyle_top, 1, 1 ); |
323 | 327 | ||
324 | m_tabstyle_bottom = new QRadioButton( tr( "Bottom" ), tab, "tabposbottom" ); | 328 | m_tabstyle_bottom = new QRadioButton( tr( "Bottom" ), tab, "tabposbottom" ); |
325 | btngrp-> insert ( m_tabstyle_bottom ); | 329 | btngrp-> insert ( m_tabstyle_bottom ); |
326 | gridLayout-> addWidget( m_tabstyle_bottom, 1, 2 ); | 330 | gridLayout-> addWidget( m_tabstyle_bottom, 1, 2 ); |
327 | 331 | ||
328 | m_tabstyle_top-> setChecked ( tabtop ); | 332 | m_tabstyle_top-> setChecked ( tabtop ); |
329 | m_tabstyle_bottom-> setChecked ( !tabtop ); | 333 | m_tabstyle_bottom-> setChecked ( !tabtop ); |
330 | 334 | ||
331 | m_original_tabstyle = style; | 335 | m_original_tabstyle = style; |
332 | m_original_tabpos = tabtop; | 336 | m_original_tabpos = tabtop; |
333 | 337 | ||
334 | return tab; | 338 | return tab; |
335 | } | 339 | } |
336 | 340 | ||
337 | 341 | ||
338 | Appearance::Appearance( QWidget* parent, const char* name, WFlags ) | 342 | Appearance::Appearance( QWidget* parent, const char* name, WFlags ) |
339 | : QDialog ( parent, name, true ) | 343 | : QDialog ( parent, name, true ) |
340 | { | 344 | { |
341 | setCaption( tr( "Appearance" ) ); | 345 | setCaption( tr( "Appearance" ) ); |
342 | 346 | ||
343 | Config config( "qpe" ); | 347 | Config config( "qpe" ); |
344 | config.setGroup( "Appearance" ); | 348 | config.setGroup( "Appearance" ); |
345 | 349 | ||
346 | QVBoxLayout *top = new QVBoxLayout ( this, 4, 4 ); | 350 | QVBoxLayout *top = new QVBoxLayout ( this, 4, 4 ); |
347 | 351 | ||
348 | m_sample = new SampleWindow ( this ); | 352 | m_sample = new SampleWindow ( this ); |
349 | m_sample-> setDecoration ( new DefaultWindowDecoration ( )); | 353 | m_sample-> setDecoration ( new DefaultWindowDecoration ( )); |
350 | 354 | ||
351 | OTabWidget* tw = new OTabWidget ( this, "tabwidget", OTabWidget::Global, OTabWidget::Bottom ); | 355 | OTabWidget* tw = new OTabWidget ( this, "tabwidget", OTabWidget::Global, OTabWidget::Bottom ); |
352 | QWidget *styletab; | 356 | QWidget *styletab; |
353 | 357 | ||
354 | tw-> addTab ( styletab = createStyleTab ( tw ), "appearance/styletabicon.png", tr( "Style" )); | 358 | tw-> addTab ( styletab = createStyleTab ( tw ), "appearance/styletabicon.png", tr( "Style" )); |
355 | tw-> addTab ( createFontTab ( tw ), "appearance/fonttabicon.png", tr( "Font" )); | 359 | tw-> addTab ( createFontTab ( tw ), "appearance/fonttabicon.png", tr( "Font" )); |
356 | tw-> addTab ( createColorTab ( tw ), "appearance/colorstabicon.png", tr( "Colors" ) ); | 360 | tw-> addTab ( createColorTab ( tw ), "appearance/colorstabicon.png", tr( "Colors" ) ); |
357 | tw-> addTab ( createDecoTab ( tw ), "appearance/styletabicon.png", tr( "Windows" ) ); | 361 | tw-> addTab ( createDecoTab ( tw ), "appearance/styletabicon.png", tr( "Windows" ) ); |
358 | tw-> addTab ( createGuiTab ( tw ), "appearance/backgroundtabicon.png", tr( "Gui" ) ); | 362 | tw-> addTab ( createGuiTab ( tw ), "appearance/backgroundtabicon.png", tr( "Gui" ) ); |
359 | 363 | ||
360 | top-> addWidget ( tw, 10 ); | 364 | top-> addWidget ( tw, 10 ); |
361 | top-> addWidget ( m_sample, 1 ); | 365 | top-> addWidget ( m_sample, 1 ); |
362 | 366 | ||
363 | tw-> setCurrentTab ( styletab ); | 367 | tw-> setCurrentTab ( styletab ); |
364 | } | 368 | } |
365 | 369 | ||
366 | Appearance::~Appearance() | 370 | Appearance::~Appearance() |
367 | { | 371 | { |
368 | } | 372 | } |
369 | 373 | ||
370 | void Appearance::accept ( ) | 374 | void Appearance::accept ( ) |
371 | { | 375 | { |
372 | Config config("qpe"); | 376 | Config config("qpe"); |
373 | config.setGroup( "Appearance" ); | 377 | config.setGroup( "Appearance" ); |
374 | 378 | ||
375 | int newtabstyle = m_tabstyle_list-> currentItem ( ); | 379 | int newtabstyle = m_tabstyle_list-> currentItem ( ); |
376 | bool newtabpos = m_tabstyle_top-> isChecked ( ); | 380 | bool newtabpos = m_tabstyle_top-> isChecked ( ); |
377 | 381 | ||
378 | 382 | ||
379 | if ( m_style_changed ) { | 383 | if ( m_style_changed ) { |
380 | StyleListItem *item = (StyleListItem *) m_style_list-> item ( m_style_list-> currentItem ( )); | 384 | StyleListItem *item = (StyleListItem *) m_style_list-> item ( m_style_list-> currentItem ( )); |
381 | if ( item ) | 385 | if ( item ) |
382 | config.writeEntry( "Style", item-> key ( )); | 386 | config.writeEntry( "Style", item-> key ( )); |
383 | } | 387 | } |
384 | 388 | ||
385 | if (( newtabstyle != m_original_tabstyle ) || ( newtabpos != m_original_tabpos )) { | 389 | if (( newtabstyle != m_original_tabstyle ) || ( newtabpos != m_original_tabpos )) { |
386 | config. writeEntry ( "TabStyle", newtabstyle + 1 ); | 390 | config. writeEntry ( "TabStyle", newtabstyle + 1 ); |
387 | config. writeEntry ( "TabPosition", newtabpos ? "Top" : "Bottom" ); | 391 | config. writeEntry ( "TabPosition", newtabpos ? "Top" : "Bottom" ); |
388 | } | 392 | } |
389 | 393 | ||
390 | if ( m_font_changed ) { | 394 | if ( m_font_changed ) { |
391 | config. writeEntry ( "FontFamily", m_fontselect-> fontFamily ( )); | 395 | config. writeEntry ( "FontFamily", m_fontselect-> fontFamily ( )); |
392 | config. writeEntry ( "FontStyle", m_fontselect-> fontStyle ( )); | 396 | config. writeEntry ( "FontStyle", m_fontselect-> fontStyle ( )); |
393 | config. writeEntry ( "FontSize", m_fontselect-> fontSize ( )); | 397 | config. writeEntry ( "FontSize", m_fontselect-> fontSize ( )); |
394 | } | 398 | } |
395 | 399 | ||
396 | 400 | ||
397 | if ( m_color_changed ) | 401 | if ( m_color_changed ) |
398 | { | 402 | { |
399 | ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); | 403 | ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); |
400 | 404 | ||
401 | if ( item ) | 405 | if ( item ) |
402 | item-> save ( config ); | 406 | item-> save ( config ); |
403 | } | 407 | } |
404 | 408 | ||
405 | config. write ( ); // need to flush the config info first | 409 | config. write ( ); // need to flush the config info first |
406 | Global::applyStyle ( ); | 410 | Global::applyStyle ( ); |
407 | 411 | ||
408 | if ( QMessageBox::warning ( this, tr( "Restart" ), tr( "Do you want to restart Opie now?" ), tr( "Yes" ), tr( "No" ), 0, 0, 1 ) == 0 ) { | 412 | if ( QMessageBox::warning ( this, tr( "Restart" ), tr( "Do you want to restart Opie now?" ), tr( "Yes" ), tr( "No" ), 0, 0, 1 ) == 0 ) { |
409 | QCopEnvelope e( "QPE/System", "restart()" ); | 413 | QCopEnvelope e( "QPE/System", "restart()" ); |
410 | } | 414 | } |
411 | 415 | ||
412 | QDialog::accept ( ); | 416 | QDialog::accept ( ); |
413 | } | 417 | } |
414 | 418 | ||
415 | void Appearance::done ( int r ) | 419 | void Appearance::done ( int r ) |
416 | { | 420 | { |
417 | QDialog::done ( r ); | 421 | QDialog::done ( r ); |
418 | close ( ); | 422 | close ( ); |
419 | } | 423 | } |
420 | 424 | ||
421 | 425 | ||
422 | void Appearance::styleClicked ( int index ) | 426 | void Appearance::styleClicked ( int index ) |
423 | { | 427 | { |
424 | StyleListItem *sli = (StyleListItem *) m_style_list-> item ( index ); | 428 | StyleListItem *sli = (StyleListItem *) m_style_list-> item ( index ); |
425 | m_style_settings-> setEnabled ( sli ? sli-> hasSettings ( ) : false ); | 429 | m_style_settings-> setEnabled ( sli ? sli-> hasSettings ( ) : false ); |
426 | 430 | ||
427 | if ( m_sample && sli && sli-> style ( )) | 431 | if ( m_sample && sli && sli-> style ( )) |
428 | m_sample-> setStyle2 ( sli-> style ( )); | 432 | m_sample-> setStyle2 ( sli-> style ( )); |
429 | 433 | ||
430 | m_style_changed |= ( index != m_original_style ); | 434 | m_style_changed |= ( index != m_original_style ); |
431 | } | 435 | } |
432 | 436 | ||
433 | void Appearance::styleSettingsClicked ( ) | 437 | void Appearance::styleSettingsClicked ( ) |
434 | { | 438 | { |
435 | StyleListItem *item = (StyleListItem *) m_style_list-> item ( m_style_list-> currentItem ( )); | 439 | StyleListItem *item = (StyleListItem *) m_style_list-> item ( m_style_list-> currentItem ( )); |
436 | 440 | ||
437 | if ( item && item-> hasSettings ( )) { | 441 | if ( item && item-> hasSettings ( )) { |
438 | QDialog *d = new QDialog ( this, "SETTINGS-DLG", true ); | 442 | QDialog *d = new QDialog ( this, "SETTINGS-DLG", true ); |
439 | QVBoxLayout *vbox = new QVBoxLayout ( d, 4, 0 ); | 443 | QVBoxLayout *vbox = new QVBoxLayout ( d, 4, 0 ); |
440 | 444 | ||
441 | QWidget *w = item-> settings ( d ); | 445 | QWidget *w = item-> settings ( d ); |
442 | 446 | ||
443 | if ( w ) { | 447 | if ( w ) { |
444 | vbox-> addWidget ( w ); | 448 | vbox-> addWidget ( w ); |
445 | 449 | ||
446 | d-> setCaption ( w-> caption ( )); | 450 | d-> setCaption ( w-> caption ( )); |
447 | 451 | ||
448 | d-> showMaximized ( ); | 452 | d-> showMaximized ( ); |
449 | bool accepted = ( d-> exec ( ) == QDialog::Accepted ); | 453 | bool accepted = ( d-> exec ( ) == QDialog::Accepted ); |
450 | 454 | ||
451 | if ( item-> setSettings ( accepted )) | 455 | if ( item-> setSettings ( accepted )) |
452 | m_style_changed = true; | 456 | m_style_changed = true; |
453 | } | 457 | } |
454 | delete d; | 458 | delete d; |
455 | } | 459 | } |
456 | } | 460 | } |
457 | 461 | ||
458 | void Appearance::decoClicked ( int index ) | 462 | void Appearance::decoClicked ( int index ) |
459 | { | 463 | { |
460 | DecoListItem *dli = (DecoListItem *) m_deco_list-> item ( index ); | 464 | DecoListItem *dli = (DecoListItem *) m_deco_list-> item ( index ); |
461 | 465 | ||
462 | if ( m_sample ) { | 466 | if ( m_sample ) { |
463 | if ( dli && dli-> interface ( )) | 467 | if ( dli && dli-> interface ( )) |
464 | m_sample-> setDecoration ( dli-> interface ( )); | 468 | m_sample-> setDecoration ( dli-> interface ( )); |
465 | else | 469 | else |
466 | m_sample-> setDecoration ( new DefaultWindowDecoration ( )); | 470 | m_sample-> setDecoration ( new DefaultWindowDecoration ( )); |
467 | } | 471 | } |
468 | m_deco_changed |= ( index != m_original_deco ); | 472 | m_deco_changed |= ( index != m_original_deco ); |
469 | } | 473 | } |
470 | 474 | ||
471 | void Appearance::fontClicked ( const QFont &f ) | 475 | void Appearance::fontClicked ( const QFont &f ) |
472 | { | 476 | { |
473 | m_font_changed |= ( f != m_sample-> font ( )); | 477 | m_font_changed |= ( f != m_sample-> font ( )); |
474 | m_sample-> setFont ( f ); | 478 | m_sample-> setFont ( f ); |
475 | } | 479 | } |
476 | 480 | ||
477 | void Appearance::colorClicked ( int index ) | 481 | void Appearance::colorClicked ( int index ) |
478 | { | 482 | { |
479 | ColorListItem *item = (ColorListItem *) m_color_list-> item ( index ); | 483 | ColorListItem *item = (ColorListItem *) m_color_list-> item ( index ); |
480 | 484 | ||
481 | if ( item ) | 485 | if ( item ) |
482 | m_sample-> setPalette ( item-> palette ( )); | 486 | m_sample-> setPalette ( item-> palette ( )); |
483 | 487 | ||
484 | m_color_changed |= ( item-> palette ( ) != qApp-> palette ( )); | 488 | m_color_changed |= ( item-> palette ( ) != qApp-> palette ( )); |
485 | } | 489 | } |
486 | 490 | ||
487 | 491 | ||
488 | void Appearance::editSchemeClicked ( ) | 492 | void Appearance::editSchemeClicked ( ) |
489 | { | 493 | { |
490 | ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); | 494 | ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); |
491 | 495 | ||
492 | int cnt = 0; | 496 | int cnt = 0; |
493 | QString controlLabel [QColorGroup::NColorRoles]; | 497 | QString labels [QColorGroup::NColorRoles]; |
494 | QString controlColor [QColorGroup::NColorRoles]; | 498 | QColor colors [QColorGroup::NColorRoles]; |
495 | 499 | ||
496 | for ( QColorGroup::ColorRole role = (QColorGroup::ColorRole) 0; role != QColorGroup::NColorRoles; ((int) role )++ ) { | 500 | for ( QColorGroup::ColorRole role = (QColorGroup::ColorRole) 0; role != QColorGroup::NColorRoles; ((int) role )++ ) { |
497 | QColor col = item-> color ( role ); | 501 | QColor col = item-> color ( role ); |
498 | 502 | ||
499 | if ( col. isValid ( )) { | 503 | if ( col. isValid ( )) { |
500 | controlLabel [cnt] = item-> label ( role ); | 504 | labels [cnt] = item-> label ( role ); |
501 | controlColor [cnt] = col. name ( ); | 505 | colors [cnt] = col; |
502 | 506 | ||
503 | cnt++; | 507 | cnt++; |
504 | } | 508 | } |
505 | } | 509 | } |
506 | 510 | ||
507 | EditScheme* editdlg = new EditScheme( this, "editScheme", true, 0, cnt, controlLabel, controlColor ); | 511 | EditScheme* editdlg = new EditScheme( cnt, labels, colors, this, "editScheme", true ); |
508 | editdlg-> showMaximized ( ); | 512 | editdlg-> showMaximized ( ); |
509 | if ( editdlg-> exec ( ) == QDialog::Accepted ) { | 513 | if ( editdlg-> exec ( ) == QDialog::Accepted ) { |
510 | ColorListItem *citem = (ColorListItem *) m_color_list-> item ( 0 ); | 514 | ColorListItem *citem = (ColorListItem *) m_color_list-> item ( 0 ); |
511 | cnt = 0; | 515 | cnt = 0; |
512 | 516 | ||
513 | for ( QColorGroup::ColorRole role = (QColorGroup::ColorRole) 0; role != QColorGroup::NColorRoles; ((int) role )++ ) { | 517 | for ( QColorGroup::ColorRole role = (QColorGroup::ColorRole) 0; role != QColorGroup::NColorRoles; ((int) role )++ ) { |
514 | if ( item-> color ( role ). isValid ( )) { | 518 | if ( item-> color ( role ). isValid ( )) { |
515 | citem-> setColor ( role, QColor ( controlColor [cnt] )); | 519 | citem-> setColor ( role, colors [cnt] ); |
516 | cnt++; | 520 | cnt++; |
517 | } | 521 | } |
518 | } | 522 | } |
519 | 523 | ||
520 | m_color_list-> setCurrentItem ( 0 ); | 524 | m_color_list-> setCurrentItem ( 0 ); |
521 | colorClicked ( 0 ); | 525 | colorClicked ( 0 ); |
522 | 526 | ||
523 | m_color_changed = true; | 527 | m_color_changed = true; |
524 | } | 528 | } |
525 | delete editdlg; | 529 | delete editdlg; |
526 | } | 530 | } |
527 | 531 | ||
528 | 532 | ||
529 | void Appearance::saveSchemeClicked() | 533 | void Appearance::saveSchemeClicked() |
530 | { | 534 | { |
531 | ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); | 535 | ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); |
532 | 536 | ||
533 | if ( !item ) | 537 | if ( !item ) |
534 | return; | 538 | return; |
535 | 539 | ||
536 | QDialog *d = new QDialog ( this, 0, true ); | 540 | QDialog *d = new QDialog ( this, 0, true ); |
537 | d-> setCaption ( tr( "Save Scheme" )); | 541 | d-> setCaption ( tr( "Save Scheme" )); |
538 | QLineEdit *ed = new QLineEdit ( this ); | 542 | QLineEdit *ed = new QLineEdit ( this ); |
539 | ( new QVBoxLayout ( d, 4, 4 ))-> addWidget ( ed ); | 543 | ( new QVBoxLayout ( d, 4, 4 ))-> addWidget ( ed ); |
540 | 544 | ||
541 | if ( d-> exec ( ) == QDialog::Accepted ) { | 545 | if ( d-> exec ( ) == QDialog::Accepted ) { |
542 | QString schemename = ed-> text ( ); | 546 | QString schemename = ed-> text ( ); |
543 | QFile file ( QPEApplication::qpeDir() + "/etc/colors/" + schemename + ".scheme" ); | 547 | QFile file ( QPEApplication::qpeDir() + "/etc/colors/" + schemename + ".scheme" ); |
544 | if ( !file. exists ( )) | 548 | if ( !file. exists ( )) |
545 | { | 549 | { |
546 | QPalette p = item-> palette ( ); | 550 | QPalette p = item-> palette ( ); |
547 | 551 | ||
548 | Config config ( file.name(), Config::File ); | 552 | Config config ( file.name(), Config::File ); |
549 | config. setGroup( "Colors" ); | 553 | config. setGroup( "Colors" ); |
550 | 554 | ||
551 | item-> save ( config ); | 555 | item-> save ( config ); |
552 | 556 | ||
553 | config. write ( ); // need to flush the config info first | 557 | config. write ( ); // need to flush the config info first |
554 | loadColors ( m_color_list ); | 558 | loadColors ( m_color_list ); |
555 | } | 559 | } |
556 | else | 560 | else |
557 | { | 561 | { |
558 | QMessageBox::information ( this, tr( "Save scheme" ), tr( "Scheme does already exist." )); | 562 | QMessageBox::information ( this, tr( "Save scheme" ), tr( "Scheme does already exist." )); |
559 | } | 563 | } |
560 | } | 564 | } |
561 | delete d; | 565 | delete d; |
562 | } | 566 | } |
563 | 567 | ||
564 | void Appearance::deleteSchemeClicked() | 568 | void Appearance::deleteSchemeClicked() |
565 | { | 569 | { |
566 | ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); | 570 | ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); |
567 | 571 | ||
568 | if ( !item ) | 572 | if ( !item ) |
569 | return; | 573 | return; |
570 | 574 | ||
571 | if ( m_color_list-> currentItem ( ) > 0 ) | 575 | if ( m_color_list-> currentItem ( ) > 0 ) |
572 | { | 576 | { |
573 | if ( QMessageBox::warning ( this, tr( "Delete scheme" ), tr( "Do you really want to delete\n" ) + item-> text ( ) + "?", | 577 | if ( QMessageBox::warning ( this, tr( "Delete scheme" ), tr( "Do you really want to delete\n" ) + item-> text ( ) + "?", |
574 | tr( "Yes" ), tr( "No" ), 0, 0, 1 ) == 0 ) { | 578 | tr( "Yes" ), tr( "No" ), 0, 0, 1 ) == 0 ) { |
575 | QFile::remove ( QPEApplication::qpeDir ( ) + "/etc/colors/" + item-> text ( ) + ".scheme" ); | 579 | QFile::remove ( QPEApplication::qpeDir ( ) + "/etc/colors/" + item-> text ( ) + ".scheme" ); |
576 | loadColors ( m_color_list ); | 580 | loadColors ( m_color_list ); |
577 | } | 581 | } |
578 | } | 582 | } |
579 | else | 583 | else |
580 | { | 584 | { |
581 | QMessageBox::information( this, tr( "Delete scheme" ), tr( "Unable to delete current scheme." )); | 585 | QMessageBox::information( this, tr( "Delete scheme" ), tr( "Unable to delete current scheme." )); |
582 | } | 586 | } |
583 | } | 587 | } |
584 | 588 | ||
diff --git a/noncore/settings/appearance2/appearance.h b/noncore/settings/appearance2/appearance.h index 4a86e57..ddf94f2 100644 --- a/noncore/settings/appearance2/appearance.h +++ b/noncore/settings/appearance2/appearance.h | |||
@@ -1,109 +1,113 @@ | |||
1 | /********************************************************************** | 1 | /* |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | =. This file is part of the OPIE Project |
3 | ** | 3 | .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> |
4 | ** This file is part of the Qtopia Environment. | 4 | .>+-= |
5 | ** | 5 | _;:, .> :=|. This library is free software; you can |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | .> <`_, > . <= redistribute it and/or modify it under |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | .="- .-=="i, .._ License as published by the Free Software |
9 | ** packaging of this file. | 9 | - . .-<_> .<> Foundation; either version 2 of the License, |
10 | ** | 10 | ._= =} : or (at your option) any later version. |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | .%`+i> _;_. |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | .i_,=:_. -<s. This library is distributed in the hope that |
13 | ** | 13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | : .. .:, . . . without even the implied warranty of |
15 | ** | 15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
17 | ** not clear to you. | 17 | ..}^=.= = ; Library General Public License for more |
18 | ** | 18 | ++= -. .` .: details. |
19 | *********************************************************************** | 19 | : = ...= . :.=- |
20 | ** | 20 | -. .:....=;==+<; You should have received a copy of the GNU |
21 | ** Enhancements by: Dan Williams, <williamsdr@acm.org> | 21 | -_. . . )=. = Library General Public License along with |
22 | ** | 22 | -- :-=` this library; see the file COPYING.LIB. |
23 | **********************************************************************/ | 23 | If not, write to the Free Software Foundation, |
24 | Inc., 59 Temple Place - Suite 330, | ||
25 | Boston, MA 02111-1307, USA. | ||
26 | |||
27 | */ | ||
24 | 28 | ||
25 | #ifndef APPEARANCESETTINGS_H | 29 | #ifndef APPEARANCESETTINGS_H |
26 | #define APPEARANCESETTINGS_H | 30 | #define APPEARANCESETTINGS_H |
27 | 31 | ||
28 | #include <qpe/fontdatabase.h> | 32 | #include <qpe/fontdatabase.h> |
29 | 33 | ||
30 | #include <qmainwindow.h> | 34 | #include <qmainwindow.h> |
31 | #include <qdialog.h> | 35 | #include <qdialog.h> |
32 | 36 | ||
33 | class QCheckBox; | 37 | class QCheckBox; |
34 | class QComboBox; | 38 | class QComboBox; |
35 | class QLabel; | 39 | class QLabel; |
36 | class QLineEdit; | 40 | class QLineEdit; |
37 | class QListBox; | 41 | class QListBox; |
38 | class QMultiLineEdit; | 42 | class QMultiLineEdit; |
39 | class QPushButton; | 43 | class QPushButton; |
40 | class QRadioButton; | 44 | class QRadioButton; |
41 | class QToolButton; | 45 | class QToolButton; |
42 | class SampleWindow; | 46 | class SampleWindow; |
43 | class OFontSelector; | 47 | class OFontSelector; |
44 | 48 | ||
45 | class Appearance : public QDialog | 49 | class Appearance : public QDialog |
46 | { | 50 | { |
47 | Q_OBJECT | 51 | Q_OBJECT |
48 | 52 | ||
49 | public: | 53 | public: |
50 | Appearance( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); | 54 | Appearance( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 ); |
51 | ~Appearance(); | 55 | ~Appearance(); |
52 | 56 | ||
53 | protected: | 57 | protected: |
54 | virtual void accept ( ); | 58 | virtual void accept ( ); |
55 | virtual void done ( int r ); | 59 | virtual void done ( int r ); |
56 | 60 | ||
57 | protected slots: | 61 | protected slots: |
58 | void styleClicked ( int ); | 62 | void styleClicked ( int ); |
59 | void styleSettingsClicked ( ); | 63 | void styleSettingsClicked ( ); |
60 | void decoClicked ( int ); | 64 | void decoClicked ( int ); |
61 | void fontClicked ( const QFont & ); | 65 | void fontClicked ( const QFont & ); |
62 | void colorClicked ( int ); | 66 | void colorClicked ( int ); |
63 | 67 | ||
64 | void editSchemeClicked(); | 68 | void editSchemeClicked(); |
65 | void saveSchemeClicked(); | 69 | void saveSchemeClicked(); |
66 | void deleteSchemeClicked(); | 70 | void deleteSchemeClicked(); |
67 | 71 | ||
68 | private: | 72 | private: |
69 | void loadStyles ( QListBox * ); | 73 | void loadStyles ( QListBox * ); |
70 | void loadDecos ( QListBox * ); | 74 | void loadDecos ( QListBox * ); |
71 | void loadColors ( QListBox * ); | 75 | void loadColors ( QListBox * ); |
72 | 76 | ||
73 | void changeText(); | 77 | void changeText(); |
74 | 78 | ||
75 | QWidget *createStyleTab ( QWidget *parent ); | 79 | QWidget *createStyleTab ( QWidget *parent ); |
76 | QWidget *createDecoTab ( QWidget *parent ); | 80 | QWidget *createDecoTab ( QWidget *parent ); |
77 | QWidget *createFontTab ( QWidget *parent ); | 81 | QWidget *createFontTab ( QWidget *parent ); |
78 | QWidget *createColorTab ( QWidget *parent ); | 82 | QWidget *createColorTab ( QWidget *parent ); |
79 | QWidget *createGuiTab ( QWidget *parent ); | 83 | QWidget *createGuiTab ( QWidget *parent ); |
80 | 84 | ||
81 | private: | 85 | private: |
82 | bool m_style_changed; | 86 | bool m_style_changed; |
83 | bool m_font_changed; | 87 | bool m_font_changed; |
84 | bool m_scheme_changed; | 88 | bool m_scheme_changed; |
85 | bool m_deco_changed; | 89 | bool m_deco_changed; |
86 | bool m_color_changed; | 90 | bool m_color_changed; |
87 | 91 | ||
88 | int m_original_style; | 92 | int m_original_style; |
89 | int m_original_deco; | 93 | int m_original_deco; |
90 | int m_original_tabstyle; | 94 | int m_original_tabstyle; |
91 | bool m_original_tabpos; | 95 | bool m_original_tabpos; |
92 | 96 | ||
93 | QListBox * m_style_list; | 97 | QListBox * m_style_list; |
94 | QPushButton * m_style_settings; | 98 | QPushButton * m_style_settings; |
95 | 99 | ||
96 | QListBox * m_deco_list; | 100 | QListBox * m_deco_list; |
97 | 101 | ||
98 | QListBox * m_color_list; | 102 | QListBox * m_color_list; |
99 | 103 | ||
100 | OFontSelector *m_fontselect; | 104 | OFontSelector *m_fontselect; |
101 | 105 | ||
102 | SampleWindow *m_sample; | 106 | SampleWindow *m_sample; |
103 | 107 | ||
104 | QComboBox * m_tabstyle_list; | 108 | QComboBox * m_tabstyle_list; |
105 | QRadioButton *m_tabstyle_top; | 109 | QRadioButton *m_tabstyle_top; |
106 | QRadioButton *m_tabstyle_bottom; | 110 | QRadioButton *m_tabstyle_bottom; |
107 | }; | 111 | }; |
108 | 112 | ||
109 | #endif | 113 | #endif |
diff --git a/noncore/settings/appearance2/colorlistitem.h b/noncore/settings/appearance2/colorlistitem.h index 1ff6ecc..1df541b 100644 --- a/noncore/settings/appearance2/colorlistitem.h +++ b/noncore/settings/appearance2/colorlistitem.h | |||
@@ -1,113 +1,141 @@ | |||
1 | /* | ||
2 | =. This file is part of the OPIE Project | ||
3 | .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> | ||
4 | .>+-= | ||
5 | _;:, .> :=|. This library is free software; you can | ||
6 | .> <`_, > . <= redistribute it and/or modify it under | ||
7 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
8 | .="- .-=="i, .._ License as published by the Free Software | ||
9 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
10 | ._= =} : or (at your option) any later version. | ||
11 | .%`+i> _;_. | ||
12 | .i_,=:_. -<s. This library is distributed in the hope that | ||
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
14 | : .. .:, . . . without even the implied warranty of | ||
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
17 | ..}^=.= = ; Library General Public License for more | ||
18 | ++= -. .` .: details. | ||
19 | : = ...= . :.=- | ||
20 | -. .:....=;==+<; You should have received a copy of the GNU | ||
21 | -_. . . )=. = Library General Public License along with | ||
22 | -- :-=` this library; see the file COPYING.LIB. | ||
23 | If not, write to the Free Software Foundation, | ||
24 | Inc., 59 Temple Place - Suite 330, | ||
25 | Boston, MA 02111-1307, USA. | ||
26 | |||
27 | */ | ||
28 | |||
1 | #ifndef COLORLISTITEM_H | 29 | #ifndef COLORLISTITEM_H |
2 | #define COLORLISTITEM_H | 30 | #define COLORLISTITEM_H |
3 | 31 | ||
4 | #include <qlistbox.h> | 32 | #include <qlistbox.h> |
5 | #include <qpalette.h> | 33 | #include <qpalette.h> |
6 | #include <qapplication.h> | 34 | #include <qapplication.h> |
7 | 35 | ||
8 | #include <qpe/config.h> | 36 | #include <qpe/config.h> |
9 | 37 | ||
10 | class Appearance; | 38 | class Appearance; |
11 | 39 | ||
12 | class ColorListItem : public QListBoxText { | 40 | class ColorListItem : public QListBoxText { |
13 | public: | 41 | public: |
14 | ColorListItem ( const QString &t, Config &cfg ) : QListBoxText ( t ) | 42 | ColorListItem ( const QString &t, Config &cfg ) : QListBoxText ( t ) |
15 | { | 43 | { |
16 | m_colors = new QColor [s_colorcount]; | 44 | m_colors = new QColor [s_colorcount]; |
17 | load ( cfg ); | 45 | load ( cfg ); |
18 | } | 46 | } |
19 | 47 | ||
20 | virtual ~ColorListItem ( ) | 48 | virtual ~ColorListItem ( ) |
21 | { | 49 | { |
22 | delete [] m_colors; | 50 | delete [] m_colors; |
23 | } | 51 | } |
24 | 52 | ||
25 | QPalette palette ( ) | 53 | QPalette palette ( ) |
26 | { | 54 | { |
27 | return m_palette; | 55 | return m_palette; |
28 | } | 56 | } |
29 | 57 | ||
30 | bool load ( Config &cfg ) | 58 | bool load ( Config &cfg ) |
31 | { | 59 | { |
32 | for ( int i = 0; i < s_colorcount; i++ ) | 60 | 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 )); | 61 | m_colors [i] = QColor ( cfg. readEntry ( s_colorlut [i]. m_key, s_colorlut [i]. m_def )); |
34 | 62 | ||
35 | buildPalette ( ); | 63 | buildPalette ( ); |
36 | return true; | 64 | return true; |
37 | } | 65 | } |
38 | 66 | ||
39 | void buildPalette ( ) | 67 | void buildPalette ( ) |
40 | { | 68 | { |
41 | m_palette = QPalette ( m_colors [r2i(QColorGroup::Button)], m_colors [r2i(QColorGroup::Background)] ); | 69 | m_palette = QPalette ( m_colors [r2i(QColorGroup::Button)], m_colors [r2i(QColorGroup::Background)] ); |
42 | m_palette. setColor ( QColorGroup::Highlight, m_colors [r2i(QColorGroup::Highlight)] ); | 70 | m_palette. setColor ( QColorGroup::Highlight, m_colors [r2i(QColorGroup::Highlight)] ); |
43 | m_palette. setColor ( QColorGroup::HighlightedText, m_colors [r2i(QColorGroup::HighlightedText)] ); | 71 | m_palette. setColor ( QColorGroup::HighlightedText, m_colors [r2i(QColorGroup::HighlightedText)] ); |
44 | m_palette. setColor ( QColorGroup::Text, m_colors [r2i(QColorGroup::Text)] ); | 72 | m_palette. setColor ( QColorGroup::Text, m_colors [r2i(QColorGroup::Text)] ); |
45 | m_palette. setColor ( QPalette::Active, QColorGroup::ButtonText, m_colors [r2i(QColorGroup::ButtonText)] ); | 73 | m_palette. setColor ( QPalette::Active, QColorGroup::ButtonText, m_colors [r2i(QColorGroup::ButtonText)] ); |
46 | m_palette. setColor ( QColorGroup::Base, m_colors [r2i(QColorGroup::Base)] ); | 74 | 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 ( )); | 75 | m_palette. setColor ( QPalette::Disabled, QColorGroup::Text, m_palette. color ( QPalette::Active, QColorGroup::Background ). dark ( )); |
48 | } | 76 | } |
49 | 77 | ||
50 | bool save ( Config &cfg ) | 78 | bool save ( Config &cfg ) |
51 | { | 79 | { |
52 | for ( int i = 0; i < s_colorcount; i++ ) | 80 | for ( int i = 0; i < s_colorcount; i++ ) |
53 | cfg. writeEntry ( s_colorlut [i]. m_key, m_colors [i]. name ( )); | 81 | cfg. writeEntry ( s_colorlut [i]. m_key, m_colors [i]. name ( )); |
54 | return true; | 82 | return true; |
55 | } | 83 | } |
56 | 84 | ||
57 | QColor color ( QColorGroup::ColorRole role ) | 85 | QColor color ( QColorGroup::ColorRole role ) |
58 | { | 86 | { |
59 | int i = r2i ( role ); | 87 | int i = r2i ( role ); |
60 | return i >= 0 ? m_colors [i] : QColor ( ); | 88 | return i >= 0 ? m_colors [i] : QColor ( ); |
61 | } | 89 | } |
62 | 90 | ||
63 | void setColor ( QColorGroup::ColorRole role, QColor c ) | 91 | void setColor ( QColorGroup::ColorRole role, QColor c ) |
64 | { | 92 | { |
65 | int i = r2i ( role ); | 93 | int i = r2i ( role ); |
66 | if ( i >= 0 ) { | 94 | if ( i >= 0 ) { |
67 | m_colors [i] = c; | 95 | m_colors [i] = c; |
68 | buildPalette ( ); | 96 | buildPalette ( ); |
69 | } | 97 | } |
70 | } | 98 | } |
71 | 99 | ||
72 | QString label ( QColorGroup::ColorRole role ) | 100 | QString label ( QColorGroup::ColorRole role ) |
73 | { | 101 | { |
74 | int i = r2i ( role ); | 102 | int i = r2i ( role ); |
75 | return i >= 0 ? qApp-> translate ( "Appearance", s_colorlut [i]. m_label ) : QString::null; | 103 | return i >= 0 ? qApp-> translate ( "Appearance", s_colorlut [i]. m_label ) : QString::null; |
76 | } | 104 | } |
77 | 105 | ||
78 | private: | 106 | private: |
79 | QPalette m_palette; | 107 | QPalette m_palette; |
80 | QColor *m_colors; | 108 | QColor *m_colors; |
81 | 109 | ||
82 | static struct colorlut { | 110 | static struct colorlut { |
83 | QColorGroup::ColorRole m_role; | 111 | QColorGroup::ColorRole m_role; |
84 | const char * m_key; | 112 | const char * m_key; |
85 | const char * m_def; | 113 | const char * m_def; |
86 | const char * m_label; | 114 | const char * m_label; |
87 | } const s_colorlut []; | 115 | } const s_colorlut []; |
88 | static const int s_colorcount; | 116 | static const int s_colorcount; |
89 | 117 | ||
90 | static int r2i ( QColorGroup::ColorRole role ) | 118 | static int r2i ( QColorGroup::ColorRole role ) |
91 | { | 119 | { |
92 | for ( int i = 0; i < s_colorcount; i++ ) { | 120 | for ( int i = 0; i < s_colorcount; i++ ) { |
93 | if ( s_colorlut [i]. m_role == role ) | 121 | if ( s_colorlut [i]. m_role == role ) |
94 | return i; | 122 | return i; |
95 | } | 123 | } |
96 | return -1; | 124 | return -1; |
97 | } | 125 | } |
98 | }; | 126 | }; |
99 | 127 | ||
100 | const ColorListItem::colorlut ColorListItem::s_colorlut [] = { | 128 | const ColorListItem::colorlut ColorListItem::s_colorlut [] = { |
101 | { QColorGroup::Base, "Base", "#FFFFFF", QT_TRANSLATE_NOOP( "Appearance", "Base" ) }, | 129 | { QColorGroup::Base, "Base", "#FFFFFF", QT_TRANSLATE_NOOP( "Appearance", "Base" ) }, |
102 | { QColorGroup::Background, "Background", "#E5E1D5", QT_TRANSLATE_NOOP( "Appearance", "Background" ) }, | 130 | { QColorGroup::Background, "Background", "#E5E1D5", QT_TRANSLATE_NOOP( "Appearance", "Background" ) }, |
103 | { QColorGroup::Button, "Button", "#D6CDBB", QT_TRANSLATE_NOOP( "Appearance", "Button" ) }, | 131 | { QColorGroup::Button, "Button", "#D6CDBB", QT_TRANSLATE_NOOP( "Appearance", "Button" ) }, |
104 | { QColorGroup::ButtonText, "ButtonText", "#000000", QT_TRANSLATE_NOOP( "Appearance", "Button Text" ) }, | 132 | { QColorGroup::ButtonText, "ButtonText", "#000000", QT_TRANSLATE_NOOP( "Appearance", "Button Text" ) }, |
105 | { QColorGroup::Highlight, "Highlight", "#800000", QT_TRANSLATE_NOOP( "Appearance", "Highlight" ) }, | 133 | { QColorGroup::Highlight, "Highlight", "#800000", QT_TRANSLATE_NOOP( "Appearance", "Highlight" ) }, |
106 | { QColorGroup::HighlightedText, "HighlightedText", "#FFFFFF", QT_TRANSLATE_NOOP( "Appearance", "Highlighted Text" ) }, | 134 | { QColorGroup::HighlightedText, "HighlightedText", "#FFFFFF", QT_TRANSLATE_NOOP( "Appearance", "Highlighted Text" ) }, |
107 | { QColorGroup::Text, "Text", "#000000", QT_TRANSLATE_NOOP( "Appearance", "Text" ) } | 135 | { QColorGroup::Text, "Text", "#000000", QT_TRANSLATE_NOOP( "Appearance", "Text" ) } |
108 | }; | 136 | }; |
109 | 137 | ||
110 | 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] ); |
111 | 139 | ||
112 | 140 | ||
113 | #endif | 141 | #endif |
diff --git a/noncore/settings/appearance2/decolistitem.h b/noncore/settings/appearance2/decolistitem.h index dfdce47..953a939 100644 --- a/noncore/settings/appearance2/decolistitem.h +++ b/noncore/settings/appearance2/decolistitem.h | |||
@@ -1,79 +1,106 @@ | |||
1 | /* | ||
2 | =. This file is part of the OPIE Project | ||
3 | .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> | ||
4 | .>+-= | ||
5 | _;:, .> :=|. This library is free software; you can | ||
6 | .> <`_, > . <= redistribute it and/or modify it under | ||
7 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
8 | .="- .-=="i, .._ License as published by the Free Software | ||
9 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
10 | ._= =} : or (at your option) any later version. | ||
11 | .%`+i> _;_. | ||
12 | .i_,=:_. -<s. This library is distributed in the hope that | ||
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
14 | : .. .:, . . . without even the implied warranty of | ||
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
17 | ..}^=.= = ; Library General Public License for more | ||
18 | ++= -. .` .: details. | ||
19 | : = ...= . :.=- | ||
20 | -. .:....=;==+<; You should have received a copy of the GNU | ||
21 | -_. . . )=. = Library General Public License along with | ||
22 | -- :-=` this library; see the file COPYING.LIB. | ||
23 | If not, write to the Free Software Foundation, | ||
24 | Inc., 59 Temple Place - Suite 330, | ||
25 | Boston, MA 02111-1307, USA. | ||
26 | |||
27 | */ | ||
1 | #ifndef DECOLISTITEM_H | 28 | #ifndef DECOLISTITEM_H |
2 | #define DECOLISTITEM_H | 29 | #define DECOLISTITEM_H |
3 | 30 | ||
4 | #include <qpe/windowdecorationinterface.h> | 31 | #include <qpe/windowdecorationinterface.h> |
5 | #include <qlistbox.h> | 32 | #include <qlistbox.h> |
6 | 33 | ||
7 | class DecoListItem : public QListBoxText { | 34 | class DecoListItem : public QListBoxText { |
8 | public: | 35 | public: |
9 | DecoListItem ( const QString &t ) : QListBoxText ( t ) | 36 | DecoListItem ( const QString &t ) : QListBoxText ( t ) |
10 | { | 37 | { |
11 | m_lib = 0; | 38 | m_lib = 0; |
12 | m_window_if = 0; | 39 | m_window_if = 0; |
13 | // m_settings_if = 0; | 40 | // m_settings_if = 0; |
14 | } | 41 | } |
15 | 42 | ||
16 | DecoListItem ( QLibrary *lib, WindowDecorationInterface *iface ) : QListBoxText ( iface-> name ( )) | 43 | DecoListItem ( QLibrary *lib, WindowDecorationInterface *iface ) : QListBoxText ( iface-> name ( )) |
17 | { | 44 | { |
18 | m_lib = lib; | 45 | m_lib = lib; |
19 | m_window_if = iface; | 46 | m_window_if = iface; |
20 | 47 | ||
21 | // iface-> queryInterface ( IID_WindowDecoration, (QUnknownInterface **) &m_settings_if ); | 48 | // iface-> queryInterface ( IID_WindowDecoration, (QUnknownInterface **) &m_settings_if ); |
22 | } | 49 | } |
23 | 50 | ||
24 | virtual ~DecoListItem ( ) | 51 | virtual ~DecoListItem ( ) |
25 | { | 52 | { |
26 | // if ( m_settings_if ) | 53 | // if ( m_settings_if ) |
27 | // m_settings_if-> release ( ); | 54 | // m_settings_if-> release ( ); |
28 | if ( m_window_if ) | 55 | if ( m_window_if ) |
29 | m_window_if-> release ( ); | 56 | m_window_if-> release ( ); |
30 | delete m_lib; | 57 | delete m_lib; |
31 | } | 58 | } |
32 | 59 | ||
33 | bool hasSettings ( ) const | 60 | bool hasSettings ( ) const |
34 | { | 61 | { |
35 | // return ( m_settings_if ); | 62 | // return ( m_settings_if ); |
36 | return false; | 63 | return false; |
37 | } | 64 | } |
38 | 65 | ||
39 | QWidget *settings ( QWidget * /*parent*/ ) | 66 | QWidget *settings ( QWidget * /*parent*/ ) |
40 | { | 67 | { |
41 | // return m_settings_if ? m_settings_if-> create ( parent ) : 0; | 68 | // return m_settings_if ? m_settings_if-> create ( parent ) : 0; |
42 | return 0; | 69 | return 0; |
43 | } | 70 | } |
44 | 71 | ||
45 | bool setSettings ( bool /*accepted*/ ) | 72 | bool setSettings ( bool /*accepted*/ ) |
46 | { | 73 | { |
47 | // if ( !m_settings_if ) | 74 | // if ( !m_settings_if ) |
48 | // return false; | 75 | // return false; |
49 | 76 | ||
50 | // if ( accepted ) | 77 | // if ( accepted ) |
51 | // return m_settings_if-> accept ( ); | 78 | // return m_settings_if-> accept ( ); |
52 | // else { | 79 | // else { |
53 | // m_settings_if-> reject ( ); | 80 | // m_settings_if-> reject ( ); |
54 | // return false; | 81 | // return false; |
55 | // } | 82 | // } |
56 | return false; | 83 | return false; |
57 | } | 84 | } |
58 | 85 | ||
59 | QString key ( ) | 86 | QString key ( ) |
60 | { | 87 | { |
61 | if ( m_window_if ) | 88 | if ( m_window_if ) |
62 | return QString ( m_window_if-> name ( )); | 89 | return QString ( m_window_if-> name ( )); |
63 | else | 90 | else |
64 | return text ( ); | 91 | return text ( ); |
65 | } | 92 | } |
66 | 93 | ||
67 | WindowDecorationInterface *interface ( ) | 94 | WindowDecorationInterface *interface ( ) |
68 | { | 95 | { |
69 | return m_window_if; | 96 | return m_window_if; |
70 | } | 97 | } |
71 | 98 | ||
72 | private: | 99 | private: |
73 | QLibrary *m_lib; | 100 | QLibrary *m_lib; |
74 | WindowDecorationInterface *m_window_if; | 101 | WindowDecorationInterface *m_window_if; |
75 | //WindowDecorationSettingsInterface *m_settings_if; | 102 | //WindowDecorationSettingsInterface *m_settings_if; |
76 | 103 | ||
77 | }; | 104 | }; |
78 | 105 | ||
79 | #endif \ No newline at end of file | 106 | #endif \ No newline at end of file |
diff --git a/noncore/settings/appearance2/editScheme.cpp b/noncore/settings/appearance2/editScheme.cpp index 4f2ac2c..8cb0f1c 100644 --- a/noncore/settings/appearance2/editScheme.cpp +++ b/noncore/settings/appearance2/editScheme.cpp | |||
@@ -1,87 +1,73 @@ | |||
1 | /********************************************************************** | 1 | /* |
2 | ** EditScheme | 2 | =. This file is part of the OPIE Project |
3 | ** | 3 | .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> |
4 | ** Dialog for editing color scheme | 4 | .>+-= |
5 | ** | 5 | _;:, .> :=|. This library is free software; you can |
6 | ** Copyright (C) 2002, Dan Williams | 6 | .> <`_, > . <= redistribute it and/or modify it under |
7 | ** williamsdr@acm.org | 7 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
8 | ** http://draknor.net | 8 | .="- .-=="i, .._ License as published by the Free Software |
9 | ** | 9 | - . .-<_> .<> Foundation; either version 2 of the License, |
10 | ** This file may be distributed and/or modified under the terms of the | 10 | ._= =} : or (at your option) any later version. |
11 | ** GNU General Public License version 2 as published by the Free Software | 11 | .%`+i> _;_. |
12 | ** Foundation and appearing in the file LICENSE.GPL included in the | 12 | .i_,=:_. -<s. This library is distributed in the hope that |
13 | ** packaging of this file. | 13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
14 | ** | 14 | : .. .:, . . . without even the implied warranty of |
15 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
16 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
17 | ** | 17 | ..}^=.= = ; Library General Public License for more |
18 | **********************************************************************/ | 18 | ++= -. .` .: details. |
19 | : = ...= . :.=- | ||
20 | -. .:....=;==+<; You should have received a copy of the GNU | ||
21 | -_. . . )=. = Library General Public License along with | ||
22 | -- :-=` this library; see the file COPYING.LIB. | ||
23 | If not, write to the Free Software Foundation, | ||
24 | Inc., 59 Temple Place - Suite 330, | ||
25 | Boston, MA 02111-1307, USA. | ||
26 | |||
27 | */ | ||
19 | 28 | ||
20 | #include "editScheme.h" | 29 | #include "editScheme.h" |
21 | 30 | ||
22 | #include "opie/colorpopupmenu.h" | 31 | #include <opie/ocolorbutton.h> |
23 | 32 | ||
24 | #include <qaction.h> | 33 | #include <qaction.h> |
25 | #include <qlabel.h> | 34 | #include <qlabel.h> |
26 | #include <qlayout.h> | 35 | #include <qlayout.h> |
27 | #include <qpopupmenu.h> | 36 | #include <qpopupmenu.h> |
28 | #include <qscrollview.h> | 37 | #include <qscrollview.h> |
29 | #include <qtoolbutton.h> | 38 | #include <qtoolbutton.h> |
30 | 39 | ||
31 | EditScheme::EditScheme( QWidget* parent, const char* name, bool modal, WFlags fl, | 40 | EditScheme::EditScheme ( int cnt, const QString *labels, QColor *colors, QWidget* parent, const char* name, bool modal, WFlags fl ) |
32 | int max, QString *list, QString *colors ) | 41 | : QDialog ( parent, name, modal, fl ) |
33 | : QDialog( parent, name, modal, fl ) | ||
34 | { | 42 | { |
35 | setCaption( tr( "Edit scheme" ) ); | 43 | setCaption ( tr( "Edit scheme" ) ); |
36 | QGridLayout* layout = new QGridLayout( this ); | 44 | QGridLayout *layout = new QGridLayout ( this, 0, 0, 4, 4 ); |
37 | layout->setSpacing( 4 ); | ||
38 | layout->setMargin( 4 ); | ||
39 | |||
40 | 45 | ||
41 | maxCount = max; | 46 | m_count = cnt; |
42 | colorList = colors; | 47 | m_buttons = new OColorButton * [cnt]; |
43 | surfaceList = list; | 48 | m_colors = colors; |
44 | colorButtons = new QToolButton * [max]; | 49 | |
45 | int i; | 50 | for ( int i = 0; i < cnt; i++ ) |
46 | QLabel* label; | ||
47 | ColorPopupMenu* colorPopupMenu; | ||
48 | for ( i = 0; i < max; i++ ) | ||
49 | { | 51 | { |
50 | // colorList[i] = colors[i]; | 52 | QLabel *l = new QLabel ( labels [i], this ); |
51 | // surfaceList[i] = list[i]; | 53 | layout-> addWidget ( l, i, 0 ); |
52 | label = new QLabel( tr( surfaceList[i] ), this ); | 54 | |
53 | layout->addWidget( label, i, 0 ); | 55 | m_buttons [i] = new OColorButton ( this ); |
54 | colorButtons[i] = new QToolButton( this, list[i] ); | 56 | m_buttons [i]-> setColor ( colors [i] ); |
55 | colorButtons[i]->setPalette( QPalette( QColor( colors[i] ) ) ); | 57 | layout-> addWidget ( m_buttons [i], i, 1 ); |
56 | layout->addWidget( colorButtons[i], i, 1 ); | ||
57 | |||
58 | colorPopupMenu = new ColorPopupMenu( colors[i], 0, list[i] ); | ||
59 | colorButtons[i]->setPopup( colorPopupMenu ); | ||
60 | colorButtons[i]->setPopupDelay( 0 ); | ||
61 | connect( colorPopupMenu, SIGNAL( colorSelected( const QColor& ) ), this, SLOT( changeColor( const QColor& ) ) ); | ||
62 | } | 58 | } |
63 | } | 59 | } |
64 | 60 | ||
65 | EditScheme::~EditScheme() | 61 | EditScheme::~EditScheme ( ) |
66 | { | 62 | { |
67 | delete [] colorButtons; | 63 | delete [] m_buttons; |
68 | } | 64 | } |
69 | 65 | ||
70 | void EditScheme::changeColor( const QColor& color ) | 66 | void EditScheme::accept ( ) |
71 | { | 67 | { |
72 | QString name( sender()->name() ); | 68 | for ( int i = 0; i < m_count; i++ ) |
73 | int i; | 69 | m_colors [i] = m_buttons [i]-> color ( ); |
74 | 70 | ||
75 | for ( i = 0; i < maxCount; i++ ) | 71 | QDialog::accept ( ); |
76 | { | ||
77 | if ( name == colorButtons[i]->name() ) | ||
78 | { | ||
79 | break; | ||
80 | } | ||
81 | } | ||
82 | if ( i < maxCount && name == colorButtons[i]->name() ) | ||
83 | { | ||
84 | colorList[i] = color.name(); | ||
85 | colorButtons[i]->setPalette( QPalette( QColor( colorList[i] ) ) ); | ||
86 | } | ||
87 | } | 72 | } |
73 | |||
diff --git a/noncore/settings/appearance2/editScheme.h b/noncore/settings/appearance2/editScheme.h index 583050f..0a025bd 100644 --- a/noncore/settings/appearance2/editScheme.h +++ b/noncore/settings/appearance2/editScheme.h | |||
@@ -1,48 +1,53 @@ | |||
1 | /********************************************************************** | 1 | /* |
2 | ** EditScheme | 2 | =. This file is part of the OPIE Project |
3 | ** | 3 | .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> |
4 | ** Dialog for editing color scheme | 4 | .>+-= |
5 | ** | 5 | _;:, .> :=|. This library is free software; you can |
6 | ** Copyright (C) 2002, Dan Williams | 6 | .> <`_, > . <= redistribute it and/or modify it under |
7 | ** williamsdr@acm.org | 7 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
8 | ** http://draknor.net | 8 | .="- .-=="i, .._ License as published by the Free Software |
9 | ** | 9 | - . .-<_> .<> Foundation; either version 2 of the License, |
10 | ** This file may be distributed and/or modified under the terms of the | 10 | ._= =} : or (at your option) any later version. |
11 | ** GNU General Public License version 2 as published by the Free Software | 11 | .%`+i> _;_. |
12 | ** Foundation and appearing in the file LICENSE.GPL included in the | 12 | .i_,=:_. -<s. This library is distributed in the hope that |
13 | ** packaging of this file. | 13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
14 | ** | 14 | : .. .:, . . . without even the implied warranty of |
15 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
16 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
17 | ** | 17 | ..}^=.= = ; Library General Public License for more |
18 | **********************************************************************/ | 18 | ++= -. .` .: details. |
19 | : = ...= . :.=- | ||
20 | -. .:....=;==+<; You should have received a copy of the GNU | ||
21 | -_. . . )=. = Library General Public License along with | ||
22 | -- :-=` this library; see the file COPYING.LIB. | ||
23 | If not, write to the Free Software Foundation, | ||
24 | Inc., 59 Temple Place - Suite 330, | ||
25 | Boston, MA 02111-1307, USA. | ||
26 | |||
27 | */ | ||
19 | 28 | ||
20 | #ifndef EDITSCHEME_H | 29 | #ifndef EDITSCHEME_H |
21 | #define EDITSCHEME_H | 30 | #define EDITSCHEME_H |
22 | 31 | ||
23 | #include <qdialog.h> | 32 | #include <qdialog.h> |
24 | #include <qtoolbutton.h> | ||
25 | 33 | ||
26 | class QColor; | 34 | class QColor; |
35 | class OColorButton; | ||
27 | 36 | ||
28 | class EditScheme : public QDialog | 37 | class EditScheme : public QDialog { |
29 | { | 38 | Q_OBJECT |
30 | Q_OBJECT | ||
31 | 39 | ||
32 | public: | 40 | public: |
33 | EditScheme( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0, | 41 | EditScheme ( int cnt, const QString *labels, QColor *colors, QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); |
34 | int = 0, QString * = 0, QString * = 0 ); | 42 | virtual ~EditScheme ( ); |
35 | ~EditScheme(); | ||
36 | |||
37 | int maxCount; | ||
38 | QString * surfaceList; | ||
39 | QString * colorList; | ||
40 | |||
41 | |||
42 | QToolButton** colorButtons; | ||
43 | 43 | ||
44 | protected slots: | 44 | protected slots: |
45 | void changeColor( const QColor& ); | 45 | virtual void accept ( ); |
46 | |||
47 | private: | ||
48 | int m_count; | ||
49 | QColor *m_colors; | ||
50 | OColorButton **m_buttons; | ||
46 | }; | 51 | }; |
47 | 52 | ||
48 | #endif // EDITSCHEME_H | 53 | #endif |
diff --git a/noncore/settings/appearance2/main.cpp b/noncore/settings/appearance2/main.cpp index cfbab0b..3afec46 100644 --- a/noncore/settings/appearance2/main.cpp +++ b/noncore/settings/appearance2/main.cpp | |||
@@ -1,35 +1,43 @@ | |||
1 | /********************************************************************** | 1 | /* |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | =. This file is part of the OPIE Project |
3 | ** | 3 | .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> |
4 | ** This file is part of Qtopia Environment. | 4 | .>+-= |
5 | ** | 5 | _;:, .> :=|. This library is free software; you can |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | .> <`_, > . <= redistribute it and/or modify it under |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | .="- .-=="i, .._ License as published by the Free Software |
9 | ** packaging of this file. | 9 | - . .-<_> .<> Foundation; either version 2 of the License, |
10 | ** | 10 | ._= =} : or (at your option) any later version. |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | .%`+i> _;_. |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | .i_,=:_. -<s. This library is distributed in the hope that |
13 | ** | 13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | : .. .:, . . . without even the implied warranty of |
15 | ** | 15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
17 | ** not clear to you. | 17 | ..}^=.= = ; Library General Public License for more |
18 | ** | 18 | ++= -. .` .: details. |
19 | **********************************************************************/ | 19 | : = ...= . :.=- |
20 | -. .:....=;==+<; You should have received a copy of the GNU | ||
21 | -_. . . )=. = Library General Public License along with | ||
22 | -- :-=` this library; see the file COPYING.LIB. | ||
23 | If not, write to the Free Software Foundation, | ||
24 | Inc., 59 Temple Place - Suite 330, | ||
25 | Boston, MA 02111-1307, USA. | ||
26 | |||
27 | */ | ||
20 | 28 | ||
21 | #include "appearance.h" | 29 | #include "appearance.h" |
22 | 30 | ||
23 | #include <qpe/qpeapplication.h> | 31 | #include <qpe/qpeapplication.h> |
24 | 32 | ||
25 | 33 | ||
26 | int main ( int argc, char **argv ) | 34 | int main ( int argc, char **argv ) |
27 | { | 35 | { |
28 | QPEApplication app ( argc, argv ); | 36 | QPEApplication app ( argc, argv ); |
29 | 37 | ||
30 | Appearance m; | 38 | Appearance m; |
31 | app. showMainDocumentWidget ( &m ); | 39 | app. showMainDocumentWidget ( &m ); |
32 | 40 | ||
33 | return app. exec ( ); | 41 | return app. exec ( ); |
34 | } | 42 | } |
35 | 43 | ||
diff --git a/noncore/settings/appearance2/sample.cpp b/noncore/settings/appearance2/sample.cpp index e447002..0d8b003 100644 --- a/noncore/settings/appearance2/sample.cpp +++ b/noncore/settings/appearance2/sample.cpp | |||
@@ -1,243 +1,272 @@ | |||
1 | /* | ||
2 | This file is part of the OPIE Project | ||
3 | =. Copyright (c) 2002 Trolltech AS <info@trolltech.com> | ||
4 | .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> | ||
5 | .>+-= | ||
6 | _;:, .> :=|. This library is free software; you can | ||
7 | .> <`_, > . <= redistribute it and/or modify it under | ||
8 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
9 | .="- .-=="i, .._ License as published by the Free Software | ||
10 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
11 | ._= =} : or (at your option) any later version. | ||
12 | .%`+i> _;_. | ||
13 | .i_,=:_. -<s. This library is distributed in the hope that | ||
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
15 | : .. .:, . . . without even the implied warranty of | ||
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
18 | ..}^=.= = ; Library General Public License for more | ||
19 | ++= -. .` .: details. | ||
20 | : = ...= . :.=- | ||
21 | -. .:....=;==+<; You should have received a copy of the GNU | ||
22 | -_. . . )=. = Library General Public License along with | ||
23 | -- :-=` this library; see the file COPYING.LIB. | ||
24 | If not, write to the Free Software Foundation, | ||
25 | Inc., 59 Temple Place - Suite 330, | ||
26 | Boston, MA 02111-1307, USA. | ||
27 | |||
28 | */ | ||
29 | |||
1 | #include <qvbox.h> | 30 | #include <qvbox.h> |
2 | #include <qpopupmenu.h> | 31 | #include <qpopupmenu.h> |
3 | #include <qpainter.h> | 32 | #include <qpainter.h> |
4 | #include <qmenubar.h> | 33 | #include <qmenubar.h> |
5 | #include <qcheckbox.h> | 34 | #include <qcheckbox.h> |
6 | #include <qpushbutton.h> | 35 | #include <qpushbutton.h> |
7 | #include <qscrollbar.h> | 36 | #include <qscrollbar.h> |
8 | #include <qlayout.h> | 37 | #include <qlayout.h> |
9 | #include <qwhatsthis.h> | 38 | #include <qwhatsthis.h> |
10 | #include <qpixmapcache.h> | 39 | #include <qpixmapcache.h> |
11 | #include <qtimer.h> | 40 | #include <qtimer.h> |
12 | #include <qobjectlist.h> | 41 | #include <qobjectlist.h> |
13 | #include <qcommonstyle.h> | 42 | #include <qcommonstyle.h> |
14 | 43 | ||
15 | #include "sample.h" | 44 | #include "sample.h" |
16 | 45 | ||
17 | 46 | ||
18 | class SampleText : public QWidget | 47 | class SampleText : public QWidget |
19 | { | 48 | { |
20 | public: | 49 | public: |
21 | SampleText( const QString &t, bool h, QWidget *parent ) | 50 | SampleText( const QString &t, bool h, QWidget *parent ) |
22 | : QWidget( parent ), hl(h), text(t) | 51 | : QWidget( parent ), hl(h), text(t) |
23 | { | 52 | { |
24 | if ( hl ) | 53 | if ( hl ) |
25 | setBackgroundMode( PaletteHighlight ); | 54 | setBackgroundMode( PaletteHighlight ); |
26 | else | 55 | else |
27 | setBackgroundMode( PaletteBase ); | 56 | setBackgroundMode( PaletteBase ); |
28 | } | 57 | } |
29 | 58 | ||
30 | QSize sizeHint() const | 59 | QSize sizeHint() const |
31 | { | 60 | { |
32 | QFontMetrics fm(font()); | 61 | QFontMetrics fm(font()); |
33 | return QSize( fm.width(text)+10, fm.height()+4 ); | 62 | return QSize( fm.width(text)+10, fm.height()+4 ); |
34 | } | 63 | } |
35 | 64 | ||
36 | void paintEvent( QPaintEvent * ) | 65 | void paintEvent( QPaintEvent * ) |
37 | { | 66 | { |
38 | QPainter p(this); | 67 | QPainter p(this); |
39 | if ( hl ) | 68 | if ( hl ) |
40 | p.setPen( colorGroup().highlightedText() ); | 69 | p.setPen( colorGroup().highlightedText() ); |
41 | else | 70 | else |
42 | p.setPen( colorGroup().text() ); | 71 | p.setPen( colorGroup().text() ); |
43 | p.drawText( rect(), AlignCenter, text ); | 72 | p.drawText( rect(), AlignCenter, text ); |
44 | } | 73 | } |
45 | 74 | ||
46 | private: | 75 | private: |
47 | bool hl; | 76 | bool hl; |
48 | QString text; | 77 | QString text; |
49 | }; | 78 | }; |
50 | 79 | ||
51 | 80 | ||
52 | SampleWindow::SampleWindow( QWidget *parent ) : QWidget(parent), iface(0) | 81 | SampleWindow::SampleWindow( QWidget *parent ) : QWidget(parent), iface(0) |
53 | { | 82 | { |
54 | init(); | 83 | init(); |
55 | } | 84 | } |
56 | 85 | ||
57 | QSize SampleWindow::sizeHint() const | 86 | QSize SampleWindow::sizeHint() const |
58 | { | 87 | { |
59 | return container->sizeHint() + QSize( 10, 35 ); | 88 | return container->sizeHint() + QSize( 10, 35 ); |
60 | } | 89 | } |
61 | 90 | ||
62 | void SampleWindow::setFont( const QFont &f ) | 91 | void SampleWindow::setFont( const QFont &f ) |
63 | { | 92 | { |
64 | QWidget::setFont( f ); | 93 | QWidget::setFont( f ); |
65 | popup->setFont( f ); | 94 | popup->setFont( f ); |
66 | QTimer::singleShot ( 0, this, SLOT( fixGeometry ( ))); | 95 | QTimer::singleShot ( 0, this, SLOT( fixGeometry ( ))); |
67 | } | 96 | } |
68 | 97 | ||
69 | static void setStyleRecursive ( QWidget *w, QStyle *s ) | 98 | static void setStyleRecursive ( QWidget *w, QStyle *s ) |
70 | { | 99 | { |
71 | w->setStyle( s ); | 100 | w->setStyle( s ); |
72 | QObjectList *childObjects=(QObjectList*)w->children(); | 101 | QObjectList *childObjects=(QObjectList*)w->children(); |
73 | if ( childObjects ) { | 102 | if ( childObjects ) { |
74 | QObject * o; | 103 | QObject * o; |
75 | for(o=childObjects->first();o!=0;o=childObjects->next()) { | 104 | for(o=childObjects->first();o!=0;o=childObjects->next()) { |
76 | if( o->isWidgetType() ) { | 105 | if( o->isWidgetType() ) { |
77 | setStyleRecursive((QWidget *)o,s); | 106 | setStyleRecursive((QWidget *)o,s); |
78 | } | 107 | } |
79 | } | 108 | } |
80 | } | 109 | } |
81 | } | 110 | } |
82 | 111 | ||
83 | 112 | ||
84 | void SampleWindow::setStyle2 ( QStyle *sty ) | 113 | void SampleWindow::setStyle2 ( QStyle *sty ) |
85 | { | 114 | { |
86 | typedef void (QStyle::*QDrawMenuBarItemImpl) (QPainter *, int, int, int, int, QMenuItem *, QColorGroup &, bool, bool); | 115 | typedef void (QStyle::*QDrawMenuBarItemImpl) (QPainter *, int, int, int, int, QMenuItem *, QColorGroup &, bool, bool); |
87 | 116 | ||
88 | extern QDrawMenuBarItemImpl qt_set_draw_menu_bar_impl(QDrawMenuBarItemImpl); | 117 | extern QDrawMenuBarItemImpl qt_set_draw_menu_bar_impl(QDrawMenuBarItemImpl); |
89 | 118 | ||
90 | QPixmapCache::clear ( ); | 119 | QPixmapCache::clear ( ); |
91 | QPalette p = palette ( ); | 120 | QPalette p = palette ( ); |
92 | sty-> polish ( p ); | 121 | sty-> polish ( p ); |
93 | qt_set_draw_menu_bar_impl ( 0 ); | 122 | qt_set_draw_menu_bar_impl ( 0 ); |
94 | setStyleRecursive ( this, sty ); | 123 | setStyleRecursive ( this, sty ); |
95 | setPalette ( p ); | 124 | setPalette ( p ); |
96 | QTimer::singleShot ( 0, this, SLOT( fixGeometry ( ))); | 125 | QTimer::singleShot ( 0, this, SLOT( fixGeometry ( ))); |
97 | } | 126 | } |
98 | 127 | ||
99 | 128 | ||
100 | void SampleWindow::setDecoration( WindowDecorationInterface *i ) | 129 | void SampleWindow::setDecoration( WindowDecorationInterface *i ) |
101 | { | 130 | { |
102 | iface = i; | 131 | iface = i; |
103 | wd.rect = QRect( 0, 0, 150, 75 ); | 132 | wd.rect = QRect( 0, 0, 150, 75 ); |
104 | wd.caption = tr("Sample"); | 133 | wd.caption = tr("Sample"); |
105 | wd.palette = palette(); | 134 | wd.palette = palette(); |
106 | wd.flags = WindowDecorationInterface::WindowData::Dialog | | 135 | wd.flags = WindowDecorationInterface::WindowData::Dialog | |
107 | WindowDecorationInterface::WindowData::Active; | 136 | WindowDecorationInterface::WindowData::Active; |
108 | wd.reserved = 1; | 137 | wd.reserved = 1; |
109 | 138 | ||
110 | th = iface->metric(WindowDecorationInterface::TitleHeight, &wd); | 139 | th = iface->metric(WindowDecorationInterface::TitleHeight, &wd); |
111 | tb = iface->metric(WindowDecorationInterface::TopBorder, &wd); | 140 | tb = iface->metric(WindowDecorationInterface::TopBorder, &wd); |
112 | lb = iface->metric(WindowDecorationInterface::LeftBorder, &wd); | 141 | lb = iface->metric(WindowDecorationInterface::LeftBorder, &wd); |
113 | rb = iface->metric(WindowDecorationInterface::RightBorder, &wd); | 142 | rb = iface->metric(WindowDecorationInterface::RightBorder, &wd); |
114 | bb = iface->metric(WindowDecorationInterface::BottomBorder, &wd); | 143 | bb = iface->metric(WindowDecorationInterface::BottomBorder, &wd); |
115 | 144 | ||
116 | int yoff = th + tb; | 145 | int yoff = th + tb; |
117 | int xoff = lb; | 146 | int xoff = lb; |
118 | 147 | ||
119 | wd.rect.setX( 0 ); | 148 | wd.rect.setX( 0 ); |
120 | wd.rect.setWidth( width() - lb - rb ); | 149 | wd.rect.setWidth( width() - lb - rb ); |
121 | wd.rect.setY( 0 ); | 150 | wd.rect.setY( 0 ); |
122 | wd.rect.setHeight( height() - yoff - bb ); | 151 | wd.rect.setHeight( height() - yoff - bb ); |
123 | 152 | ||
124 | container->setGeometry( xoff, yoff, wd.rect.width(), wd.rect.height() ); | 153 | container->setGeometry( xoff, yoff, wd.rect.width(), wd.rect.height() ); |
125 | setMinimumSize( container->sizeHint().width()+lb+rb, | 154 | setMinimumSize( container->sizeHint().width()+lb+rb, |
126 | container->sizeHint().height()+tb+th+bb ); | 155 | container->sizeHint().height()+tb+th+bb ); |
127 | } | 156 | } |
128 | 157 | ||
129 | void SampleWindow::paintEvent( QPaintEvent * ) | 158 | void SampleWindow::paintEvent( QPaintEvent * ) |
130 | { | 159 | { |
131 | if ( !iface ) | 160 | if ( !iface ) |
132 | return; | 161 | return; |
133 | 162 | ||
134 | QPainter p( this ); | 163 | QPainter p( this ); |
135 | 164 | ||
136 | p.translate( lb, th+tb ); | 165 | p.translate( lb, th+tb ); |
137 | 166 | ||
138 | iface->drawArea(WindowDecorationInterface::Border, &p, &wd); | 167 | iface->drawArea(WindowDecorationInterface::Border, &p, &wd); |
139 | iface->drawArea(WindowDecorationInterface::Title, &p, &wd); | 168 | iface->drawArea(WindowDecorationInterface::Title, &p, &wd); |
140 | 169 | ||
141 | p.setPen(palette().active().color(QColorGroup::HighlightedText)); | 170 | p.setPen(palette().active().color(QColorGroup::HighlightedText)); |
142 | QFont f( font() ); | 171 | QFont f( font() ); |
143 | f.setWeight( QFont::Bold ); | 172 | f.setWeight( QFont::Bold ); |
144 | p.setFont(f); | 173 | p.setFont(f); |
145 | iface->drawArea(WindowDecorationInterface::TitleText, &p, &wd); | 174 | iface->drawArea(WindowDecorationInterface::TitleText, &p, &wd); |
146 | 175 | ||
147 | QRect brect( 0, -th, iface->metric(WindowDecorationInterface::HelpWidth,&wd), th ); | 176 | QRect brect( 0, -th, iface->metric(WindowDecorationInterface::HelpWidth,&wd), th ); |
148 | iface->drawButton( WindowDecorationInterface::Help, &p, &wd, | 177 | iface->drawButton( WindowDecorationInterface::Help, &p, &wd, |
149 | brect.x(), brect.y(), brect.width(), brect.height(), (QWSButton::State)0 ); | 178 | brect.x(), brect.y(), brect.width(), brect.height(), (QWSButton::State)0 ); |
150 | brect.moveBy( wd.rect.width() - | 179 | brect.moveBy( wd.rect.width() - |
151 | iface->metric(WindowDecorationInterface::OKWidth,&wd) - | 180 | iface->metric(WindowDecorationInterface::OKWidth,&wd) - |
152 | iface->metric(WindowDecorationInterface::CloseWidth,&wd), 0 ); | 181 | iface->metric(WindowDecorationInterface::CloseWidth,&wd), 0 ); |
153 | iface->drawButton( WindowDecorationInterface::Close, &p, &wd, | 182 | iface->drawButton( WindowDecorationInterface::Close, &p, &wd, |
154 | brect.x(), brect.y(), brect.width(), brect.height(), (QWSButton::State)0 ); | 183 | brect.x(), brect.y(), brect.width(), brect.height(), (QWSButton::State)0 ); |
155 | brect.moveBy( iface->metric(WindowDecorationInterface::CloseWidth,&wd), 0 ); | 184 | brect.moveBy( iface->metric(WindowDecorationInterface::CloseWidth,&wd), 0 ); |
156 | iface->drawButton( WindowDecorationInterface::OK, &p, &wd, | 185 | iface->drawButton( WindowDecorationInterface::OK, &p, &wd, |
157 | brect.x(), brect.y(), brect.width(), brect.height(), (QWSButton::State)0 ); | 186 | brect.x(), brect.y(), brect.width(), brect.height(), (QWSButton::State)0 ); |
158 | } | 187 | } |
159 | 188 | ||
160 | void SampleWindow::init() | 189 | void SampleWindow::init() |
161 | { | 190 | { |
162 | container = new QVBox( this ); | 191 | container = new QVBox( this ); |
163 | popup = new QPopupMenu( this ); | 192 | popup = new QPopupMenu( this ); |
164 | popup->insertItem( tr("Normal Item"), 1 ); | 193 | popup->insertItem( tr("Normal Item"), 1 ); |
165 | popup->insertItem( tr("Disabled Item"), 2 ); | 194 | popup->insertItem( tr("Disabled Item"), 2 ); |
166 | popup->setItemEnabled(2, FALSE); | 195 | popup->setItemEnabled(2, FALSE); |
167 | QMenuBar *mb = new QMenuBar( container ); | 196 | QMenuBar *mb = new QMenuBar( container ); |
168 | mb->insertItem( tr("Menu"), popup ); | 197 | mb->insertItem( tr("Menu"), popup ); |
169 | QHBox *hb = new QHBox( container ); | 198 | QHBox *hb = new QHBox( container ); |
170 | QWidget *w = new QWidget( hb ); | 199 | QWidget *w = new QWidget( hb ); |
171 | (void)new QScrollBar( 0, 0, 0, 0, 0, Vertical, hb ); | 200 | (void)new QScrollBar( 0, 0, 0, 0, 0, Vertical, hb ); |
172 | 201 | ||
173 | QGridLayout *gl = new QGridLayout( w, 2, 2, 4 ); | 202 | QGridLayout *gl = new QGridLayout( w, 2, 2, 4 ); |
174 | SampleText *l = new SampleText( tr("Normal Text"), FALSE, w ); | 203 | SampleText *l = new SampleText( tr("Normal Text"), FALSE, w ); |
175 | gl->addWidget( l, 0, 0 ); | 204 | gl->addWidget( l, 0, 0 ); |
176 | 205 | ||
177 | l = new SampleText( tr("Highlighted Text"), TRUE, w ); | 206 | l = new SampleText( tr("Highlighted Text"), TRUE, w ); |
178 | gl->addWidget( l, 1, 0 ); | 207 | gl->addWidget( l, 1, 0 ); |
179 | 208 | ||
180 | QPushButton *pb = new QPushButton( tr("Button"), w ); | 209 | QPushButton *pb = new QPushButton( tr("Button"), w ); |
181 | gl->addWidget( pb, 0, 1 ); | 210 | gl->addWidget( pb, 0, 1 ); |
182 | pb->setFocusPolicy( NoFocus ); | 211 | pb->setFocusPolicy( NoFocus ); |
183 | 212 | ||
184 | QCheckBox *cb = new QCheckBox( tr("Check Box"), w ); | 213 | QCheckBox *cb = new QCheckBox( tr("Check Box"), w ); |
185 | gl->addWidget( cb, 1, 1 ); | 214 | gl->addWidget( cb, 1, 1 ); |
186 | cb->setFocusPolicy( NoFocus ); | 215 | cb->setFocusPolicy( NoFocus ); |
187 | cb->setChecked( TRUE ); | 216 | cb->setChecked( TRUE ); |
188 | 217 | ||
189 | QWhatsThis::add( this, tr("Sample window using the selected settings.") ); | 218 | QWhatsThis::add( this, tr("Sample window using the selected settings.") ); |
190 | } | 219 | } |
191 | 220 | ||
192 | bool SampleWindow::eventFilter( QObject *, QEvent *e ) | 221 | bool SampleWindow::eventFilter( QObject *, QEvent *e ) |
193 | { | 222 | { |
194 | switch ( e->type() ) { | 223 | switch ( e->type() ) { |
195 | case QEvent::MouseButtonPress: | 224 | case QEvent::MouseButtonPress: |
196 | case QEvent::MouseButtonRelease: | 225 | case QEvent::MouseButtonRelease: |
197 | case QEvent::MouseButtonDblClick: | 226 | case QEvent::MouseButtonDblClick: |
198 | case QEvent::MouseMove: | 227 | case QEvent::MouseMove: |
199 | case QEvent::KeyPress: | 228 | case QEvent::KeyPress: |
200 | case QEvent::KeyRelease: | 229 | case QEvent::KeyRelease: |
201 | return TRUE; | 230 | return TRUE; |
202 | default: | 231 | default: |
203 | break; | 232 | break; |
204 | } | 233 | } |
205 | 234 | ||
206 | return FALSE; | 235 | return FALSE; |
207 | } | 236 | } |
208 | 237 | ||
209 | void SampleWindow::paletteChange( const QPalette &old ) | 238 | void SampleWindow::paletteChange( const QPalette &old ) |
210 | { | 239 | { |
211 | QWidget::paletteChange ( old ); | 240 | QWidget::paletteChange ( old ); |
212 | wd. palette = palette ( ); | 241 | wd. palette = palette ( ); |
213 | popup-> setPalette ( palette ( )); | 242 | popup-> setPalette ( palette ( )); |
214 | } | 243 | } |
215 | 244 | ||
216 | 245 | ||
217 | void SampleWindow::setPalette ( const QPalette &pal ) | 246 | void SampleWindow::setPalette ( const QPalette &pal ) |
218 | { | 247 | { |
219 | QPixmapCache::clear ( ); | 248 | QPixmapCache::clear ( ); |
220 | QPalette p = pal; | 249 | QPalette p = pal; |
221 | style ( ). polish ( p ); | 250 | style ( ). polish ( p ); |
222 | QWidget::setPalette ( p ); | 251 | QWidget::setPalette ( p ); |
223 | } | 252 | } |
224 | 253 | ||
225 | void SampleWindow::resizeEvent( QResizeEvent *re ) | 254 | void SampleWindow::resizeEvent( QResizeEvent *re ) |
226 | { | 255 | { |
227 | wd.rect = QRect( 0, 0, 150, 75 ); | 256 | wd.rect = QRect( 0, 0, 150, 75 ); |
228 | 257 | ||
229 | wd.rect.setX( 0 ); | 258 | wd.rect.setX( 0 ); |
230 | wd.rect.setWidth( width() - lb - rb ); | 259 | wd.rect.setWidth( width() - lb - rb ); |
231 | wd.rect.setY( 0 ); | 260 | wd.rect.setY( 0 ); |
232 | wd.rect.setHeight( height() - th - tb - bb ); | 261 | wd.rect.setHeight( height() - th - tb - bb ); |
233 | 262 | ||
234 | container->setGeometry( lb, th+tb, wd.rect.width(), wd.rect.height() ); | 263 | container->setGeometry( lb, th+tb, wd.rect.width(), wd.rect.height() ); |
235 | QWidget::resizeEvent( re ); | 264 | QWidget::resizeEvent( re ); |
236 | } | 265 | } |
237 | 266 | ||
238 | void SampleWindow::fixGeometry() | 267 | void SampleWindow::fixGeometry() |
239 | { | 268 | { |
240 | setMinimumSize( container->sizeHint().width()+lb+rb, | 269 | setMinimumSize( container->sizeHint().width()+lb+rb, |
241 | container->sizeHint().height()+tb+th+bb ); | 270 | container->sizeHint().height()+tb+th+bb ); |
242 | } | 271 | } |
243 | 272 | ||
diff --git a/noncore/settings/appearance2/sample.h b/noncore/settings/appearance2/sample.h index c6f9b5a..a189f69 100644 --- a/noncore/settings/appearance2/sample.h +++ b/noncore/settings/appearance2/sample.h | |||
@@ -1,49 +1,78 @@ | |||
1 | /* | ||
2 | This file is part of the OPIE Project | ||
3 | =. Copyright (c) 2002 Trolltech AS <info@trolltech.com> | ||
4 | .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> | ||
5 | .>+-= | ||
6 | _;:, .> :=|. This library is free software; you can | ||
7 | .> <`_, > . <= redistribute it and/or modify it under | ||
8 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
9 | .="- .-=="i, .._ License as published by the Free Software | ||
10 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
11 | ._= =} : or (at your option) any later version. | ||
12 | .%`+i> _;_. | ||
13 | .i_,=:_. -<s. This library is distributed in the hope that | ||
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
15 | : .. .:, . . . without even the implied warranty of | ||
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
18 | ..}^=.= = ; Library General Public License for more | ||
19 | ++= -. .` .: details. | ||
20 | : = ...= . :.=- | ||
21 | -. .:....=;==+<; You should have received a copy of the GNU | ||
22 | -_. . . )=. = Library General Public License along with | ||
23 | -- :-=` this library; see the file COPYING.LIB. | ||
24 | If not, write to the Free Software Foundation, | ||
25 | Inc., 59 Temple Place - Suite 330, | ||
26 | Boston, MA 02111-1307, USA. | ||
27 | |||
28 | */ | ||
29 | |||
1 | #ifndef __PREVIEW_H__ | 30 | #ifndef __PREVIEW_H__ |
2 | #define __PREVIEW_H__ | 31 | #define __PREVIEW_H__ |
3 | 32 | ||
4 | #include <qwidget.h> | 33 | #include <qwidget.h> |
5 | 34 | ||
6 | #include <qpe/windowdecorationinterface.h> | 35 | #include <qpe/windowdecorationinterface.h> |
7 | 36 | ||
8 | class QVBox; | 37 | class QVBox; |
9 | class QPopupMenu; | 38 | class QPopupMenu; |
10 | class SampleText; | 39 | class SampleText; |
11 | 40 | ||
12 | class SampleWindow : public QWidget | 41 | class SampleWindow : public QWidget |
13 | { | 42 | { |
14 | Q_OBJECT | 43 | Q_OBJECT |
15 | public: | 44 | public: |
16 | SampleWindow( QWidget *parent ); | 45 | SampleWindow( QWidget *parent ); |
17 | 46 | ||
18 | QSize sizeHint() const; | 47 | QSize sizeHint() const; |
19 | 48 | ||
20 | virtual void setFont( const QFont &f ); | 49 | virtual void setFont( const QFont &f ); |
21 | 50 | ||
22 | void setStyle2 ( QStyle *sty ); | 51 | void setStyle2 ( QStyle *sty ); |
23 | void setDecoration( WindowDecorationInterface *i ); | 52 | void setDecoration( WindowDecorationInterface *i ); |
24 | void setPalette ( const QPalette & ); | 53 | void setPalette ( const QPalette & ); |
25 | 54 | ||
26 | virtual void paintEvent( QPaintEvent * ); | 55 | virtual void paintEvent( QPaintEvent * ); |
27 | 56 | ||
28 | void init(); | 57 | void init(); |
29 | 58 | ||
30 | virtual bool eventFilter( QObject *, QEvent *e ); | 59 | virtual bool eventFilter( QObject *, QEvent *e ); |
31 | virtual void paletteChange( const QPalette &old ); | 60 | virtual void paletteChange( const QPalette &old ); |
32 | virtual void resizeEvent( QResizeEvent *re ); | 61 | virtual void resizeEvent( QResizeEvent *re ); |
33 | 62 | ||
34 | public slots: | 63 | public slots: |
35 | void fixGeometry(); | 64 | void fixGeometry(); |
36 | 65 | ||
37 | protected: | 66 | protected: |
38 | WindowDecorationInterface *iface; | 67 | WindowDecorationInterface *iface; |
39 | WindowDecorationInterface::WindowData wd; | 68 | WindowDecorationInterface::WindowData wd; |
40 | QVBox *container; | 69 | QVBox *container; |
41 | QPopupMenu *popup; | 70 | QPopupMenu *popup; |
42 | int th; | 71 | int th; |
43 | int tb; | 72 | int tb; |
44 | int lb; | 73 | int lb; |
45 | int rb; | 74 | int rb; |
46 | int bb; | 75 | int bb; |
47 | }; | 76 | }; |
48 | 77 | ||
49 | #endif | 78 | #endif |
diff --git a/noncore/settings/appearance2/stylelistitem.h b/noncore/settings/appearance2/stylelistitem.h index 3cc63dc..bbfbd41 100644 --- a/noncore/settings/appearance2/stylelistitem.h +++ b/noncore/settings/appearance2/stylelistitem.h | |||
@@ -1,85 +1,113 @@ | |||
1 | /* | ||
2 | =. This file is part of the OPIE Project | ||
3 | .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> | ||
4 | .>+-= | ||
5 | _;:, .> :=|. This library is free software; you can | ||
6 | .> <`_, > . <= redistribute it and/or modify it under | ||
7 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
8 | .="- .-=="i, .._ License as published by the Free Software | ||
9 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
10 | ._= =} : or (at your option) any later version. | ||
11 | .%`+i> _;_. | ||
12 | .i_,=:_. -<s. This library is distributed in the hope that | ||
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
14 | : .. .:, . . . without even the implied warranty of | ||
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
17 | ..}^=.= = ; Library General Public License for more | ||
18 | ++= -. .` .: details. | ||
19 | : = ...= . :.=- | ||
20 | -. .:....=;==+<; You should have received a copy of the GNU | ||
21 | -_. . . )=. = Library General Public License along with | ||
22 | -- :-=` this library; see the file COPYING.LIB. | ||
23 | If not, write to the Free Software Foundation, | ||
24 | Inc., 59 Temple Place - Suite 330, | ||
25 | Boston, MA 02111-1307, USA. | ||
26 | |||
27 | */ | ||
28 | |||
1 | #ifndef STYLELISTITEM_H | 29 | #ifndef STYLELISTITEM_H |
2 | #define STYLELISTITEM_H | 30 | #define STYLELISTITEM_H |
3 | 31 | ||
4 | #include <qlistbox.h> | 32 | #include <qlistbox.h> |
5 | #include <qpe/styleinterface.h> | 33 | #include <qpe/styleinterface.h> |
6 | 34 | ||
7 | #include <stdio.h> | 35 | #include <stdio.h> |
8 | 36 | ||
9 | class StyleListItem : public QListBoxText { | 37 | class StyleListItem : public QListBoxText { |
10 | public: | 38 | public: |
11 | StyleListItem ( const QString &t, QStyle *sty ) : QListBoxText ( t ) | 39 | StyleListItem ( const QString &t, QStyle *sty ) : QListBoxText ( t ) |
12 | { | 40 | { |
13 | m_lib = 0; | 41 | m_lib = 0; |
14 | m_style_if = 0; | 42 | m_style_if = 0; |
15 | m_settings_if = 0; | 43 | m_settings_if = 0; |
16 | m_style = sty; | 44 | m_style = sty; |
17 | } | 45 | } |
18 | 46 | ||
19 | StyleListItem ( QLibrary *lib, StyleInterface *iface ) : QListBoxText ( iface-> name ( )) | 47 | StyleListItem ( QLibrary *lib, StyleInterface *iface ) : QListBoxText ( iface-> name ( )) |
20 | { | 48 | { |
21 | m_lib = lib; | 49 | m_lib = lib; |
22 | m_style_if = iface; | 50 | m_style_if = iface; |
23 | m_settings_if = 0; | 51 | m_settings_if = 0; |
24 | m_style = iface-> create ( ); | 52 | m_style = iface-> create ( ); |
25 | 53 | ||
26 | iface-> queryInterface ( IID_StyleSettings, (QUnknownInterface **) &m_settings_if ); | 54 | iface-> queryInterface ( IID_StyleSettings, (QUnknownInterface **) &m_settings_if ); |
27 | } | 55 | } |
28 | 56 | ||
29 | virtual ~StyleListItem ( ) | 57 | virtual ~StyleListItem ( ) |
30 | { | 58 | { |
31 | delete m_style; | 59 | delete m_style; |
32 | 60 | ||
33 | if ( m_settings_if ) | 61 | if ( m_settings_if ) |
34 | m_settings_if-> release ( ); | 62 | m_settings_if-> release ( ); |
35 | if ( m_style_if ) | 63 | if ( m_style_if ) |
36 | m_style_if-> release ( ); | 64 | m_style_if-> release ( ); |
37 | delete m_lib; | 65 | delete m_lib; |
38 | } | 66 | } |
39 | 67 | ||
40 | bool hasSettings ( ) const | 68 | bool hasSettings ( ) const |
41 | { | 69 | { |
42 | return ( m_settings_if ); | 70 | return ( m_settings_if ); |
43 | } | 71 | } |
44 | 72 | ||
45 | QWidget *settings ( QWidget *parent ) | 73 | QWidget *settings ( QWidget *parent ) |
46 | { | 74 | { |
47 | return m_settings_if ? m_settings_if-> create ( parent ) : 0; | 75 | return m_settings_if ? m_settings_if-> create ( parent ) : 0; |
48 | } | 76 | } |
49 | 77 | ||
50 | bool setSettings ( bool accepted ) | 78 | bool setSettings ( bool accepted ) |
51 | { | 79 | { |
52 | if ( !m_settings_if ) | 80 | if ( !m_settings_if ) |
53 | return false; | 81 | return false; |
54 | 82 | ||
55 | if ( accepted ) | 83 | if ( accepted ) |
56 | return m_settings_if-> accept ( ); | 84 | return m_settings_if-> accept ( ); |
57 | else { | 85 | else { |
58 | m_settings_if-> reject ( ); | 86 | m_settings_if-> reject ( ); |
59 | return false; | 87 | return false; |
60 | } | 88 | } |
61 | } | 89 | } |
62 | 90 | ||
63 | QString key ( ) | 91 | QString key ( ) |
64 | { | 92 | { |
65 | if ( m_style_if ) | 93 | if ( m_style_if ) |
66 | return QString ( m_style_if-> key ( )); | 94 | return QString ( m_style_if-> key ( )); |
67 | else | 95 | else |
68 | return text ( ); | 96 | return text ( ); |
69 | } | 97 | } |
70 | 98 | ||
71 | QStyle *style ( ) | 99 | QStyle *style ( ) |
72 | { | 100 | { |
73 | return m_style; | 101 | return m_style; |
74 | } | 102 | } |
75 | 103 | ||
76 | private: | 104 | private: |
77 | QLibrary *m_lib; | 105 | QLibrary *m_lib; |
78 | QStyle *m_style; | 106 | QStyle *m_style; |
79 | StyleInterface *m_style_if; | 107 | StyleInterface *m_style_if; |
80 | StyleSettingsInterface *m_settings_if; | 108 | StyleSettingsInterface *m_settings_if; |
81 | 109 | ||
82 | }; | 110 | }; |
83 | 111 | ||
84 | 112 | ||
85 | #endif | 113 | #endif |