summaryrefslogtreecommitdiff
path: root/noncore/settings/appearance2/appearance.cpp
Unidiff
Diffstat (limited to 'noncore/settings/appearance2/appearance.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/appearance2/appearance.cpp162
1 files changed, 98 insertions, 64 deletions
diff --git a/noncore/settings/appearance2/appearance.cpp b/noncore/settings/appearance2/appearance.cpp
index 9e5eede..ba12e55 100644
--- a/noncore/settings/appearance2/appearance.cpp
+++ b/noncore/settings/appearance2/appearance.cpp
@@ -18,85 +18,87 @@
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"
31#include "editScheme.h"
32#include "stylelistitem.h"
33#include "decolistitem.h"
34#include "colorlistitem.h"
35#include "exceptlistitem.h"
36#include "sample.h"
37
38/* OPIE */
39#include <opie/ofontselector.h>
40#include <opie/odevice.h>
41#include <opie/ofiledialog.h>
42#include <opie/otabwidget.h>
43
44#include <qpe/config.h>
45#include <qpe/global.h>
46#include <qpe/qpeapplication.h>
47#include <qpe/qpemessagebox.h>
48#include <qpe/qcopenvelope_qws.h>
49#include <qpe/qpestyle.h>
50#include <qpe/lightstyle.h>
51#include <qpe/styleinterface.h>
52
53/* QT */
30#include <qbuttongroup.h> 54#include <qbuttongroup.h>
31#include <qcheckbox.h> 55#include <qcheckbox.h>
32#include <qcombobox.h> 56#include <qcombobox.h>
33#include <qdialog.h> 57#include <qdialog.h>
34#include <qdir.h> 58#include <qdir.h>
35#include <qlabel.h> 59#include <qlabel.h>
36#include <qlayout.h> 60#include <qlayout.h>
37#include <qlineedit.h> 61#include <qlineedit.h>
38#include <qlistbox.h> 62#include <qlistbox.h>
39#include <qmessagebox.h> 63#include <qmessagebox.h>
40#include <qpushbutton.h> 64#include <qpushbutton.h>
41#include <qradiobutton.h> 65#include <qradiobutton.h>
42#if QT_VERSION >= 300 66#if QT_VERSION >= 300
43#include <qstylefactory.h> 67#include <qstylefactory.h>
44#endif 68#endif
45#include <qtoolbutton.h> 69#include <qtoolbutton.h>
46#include <qwindowsstyle.h> 70#include <qwindowsstyle.h>
47#include <qlistview.h> 71#include <qlistview.h>
48#include <qheader.h> 72#include <qheader.h>
49#include <qvbox.h> 73#include <qvbox.h>
50#include <qwhatsthis.h> 74#include <qwhatsthis.h>
51 75
52#include <qpe/config.h>
53#include <qpe/global.h>
54#include <qpe/resource.h>
55#include <qpe/qpeapplication.h>
56#include <qpe/qpemessagebox.h>
57#include <qpe/qcopenvelope_qws.h>
58#include <qpe/qpestyle.h>
59#include <qpe/lightstyle.h>
60#include <qpe/qlibrary.h>
61#include <qpe/styleinterface.h>
62
63#include <opie/ofontselector.h>
64#include <opie/odevice.h>
65#include <opie/ofiledialog.h>
66#include <opie/otabwidget.h>
67
68#include "appearance.h"
69#include "editScheme.h"
70#include "stylelistitem.h"
71#include "decolistitem.h"
72#include "colorlistitem.h"
73#include "exceptlistitem.h"
74#include "sample.h"
75
76
77using namespace Opie; 76using namespace Opie;
78 77
79 78
80class DefaultWindowDecoration : public WindowDecorationInterface 79class DefaultWindowDecoration : public WindowDecorationInterface
81{ 80{
82public: 81public:
83 DefaultWindowDecoration() : ref(0) {} 82 DefaultWindowDecoration() : ref(0) {}
84 QString name() const { 83 QString name() const
84 {
85 return "Default"; 85 return "Default";
86 } 86 }
87QPixmap icon() const { 87 QPixmap icon() const
88 {
88 return QPixmap(); 89 return QPixmap();
89 } 90 }
90 QRESULT queryInterface( const QUuid &uuid, QUnknownInterface **iface ) { 91 QRESULT queryInterface( const QUuid &uuid, QUnknownInterface **iface )
92 {
91 *iface = 0; 93 *iface = 0;
92 if ( uuid == IID_QUnknown ) 94 if ( uuid == IID_QUnknown )
93 *iface = this; 95 *iface = this;
94 else if ( uuid == IID_WindowDecoration ) 96 else if ( uuid == IID_WindowDecoration )
95 *iface = this; 97 *iface = this;
96 98
97 if ( *iface ) 99 if ( *iface )
98 (*iface)->addRef(); 100 (*iface)->addRef();
99 return QS_OK; 101 return QS_OK;
100 } 102 }
101 Q_REFCOUNT 103 Q_REFCOUNT
102 104
@@ -125,37 +127,40 @@ QWidget *Appearance::createStyleTab ( QWidget *parent, Config &cfg )
125 QWhatsThis::add( m_style_settings, tr( "Click here to configure the currently selected style.\n\nNote: This option is not available for all styles." ) ); 127 QWhatsThis::add( m_style_settings, tr( "Click here to configure the currently selected style.\n\nNote: This option is not available for all styles." ) );
126 128
127 QString s = cfg. readEntry ( "Style", "Light" ); 129 QString s = cfg. readEntry ( "Style", "Light" );
128 130
129 131
130#if QT_VERSION >= 300 132#if QT_VERSION >= 300
131 m_style_list->insertStringList(QStyleFactory::styles()); 133 m_style_list->insertStringList(QStyleFactory::styles());
132#else 134#else
133 m_style_list-> insertItem ( new StyleListItem ( "Windows", new QWindowsStyle ( ))); 135 m_style_list-> insertItem ( new StyleListItem ( "Windows", new QWindowsStyle ( )));
134 m_style_list-> insertItem ( new StyleListItem ( "Light", new LightStyle ( ))); 136 m_style_list-> insertItem ( new StyleListItem ( "Light", new LightStyle ( )));
135 m_style_list-> insertItem ( new StyleListItem ( "QPE", new QPEStyle ( ))); 137 m_style_list-> insertItem ( new StyleListItem ( "QPE", new QPEStyle ( )));
136#endif 138#endif
139
137 { 140 {
138 QString path = QPEApplication::qpeDir ( ); 141 QString path = QPEApplication::qpeDir ( );
139 path.append( "/plugins/styles/" ); 142 path.append( "/plugins/styles/" );
140 QStringList sl = QDir ( path, "lib*.so" ). entryList ( ); 143 QStringList sl = QDir ( path, "lib*.so" ). entryList ( );
141 144
142 for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) { 145 for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it )
146 {
143 QString libstr = path; 147 QString libstr = path;
144 libstr.append( "/" ); 148 libstr.append( "/" );
145 libstr.append( *it ); 149 libstr.append( *it );
146 QLibrary *lib = new QLibrary ( libstr ); 150 QLibrary *lib = new QLibrary ( libstr );
147 StyleInterface *iface; 151 StyleInterface *iface;
148 152
149 if (( lib-> queryInterface ( IID_Style, (QUnknownInterface **) &iface ) == QS_OK ) && iface ) { 153 if (( lib-> queryInterface ( IID_Style, (QUnknownInterface **) &iface ) == QS_OK ) && iface )
154 {
150 StyleListItem *slit = new StyleListItem ( lib, iface ); 155 StyleListItem *slit = new StyleListItem ( lib, iface );
151 m_style_list-> insertItem ( slit ); 156 m_style_list-> insertItem ( slit );
152 157
153 if ( slit-> key ( ) == s ) 158 if ( slit-> key ( ) == s )
154 m_style_list-> setCurrentItem ( slit ); 159 m_style_list-> setCurrentItem ( slit );
155 } 160 }
156 else 161 else
157 delete lib; 162 delete lib;
158 } 163 }
159 } 164 }
160 165
161 m_original_style = m_style_list-> currentItem ( ); 166 m_original_style = m_style_list-> currentItem ( );
@@ -175,32 +180,34 @@ QWidget *Appearance::createDecoTab ( QWidget *parent, Config &cfg )
175 vertLayout->addWidget( m_deco_list ); 180 vertLayout->addWidget( m_deco_list );
176 QWhatsThis::add( m_deco_list, tr( "Window decorations control the way the application title bar and its buttons appear.\n\nClick here to select an available decoration." ) ); 181 QWhatsThis::add( m_deco_list, tr( "Window decorations control the way the application title bar and its buttons appear.\n\nClick here to select an available decoration." ) );
177 182
178 QString s = cfg. readEntry ( "Decoration", "libflat.so" ); 183 QString s = cfg. readEntry ( "Decoration", "libflat.so" );
179 184
180 m_deco_list-> insertItem ( new DecoListItem ( "QPE" )); 185 m_deco_list-> insertItem ( new DecoListItem ( "QPE" ));
181 186
182 { 187 {
183 QString path = QPEApplication::qpeDir(); 188 QString path = QPEApplication::qpeDir();
184 path.append( "/plugins/decorations/" ); 189 path.append( "/plugins/decorations/" );
185 QStringList sl = QDir ( path, "lib*.so" ). entryList ( ); 190 QStringList sl = QDir ( path, "lib*.so" ). entryList ( );
186 191
187 for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) { 192 for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it )
193 {
188 QString libstr = path; 194 QString libstr = path;
189 libstr.append( "/" ); 195 libstr.append( "/" );
190 libstr.append( *it ); 196 libstr.append( *it );
191 QLibrary *lib = new QLibrary ( libstr ); 197 QLibrary *lib = new QLibrary ( libstr );
192 WindowDecorationInterface *iface; 198 WindowDecorationInterface *iface;
193 199
194 if ( lib-> queryInterface ( IID_WindowDecoration, (QUnknownInterface **) &iface ) == QS_OK ) { 200 if ( lib-> queryInterface ( IID_WindowDecoration, (QUnknownInterface **) &iface ) == QS_OK )
201 {
195 DecoListItem *dlit = new DecoListItem ( lib, iface ); 202 DecoListItem *dlit = new DecoListItem ( lib, iface );
196 m_deco_list-> insertItem ( dlit ); 203 m_deco_list-> insertItem ( dlit );
197 204
198 if ( dlit-> key ( ) == s ) 205 if ( dlit-> key ( ) == s )
199 m_deco_list-> setCurrentItem ( dlit ); 206 m_deco_list-> setCurrentItem ( dlit );
200 } 207 }
201 else 208 else
202 delete lib; 209 delete lib;
203 } 210 }
204 } 211 }
205 212
206 m_original_deco = m_deco_list-> currentItem ( ); 213 m_original_deco = m_deco_list-> currentItem ( );
@@ -237,25 +244,26 @@ QWidget *Appearance::createColorTab ( QWidget *parent, Config &cfg )
237 244
238 m_color_list = new QListBox ( tab ); 245 m_color_list = new QListBox ( tab );
239 gridLayout->addMultiCellWidget ( m_color_list, 0, 3, 0, 0 ); 246 gridLayout->addMultiCellWidget ( m_color_list, 0, 3, 0, 0 );
240 connect( m_color_list, SIGNAL( highlighted( int ) ), this, SLOT( colorClicked( int ) ) ); 247 connect( m_color_list, SIGNAL( highlighted( int ) ), this, SLOT( colorClicked( int ) ) );
241 QWhatsThis::add( m_color_list, tr( "Color schemes are a collection of colors which are used for various parts of the display.\n\nClick here to select an available scheme." ) ); 248 QWhatsThis::add( m_color_list, tr( "Color schemes are a collection of colors which are used for various parts of the display.\n\nClick here to select an available scheme." ) );
242 249
243 m_color_list-> insertItem ( new ColorListItem ( tr( "Current scheme" ), cfg )); 250 m_color_list-> insertItem ( new ColorListItem ( tr( "Current scheme" ), cfg ));
244 251
245 QString path = QPEApplication::qpeDir ( ); 252 QString path = QPEApplication::qpeDir ( );
246 path.append( "/etc/colors/" ); 253 path.append( "/etc/colors/" );
247 QStringList sl = QDir ( path ). entryList ( "*.scheme" ); 254 QStringList sl = QDir ( path ). entryList ( "*.scheme" );
248 255
249 for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) { 256 for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it )
257 {
250 QString name = (*it). left ((*it). find ( ".scheme" )); 258 QString name = (*it). left ((*it). find ( ".scheme" ));
251 QString pathstr = path; 259 QString pathstr = path;
252 pathstr.append( *it ); 260 pathstr.append( *it );
253 Config config ( pathstr, Config::File ); 261 Config config ( pathstr, Config::File );
254 config. setGroup ( "Colors" ); 262 config. setGroup ( "Colors" );
255 263
256 m_color_list-> insertItem ( new ColorListItem ( name, config )); 264 m_color_list-> insertItem ( new ColorListItem ( name, config ));
257 } 265 }
258 266
259 m_color_list-> setCurrentItem ( 0 ); 267 m_color_list-> setCurrentItem ( 0 );
260 268
261 QPushButton* tempButton = new QPushButton( tab, "editSchemeButton" ); 269 QPushButton* tempButton = new QPushButton( tab, "editSchemeButton" );
@@ -339,25 +347,26 @@ QWidget *Appearance::createAdvancedTab ( QWidget *parent, Config &cfg )
339 tb = new QToolButton ( tab ); 347 tb = new QToolButton ( tab );
340 tb-> setIconSet ( Resource::loadIconSet ( "down" )); 348 tb-> setIconSet ( Resource::loadIconSet ( "down" ));
341 tb-> setFocusPolicy ( QWidget::StrongFocus ); 349 tb-> setFocusPolicy ( QWidget::StrongFocus );
342 lay-> addWidget ( tb, 5, 1 ); 350 lay-> addWidget ( tb, 5, 1 );
343 connect ( tb, SIGNAL( clicked ( )), this, SLOT( downExcept ( ))); 351 connect ( tb, SIGNAL( clicked ( )), this, SLOT( downExcept ( )));
344 QWhatsThis::add( tb, tr( "Click here to move the currently selected application down in the list." ) ); 352 QWhatsThis::add( tb, tr( "Click here to move the currently selected application down in the list." ) );
345 353
346 lay-> setRowStretch ( 6, 10 ); 354 lay-> setRowStretch ( 6, 10 );
347 lay-> setColStretch ( 0, 10 ); 355 lay-> setColStretch ( 0, 10 );
348 356
349 QStringList sl = cfg. readListEntry ( "NoStyle", ';' ); 357 QStringList sl = cfg. readListEntry ( "NoStyle", ';' );
350 QListViewItem *lvit = 0; 358 QListViewItem *lvit = 0;
351 for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) { 359 for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it )
360 {
352 int fl = ( *it ). left ( 1 ). toInt ( 0, 32 ); 361 int fl = ( *it ). left ( 1 ). toInt ( 0, 32 );
353 362
354 lvit = new ExceptListItem ( m_except, lvit, ( *it ). mid ( 1 ), fl & 0x01, fl & 0x02, fl & 0x04 ); 363 lvit = new ExceptListItem ( m_except, lvit, ( *it ). mid ( 1 ), fl & 0x01, fl & 0x02, fl & 0x04 );
355 } 364 }
356 365
357 366
358 vertLayout-> addSpacing ( 3 ); 367 vertLayout-> addSpacing ( 3 );
359 QFrame *f = new QFrame ( tab ); 368 QFrame *f = new QFrame ( tab );
360 f-> setFrameStyle ( QFrame::HLine | QFrame::Sunken ); 369 f-> setFrameStyle ( QFrame::HLine | QFrame::Sunken );
361 vertLayout-> addWidget ( f ); 370 vertLayout-> addWidget ( f );
362 vertLayout-> addSpacing ( 3 ); 371 vertLayout-> addSpacing ( 3 );
363 372
@@ -423,27 +432,30 @@ QWidget *Appearance::createAdvancedTab ( QWidget *parent, Config &cfg )
423 m_rotdir_cw-> setPixmap( cw1 ); 432 m_rotdir_cw-> setPixmap( cw1 );
424 m_rotdir_ccw-> setPixmap( ccw1 ); 433 m_rotdir_ccw-> setPixmap( ccw1 );
425 m_rotdir_flip-> setPixmap( flip1 ); 434 m_rotdir_flip-> setPixmap( flip1 );
426 435
427 rotLay-> addWidget ( rotlabel, 0 ); 436 rotLay-> addWidget ( rotlabel, 0 );
428 rotLay-> addWidget ( m_rotdir_cw, 0 ); 437 rotLay-> addWidget ( m_rotdir_cw, 0 );
429 rotLay-> addWidget ( m_rotdir_ccw, 0 ); 438 rotLay-> addWidget ( m_rotdir_ccw, 0 );
430 rotLay-> addWidget ( m_rotdir_flip, 0 ); 439 rotLay-> addWidget ( m_rotdir_flip, 0 );
431 440
432 int rotDirection = cfg.readNumEntry( "rotatedir" ); 441 int rotDirection = cfg.readNumEntry( "rotatedir" );
433 ODirection rot = CW; 442 ODirection rot = CW;
434 443
435 if (rotDirection == -1) { 444 if (rotDirection == -1)
445 {
436 rot = ODevice::inst ( )-> direction ( ); 446 rot = ODevice::inst ( )-> direction ( );
437 } else { 447 }
448 else
449 {
438 rot = (ODirection)rotDirection; 450 rot = (ODirection)rotDirection;
439 } 451 }
440 452
441 m_rotdir_cw-> setChecked ( rot == CW ); 453 m_rotdir_cw-> setChecked ( rot == CW );
442 m_rotdir_ccw-> setChecked ( rot == CCW ); 454 m_rotdir_ccw-> setChecked ( rot == CCW );
443 m_rotdir_flip-> setChecked ( rot == Flip ); 455 m_rotdir_flip-> setChecked ( rot == Flip );
444 456
445 return tab; 457 return tab;
446} 458}
447 459
448 460
449Appearance::Appearance( QWidget* parent, const char* name, WFlags ) 461Appearance::Appearance( QWidget* parent, const char* name, WFlags )
@@ -473,92 +485,102 @@ Appearance::Appearance( QWidget* parent, const char* name, WFlags )
473 tw-> addTab ( m_advtab = createAdvancedTab ( tw, config ), "SettingsIcon", tr( "Advanced" ) ); 485 tw-> addTab ( m_advtab = createAdvancedTab ( tw, config ), "SettingsIcon", tr( "Advanced" ) );
474 486
475 top-> addWidget ( tw, 10 ); 487 top-> addWidget ( tw, 10 );
476 top-> addWidget ( m_sample, 1 ); 488 top-> addWidget ( m_sample, 1 );
477 489
478 tw-> setCurrentTab ( styletab ); 490 tw-> setCurrentTab ( styletab );
479 connect ( tw, SIGNAL( currentChanged ( QWidget * )), this, SLOT( tabChanged ( QWidget * ))); 491 connect ( tw, SIGNAL( currentChanged ( QWidget * )), this, SLOT( tabChanged ( QWidget * )));
480 492
481 m_style_changed = m_font_changed = m_color_changed = m_deco_changed = false; 493 m_style_changed = m_font_changed = m_color_changed = m_deco_changed = false;
482} 494}
483 495
484Appearance::~Appearance() 496Appearance::~Appearance()
485{ 497{}
486}
487 498
488void Appearance::tabChanged ( QWidget *w ) 499void Appearance::tabChanged ( QWidget *w )
489{ 500{
490 if ( w == m_advtab ) { 501 if ( w == m_advtab )
502 {
491 m_sample-> hide ( ); 503 m_sample-> hide ( );
492 updateGeometry ( ); // shouldn't be necessary ... 504 updateGeometry ( ); // shouldn't be necessary ...
493 } 505 }
494 else 506 else
495 m_sample-> show ( ); 507 m_sample-> show ( );
496} 508}
497 509
498void Appearance::accept ( ) 510void Appearance::accept ( )
499{ 511{
500 bool newtabpos = m_tabstyle_top-> isChecked ( ); 512 bool newtabpos = m_tabstyle_top-> isChecked ( );
501 int newtabstyle = m_tabstyle_list-> currentItem ( ); 513 int newtabstyle = m_tabstyle_list-> currentItem ( );
502 514
503 Config config ( "qpe" ); 515 Config config ( "qpe" );
504 config. setGroup ( "Appearance" ); 516 config. setGroup ( "Appearance" );
505 517
506 if ( m_style_changed ) { 518 if ( m_style_changed )
519 {
507 StyleListItem *item = (StyleListItem *) m_style_list-> item ( m_style_list-> currentItem ( )); 520 StyleListItem *item = (StyleListItem *) m_style_list-> item ( m_style_list-> currentItem ( ));
508 if ( item ) 521 if ( item )
509 config.writeEntry( "Style", item-> key ( )); 522 config.writeEntry( "Style", item-> key ( ));
510 } 523 }
511 524
512 if ( m_deco_changed ) { 525 if ( m_deco_changed )
526 {
513 DecoListItem *item = (DecoListItem *) m_deco_list-> item ( m_deco_list-> currentItem ( )); 527 DecoListItem *item = (DecoListItem *) m_deco_list-> item ( m_deco_list-> currentItem ( ));
514 if ( item ) 528 if ( item )
515 config.writeEntry( "Decoration", item-> key ( )); 529 config.writeEntry( "Decoration", item-> key ( ));
516 } 530 }
517 531
518 if (( newtabstyle != m_original_tabstyle ) || ( newtabpos != m_original_tabpos )) { 532 if (( newtabstyle != m_original_tabstyle ) || ( newtabpos != m_original_tabpos ))
533 {
519 config. writeEntry ( "TabStyle", newtabstyle + 1 ); 534 config. writeEntry ( "TabStyle", newtabstyle + 1 );
520 config. writeEntry ( "TabPosition", newtabpos ? "Top" : "Bottom" ); 535 config. writeEntry ( "TabPosition", newtabpos ? "Top" : "Bottom" );
521 } 536 }
522 537
523 if ( m_font_changed ) { 538 if ( m_font_changed )
539 {
524 config. writeEntry ( "FontFamily", m_fontselect-> fontFamily ( )); 540 config. writeEntry ( "FontFamily", m_fontselect-> fontFamily ( ));
525 config. writeEntry ( "FontStyle", m_fontselect-> fontStyle ( )); 541 config. writeEntry ( "FontStyle", m_fontselect-> fontStyle ( ));
526 config. writeEntry ( "FontSize", m_fontselect-> fontSize ( )); 542 config. writeEntry ( "FontSize", m_fontselect-> fontSize ( ));
527 } 543 }
528 544
529 545
530 if ( m_color_changed ) 546 if ( m_color_changed )
531 { 547 {
532 ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); 548 ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( ));
533 549
534 if ( item ) 550 if ( item )
535 item-> save ( config ); 551 item-> save ( config );
536 } 552 }
537 553
538 ODirection rot; 554 ODirection rot;
539 if (m_rotdir_ccw-> isChecked ( )) { 555 if (m_rotdir_ccw-> isChecked ( ))
556 {
540 rot = CCW; 557 rot = CCW;
541 } else if (m_rotdir_cw-> isChecked ( )) { 558 }
559 else if (m_rotdir_cw-> isChecked ( ))
560 {
542 rot = CW; 561 rot = CW;
543 } else { 562 }
563 else
564 {
544 rot = Flip; 565 rot = Flip;
545 } 566 }
546 config. writeEntry ( "rotatedir", (int)rot ); 567 config. writeEntry ( "rotatedir", (int)rot );
547 568
548 m_except-> setFocus ( ); // if the focus was on the embedded line-edit, we have to move it away first, so the contents are updated 569 m_except-> setFocus ( ); // if the focus was on the embedded line-edit, we have to move it away first, so the contents are updated
549 570
550 QStringList sl; 571 QStringList sl;
551 QString exceptstr; 572 QString exceptstr;
552 for ( ExceptListItem *it = (ExceptListItem *) m_except-> firstChild ( ); it; it = (ExceptListItem *) it-> nextSibling ( )) { 573 for ( ExceptListItem *it = (ExceptListItem *) m_except-> firstChild ( ); it; it = (ExceptListItem *) it-> nextSibling ( ))
574 {
553 int fl = 0; 575 int fl = 0;
554 fl |= ( it-> noStyle ( ) ? 0x01 : 0 ); 576 fl |= ( it-> noStyle ( ) ? 0x01 : 0 );
555 fl |= ( it-> noFont ( ) ? 0x02 : 0 ); 577 fl |= ( it-> noFont ( ) ? 0x02 : 0 );
556 fl |= ( it-> noDeco ( ) ? 0x04 : 0 ); 578 fl |= ( it-> noDeco ( ) ? 0x04 : 0 );
557 exceptstr = QString::number ( fl, 32 ); 579 exceptstr = QString::number ( fl, 32 );
558 exceptstr.append( it-> pattern ( )); 580 exceptstr.append( it-> pattern ( ));
559 sl << exceptstr; 581 sl << exceptstr;
560 } 582 }
561 config. writeEntry ( "NoStyle", sl, ';' ); 583 config. writeEntry ( "NoStyle", sl, ';' );
562 config. writeEntry ( "ForceStyle", m_force-> isChecked ( )); 584 config. writeEntry ( "ForceStyle", m_force-> isChecked ( ));
563 585
564 config. write ( ); // need to flush the config info first 586 config. write ( ); // need to flush the config info first
@@ -570,63 +592,66 @@ void Appearance::accept ( )
570void Appearance::done ( int r ) 592void Appearance::done ( int r )
571{ 593{
572 QDialog::done ( r ); 594 QDialog::done ( r );
573 close ( ); 595 close ( );
574} 596}
575 597
576 598
577void Appearance::styleClicked ( int index ) 599void Appearance::styleClicked ( int index )
578{ 600{
579 StyleListItem *sli = (StyleListItem *) m_style_list-> item ( index ); 601 StyleListItem *sli = (StyleListItem *) m_style_list-> item ( index );
580 m_style_settings-> setEnabled ( sli ? sli-> hasSettings ( ) : false ); 602 m_style_settings-> setEnabled ( sli ? sli-> hasSettings ( ) : false );
581 603
582 if ( m_sample && sli && sli-> style ( )) { 604 if ( m_sample && sli && sli-> style ( ))
605 {
583 int ci = m_color_list ? m_color_list-> currentItem ( ) : -1; 606 int ci = m_color_list ? m_color_list-> currentItem ( ) : -1;
584 607
585 m_sample-> setStyle2 ( sli-> style ( ), ci < 0 ? palette ( ) : ((ColorListItem *) m_color_list-> item ( ci ))-> palette ( )); 608 m_sample-> setStyle2 ( sli-> style ( ), ci < 0 ? palette ( ) : ((ColorListItem *) m_color_list-> item ( ci ))-> palette ( ));
586 } 609 }
587 610
588 m_style_changed |= ( index != m_original_style ); 611 m_style_changed |= ( index != m_original_style );
589} 612}
590 613
591void Appearance::styleSettingsClicked ( ) 614void Appearance::styleSettingsClicked ( )
592{ 615{
593 StyleListItem *item = (StyleListItem *) m_style_list-> item ( m_style_list-> currentItem ( )); 616 StyleListItem *item = (StyleListItem *) m_style_list-> item ( m_style_list-> currentItem ( ));
594 617
595 if ( item && item-> hasSettings ( )) { 618 if ( item && item-> hasSettings ( ))
619 {
596 QDialog *d = new QDialog ( this, "SETTINGS-DLG", true ); 620 QDialog *d = new QDialog ( this, "SETTINGS-DLG", true );
597 QVBoxLayout *vbox = new QVBoxLayout ( d, 3, 0 ); 621 QVBoxLayout *vbox = new QVBoxLayout ( d, 3, 0 );
598 622
599 QWidget *w = item-> settings ( d ); 623 QWidget *w = item-> settings ( d );
600 624
601 if ( w ) { 625 if ( w )
626 {
602 vbox-> addWidget ( w ); 627 vbox-> addWidget ( w );
603 628
604 d-> setCaption ( w-> caption ( )); 629 d-> setCaption ( w-> caption ( ));
605 630
606 d-> showMaximized ( ); 631 bool accepted = ( QPEApplication::execDialog ( d ) == QDialog::Accepted );
607 bool accepted = ( d-> exec ( ) == QDialog::Accepted );
608 632
609 if ( item-> setSettings ( accepted )) 633 if ( item-> setSettings ( accepted ))
610 m_style_changed = true; 634 m_style_changed = true;
611 } 635 }
612 delete d; 636 delete d;
613 } 637 }
614} 638}
615 639
616void Appearance::decoClicked ( int index ) 640void Appearance::decoClicked ( int index )
617{ 641{
618 DecoListItem *dli = (DecoListItem *) m_deco_list-> item ( index ); 642 DecoListItem *dli = (DecoListItem *) m_deco_list-> item ( index );
619 643
620 if ( m_sample ) { 644 if ( m_sample )
645 {
621 if ( dli && dli-> interface ( )) 646 if ( dli && dli-> interface ( ))
622 m_sample-> setDecoration ( dli-> interface ( )); 647 m_sample-> setDecoration ( dli-> interface ( ));
623 else 648 else
624 m_sample-> setDecoration ( new DefaultWindowDecoration ( )); 649 m_sample-> setDecoration ( new DefaultWindowDecoration ( ));
625 m_sample-> repaint ( ); 650 m_sample-> repaint ( );
626 } 651 }
627 m_deco_changed |= ( index != m_original_deco ); 652 m_deco_changed |= ( index != m_original_deco );
628} 653}
629 654
630void Appearance::fontClicked ( const QFont &f ) 655void Appearance::fontClicked ( const QFont &f )
631{ 656{
632 m_font_changed |= ( f != m_sample-> font ( )); 657 m_font_changed |= ( f != m_sample-> font ( ));
@@ -643,43 +668,47 @@ void Appearance::colorClicked ( int index )
643 m_color_changed |= ( item-> palette ( ) != qApp-> palette ( )); 668 m_color_changed |= ( item-> palette ( ) != qApp-> palette ( ));
644} 669}
645 670
646 671
647void Appearance::editSchemeClicked ( ) 672void Appearance::editSchemeClicked ( )
648{ 673{
649 ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); 674 ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( ));
650 675
651 int cnt = 0; 676 int cnt = 0;
652 QString labels [QColorGroup::NColorRoles]; 677 QString labels [QColorGroup::NColorRoles];
653 QColor colors [QColorGroup::NColorRoles]; 678 QColor colors [QColorGroup::NColorRoles];
654 679
655 for ( QColorGroup::ColorRole role = (QColorGroup::ColorRole) 0; role != QColorGroup::NColorRoles; ((int) role )++ ) { 680 for ( QColorGroup::ColorRole role = (QColorGroup::ColorRole) 0; role != QColorGroup::NColorRoles; ((int) role )++ )
681 {
656 QColor col = item-> color ( role ); 682 QColor col = item-> color ( role );
657 683
658 if ( col. isValid ( )) { 684 if ( col. isValid ( ))
685 {
659 labels [cnt] = item-> label ( role ); 686 labels [cnt] = item-> label ( role );
660 colors [cnt] = col; 687 colors [cnt] = col;
661 688
662 cnt++; 689 cnt++;
663 } 690 }
664 } 691 }
665 692
666 EditScheme* editdlg = new EditScheme( cnt, labels, colors, this, "editScheme", true ); 693 EditScheme* editdlg = new EditScheme( cnt, labels, colors, this, "editScheme", true );
667 editdlg-> showMaximized ( ); 694 if ( QPEApplication::execDialog( editdlg ) == QDialog::Accepted )
668 if ( editdlg-> exec ( ) == QDialog::Accepted ) { 695 {
669 ColorListItem *citem = (ColorListItem *) m_color_list-> item ( 0 ); 696 ColorListItem *citem = (ColorListItem *) m_color_list-> item ( 0 );
670 cnt = 0; 697 cnt = 0;
671 698
672 for ( QColorGroup::ColorRole role = (QColorGroup::ColorRole) 0; role != QColorGroup::NColorRoles; ((int) role )++ ) { 699 for ( QColorGroup::ColorRole role = (QColorGroup::ColorRole) 0; role != QColorGroup::NColorRoles; ((int) role )++ )
673 if ( item-> color ( role ). isValid ( )) { 700 {
701 if ( item-> color ( role ). isValid ( ))
702 {
674 citem-> setColor ( role, colors [cnt] ); 703 citem-> setColor ( role, colors [cnt] );
675 cnt++; 704 cnt++;
676 } 705 }
677 } 706 }
678 707
679 m_color_list-> setCurrentItem ( 0 ); 708 m_color_list-> setCurrentItem ( 0 );
680 colorClicked ( 0 ); 709 colorClicked ( 0 );
681 710
682 m_color_changed = true; 711 m_color_changed = true;
683 } 712 }
684 delete editdlg; 713 delete editdlg;
685} 714}
@@ -689,25 +718,26 @@ void Appearance::saveSchemeClicked()
689{ 718{
690 ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); 719 ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( ));
691 720
692 if ( !item ) 721 if ( !item )
693 return; 722 return;
694 723
695 QDialog *d = new QDialog ( this, 0, true ); 724 QDialog *d = new QDialog ( this, 0, true );
696 d-> setCaption ( tr( "Save Scheme" )); 725 d-> setCaption ( tr( "Save Scheme" ));
697 QLineEdit *ed = new QLineEdit ( d ); 726 QLineEdit *ed = new QLineEdit ( d );
698 ( new QVBoxLayout ( d, 3, 3 ))-> addWidget ( ed ); 727 ( new QVBoxLayout ( d, 3, 3 ))-> addWidget ( ed );
699 ed-> setFocus ( ); 728 ed-> setFocus ( );
700 729
701 if ( d-> exec ( ) == QDialog::Accepted ) { 730 if ( d-> exec ( ) == QDialog::Accepted )
731 {
702 QString schemename = ed-> text ( ); 732 QString schemename = ed-> text ( );
703 QString filestr = QPEApplication::qpeDir(); 733 QString filestr = QPEApplication::qpeDir();
704 filestr.append( "/etc/colors/" ); 734 filestr.append( "/etc/colors/" );
705 filestr.append( schemename ); 735 filestr.append( schemename );
706 filestr.append( ".scheme" ); 736 filestr.append( ".scheme" );
707 QFile file ( filestr ); 737 QFile file ( filestr );
708 if ( !file. exists ( )) 738 if ( !file. exists ( ))
709 { 739 {
710 QPalette p = item-> palette ( ); 740 QPalette p = item-> palette ( );
711 741
712 Config config ( file.name(), Config::File ); 742 Config config ( file.name(), Config::File );
713 config. setGroup( "Colors" ); 743 config. setGroup( "Colors" );
@@ -752,47 +782,49 @@ void Appearance::deleteSchemeClicked()
752} 782}
753 783
754 784
755void Appearance::addExcept ( ) 785void Appearance::addExcept ( )
756{ 786{
757 ExceptListItem *it = new ExceptListItem ( m_except, 0, tr( "<new>" ), true, true, true ); 787 ExceptListItem *it = new ExceptListItem ( m_except, 0, tr( "<new>" ), true, true, true );
758 m_except-> ensureItemVisible ( it ); 788 m_except-> ensureItemVisible ( it );
759 m_except-> setSelected ( it, true ); 789 m_except-> setSelected ( it, true );
760} 790}
761 791
762void Appearance::delExcept ( ) 792void Appearance::delExcept ( )
763{ 793{
764 if ( m_except-> selectedItem ( )) { 794 if ( m_except-> selectedItem ( ))
795 {
765 m_except-> setFocus ( ); 796 m_except-> setFocus ( );
766 delete m_except-> selectedItem ( ); 797 delete m_except-> selectedItem ( );
767 } 798 }
768} 799}
769 800
770void Appearance::upExcept ( ) 801void Appearance::upExcept ( )
771{ 802{
772 ExceptListItem *it = (ExceptListItem *) m_except-> selectedItem ( ); 803 ExceptListItem *it = (ExceptListItem *) m_except-> selectedItem ( );
773 804
774 if ( it && it-> itemAbove ( )) 805 if ( it && it-> itemAbove ( ))
775 it-> itemAbove ( )-> moveItem ( it ); 806 it-> itemAbove ( )-> moveItem ( it );
776} 807}
777 808
778void Appearance::downExcept ( ) 809void Appearance::downExcept ( )
779{ 810{
780 ExceptListItem *it = (ExceptListItem *) m_except-> selectedItem ( ); 811 ExceptListItem *it = (ExceptListItem *) m_except-> selectedItem ( );
781 812
782 if ( it && it-> itemBelow ( )) 813 if ( it && it-> itemBelow ( ))
783 it-> moveItem ( it-> itemBelow ( )); 814 it-> moveItem ( it-> itemBelow ( ));
784} 815}
785 816
786class ExEdit : public QLineEdit { 817class ExEdit : public QLineEdit
818{
787public: 819public:
788 ExEdit ( ExceptListItem *item ) 820 ExEdit ( ExceptListItem *item )
789 : QLineEdit ( item-> listView ( )-> viewport ( ), "exedit" ), it ( item ) 821 : QLineEdit ( item-> listView ( )-> viewport ( ), "exedit" ), it ( item )
790 { 822 {
791 setFrame ( false ); 823 setFrame ( false );
792 824
793 QRect r = it-> listView ( )-> itemRect ( it ); 825 QRect r = it-> listView ( )-> itemRect ( it );
794 826
795 int x = it-> listView ( )-> header ( )-> cellPos ( 3 ) - 1; 827 int x = it-> listView ( )-> header ( )-> cellPos ( 3 ) - 1;
796 int y = r. y ( ); 828 int y = r. y ( );
797 int w = it-> listView ( )-> viewport ( )-> width ( ) - x; 829 int w = it-> listView ( )-> viewport ( )-> width ( ) - x;
798 int h = r. height ( ); // + 2; 830 int h = r. height ( ); // + 2;
@@ -813,25 +845,26 @@ public:
813 virtual void focusOutEvent ( QFocusEvent * ) 845 virtual void focusOutEvent ( QFocusEvent * )
814 { 846 {
815 hide ( ); 847 hide ( );
816 if ( m_out ) 848 if ( m_out )
817 it-> setPattern ( text ( )); 849 it-> setPattern ( text ( ));
818 delete this; 850 delete this;
819 } 851 }
820 852
821 virtual void keyPressEvent ( QKeyEvent *e ) 853 virtual void keyPressEvent ( QKeyEvent *e )
822 { 854 {
823 if ( e-> key ( ) == Key_Return ) 855 if ( e-> key ( ) == Key_Return )
824 it-> listView ( )-> setFocus ( ); 856 it-> listView ( )-> setFocus ( );
825 else if ( e-> key ( ) == Key_Escape ) { 857 else if ( e-> key ( ) == Key_Escape )
858 {
826 m_out = false; 859 m_out = false;
827 it-> listView ( )-> setFocus ( ); 860 it-> listView ( )-> setFocus ( );
828 } 861 }
829 else 862 else
830 QLineEdit::keyPressEvent ( e ); 863 QLineEdit::keyPressEvent ( e );
831 } 864 }
832 865
833private: 866private:
834 ExceptListItem *it; 867 ExceptListItem *it;
835 bool m_out; 868 bool m_out;
836}; 869};
837 870
@@ -839,18 +872,19 @@ void Appearance::clickedExcept ( QListViewItem *item, const QPoint &, int c )
839{ 872{
840 if ( !item || c < 0 || c > 3 ) 873 if ( !item || c < 0 || c > 3 )
841 return; 874 return;
842 875
843 ExceptListItem *it = (ExceptListItem *) item; 876 ExceptListItem *it = (ExceptListItem *) item;
844 877
845 if ( c == 0 ) 878 if ( c == 0 )
846 it-> setNoStyle ( !it-> noStyle ( )); 879 it-> setNoStyle ( !it-> noStyle ( ));
847 else if ( c == 1 ) 880 else if ( c == 1 )
848 it-> setNoFont ( !it-> noFont ( )); 881 it-> setNoFont ( !it-> noFont ( ));
849 else if ( c == 2 ) 882 else if ( c == 2 )
850 it-> setNoDeco ( !it-> noDeco ( )); 883 it-> setNoDeco ( !it-> noDeco ( ));
851 else if ( c == 3 ) { 884 else if ( c == 3 )
885 {
852 m_except-> ensureItemVisible ( it ); 886 m_except-> ensureItemVisible ( it );
853 new ExEdit ( it ); 887 new ExEdit ( it );
854 } 888 }
855} 889}
856 890