summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/appearance2/appearance.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/noncore/settings/appearance2/appearance.cpp b/noncore/settings/appearance2/appearance.cpp
index 4132b30..303e0b9 100644
--- a/noncore/settings/appearance2/appearance.cpp
+++ b/noncore/settings/appearance2/appearance.cpp
@@ -1,610 +1,611 @@
1/* 1/*
2                This file is part of the OPIE Project 2                This file is part of the OPIE Project
3 Copyright (c) 2002 Trolltech AS <info@trolltech.com> 3 Copyright (c) 2002 Trolltech AS <info@trolltech.com>
4 =. Copyright (c) 2002 Dan Williams <williamsdr@acm.org> 4 =. Copyright (c) 2002 Dan Williams <williamsdr@acm.org>
5             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org> 5             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org>
6           .>+-= 6           .>+-=
7 _;:,     .>    :=|. This file is free software; you can 7 _;:,     .>    :=|. This file is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU General Public 9:`=1 )Y*s>-.--   : the terms of the GNU General Public
10.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_. 13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This file is distributed in the hope that 14    .i_,=:_.      -<s. This file is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
19..}^=.=       =       ; Public License for more details. 19..}^=.=       =       ; Public License for more details.
20++=   -.     .`     .: 20++=   -.     .`     .:
21 :     =  ...= . :.=- You should have received a copy of the GNU 21 :     =  ...= . :.=- You should have received a copy of the GNU
22 -.   .:....=;==+<; General Public License along with this file; 22 -.   .:....=;==+<; General Public License along with this file;
23  -_. . .   )=.  = see the file COPYING. If not, write to the 23  -_. . .   )=.  = see the file COPYING. If not, write to the
24    --        :-=` Free Software Foundation, Inc., 24    --        :-=` Free Software Foundation, Inc.,
25 59 Temple Place - Suite 330, 25 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA. 26 Boston, MA 02111-1307, USA.
27 27
28*/ 28*/
29 29
30#include "appearance.h" 30#include "appearance.h"
31#include "editScheme.h" 31#include "editScheme.h"
32 32
33#include <opie/ofiledialog.h> 33#include <opie/ofiledialog.h>
34#include <opie/otabwidget.h> 34#include <opie/otabwidget.h>
35 35
36#include <qpe/applnk.h> 36#include <qpe/applnk.h>
37#include <qpe/config.h> 37#include <qpe/config.h>
38#include <qpe/global.h> 38#include <qpe/global.h>
39#include <qpe/resource.h> 39#include <qpe/resource.h>
40#include <qpe/qpeapplication.h> 40#include <qpe/qpeapplication.h>
41#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 41#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
42#include <qpe/qcopenvelope_qws.h> 42#include <qpe/qcopenvelope_qws.h>
43#endif 43#endif
44 44
45#include <qaction.h> 45#include <qaction.h>
46#include <qbuttongroup.h> 46#include <qbuttongroup.h>
47#include <qcheckbox.h> 47#include <qcheckbox.h>
48#include <qcombobox.h> 48#include <qcombobox.h>
49#include <qdialog.h> 49#include <qdialog.h>
50#include <qdir.h> 50#include <qdir.h>
51#include <qlabel.h> 51#include <qlabel.h>
52#include <qlayout.h> 52#include <qlayout.h>
53#include <qlineedit.h> 53#include <qlineedit.h>
54#include <qlistbox.h> 54#include <qlistbox.h>
55#include <qmessagebox.h> 55#include <qmessagebox.h>
56#include <qmultilineedit.h> 56#include <qmultilineedit.h>
57#include <qpopupmenu.h> 57#include <qpopupmenu.h>
58#include <qpushbutton.h> 58#include <qpushbutton.h>
59#include <qradiobutton.h> 59#include <qradiobutton.h>
60#if QT_VERSION >= 300 60#if QT_VERSION >= 300
61#include <qstylefactory.h> 61#include <qstylefactory.h>
62#else 62#else
63#include <qwindowsstyle.h> 63#include <qwindowsstyle.h>
64#include <qpe/qpestyle.h> 64#include <qpe/qpestyle.h>
65#include <qpe/lightstyle.h> 65#include <qpe/lightstyle.h>
66#include <qpe/qlibrary.h> 66#include <qpe/qlibrary.h>
67#include <qpe/styleinterface.h> 67#include <qpe/styleinterface.h>
68#endif 68#endif
69#include <qtabwidget.h> 69#include <qtabwidget.h>
70#include <qtoolbutton.h> 70#include <qtoolbutton.h>
71#include <qvgroupbox.h> 71#include <qvgroupbox.h>
72#include <qwidget.h> 72#include <qwidget.h>
73 73
74#include "stylelistitem.h" 74#include "stylelistitem.h"
75#include "decolistitem.h" 75#include "decolistitem.h"
76#include "colorlistitem.h" 76#include "colorlistitem.h"
77 77
78#include "sample.h" 78#include "sample.h"
79 79
80#include <opie/ofontselector.h> 80#include <opie/ofontselector.h>
81 81
82 82
83class DefaultWindowDecoration : public WindowDecorationInterface 83class DefaultWindowDecoration : public WindowDecorationInterface
84{ 84{
85public: 85public:
86 DefaultWindowDecoration() : ref(0) {} 86 DefaultWindowDecoration() : ref(0) {}
87 QString name() const { 87 QString name() const {
88 return "Default"; 88 return "Default";
89 } 89 }
90 QPixmap icon() const { 90 QPixmap icon() const {
91 return QPixmap(); 91 return QPixmap();
92 } 92 }
93 QRESULT queryInterface( const QUuid &uuid, QUnknownInterface **iface ) { 93 QRESULT queryInterface( const QUuid &uuid, QUnknownInterface **iface ) {
94 *iface = 0; 94 *iface = 0;
95 if ( uuid == IID_QUnknown ) 95 if ( uuid == IID_QUnknown )
96 *iface = this; 96 *iface = this;
97 else if ( uuid == IID_WindowDecoration ) 97 else if ( uuid == IID_WindowDecoration )
98 *iface = this; 98 *iface = this;
99 99
100 if ( *iface ) 100 if ( *iface )
101 (*iface)->addRef(); 101 (*iface)->addRef();
102 return QS_OK; 102 return QS_OK;
103 } 103 }
104 Q_REFCOUNT 104 Q_REFCOUNT
105 105
106private: 106private:
107 ulong ref; 107 ulong ref;
108}; 108};
109 109
110 110
111 111
112void Appearance::loadStyles ( QListBox *list ) 112void Appearance::loadStyles ( QListBox *list )
113{ 113{
114#if QT_VERSION >= 300 114#if QT_VERSION >= 300
115 list->insertStringList(QStyleFactory::styles()); 115 list->insertStringList(QStyleFactory::styles());
116#else 116#else
117 list->insertItem( new StyleListItem ( "Windows", new QWindowsStyle ( ))); 117 list->insertItem( new StyleListItem ( "Windows", new QWindowsStyle ( )));
118 list->insertItem( new StyleListItem ( "Light", new LightStyle ( ))); 118 list->insertItem( new StyleListItem ( "Light", new LightStyle ( )));
119#ifndef QT_NO_STYLE_MOTIF 119#ifndef QT_NO_STYLE_MOTIF
120 list->insertItem( new StyleListItem ( "Motif", new QMotifStyle ( ))); 120 list->insertItem( new StyleListItem ( "Motif", new QMotifStyle ( )));
121#endif 121#endif
122#ifndef QT_NO_STYLE_MOTIFPLUS 122#ifndef QT_NO_STYLE_MOTIFPLUS
123 list->insertItem( new StyleListItem ( "MotifPlus", new QMotifPlusStyle ( ))); 123 list->insertItem( new StyleListItem ( "MotifPlus", new QMotifPlusStyle ( )));
124#endif 124#endif
125#ifndef QT_NO_STYLE_PLATINUM 125#ifndef QT_NO_STYLE_PLATINUM
126 list->insertItem( new StyleListItem ( "Platinum", new QPlatinumStyle ( ))); 126 list->insertItem( new StyleListItem ( "Platinum", new QPlatinumStyle ( )));
127#endif 127#endif
128#endif 128#endif
129 list->insertItem( new StyleListItem ( "QPE", new QPEStyle ( ))); 129 list->insertItem( new StyleListItem ( "QPE", new QPEStyle ( )));
130 130
131#if QT_VERSION < 300 131#if QT_VERSION < 300
132 { 132 {
133 QString path = QPEApplication::qpeDir() + "/plugins/styles/"; 133 QString path = QPEApplication::qpeDir() + "/plugins/styles/";
134 QStringList sl = QDir ( path, "lib*.so" ). entryList ( ); 134 QStringList sl = QDir ( path, "lib*.so" ). entryList ( );
135 135
136 for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) { 136 for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) {
137 QLibrary *lib = new QLibrary ( path + "/" + *it ); 137 QLibrary *lib = new QLibrary ( path + "/" + *it );
138 StyleInterface *iface; 138 StyleInterface *iface;
139 139
140 if (( lib-> queryInterface ( IID_Style, (QUnknownInterface **) &iface ) == QS_OK ) && iface ) 140 if (( lib-> queryInterface ( IID_Style, (QUnknownInterface **) &iface ) == QS_OK ) && iface )
141 list-> insertItem ( new StyleListItem ( lib, iface )); 141 list-> insertItem ( new StyleListItem ( lib, iface ));
142 else 142 else
143 delete lib; 143 delete lib;
144 } 144 }
145 } 145 }
146 146
147#endif 147#endif
148} 148}
149 149
150void Appearance::loadDecos ( QListBox *list ) 150void Appearance::loadDecos ( QListBox *list )
151{ 151{
152 list-> insertItem ( new DecoListItem ( "QPE" )); 152 list-> insertItem ( new DecoListItem ( "QPE" ));
153 153
154 { 154 {
155 QString path = QPEApplication::qpeDir() + "/plugins/decorations/"; 155 QString path = QPEApplication::qpeDir() + "/plugins/decorations/";
156 QStringList sl = QDir ( path, "lib*.so" ). entryList ( ); 156 QStringList sl = QDir ( path, "lib*.so" ). entryList ( );
157 157
158 for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) { 158 for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) {
159 QLibrary *lib = new QLibrary ( path + "/" + *it ); 159 QLibrary *lib = new QLibrary ( path + "/" + *it );
160 WindowDecorationInterface *iface; 160 WindowDecorationInterface *iface;
161 161
162 if ( lib-> queryInterface ( IID_WindowDecoration, (QUnknownInterface **) &iface ) == QS_OK ) 162 if ( lib-> queryInterface ( IID_WindowDecoration, (QUnknownInterface **) &iface ) == QS_OK )
163 list-> insertItem ( new DecoListItem ( lib, iface )); 163 list-> insertItem ( new DecoListItem ( lib, iface ));
164 else 164 else
165 delete lib; 165 delete lib;
166 } 166 }
167 } 167 }
168} 168}
169 169
170void Appearance::loadColors ( QListBox *list ) 170void Appearance::loadColors ( QListBox *list )
171{ 171{
172 list-> clear ( ); 172 list-> clear ( );
173 { 173 {
174 Config config ( "qpe" ); 174 Config config ( "qpe" );
175 config. setGroup ( "Appearance" ); 175 config. setGroup ( "Appearance" );
176 176
177 list-> insertItem ( new ColorListItem ( tr( "Current scheme" ), config )); 177 list-> insertItem ( new ColorListItem ( tr( "Current scheme" ), config ));
178 } 178 }
179 179
180 QString path = QPEApplication::qpeDir ( ) + "/etc/colors/"; 180 QString path = QPEApplication::qpeDir ( ) + "/etc/colors/";
181 QStringList sl = QDir ( path ). entryList ( "*.scheme" ); 181 QStringList sl = QDir ( path ). entryList ( "*.scheme" );
182 182
183 for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) { 183 for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) {
184 QString name = (*it). left ((*it). find ( ".scheme" )); 184 QString name = (*it). left ((*it). find ( ".scheme" ));
185 Config config ( path + *it, Config::File ); 185 Config config ( path + *it, Config::File );
186 config. setGroup ( "Colors" ); 186 config. setGroup ( "Colors" );
187 187
188 list-> insertItem ( new ColorListItem ( name, config )); 188 list-> insertItem ( new ColorListItem ( name, config ));
189 } 189 }
190} 190}
191 191
192 192
193QWidget *Appearance::createStyleTab ( QWidget *parent ) 193QWidget *Appearance::createStyleTab ( QWidget *parent )
194{ 194{
195 Config config ( "qpe" ); 195 Config config ( "qpe" );
196 config. setGroup ( "Appearance" ); 196 config. setGroup ( "Appearance" );
197 197
198 QWidget* tab = new QWidget( parent, "StyleTab" ); 198 QWidget* tab = new QWidget( parent, "StyleTab" );
199 QVBoxLayout* vertLayout = new QVBoxLayout( tab, 4, 4 ); 199 QVBoxLayout* vertLayout = new QVBoxLayout( tab, 4, 4 );
200 200
201 m_style_list = new QListBox( tab, "m_style_list" ); 201 m_style_list = new QListBox( tab, "m_style_list" );
202 vertLayout->addWidget( m_style_list ); 202 vertLayout->addWidget( m_style_list );
203 203
204 m_style_settings = new QPushButton ( tr( "Settings..." ), tab ); 204 m_style_settings = new QPushButton ( tr( "Settings..." ), tab );
205 connect ( m_style_settings, SIGNAL( clicked ( )), this, SLOT( styleSettingsClicked ( ))); 205 connect ( m_style_settings, SIGNAL( clicked ( )), this, SLOT( styleSettingsClicked ( )));
206 vertLayout-> addWidget ( m_style_settings ); 206 vertLayout-> addWidget ( m_style_settings );
207 207
208 loadStyles ( m_style_list ); 208 loadStyles ( m_style_list );
209 209
210 QString s = config. readEntry ( "Style", "Light" ); 210 QString s = config. readEntry ( "Style", "Light" );
211 211
212 for ( uint i = 0; i < m_style_list-> count ( ); i++ ) { 212 for ( uint i = 0; i < m_style_list-> count ( ); i++ ) {
213 if (((StyleListItem *) m_style_list-> item ( i ))-> key ( ) == s ) { 213 if (((StyleListItem *) m_style_list-> item ( i ))-> key ( ) == s ) {
214 m_style_list-> setCurrentItem ( i ); 214 m_style_list-> setCurrentItem ( i );
215 break; 215 break;
216 } 216 }
217 } 217 }
218 218
219 m_original_style = m_style_list-> currentItem ( ); 219 m_original_style = m_style_list-> currentItem ( );
220 styleClicked ( m_original_style ); 220 styleClicked ( m_original_style );
221 221
222 connect( m_style_list, SIGNAL( highlighted( int ) ), this, SLOT( styleClicked( int ) ) ); 222 connect( m_style_list, SIGNAL( highlighted( int ) ), this, SLOT( styleClicked( int ) ) );
223 223
224 return tab; 224 return tab;
225} 225}
226 226
227QWidget *Appearance::createDecoTab ( QWidget *parent ) 227QWidget *Appearance::createDecoTab ( QWidget *parent )
228{ 228{
229 Config config ( "qpe" ); 229 Config config ( "qpe" );
230 config. setGroup ( "Appearance" ); 230 config. setGroup ( "Appearance" );
231 231
232 QWidget* tab = new QWidget( parent, "DecoTab" ); 232 QWidget* tab = new QWidget( parent, "DecoTab" );
233 QVBoxLayout* vertLayout = new QVBoxLayout( tab, 4, 4 ); 233 QVBoxLayout* vertLayout = new QVBoxLayout( tab, 4, 4 );
234 234
235 m_deco_list = new QListBox( tab, "m_deco_list" ); 235 m_deco_list = new QListBox( tab, "m_deco_list" );
236 vertLayout->addWidget( m_deco_list ); 236 vertLayout->addWidget( m_deco_list );
237 237
238 loadDecos ( m_deco_list ); 238 loadDecos ( m_deco_list );
239 239
240 QString s = config. readEntry ( "Decoration" ); 240 QString s = config. readEntry ( "Decoration" );
241 241
242 for ( uint i = 0; i < m_deco_list-> count ( ); i++ ) { 242 for ( uint i = 0; i < m_deco_list-> count ( ); i++ ) {
243 if (((DecoListItem *) m_deco_list-> item ( i ))-> key ( ) == s ) { 243 if (((DecoListItem *) m_deco_list-> item ( i ))-> key ( ) == s ) {
244 m_deco_list-> setCurrentItem ( i ); 244 m_deco_list-> setCurrentItem ( i );
245 break; 245 break;
246 } 246 }
247 } 247 }
248 248
249 m_original_deco = m_deco_list-> currentItem ( ); 249 m_original_deco = m_deco_list-> currentItem ( );
250 if ( m_deco_list-> currentItem ( ) < 0 ) 250 if ( m_deco_list-> currentItem ( ) < 0 )
251 m_deco_list-> setCurrentItem ( 0 ); 251 m_deco_list-> setCurrentItem ( 0 );
252 decoClicked ( m_original_deco ); 252 decoClicked ( m_original_deco );
253 253
254 connect( m_deco_list, SIGNAL( highlighted( int ) ), this, SLOT( decoClicked( int ) ) ); 254 connect( m_deco_list, SIGNAL( highlighted( int ) ), this, SLOT( decoClicked( int ) ) );
255 255
256 return tab; 256 return tab;
257} 257}
258 258
259QWidget *Appearance::createFontTab ( QWidget *parent ) 259QWidget *Appearance::createFontTab ( QWidget *parent )
260{ 260{
261 Config config ( "qpe" ); 261 Config config ( "qpe" );
262 config. setGroup ( "Appearance" ); 262 config. setGroup ( "Appearance" );
263 263
264 QString familyStr = config.readEntry( "FontFamily", "Helvetica" ); 264 QString familyStr = config.readEntry( "FontFamily", "Helvetica" );
265 QString styleStr = config.readEntry( "FontStyle", "Regular" ); 265 QString styleStr = config.readEntry( "FontStyle", "Regular" );
266 int size = config.readNumEntry( "FontSize", 10 ); 266 int size = config.readNumEntry( "FontSize", 10 );
267 267
268 m_fontselect = new OFontSelector ( false, parent, "FontTab" ); 268 m_fontselect = new OFontSelector ( false, parent, "FontTab" );
269 m_fontselect-> setSelectedFont ( familyStr, styleStr, size ); 269 m_fontselect-> setSelectedFont ( familyStr, styleStr, size );
270 270
271 connect( m_fontselect, SIGNAL( fontSelected ( const QFont & )), 271 connect( m_fontselect, SIGNAL( fontSelected ( const QFont & )),
272 this, SLOT( fontClicked ( const QFont & ))); 272 this, SLOT( fontClicked ( const QFont & )));
273 273
274 return m_fontselect; 274 return m_fontselect;
275} 275}
276 276
277QWidget *Appearance::createColorTab ( QWidget *parent ) 277QWidget *Appearance::createColorTab ( QWidget *parent )
278{ 278{
279 Config config ( "qpe" ); 279 Config config ( "qpe" );
280 config. setGroup ( "Appearance" ); 280 config. setGroup ( "Appearance" );
281 281
282 282
283 QWidget *tab = new QWidget( parent, "ColorTab" ); 283 QWidget *tab = new QWidget( parent, "ColorTab" );
284 QGridLayout *gridLayout = new QGridLayout( tab, 0, 0, 4, 4 ); 284 QGridLayout *gridLayout = new QGridLayout( tab, 0, 0, 4, 4 );
285 gridLayout->setRowStretch ( 3, 10 ); 285 gridLayout->setRowStretch ( 3, 10 );
286 286
287 m_color_list = new QListBox ( tab ); 287 m_color_list = new QListBox ( tab );
288 gridLayout->addMultiCellWidget ( m_color_list, 0, 3, 0, 0 ); 288 gridLayout->addMultiCellWidget ( m_color_list, 0, 3, 0, 0 );
289 connect( m_color_list, SIGNAL( highlighted( int ) ), this, SLOT( colorClicked( int ) ) ); 289 connect( m_color_list, SIGNAL( highlighted( int ) ), this, SLOT( colorClicked( int ) ) );
290 290
291 loadColors ( m_color_list ); 291 loadColors ( m_color_list );
292 m_color_list-> setCurrentItem ( 0 ); 292 m_color_list-> setCurrentItem ( 0 );
293 293
294 QPushButton* tempButton = new QPushButton( tab, "editSchemeButton" ); 294 QPushButton* tempButton = new QPushButton( tab, "editSchemeButton" );
295 tempButton->setText( tr( "Edit..." ) ); 295 tempButton->setText( tr( "Edit..." ) );
296 connect( tempButton, SIGNAL( clicked() ), this, SLOT( editSchemeClicked() ) ); 296 connect( tempButton, SIGNAL( clicked() ), this, SLOT( editSchemeClicked() ) );
297 gridLayout->addWidget( tempButton, 0, 1 ); 297 gridLayout->addWidget( tempButton, 0, 1 );
298 298
299 tempButton = new QPushButton( tab, "deleteSchemeButton" ); 299 tempButton = new QPushButton( tab, "deleteSchemeButton" );
300 tempButton->setText( tr( "Delete" ) ); 300 tempButton->setText( tr( "Delete" ) );
301 connect( tempButton, SIGNAL( clicked() ), this, SLOT( deleteSchemeClicked() ) ); 301 connect( tempButton, SIGNAL( clicked() ), this, SLOT( deleteSchemeClicked() ) );
302 gridLayout->addWidget( tempButton, 1, 1 ); 302 gridLayout->addWidget( tempButton, 1, 1 );
303 303
304 tempButton = new QPushButton( tab, "saveSchemeButton" ); 304 tempButton = new QPushButton( tab, "saveSchemeButton" );
305 tempButton->setText( tr( "Save" ) ); 305 tempButton->setText( tr( "Save" ) );
306 connect( tempButton, SIGNAL( clicked() ), this, SLOT( saveSchemeClicked() ) ); 306 connect( tempButton, SIGNAL( clicked() ), this, SLOT( saveSchemeClicked() ) );
307 gridLayout->addWidget( tempButton, 2, 1 ); 307 gridLayout->addWidget( tempButton, 2, 1 );
308 308
309 return tab; 309 return tab;
310} 310}
311 311
312QWidget *Appearance::createGuiTab ( QWidget *parent ) 312QWidget *Appearance::createGuiTab ( QWidget *parent )
313{ 313{
314 Config config ( "qpe" ); 314 Config config ( "qpe" );
315 config. setGroup ( "Appearance" ); 315 config. setGroup ( "Appearance" );
316 316
317 QWidget *tab = new QWidget( parent, "AdvancedTab" ); 317 QWidget *tab = new QWidget( parent, "AdvancedTab" );
318 QVBoxLayout *vertLayout = new QVBoxLayout( tab, 4, 4 ); 318 QVBoxLayout *vertLayout = new QVBoxLayout( tab, 4, 4 );
319 319
320 QGridLayout* gridLayout = new QGridLayout ( vertLayout ); 320 QGridLayout* gridLayout = new QGridLayout ( vertLayout );
321 321
322 int style = config. readNumEntry ( "TabStyle", 2 ) - 1; 322 int style = config. readNumEntry ( "TabStyle", 2 ) - 1;
323 bool tabtop = ( config. readEntry ( "TabPosition", "Top" ) == "Top" ); 323 bool tabtop = ( config. readEntry ( "TabPosition", "Top" ) == "Top" );
324 324
325 QLabel* label = new QLabel( tr( "Tab style:" ), tab ); 325 QLabel* label = new QLabel( tr( "Tab style:" ), tab );
326 gridLayout-> addWidget ( label, 0, 0 ); 326 gridLayout-> addWidget ( label, 0, 0 );
327 QButtonGroup* btngrp = new QButtonGroup( tab, "buttongroup" ); 327 QButtonGroup* btngrp = new QButtonGroup( tab, "buttongroup" );
328 btngrp-> hide ( ); 328 btngrp-> hide ( );
329 btngrp-> setExclusive ( true ); 329 btngrp-> setExclusive ( true );
330 330
331 m_tabstyle_list = new QComboBox ( false, tab, "tabstyle" ); 331 m_tabstyle_list = new QComboBox ( false, tab, "tabstyle" );
332 m_tabstyle_list-> insertItem ( tr( "Tabs" )); 332 m_tabstyle_list-> insertItem ( tr( "Tabs" ));
333 m_tabstyle_list-> insertItem ( tr( "Tabs w/icons" )); 333 m_tabstyle_list-> insertItem ( tr( "Tabs w/icons" ));
334 m_tabstyle_list-> insertItem ( tr( "Drop down list" )); 334 m_tabstyle_list-> insertItem ( tr( "Drop down list" ));
335 m_tabstyle_list-> insertItem ( tr( "Drop down list w/icons" )); 335 m_tabstyle_list-> insertItem ( tr( "Drop down list w/icons" ));
336 m_tabstyle_list-> setCurrentItem ( style ); 336 m_tabstyle_list-> setCurrentItem ( style );
337 gridLayout-> addMultiCellWidget ( m_tabstyle_list, 0, 0, 1, 2 ); 337 gridLayout-> addMultiCellWidget ( m_tabstyle_list, 0, 0, 1, 2 );
338 338
339 m_tabstyle_top = new QRadioButton( tr( "Top" ), tab, "tabpostop" ); 339 m_tabstyle_top = new QRadioButton( tr( "Top" ), tab, "tabpostop" );
340 btngrp-> insert ( m_tabstyle_top ); 340 btngrp-> insert ( m_tabstyle_top );
341 gridLayout-> addWidget( m_tabstyle_top, 1, 1 ); 341 gridLayout-> addWidget( m_tabstyle_top, 1, 1 );
342 342
343 m_tabstyle_bottom = new QRadioButton( tr( "Bottom" ), tab, "tabposbottom" ); 343 m_tabstyle_bottom = new QRadioButton( tr( "Bottom" ), tab, "tabposbottom" );
344 btngrp-> insert ( m_tabstyle_bottom ); 344 btngrp-> insert ( m_tabstyle_bottom );
345 gridLayout-> addWidget( m_tabstyle_bottom, 1, 2 ); 345 gridLayout-> addWidget( m_tabstyle_bottom, 1, 2 );
346 346
347 m_tabstyle_top-> setChecked ( tabtop ); 347 m_tabstyle_top-> setChecked ( tabtop );
348 m_tabstyle_bottom-> setChecked ( !tabtop ); 348 m_tabstyle_bottom-> setChecked ( !tabtop );
349 349
350 m_original_tabstyle = style; 350 m_original_tabstyle = style;
351 m_original_tabpos = tabtop; 351 m_original_tabpos = tabtop;
352 352
353 return tab; 353 return tab;
354} 354}
355 355
356 356
357Appearance::Appearance( QWidget* parent, const char* name, WFlags ) 357Appearance::Appearance( QWidget* parent, const char* name, WFlags )
358 : QDialog ( parent, name, true ) 358 : QDialog ( parent, name, true )
359{ 359{
360 setCaption( tr( "Appearance" ) ); 360 setCaption( tr( "Appearance" ) );
361 361
362 Config config( "qpe" ); 362 Config config( "qpe" );
363 config.setGroup( "Appearance" ); 363 config.setGroup( "Appearance" );
364 364
365 QVBoxLayout *top = new QVBoxLayout ( this, 4, 4 ); 365 QVBoxLayout *top = new QVBoxLayout ( this, 4, 4 );
366 366
367 m_sample = new SampleWindow ( this ); 367 m_sample = new SampleWindow ( this );
368 m_sample-> setDecoration ( new DefaultWindowDecoration ( )); 368 m_sample-> setDecoration ( new DefaultWindowDecoration ( ));
369 369
370 OTabWidget* tw = new OTabWidget ( this, "tabwidget", OTabWidget::Global, OTabWidget::Bottom ); 370 OTabWidget* tw = new OTabWidget ( this, "tabwidget", OTabWidget::Global, OTabWidget::Bottom );
371 QWidget *styletab; 371 QWidget *styletab;
372 372
373 tw-> addTab ( styletab = createStyleTab ( tw ), "appearance/styletabicon.png", tr( "Style" )); 373 tw-> addTab ( styletab = createStyleTab ( tw ), "appearance/styletabicon.png", tr( "Style" ));
374 tw-> addTab ( createFontTab ( tw ), "appearance/fonttabicon.png", tr( "Font" )); 374 tw-> addTab ( createFontTab ( tw ), "appearance/fonttabicon.png", tr( "Font" ));
375 tw-> addTab ( createColorTab ( tw ), "appearance/colorstabicon.png", tr( "Colors" ) ); 375 tw-> addTab ( createColorTab ( tw ), "appearance/colorstabicon.png", tr( "Colors" ) );
376 tw-> addTab ( createDecoTab ( tw ), "appearance/decotabicon.png", tr( "Windows" ) ); 376 tw-> addTab ( createDecoTab ( tw ), "appearance/decotabicon.png", tr( "Windows" ) );
377 tw-> addTab ( createGuiTab ( tw ), "appearance/advancedtabicon.png", tr( "Gui" ) ); 377 tw-> addTab ( createGuiTab ( tw ), "appearance/advancedtabicon.png", tr( "Gui" ) );
378 378
379 top-> addWidget ( tw, 10 ); 379 top-> addWidget ( tw, 10 );
380 top-> addWidget ( m_sample, 1 ); 380 top-> addWidget ( m_sample, 1 );
381 381
382 tw-> setCurrentTab ( styletab ); 382 tw-> setCurrentTab ( styletab );
383
384 m_style_changed = m_font_changed = m_color_changed = m_deco_changed = false;
383} 385}
384 386
385Appearance::~Appearance() 387Appearance::~Appearance()
386{ 388{
387} 389}
388 390
389void Appearance::accept ( ) 391void Appearance::accept ( )
390{ 392{
391 Config config("qpe");
392 config.setGroup( "Appearance" );
393
394 int newtabstyle = m_tabstyle_list-> currentItem ( );
395 bool newtabpos = m_tabstyle_top-> isChecked ( ); 393 bool newtabpos = m_tabstyle_top-> isChecked ( );
394 int newtabstyle = m_tabstyle_list-> currentItem ( );
396 395
396 Config config ( "qpe" );
397 config. setGroup ( "Appearance" );
397 398
398 if ( m_style_changed ) { 399 if ( m_style_changed ) {
399 StyleListItem *item = (StyleListItem *) m_style_list-> item ( m_style_list-> currentItem ( )); 400 StyleListItem *item = (StyleListItem *) m_style_list-> item ( m_style_list-> currentItem ( ));
400 if ( item ) 401 if ( item )
401 config.writeEntry( "Style", item-> key ( )); 402 config.writeEntry( "Style", item-> key ( ));
402 } 403 }
403 404
404 if ( m_deco_changed ) { 405 if ( m_deco_changed ) {
405 DecoListItem *item = (DecoListItem *) m_deco_list-> item ( m_deco_list-> currentItem ( )); 406 DecoListItem *item = (DecoListItem *) m_deco_list-> item ( m_deco_list-> currentItem ( ));
406 if ( item ) 407 if ( item )
407 config.writeEntry( "Decoration", item-> key ( )); 408 config.writeEntry( "Decoration", item-> key ( ));
408 } 409 }
409 410
410 if (( newtabstyle != m_original_tabstyle ) || ( newtabpos != m_original_tabpos )) { 411 if (( newtabstyle != m_original_tabstyle ) || ( newtabpos != m_original_tabpos )) {
411 config. writeEntry ( "TabStyle", newtabstyle + 1 ); 412 config. writeEntry ( "TabStyle", newtabstyle + 1 );
412 config. writeEntry ( "TabPosition", newtabpos ? "Top" : "Bottom" ); 413 config. writeEntry ( "TabPosition", newtabpos ? "Top" : "Bottom" );
413 } 414 }
414 415
415 if ( m_font_changed ) { 416 if ( m_font_changed ) {
416 config. writeEntry ( "FontFamily", m_fontselect-> fontFamily ( )); 417 config. writeEntry ( "FontFamily", m_fontselect-> fontFamily ( ));
417 config. writeEntry ( "FontStyle", m_fontselect-> fontStyle ( )); 418 config. writeEntry ( "FontStyle", m_fontselect-> fontStyle ( ));
418 config. writeEntry ( "FontSize", m_fontselect-> fontSize ( )); 419 config. writeEntry ( "FontSize", m_fontselect-> fontSize ( ));
419 } 420 }
420 421
421 422
422 if ( m_color_changed ) 423 if ( m_color_changed )
423 { 424 {
424 ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); 425 ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( ));
425 426
426 if ( item ) 427 if ( item )
427 item-> save ( config ); 428 item-> save ( config );
428 } 429 }
429 430
430 config. write ( ); // need to flush the config info first 431 config. write ( ); // need to flush the config info first
431 Global::applyStyle ( ); 432 Global::applyStyle ( );
432 433
433 if ( QMessageBox::warning ( this, tr( "Restart" ), tr( "Do you want to restart Opie now?" ), tr( "Yes" ), tr( "No" ), 0, 0, 1 ) == 0 ) { 434 if ( QMessageBox::warning ( this, tr( "Restart" ), tr( "Do you want to restart Opie now?" ), tr( "Yes" ), tr( "No" ), 0, 0, 1 ) == 0 ) {
434 QCopEnvelope e( "QPE/System", "restart()" ); 435 QCopEnvelope e( "QPE/System", "restart()" );
435 } 436 }
436 437
437 QDialog::accept ( ); 438 QDialog::accept ( );
438} 439}
439 440
440void Appearance::done ( int r ) 441void Appearance::done ( int r )
441{ 442{
442 QDialog::done ( r ); 443 QDialog::done ( r );
443 close ( ); 444 close ( );
444} 445}
445 446
446 447
447void Appearance::styleClicked ( int index ) 448void Appearance::styleClicked ( int index )
448{ 449{
449 StyleListItem *sli = (StyleListItem *) m_style_list-> item ( index ); 450 StyleListItem *sli = (StyleListItem *) m_style_list-> item ( index );
450 m_style_settings-> setEnabled ( sli ? sli-> hasSettings ( ) : false ); 451 m_style_settings-> setEnabled ( sli ? sli-> hasSettings ( ) : false );
451 452
452 if ( m_sample && sli && sli-> style ( )) 453 if ( m_sample && sli && sli-> style ( ))
453 m_sample-> setStyle2 ( sli-> style ( )); 454 m_sample-> setStyle2 ( sli-> style ( ));
454 455
455 m_style_changed |= ( index != m_original_style ); 456 m_style_changed |= ( index != m_original_style );
456} 457}
457 458
458void Appearance::styleSettingsClicked ( ) 459void Appearance::styleSettingsClicked ( )
459{ 460{
460 StyleListItem *item = (StyleListItem *) m_style_list-> item ( m_style_list-> currentItem ( )); 461 StyleListItem *item = (StyleListItem *) m_style_list-> item ( m_style_list-> currentItem ( ));
461 462
462 if ( item && item-> hasSettings ( )) { 463 if ( item && item-> hasSettings ( )) {
463 QDialog *d = new QDialog ( this, "SETTINGS-DLG", true ); 464 QDialog *d = new QDialog ( this, "SETTINGS-DLG", true );
464 QVBoxLayout *vbox = new QVBoxLayout ( d, 4, 0 ); 465 QVBoxLayout *vbox = new QVBoxLayout ( d, 4, 0 );
465 466
466 QWidget *w = item-> settings ( d ); 467 QWidget *w = item-> settings ( d );
467 468
468 if ( w ) { 469 if ( w ) {
469 vbox-> addWidget ( w ); 470 vbox-> addWidget ( w );
470 471
471 d-> setCaption ( w-> caption ( )); 472 d-> setCaption ( w-> caption ( ));
472 473
473 d-> showMaximized ( ); 474 d-> showMaximized ( );
474 bool accepted = ( d-> exec ( ) == QDialog::Accepted ); 475 bool accepted = ( d-> exec ( ) == QDialog::Accepted );
475 476
476 if ( item-> setSettings ( accepted )) 477 if ( item-> setSettings ( accepted ))
477 m_style_changed = true; 478 m_style_changed = true;
478 } 479 }
479 delete d; 480 delete d;
480 } 481 }
481} 482}
482 483
483void Appearance::decoClicked ( int index ) 484void Appearance::decoClicked ( int index )
484{ 485{
485 DecoListItem *dli = (DecoListItem *) m_deco_list-> item ( index ); 486 DecoListItem *dli = (DecoListItem *) m_deco_list-> item ( index );
486 487
487 if ( m_sample ) { 488 if ( m_sample ) {
488 if ( dli && dli-> interface ( )) 489 if ( dli && dli-> interface ( ))
489 m_sample-> setDecoration ( dli-> interface ( )); 490 m_sample-> setDecoration ( dli-> interface ( ));
490 else 491 else
491 m_sample-> setDecoration ( new DefaultWindowDecoration ( )); 492 m_sample-> setDecoration ( new DefaultWindowDecoration ( ));
492 m_sample-> repaint ( ); 493 m_sample-> repaint ( );
493 } 494 }
494 m_deco_changed |= ( index != m_original_deco ); 495 m_deco_changed |= ( index != m_original_deco );
495} 496}
496 497
497void Appearance::fontClicked ( const QFont &f ) 498void Appearance::fontClicked ( const QFont &f )
498{ 499{
499 m_font_changed |= ( f != m_sample-> font ( )); 500 m_font_changed |= ( f != m_sample-> font ( ));
500 m_sample-> setFont ( f ); 501 m_sample-> setFont ( f );
501} 502}
502 503
503void Appearance::colorClicked ( int index ) 504void Appearance::colorClicked ( int index )
504{ 505{
505 ColorListItem *item = (ColorListItem *) m_color_list-> item ( index ); 506 ColorListItem *item = (ColorListItem *) m_color_list-> item ( index );
506 507
507 if ( item ) 508 if ( item )
508 m_sample-> setPalette ( item-> palette ( )); 509 m_sample-> setPalette ( item-> palette ( ));
509 510
510 m_color_changed |= ( item-> palette ( ) != qApp-> palette ( )); 511 m_color_changed |= ( item-> palette ( ) != qApp-> palette ( ));
511} 512}
512 513
513 514
514void Appearance::editSchemeClicked ( ) 515void Appearance::editSchemeClicked ( )
515{ 516{
516 ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); 517 ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( ));
517 518
518 int cnt = 0; 519 int cnt = 0;
519 QString labels [QColorGroup::NColorRoles]; 520 QString labels [QColorGroup::NColorRoles];
520 QColor colors [QColorGroup::NColorRoles]; 521 QColor colors [QColorGroup::NColorRoles];
521 522
522 for ( QColorGroup::ColorRole role = (QColorGroup::ColorRole) 0; role != QColorGroup::NColorRoles; ((int) role )++ ) { 523 for ( QColorGroup::ColorRole role = (QColorGroup::ColorRole) 0; role != QColorGroup::NColorRoles; ((int) role )++ ) {
523 QColor col = item-> color ( role ); 524 QColor col = item-> color ( role );
524 525
525 if ( col. isValid ( )) { 526 if ( col. isValid ( )) {
526 labels [cnt] = item-> label ( role ); 527 labels [cnt] = item-> label ( role );
527 colors [cnt] = col; 528 colors [cnt] = col;
528 529
529 cnt++; 530 cnt++;
530 } 531 }
531 } 532 }
532 533
533 EditScheme* editdlg = new EditScheme( cnt, labels, colors, this, "editScheme", true ); 534 EditScheme* editdlg = new EditScheme( cnt, labels, colors, this, "editScheme", true );
534 editdlg-> showMaximized ( ); 535 editdlg-> showMaximized ( );
535 if ( editdlg-> exec ( ) == QDialog::Accepted ) { 536 if ( editdlg-> exec ( ) == QDialog::Accepted ) {
536 ColorListItem *citem = (ColorListItem *) m_color_list-> item ( 0 ); 537 ColorListItem *citem = (ColorListItem *) m_color_list-> item ( 0 );
537 cnt = 0; 538 cnt = 0;
538 539
539 for ( QColorGroup::ColorRole role = (QColorGroup::ColorRole) 0; role != QColorGroup::NColorRoles; ((int) role )++ ) { 540 for ( QColorGroup::ColorRole role = (QColorGroup::ColorRole) 0; role != QColorGroup::NColorRoles; ((int) role )++ ) {
540 if ( item-> color ( role ). isValid ( )) { 541 if ( item-> color ( role ). isValid ( )) {
541 citem-> setColor ( role, colors [cnt] ); 542 citem-> setColor ( role, colors [cnt] );
542 cnt++; 543 cnt++;
543 } 544 }
544 } 545 }
545 546
546 m_color_list-> setCurrentItem ( 0 ); 547 m_color_list-> setCurrentItem ( 0 );
547 colorClicked ( 0 ); 548 colorClicked ( 0 );
548 549
549 m_color_changed = true; 550 m_color_changed = true;
550 } 551 }
551 delete editdlg; 552 delete editdlg;
552} 553}
553 554
554 555
555void Appearance::saveSchemeClicked() 556void Appearance::saveSchemeClicked()
556{ 557{
557 ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); 558 ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( ));
558 559
559 if ( !item ) 560 if ( !item )
560 return; 561 return;
561 562
562 QDialog *d = new QDialog ( this, 0, true ); 563 QDialog *d = new QDialog ( this, 0, true );
563 d-> setCaption ( tr( "Save Scheme" )); 564 d-> setCaption ( tr( "Save Scheme" ));
564 QLineEdit *ed = new QLineEdit ( this ); 565 QLineEdit *ed = new QLineEdit ( this );
565 ( new QVBoxLayout ( d, 4, 4 ))-> addWidget ( ed ); 566 ( new QVBoxLayout ( d, 4, 4 ))-> addWidget ( ed );
566 567
567 if ( d-> exec ( ) == QDialog::Accepted ) { 568 if ( d-> exec ( ) == QDialog::Accepted ) {
568 QString schemename = ed-> text ( ); 569 QString schemename = ed-> text ( );
569 QFile file ( QPEApplication::qpeDir() + "/etc/colors/" + schemename + ".scheme" ); 570 QFile file ( QPEApplication::qpeDir() + "/etc/colors/" + schemename + ".scheme" );
570 if ( !file. exists ( )) 571 if ( !file. exists ( ))
571 { 572 {
572 QPalette p = item-> palette ( ); 573 QPalette p = item-> palette ( );
573 574
574 Config config ( file.name(), Config::File ); 575 Config config ( file.name(), Config::File );
575 config. setGroup( "Colors" ); 576 config. setGroup( "Colors" );
576 577
577 item-> save ( config ); 578 item-> save ( config );
578 579
579 config. write ( ); // need to flush the config info first 580 config. write ( ); // need to flush the config info first
580 loadColors ( m_color_list ); 581 loadColors ( m_color_list );
581 } 582 }
582 else 583 else
583 { 584 {
584 QMessageBox::information ( this, tr( "Save scheme" ), tr( "Scheme does already exist." )); 585 QMessageBox::information ( this, tr( "Save scheme" ), tr( "Scheme does already exist." ));
585 } 586 }
586 } 587 }
587 delete d; 588 delete d;
588} 589}
589 590
590void Appearance::deleteSchemeClicked() 591void Appearance::deleteSchemeClicked()
591{ 592{
592 ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); 593 ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( ));
593 594
594 if ( !item ) 595 if ( !item )
595 return; 596 return;
596 597
597 if ( m_color_list-> currentItem ( ) > 0 ) 598 if ( m_color_list-> currentItem ( ) > 0 )
598 { 599 {
599 if ( QMessageBox::warning ( this, tr( "Delete scheme" ), tr( "Do you really want to delete\n" ) + item-> text ( ) + "?", 600 if ( QMessageBox::warning ( this, tr( "Delete scheme" ), tr( "Do you really want to delete\n" ) + item-> text ( ) + "?",
600 tr( "Yes" ), tr( "No" ), 0, 0, 1 ) == 0 ) { 601 tr( "Yes" ), tr( "No" ), 0, 0, 1 ) == 0 ) {
601 QFile::remove ( QPEApplication::qpeDir ( ) + "/etc/colors/" + item-> text ( ) + ".scheme" ); 602 QFile::remove ( QPEApplication::qpeDir ( ) + "/etc/colors/" + item-> text ( ) + ".scheme" );
602 loadColors ( m_color_list ); 603 loadColors ( m_color_list );
603 } 604 }
604 } 605 }
605 else 606 else
606 { 607 {
607 QMessageBox::information( this, tr( "Delete scheme" ), tr( "Unable to delete current scheme." )); 608 QMessageBox::information( this, tr( "Delete scheme" ), tr( "Unable to delete current scheme." ));
608 } 609 }
609} 610}
610 611