summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/appearance2/appearance.cpp461
-rw-r--r--noncore/settings/appearance2/appearance.h30
-rw-r--r--noncore/settings/appearance2/exceptlistitem.h199
3 files changed, 521 insertions, 169 deletions
diff --git a/noncore/settings/appearance2/appearance.cpp b/noncore/settings/appearance2/appearance.cpp
index 303e0b9..22b12b4 100644
--- a/noncore/settings/appearance2/appearance.cpp
+++ b/noncore/settings/appearance2/appearance.cpp
@@ -28,20 +28,4 @@
28*/ 28*/
29 29
30#include "appearance.h"
31#include "editScheme.h"
32
33#include <opie/ofiledialog.h>
34#include <opie/otabwidget.h>
35
36#include <qpe/applnk.h>
37#include <qpe/config.h>
38#include <qpe/global.h>
39#include <qpe/resource.h>
40#include <qpe/qpeapplication.h>
41#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
42#include <qpe/qcopenvelope_qws.h>
43#endif
44
45#include <qaction.h>
46#include <qbuttongroup.h> 30#include <qbuttongroup.h>
47#include <qcheckbox.h> 31#include <qcheckbox.h>
@@ -54,29 +38,40 @@
54#include <qlistbox.h> 38#include <qlistbox.h>
55#include <qmessagebox.h> 39#include <qmessagebox.h>
56#include <qmultilineedit.h>
57#include <qpopupmenu.h>
58#include <qpushbutton.h> 40#include <qpushbutton.h>
59#include <qradiobutton.h> 41#include <qradiobutton.h>
60#if QT_VERSION >= 300 42#if QT_VERSION >= 300
61#include <qstylefactory.h> 43#include <qstylefactory.h>
62#else 44#endif
45#include <qtoolbutton.h>
63#include <qwindowsstyle.h> 46#include <qwindowsstyle.h>
47#include <qlistview.h>
48#include <qheader.h>
49#include <qvbox.h>
50
51#include <qpe/config.h>
52#include <qpe/global.h>
53#include <qpe/resource.h>
54#include <qpe/qpeapplication.h>
55#include <qpe/qcopenvelope_qws.h>
64#include <qpe/qpestyle.h> 56#include <qpe/qpestyle.h>
65#include <qpe/lightstyle.h> 57#include <qpe/lightstyle.h>
66#include <qpe/qlibrary.h> 58#include <qpe/qlibrary.h>
67#include <qpe/styleinterface.h> 59#include <qpe/styleinterface.h>
68#endif
69#include <qtabwidget.h>
70#include <qtoolbutton.h>
71#include <qvgroupbox.h>
72#include <qwidget.h>
73 60
61#include <opie/ofontselector.h>
62#include <opie/odevice.h>
63#include <opie/ofiledialog.h>
64#include <opie/otabwidget.h>
65
66#include "appearance.h"
67#include "editScheme.h"
74#include "stylelistitem.h" 68#include "stylelistitem.h"
75#include "decolistitem.h" 69#include "decolistitem.h"
76#include "colorlistitem.h" 70#include "colorlistitem.h"
77 71#include "exceptlistitem.h"
78#include "sample.h" 72#include "sample.h"
79 73
80#include <opie/ofontselector.h> 74
75using namespace Opie;
81 76
82 77
@@ -110,92 +105,12 @@ private:
110 105
111 106
112void Appearance::loadStyles ( QListBox *list )
113{
114#if QT_VERSION >= 300
115 list->insertStringList(QStyleFactory::styles());
116#else
117 list->insertItem( new StyleListItem ( "Windows", new QWindowsStyle ( )));
118 list->insertItem( new StyleListItem ( "Light", new LightStyle ( )));
119#ifndef QT_NO_STYLE_MOTIF
120 list->insertItem( new StyleListItem ( "Motif", new QMotifStyle ( )));
121#endif
122#ifndef QT_NO_STYLE_MOTIFPLUS
123 list->insertItem( new StyleListItem ( "MotifPlus", new QMotifPlusStyle ( )));
124#endif
125#ifndef QT_NO_STYLE_PLATINUM
126 list->insertItem( new StyleListItem ( "Platinum", new QPlatinumStyle ( )));
127#endif
128#endif
129 list->insertItem( new StyleListItem ( "QPE", new QPEStyle ( )));
130 107
131#if QT_VERSION < 300
132 {
133 QString path = QPEApplication::qpeDir() + "/plugins/styles/";
134 QStringList sl = QDir ( path, "lib*.so" ). entryList ( );
135 108
136 for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) {
137 QLibrary *lib = new QLibrary ( path + "/" + *it );
138 StyleInterface *iface;
139 109
140 if (( lib-> queryInterface ( IID_Style, (QUnknownInterface **) &iface ) == QS_OK ) && iface )
141 list-> insertItem ( new StyleListItem ( lib, iface ));
142 else
143 delete lib;
144 }
145 }
146 110
147#endif 111QWidget *Appearance::createStyleTab ( QWidget *parent, Config &cfg )
148}
149
150void Appearance::loadDecos ( QListBox *list )
151{ 112{
152 list-> insertItem ( new DecoListItem ( "QPE" ));
153
154 {
155 QString path = QPEApplication::qpeDir() + "/plugins/decorations/";
156 QStringList sl = QDir ( path, "lib*.so" ). entryList ( );
157
158 for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) {
159 QLibrary *lib = new QLibrary ( path + "/" + *it );
160 WindowDecorationInterface *iface;
161
162 if ( lib-> queryInterface ( IID_WindowDecoration, (QUnknownInterface **) &iface ) == QS_OK )
163 list-> insertItem ( new DecoListItem ( lib, iface ));
164 else
165 delete lib;
166 }
167 }
168}
169
170void Appearance::loadColors ( QListBox *list )
171{
172 list-> clear ( );
173 {
174 Config config ( "qpe" );
175 config. setGroup ( "Appearance" );
176
177 list-> insertItem ( new ColorListItem ( tr( "Current scheme" ), config ));
178 }
179
180 QString path = QPEApplication::qpeDir ( ) + "/etc/colors/";
181 QStringList sl = QDir ( path ). entryList ( "*.scheme" );
182
183 for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) {
184 QString name = (*it). left ((*it). find ( ".scheme" ));
185 Config config ( path + *it, Config::File );
186 config. setGroup ( "Colors" );
187
188 list-> insertItem ( new ColorListItem ( name, config ));
189 }
190}
191
192
193QWidget *Appearance::createStyleTab ( QWidget *parent )
194{
195 Config config ( "qpe" );
196 config. setGroup ( "Appearance" );
197
198 QWidget* tab = new QWidget( parent, "StyleTab" ); 113 QWidget* tab = new QWidget( parent, "StyleTab" );
199 QVBoxLayout* vertLayout = new QVBoxLayout( tab, 4, 4 ); 114 QVBoxLayout* vertLayout = new QVBoxLayout( tab, 3, 3 );
200 115
201 m_style_list = new QListBox( tab, "m_style_list" ); 116 m_style_list = new QListBox( tab, "m_style_list" );
@@ -206,12 +121,31 @@ QWidget *Appearance::createStyleTab ( QWidget *parent )
206 vertLayout-> addWidget ( m_style_settings ); 121 vertLayout-> addWidget ( m_style_settings );
207 122
208 loadStyles ( m_style_list ); 123 QString s = cfg. readEntry ( "Style", "Light" );
124
125
126#if QT_VERSION >= 300
127 m_style_list->insertStringList(QStyleFactory::styles());
128#else
129 m_style_list-> insertItem ( new StyleListItem ( "Windows", new QWindowsStyle ( )));
130 m_style_list-> insertItem ( new StyleListItem ( "Light", new LightStyle ( )));
131 m_style_list-> insertItem ( new StyleListItem ( "QPE", new QPEStyle ( )));
132#endif
133 {
134 QString path = QPEApplication::qpeDir ( ) + "/plugins/styles/";
135 QStringList sl = QDir ( path, "lib*.so" ). entryList ( );
136
137 for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) {
138 QLibrary *lib = new QLibrary ( path + "/" + *it );
139 StyleInterface *iface;
209 140
210 QString s = config. readEntry ( "Style", "Light" ); 141 if (( lib-> queryInterface ( IID_Style, (QUnknownInterface **) &iface ) == QS_OK ) && iface ) {
142 StyleListItem *slit = new StyleListItem ( lib, iface );
143 m_style_list-> insertItem ( slit );
211 144
212 for ( uint i = 0; i < m_style_list-> count ( ); i++ ) { 145 if ( slit-> key ( ) == s )
213 if (((StyleListItem *) m_style_list-> item ( i ))-> key ( ) == s ) { 146 m_style_list-> setCurrentItem ( slit );
214 m_style_list-> setCurrentItem ( i ); 147 }
215 break; 148 else
149 delete lib;
216 } 150 }
217 } 151 }
@@ -225,23 +159,33 @@ QWidget *Appearance::createStyleTab ( QWidget *parent )
225} 159}
226 160
227QWidget *Appearance::createDecoTab ( QWidget *parent ) 161QWidget *Appearance::createDecoTab ( QWidget *parent, Config &cfg )
228{ 162{
229 Config config ( "qpe" );
230 config. setGroup ( "Appearance" );
231
232 QWidget* tab = new QWidget( parent, "DecoTab" ); 163 QWidget* tab = new QWidget( parent, "DecoTab" );
233 QVBoxLayout* vertLayout = new QVBoxLayout( tab, 4, 4 ); 164 QVBoxLayout* vertLayout = new QVBoxLayout( tab, 3, 3 );
234 165
235 m_deco_list = new QListBox( tab, "m_deco_list" ); 166 m_deco_list = new QListBox( tab, "m_deco_list" );
236 vertLayout->addWidget( m_deco_list ); 167 vertLayout->addWidget( m_deco_list );
237 168
238 loadDecos ( m_deco_list ); 169 QString s = cfg. readEntry ( "Decoration" );
239 170
240 QString s = config. readEntry ( "Decoration" ); 171 m_deco_list-> insertItem ( new DecoListItem ( "QPE" ));
241 172
242 for ( uint i = 0; i < m_deco_list-> count ( ); i++ ) { 173 {
243 if (((DecoListItem *) m_deco_list-> item ( i ))-> key ( ) == s ) { 174 QString path = QPEApplication::qpeDir() + "/plugins/decorations/";
244 m_deco_list-> setCurrentItem ( i ); 175 QStringList sl = QDir ( path, "lib*.so" ). entryList ( );
245 break; 176
177 for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) {
178 QLibrary *lib = new QLibrary ( path + "/" + *it );
179 WindowDecorationInterface *iface;
180
181 if ( lib-> queryInterface ( IID_WindowDecoration, (QUnknownInterface **) &iface ) == QS_OK ) {
182 DecoListItem *dlit = new DecoListItem ( lib, iface );
183 m_deco_list-> insertItem ( dlit );
184
185 if ( dlit-> key ( ) == s )
186 m_deco_list-> setCurrentItem ( dlit );
187 }
188 else
189 delete lib;
246 } 190 }
247 } 191 }
@@ -257,12 +201,9 @@ QWidget *Appearance::createDecoTab ( QWidget *parent )
257} 201}
258 202
259QWidget *Appearance::createFontTab ( QWidget *parent ) 203QWidget *Appearance::createFontTab ( QWidget *parent, Config &cfg )
260{ 204{
261 Config config ( "qpe" ); 205 QString familyStr = cfg. readEntry ( "FontFamily", "Helvetica" );
262 config. setGroup ( "Appearance" ); 206 QString styleStr = cfg. readEntry ( "FontStyle", "Regular" );
263 207 int size = cfg. readNumEntry ( "FontSize", 10 );
264 QString familyStr = config.readEntry( "FontFamily", "Helvetica" );
265 QString styleStr = config.readEntry( "FontStyle", "Regular" );
266 int size = config.readNumEntry( "FontSize", 10 );
267 208
268 m_fontselect = new OFontSelector ( false, parent, "FontTab" ); 209 m_fontselect = new OFontSelector ( false, parent, "FontTab" );
@@ -275,12 +216,8 @@ QWidget *Appearance::createFontTab ( QWidget *parent )
275} 216}
276 217
277QWidget *Appearance::createColorTab ( QWidget *parent ) 218QWidget *Appearance::createColorTab ( QWidget *parent, Config &cfg )
278{ 219{
279 Config config ( "qpe" );
280 config. setGroup ( "Appearance" );
281
282
283 QWidget *tab = new QWidget( parent, "ColorTab" ); 220 QWidget *tab = new QWidget( parent, "ColorTab" );
284 QGridLayout *gridLayout = new QGridLayout( tab, 0, 0, 4, 4 ); 221 QGridLayout *gridLayout = new QGridLayout( tab, 0, 0, 3, 3 );
285 gridLayout->setRowStretch ( 3, 10 ); 222 gridLayout->setRowStretch ( 3, 10 );
286 223
@@ -289,5 +226,17 @@ QWidget *Appearance::createColorTab ( QWidget *parent )
289 connect( m_color_list, SIGNAL( highlighted( int ) ), this, SLOT( colorClicked( int ) ) ); 226 connect( m_color_list, SIGNAL( highlighted( int ) ), this, SLOT( colorClicked( int ) ) );
290 227
291 loadColors ( m_color_list ); 228 m_color_list-> insertItem ( new ColorListItem ( tr( "Current scheme" ), cfg ));
229
230 QString path = QPEApplication::qpeDir ( ) + "/etc/colors/";
231 QStringList sl = QDir ( path ). entryList ( "*.scheme" );
232
233 for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) {
234 QString name = (*it). left ((*it). find ( ".scheme" ));
235 Config config ( path + *it, Config::File );
236 config. setGroup ( "Colors" );
237
238 m_color_list-> insertItem ( new ColorListItem ( name, config ));
239 }
240
292 m_color_list-> setCurrentItem ( 0 ); 241 m_color_list-> setCurrentItem ( 0 );
293 242
@@ -310,16 +259,82 @@ QWidget *Appearance::createColorTab ( QWidget *parent )
310} 259}
311 260
312QWidget *Appearance::createGuiTab ( QWidget *parent ) 261QWidget *Appearance::createAdvancedTab ( QWidget *parent, Config &cfg )
313{ 262{
314 Config config ( "qpe" ); 263 QWidget *tab = new QWidget ( parent );
315 config. setGroup ( "Appearance" ); 264 QVBoxLayout *vertLayout = new QVBoxLayout( tab, 3, 3 );
265
266 QGridLayout *lay = new QGridLayout ( vertLayout, 0, 0, 3, 0 );
267
268 m_force = new QCheckBox ( tr( "Force styling for all applications." ), tab );
269 m_force-> setChecked ( cfg. readBoolEntry ( "ForceStyle" ));
270 lay-> addMultiCellWidget ( m_force, 0, 0, 0, 1 );
271
272 QLabel *l = new QLabel ( tab );
273 l-> setText ( QString ( "<p>%1</p>" ). arg ( tr( "Disable styling for these applications ( <b>*</b> can be used as a wildcard):" )));
274 lay-> addMultiCellWidget ( l, 1, 1, 0, 1 );
275
276 m_except = new QListView ( tab );
277 m_except-> addColumn ( Resource::loadIconSet ( "appearance/style.png" ), "", 24 );
278 m_except-> addColumn ( Resource::loadIconSet ( "appearance/font.png" ), "", 24 );
279 m_except-> addColumn ( Resource::loadIconSet ( "appearance/deco.png" ), "", 24 );
280 m_except-> addColumn ( tr( "Binary file(s)" ));
281 m_except-> setColumnAlignment ( 0, AlignCenter );
282 m_except-> setColumnAlignment ( 1, AlignCenter );
283 m_except-> setColumnAlignment ( 2, AlignCenter );
284 m_except-> setAllColumnsShowFocus ( true );
285 m_except-> setMinimumHeight ( 30 );
286 m_except-> header ( )-> setClickEnabled ( false );
287 m_except-> header ( )-> setResizeEnabled ( false );
288 m_except-> header ( )-> setMovingEnabled ( false );
289 lay-> addMultiCellWidget ( m_except, 2, 6, 0, 0 );
290
291 connect ( m_except, SIGNAL( clicked ( QListViewItem *, const QPoint &, int )), this, SLOT( clickedExcept ( QListViewItem *, const QPoint &, int )));
292
293 QToolButton *tb = new QToolButton ( tab );
294 tb-> setIconSet ( Resource::loadIconSet ( "appearance/add" ));
295 tb-> setFocusPolicy ( QWidget::StrongFocus );
296 lay-> addWidget ( tb, 2, 1 );
297 connect ( tb, SIGNAL( clicked ( )), this, SLOT( addExcept ( )));
298
299 tb = new QToolButton ( tab );
300 tb-> setIconSet ( Resource::loadIconSet ( "editdelete" ));
301 tb-> setFocusPolicy ( QWidget::StrongFocus );
302 lay-> addWidget ( tb, 3, 1 );
303 connect ( tb, SIGNAL( clicked ( )), this, SLOT( delExcept ( )));
304
305 tb = new QToolButton ( tab );
306 tb-> setIconSet ( Resource::loadIconSet ( "up" ));
307 tb-> setFocusPolicy ( QWidget::StrongFocus );
308 lay-> addWidget ( tb, 4, 1 );
309 connect ( tb, SIGNAL( clicked ( )), this, SLOT( upExcept ( )));
310
311 tb = new QToolButton ( tab );
312 tb-> setIconSet ( Resource::loadIconSet ( "down" ));
313 tb-> setFocusPolicy ( QWidget::StrongFocus );
314 lay-> addWidget ( tb, 5, 1 );
315 connect ( tb, SIGNAL( clicked ( )), this, SLOT( downExcept ( )));
316
317 lay-> setRowStretch ( 6, 10 );
318 lay-> setColStretch ( 0, 10 );
319
320 QStringList sl = cfg. readListEntry ( "NoStyle", ';' );
321 for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) {
322 int fl = ( *it ). left ( 1 ). toInt ( 0, 32 );
323
324 new ExceptListItem ( m_except, ( *it ). mid ( 1 ), fl & 0x01, fl & 0x02, fl & 0x04 );
325 }
326
327
328 vertLayout-> addSpacing ( 3 );
329 QFrame *f = new QFrame ( tab );
330 f-> setFrameStyle ( QFrame::HLine | QFrame::Sunken );
331 vertLayout-> addWidget ( f );
332 vertLayout-> addSpacing ( 3 );
316 333
317 QWidget *tab = new QWidget( parent, "AdvancedTab" );
318 QVBoxLayout *vertLayout = new QVBoxLayout( tab, 4, 4 );
319 334
320 QGridLayout* gridLayout = new QGridLayout ( vertLayout ); 335 QGridLayout* gridLayout = new QGridLayout ( vertLayout, 0, 0, 3, 0 );
321 336
322 int style = config. readNumEntry ( "TabStyle", 2 ) - 1; 337 int style = cfg. readNumEntry ( "TabStyle", 2 ) - 1;
323 bool tabtop = ( config. readEntry ( "TabPosition", "Top" ) == "Top" ); 338 bool tabtop = ( cfg. readEntry ( "TabPosition", "Top" ) == "Top" );
324 339
325 QLabel* label = new QLabel( tr( "Tab style:" ), tab ); 340 QLabel* label = new QLabel( tr( "Tab style:" ), tab );
@@ -363,5 +378,5 @@ Appearance::Appearance( QWidget* parent, const char* name, WFlags )
363 config.setGroup( "Appearance" ); 378 config.setGroup( "Appearance" );
364 379
365 QVBoxLayout *top = new QVBoxLayout ( this, 4, 4 ); 380 QVBoxLayout *top = new QVBoxLayout ( this, 3, 3 );
366 381
367 m_sample = new SampleWindow ( this ); 382 m_sample = new SampleWindow ( this );
@@ -371,9 +386,9 @@ Appearance::Appearance( QWidget* parent, const char* name, WFlags )
371 QWidget *styletab; 386 QWidget *styletab;
372 387
373 tw-> addTab ( styletab = createStyleTab ( tw ), "appearance/styletabicon.png", tr( "Style" )); 388 tw-> addTab ( styletab = createStyleTab ( tw, config ), "appearance/style.png", tr( "Style" ));
374 tw-> addTab ( createFontTab ( tw ), "appearance/fonttabicon.png", tr( "Font" )); 389 tw-> addTab ( createFontTab ( tw, config ), "appearance/font.png", tr( "Font" ));
375 tw-> addTab ( createColorTab ( tw ), "appearance/colorstabicon.png", tr( "Colors" ) ); 390 tw-> addTab ( createColorTab ( tw, config ), "appearance/color.png", tr( "Colors" ) );
376 tw-> addTab ( createDecoTab ( tw ), "appearance/decotabicon.png", tr( "Windows" ) ); 391 tw-> addTab ( createDecoTab ( tw, config ), "appearance/deco.png", tr( "Windows" ) );
377 tw-> addTab ( createGuiTab ( tw ), "appearance/advancedtabicon.png", tr( "Gui" ) ); 392 tw-> addTab ( m_advtab = createAdvancedTab ( tw, config ), "appearance/advanced.png", tr( "Advanced" ) );
378 393
379 top-> addWidget ( tw, 10 ); 394 top-> addWidget ( tw, 10 );
@@ -381,4 +396,5 @@ Appearance::Appearance( QWidget* parent, const char* name, WFlags )
381 396
382 tw-> setCurrentTab ( styletab ); 397 tw-> setCurrentTab ( styletab );
398 connect ( tw, SIGNAL( currentChanged ( QWidget * )), this, SLOT( tabChanged ( QWidget * )));
383 399
384 m_style_changed = m_font_changed = m_color_changed = m_deco_changed = false; 400 m_style_changed = m_font_changed = m_color_changed = m_deco_changed = false;
@@ -389,4 +405,14 @@ Appearance::~Appearance()
389} 405}
390 406
407void Appearance::tabChanged ( QWidget *w )
408{
409 if ( w == m_advtab ) {
410 m_sample-> hide ( );
411 updateGeometry ( ); // shouldn't be necessary ...
412 }
413 else
414 m_sample-> show ( );
415}
416
391void Appearance::accept ( ) 417void Appearance::accept ( )
392{ 418{
@@ -429,8 +455,20 @@ void Appearance::accept ( )
429 } 455 }
430 456
457
458 QStringList sl;
459 for ( ExceptListItem *it = (ExceptListItem *) m_except-> firstChild ( ); it; it = (ExceptListItem *) it-> nextSibling ( )) {
460 int fl = 0;
461 fl |= ( it-> noStyle ( ) ? 0x01 : 0 );
462 fl |= ( it-> noFont ( ) ? 0x02 : 0 );
463 fl |= ( it-> noDeco ( ) ? 0x04 : 0 );
464 sl << ( QString::number ( fl, 32 ) + it-> pattern ( ));
465 }
466 config. writeEntry ( "NoStyle", sl, ';' );
467 config. writeEntry ( "ForceStyle", m_force-> isChecked ( ));
468
431 config. write ( ); // need to flush the config info first 469 config. write ( ); // need to flush the config info first
432 Global::applyStyle ( ); 470 Global::applyStyle ( );
433 471
434 if ( QMessageBox::warning ( this, tr( "Restart" ), tr( "Do you want to restart Opie now?" ), tr( "Yes" ), tr( "No" ), 0, 0, 1 ) == 0 ) { 472 if ( QMessageBox::warning ( this, tr( "Restart" ), tr( "Do you want to restart %1 now?" ). arg ( ODevice::inst ( )-> system ( ) == System_Zaurus ? "Qtopia" : "Opie" ), tr( "Yes" ), tr( "No" ), 0, 0, 1 ) == 0 ) {
435 QCopEnvelope e( "QPE/System", "restart()" ); 473 QCopEnvelope e( "QPE/System", "restart()" );
436 } 474 }
@@ -463,5 +501,5 @@ void Appearance::styleSettingsClicked ( )
463 if ( item && item-> hasSettings ( )) { 501 if ( item && item-> hasSettings ( )) {
464 QDialog *d = new QDialog ( this, "SETTINGS-DLG", true ); 502 QDialog *d = new QDialog ( this, "SETTINGS-DLG", true );
465 QVBoxLayout *vbox = new QVBoxLayout ( d, 4, 0 ); 503 QVBoxLayout *vbox = new QVBoxLayout ( d, 3, 0 );
466 504
467 QWidget *w = item-> settings ( d ); 505 QWidget *w = item-> settings ( d );
@@ -563,6 +601,7 @@ void Appearance::saveSchemeClicked()
563 QDialog *d = new QDialog ( this, 0, true ); 601 QDialog *d = new QDialog ( this, 0, true );
564 d-> setCaption ( tr( "Save Scheme" )); 602 d-> setCaption ( tr( "Save Scheme" ));
565 QLineEdit *ed = new QLineEdit ( this ); 603 QLineEdit *ed = new QLineEdit ( d );
566 ( new QVBoxLayout ( d, 4, 4 ))-> addWidget ( ed ); 604 ( new QVBoxLayout ( d, 3, 3 ))-> addWidget ( ed );
605 ed-> setFocus ( );
567 606
568 if ( d-> exec ( ) == QDialog::Accepted ) { 607 if ( d-> exec ( ) == QDialog::Accepted ) {
@@ -579,5 +618,6 @@ void Appearance::saveSchemeClicked()
579 618
580 config. write ( ); // need to flush the config info first 619 config. write ( ); // need to flush the config info first
581 loadColors ( m_color_list ); 620
621 m_color_list-> insertItem ( new ColorListItem ( schemename, config ));
582 } 622 }
583 else 623 else
@@ -601,5 +641,5 @@ void Appearance::deleteSchemeClicked()
601 tr( "Yes" ), tr( "No" ), 0, 0, 1 ) == 0 ) { 641 tr( "Yes" ), tr( "No" ), 0, 0, 1 ) == 0 ) {
602 QFile::remove ( QPEApplication::qpeDir ( ) + "/etc/colors/" + item-> text ( ) + ".scheme" ); 642 QFile::remove ( QPEApplication::qpeDir ( ) + "/etc/colors/" + item-> text ( ) + ".scheme" );
603 loadColors ( m_color_list ); 643 delete item;
604 } 644 }
605 } 645 }
@@ -610,2 +650,105 @@ void Appearance::deleteSchemeClicked()
610} 650}
611 651
652
653void Appearance::addExcept ( )
654{
655 ExceptListItem *it = new ExceptListItem ( m_except, tr( "<new>" ), true, true, true );
656 m_except-> ensureItemVisible ( it );
657 m_except-> setSelected ( it, true );
658}
659
660void Appearance::delExcept ( )
661{
662 if ( m_except-> selectedItem ( )) {
663 m_except-> setFocus ( );
664 delete m_except-> selectedItem ( );
665 }
666}
667
668void Appearance::upExcept ( )
669{
670 ExceptListItem *it = (ExceptListItem *) m_except-> selectedItem ( );
671
672 if ( it && it-> itemAbove ( ))
673 it-> itemAbove ( )-> moveItem ( it );
674}
675
676void Appearance::downExcept ( )
677{
678 ExceptListItem *it = (ExceptListItem *) m_except-> selectedItem ( );
679
680 if ( it && it-> itemBelow ( ))
681 it-> moveItem ( it-> itemBelow ( ));
682}
683
684class ExEdit : public QLineEdit {
685public:
686 ExEdit ( ExceptListItem *item )
687 : QLineEdit ( item-> listView ( )-> viewport ( ), "exedit" ), it ( item )
688 {
689 setFrame ( false );
690
691 QRect r = it-> listView ( )-> itemRect ( it );
692
693 int x = it-> listView ( )-> header ( )-> cellPos ( 3 ) - 1;
694 int y = r. y ( );
695 int w = it-> listView ( )-> viewport ( )-> width ( ) - x;
696 int h = r. height ( ); // + 2;
697
698 setText ( it-> pattern ( ));
699 setGeometry ( x, y, w, h );
700
701 qDebug ( "ExEdit: [%s] at %d,%d %d,%d", it->text(2).latin1(),x,y,w,h);
702
703 m_out = true;
704
705 show ( );
706 setFocus ( );
707 selectAll ( );
708 end ( true );
709 }
710
711 virtual void focusOutEvent ( QFocusEvent * )
712 {
713 hide ( );
714 if ( m_out )
715 it-> setPattern ( text ( ));
716 delete this;
717 }
718
719 virtual void keyPressEvent ( QKeyEvent *e )
720 {
721 if ( e-> key ( ) == Key_Return )
722 it-> listView ( )-> setFocus ( );
723 else if ( e-> key ( ) == Key_Escape ) {
724 m_out = false;
725 it-> listView ( )-> setFocus ( );
726 }
727 else
728 QLineEdit::keyPressEvent ( e );
729 }
730
731private:
732 ExceptListItem *it;
733 bool m_out;
734};
735
736void Appearance::clickedExcept ( QListViewItem *item, const QPoint &, int c )
737{
738 if ( !item || c < 0 || c > 3 )
739 return;
740
741 ExceptListItem *it = (ExceptListItem *) item;
742
743 if ( c == 0 )
744 it-> setNoStyle ( !it-> noStyle ( ));
745 else if ( c == 1 )
746 it-> setNoFont ( !it-> noFont ( ));
747 else if ( c == 2 )
748 it-> setNoDeco ( !it-> noDeco ( ));
749 else if ( c == 3 ) {
750 m_except-> ensureItemVisible ( it );
751 new ExEdit ( it );
752 }
753}
754
diff --git a/noncore/settings/appearance2/appearance.h b/noncore/settings/appearance2/appearance.h
index a392aa7..065dfb7 100644
--- a/noncore/settings/appearance2/appearance.h
+++ b/noncore/settings/appearance2/appearance.h
@@ -32,5 +32,4 @@
32#include <qpe/fontdatabase.h> 32#include <qpe/fontdatabase.h>
33 33
34#include <qmainwindow.h>
35#include <qdialog.h> 34#include <qdialog.h>
36 35
@@ -46,4 +45,7 @@ class QToolButton;
46class SampleWindow; 45class SampleWindow;
47class OFontSelector; 46class OFontSelector;
47class QListView;
48class QListViewItem;
49class Config;
48 50
49class Appearance : public QDialog 51class Appearance : public QDialog
@@ -70,16 +72,20 @@ protected slots:
70 void deleteSchemeClicked(); 72 void deleteSchemeClicked();
71 73
72private: 74 void tabChanged ( QWidget * );
73 void loadStyles ( QListBox * ); 75
74 void loadDecos ( QListBox * ); 76 void addExcept ( );
75 void loadColors ( QListBox * ); 77 void delExcept ( );
78 void upExcept ( );
79 void downExcept ( );
80 void clickedExcept ( QListViewItem *, const QPoint &, int );
76 81
82private:
77 void changeText(); 83 void changeText();
78 84
79 QWidget *createStyleTab ( QWidget *parent ); 85 QWidget *createStyleTab ( QWidget *parent, Config &cfg );
80 QWidget *createDecoTab ( QWidget *parent ); 86 QWidget *createDecoTab ( QWidget *parent, Config &cfg );
81 QWidget *createFontTab ( QWidget *parent ); 87 QWidget *createFontTab ( QWidget *parent, Config &cfg );
82 QWidget *createColorTab ( QWidget *parent ); 88 QWidget *createColorTab ( QWidget *parent, Config &cfg );
83 QWidget *createGuiTab ( QWidget *parent ); 89 QWidget *createAdvancedTab ( QWidget *parent, Config &cfg );
84 90
85private: 91private:
@@ -109,4 +115,8 @@ private:
109 QRadioButton *m_tabstyle_top; 115 QRadioButton *m_tabstyle_top;
110 QRadioButton *m_tabstyle_bottom; 116 QRadioButton *m_tabstyle_bottom;
117
118 QWidget * m_advtab;
119 QListView * m_except;
120 QCheckBox * m_force;
111}; 121};
112 122
diff --git a/noncore/settings/appearance2/exceptlistitem.h b/noncore/settings/appearance2/exceptlistitem.h
new file mode 100644
index 0000000..5eda79c
--- a/dev/null
+++ b/noncore/settings/appearance2/exceptlistitem.h
@@ -0,0 +1,199 @@
1/*
2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org>
4           .>+-=
5 _;:,     .>    :=|. This file is free software; you can
6.> <`_,   >  .   <= redistribute it and/or modify it under
7:`=1 )Y*s>-.--   : the terms of the GNU 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 file 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 General
17..}^=.=       =       ; Public License for more details.
18++=   -.     .`     .:
19 :     =  ...= . :.=- You should have received a copy of the GNU
20 -.   .:....=;==+<; General Public License along with this file;
21  -_. . .   )=.  = see the file COPYING. If not, write to the
22    --        :-=` Free Software Foundation, Inc.,
23 59 Temple Place - Suite 330,
24 Boston, MA 02111-1307, USA.
25
26*/
27
28#ifndef EXCEPTLISTITEM_H
29#define EXCEPTLISTITEM_H
30
31#include <qlistview.h>
32#include <qpixmap.h>
33#include <qimage.h>
34#include <qpainter.h>
35
36class ExceptListItem : public QListViewItem {
37public:
38 ExceptListItem ( QListView *lv, const QString &t, bool nostyle = true, bool nofont = true, bool nodeco = true ) : QListViewItem ( lv )
39 {
40 m_text = t;
41
42 m_nofont = nofont;
43 m_nostyle = nostyle;
44 m_nodeco = nodeco;
45
46 init ( );
47 }
48
49 virtual ~ExceptListItem ( )
50 {
51 }
52
53 static void overlay ( QImage &img, const QImage &ovl )
54 {
55 if (( img. size ( ) != ovl. size ( )) ||
56 ( img. depth ( ) != ovl. depth ( )))
57 return;
58
59 for ( int y = 0; y != img. height ( ); y++ ) {
60 QRgb *iline = (QRgb *) img. scanLine ( y );
61 QRgb *oline = (QRgb *) ovl. scanLine ( y );
62
63 for ( int x = 0; x != img. width ( ); x++ ) {
64 QRgb i = *iline;
65 QRgb o = *oline;
66
67 *iline = qRgba (( qRed ( i ) + qRed ( o )) / 2,
68 ( qGreen ( i ) + qGreen ( o )) / 2,
69 ( qBlue ( i ) + qBlue ( o )) / 2,
70 ( qAlpha ( i ) + qAlpha ( o )) / 2 );
71 iline++;
72 oline++;
73 }
74 }
75 }
76
77 static void init ( )
78 {
79 static bool init = false;
80
81 if ( init )
82 return;
83
84 QImage noimg = Resource::loadImage ( "appearance/no.png" );
85 QImage fontimg = Resource::loadImage ( "appearance/font.png" );
86 QImage styleimg = Resource::loadImage ( "appearance/style.png" );
87 QImage decoimg = Resource::loadImage ( "appearance/deco.png" );
88
89 s_fontpix [0] = new QPixmap ( );
90 s_fontpix [0]-> convertFromImage ( fontimg );
91 overlay ( fontimg, noimg );
92 s_fontpix [1] = new QPixmap ( );
93 s_fontpix [1]-> convertFromImage ( fontimg );
94
95 s_stylepix [0] = new QPixmap ( );
96 s_stylepix [0]-> convertFromImage ( styleimg );
97 overlay ( styleimg, noimg );
98 s_stylepix [1] = new QPixmap ( );
99 s_stylepix [1]-> convertFromImage ( styleimg );
100
101 s_decopix [0] = new QPixmap ( );
102 s_decopix [0]-> convertFromImage ( decoimg );
103 overlay ( decoimg, noimg );
104 s_decopix [1] = new QPixmap ( );
105 s_decopix [1]-> convertFromImage ( decoimg );
106
107 init = true;
108 }
109
110 bool noFont ( ) const
111 {
112 return m_nofont;
113 }
114
115 bool noStyle ( ) const
116 {
117 return m_nostyle;
118 }
119
120 bool noDeco ( ) const
121 {
122 return m_nodeco;
123 }
124
125 void setNoDeco ( bool b )
126 {
127 if ( b != m_nodeco ) {
128 m_nodeco = b;
129 repaint ( );
130 }
131 }
132
133 void setNoStyle ( bool b )
134 {
135 if ( b != m_nostyle ) {
136 m_nostyle = b;
137 repaint ( );
138 }
139 }
140
141 void setNoFont ( bool b )
142 {
143 if ( b != m_nofont ) {
144 m_nofont = b;
145 repaint ( );
146 }
147 }
148
149 QString pattern ( ) const
150 {
151 return m_text;
152 }
153
154 void setPattern ( const QString &s )
155 {
156 if ( s != m_text ) {
157 m_text = s;
158 widthChanged ( 3 );
159 repaint ( );
160 }
161 }
162
163 QString text ( int i ) const
164 {
165 if ( i == 3 )
166 return m_text;
167 else
168 return QString::null;
169
170 }
171
172 const QPixmap *pixmap ( int i ) const
173 {
174 if ( i == 0 )
175 return (const QPixmap *) s_stylepix [m_nostyle ? 1 : 0];
176 else if ( i == 1 )
177 return (const QPixmap *) s_fontpix [m_nofont ? 1 : 0];
178 else if ( i == 2 )
179 return (const QPixmap *) s_decopix [m_nodeco ? 1 : 0];
180 else
181 return 0;
182 }
183
184private:
185 QString m_text;
186 bool m_nofont;
187 bool m_nostyle;
188 bool m_nodeco;
189
190 static QPixmap *s_stylepix [2];
191 static QPixmap *s_fontpix [2];
192 static QPixmap *s_decopix [2];
193};
194
195QPixmap *ExceptListItem::s_stylepix [2] = { 0, 0 };
196QPixmap *ExceptListItem::s_fontpix [2] = { 0, 0 };
197QPixmap *ExceptListItem::s_decopix [2] = { 0, 0 };
198
199#endif