summaryrefslogtreecommitdiff
path: root/noncore/settings/appearance2/appearance.cpp
Unidiff
Diffstat (limited to 'noncore/settings/appearance2/appearance.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/appearance2/appearance.cpp475
1 files changed, 309 insertions, 166 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
@@ -29,18 +29,2 @@
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>
@@ -55,4 +39,2 @@
55#include <qmessagebox.h> 39#include <qmessagebox.h>
56#include <qmultilineedit.h>
57#include <qpopupmenu.h>
58#include <qpushbutton.h> 40#include <qpushbutton.h>
@@ -61,4 +43,14 @@
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>
@@ -67,8 +59,10 @@
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"
@@ -76,6 +70,7 @@
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
@@ -111,46 +106,30 @@ private:
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
131#if QT_VERSION < 300
132 {
133 QString path = QPEApplication::qpeDir() + "/plugins/styles/";
134 QStringList sl = QDir ( path, "lib*.so" ). entryList ( );
135 107
136 for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) {
137 QLibrary *lib = new QLibrary ( path + "/" + *it );
138 StyleInterface *iface;
139 108
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 109
147#endif
148}
149 110
150void Appearance::loadDecos ( QListBox *list ) 111QWidget *Appearance::createStyleTab ( QWidget *parent, Config &cfg )
151{ 112{
152 list-> insertItem ( new DecoListItem ( "QPE" )); 113 QWidget* tab = new QWidget( parent, "StyleTab" );
114 QVBoxLayout* vertLayout = new QVBoxLayout( tab, 3, 3 );
153 115
116 m_style_list = new QListBox( tab, "m_style_list" );
117 vertLayout->addWidget( m_style_list );
118
119 m_style_settings = new QPushButton ( tr( "Settings..." ), tab );
120 connect ( m_style_settings, SIGNAL( clicked ( )), this, SLOT( styleSettingsClicked ( )));
121 vertLayout-> addWidget ( m_style_settings );
122
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
154 { 133 {
155 QString path = QPEApplication::qpeDir() + "/plugins/decorations/"; 134 QString path = QPEApplication::qpeDir ( ) + "/plugins/styles/";
156 QStringList sl = QDir ( path, "lib*.so" ). entryList ( ); 135 QStringList sl = QDir ( path, "lib*.so" ). entryList ( );
@@ -159,6 +138,11 @@ void Appearance::loadDecos ( QListBox *list )
159 QLibrary *lib = new QLibrary ( path + "/" + *it ); 138 QLibrary *lib = new QLibrary ( path + "/" + *it );
160 WindowDecorationInterface *iface; 139 StyleInterface *iface;
161 140
162 if ( lib-> queryInterface ( IID_WindowDecoration, (QUnknownInterface **) &iface ) == QS_OK ) 141 if (( lib-> queryInterface ( IID_Style, (QUnknownInterface **) &iface ) == QS_OK ) && iface ) {
163 list-> insertItem ( new DecoListItem ( lib, iface )); 142 StyleListItem *slit = new StyleListItem ( lib, iface );
143 m_style_list-> insertItem ( slit );
144
145 if ( slit-> key ( ) == s )
146 m_style_list-> setCurrentItem ( slit );
147 }
164 else 148 else
@@ -167,53 +151,3 @@ void Appearance::loadDecos ( QListBox *list )
167 } 151 }
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 152
198 QWidget* tab = new QWidget( parent, "StyleTab" );
199 QVBoxLayout* vertLayout = new QVBoxLayout( tab, 4, 4 );
200
201 m_style_list = new QListBox( tab, "m_style_list" );
202 vertLayout->addWidget( m_style_list );
203
204 m_style_settings = new QPushButton ( tr( "Settings..." ), tab );
205 connect ( m_style_settings, SIGNAL( clicked ( )), this, SLOT( styleSettingsClicked ( )));
206 vertLayout-> addWidget ( m_style_settings );
207
208 loadStyles ( m_style_list );
209
210 QString s = config. readEntry ( "Style", "Light" );
211
212 for ( uint i = 0; i < m_style_list-> count ( ); i++ ) {
213 if (((StyleListItem *) m_style_list-> item ( i ))-> key ( ) == s ) {
214 m_style_list-> setCurrentItem ( i );
215 break;
216 }
217 }
218
219 m_original_style = m_style_list-> currentItem ( ); 153 m_original_style = m_style_list-> currentItem ( );
@@ -226,9 +160,6 @@ QWidget *Appearance::createStyleTab ( QWidget *parent )
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
@@ -237,13 +168,26 @@ QWidget *Appearance::createDecoTab ( QWidget *parent )
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" ));
172
173 {
174 QString path = QPEApplication::qpeDir() + "/plugins/decorations/";
175 QStringList sl = QDir ( path, "lib*.so" ). entryList ( );
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;
190 }
191 }
241 192
242 for ( uint i = 0; i < m_deco_list-> count ( ); i++ ) {
243 if (((DecoListItem *) m_deco_list-> item ( i ))-> key ( ) == s ) {
244 m_deco_list-> setCurrentItem ( i );
245 break;
246 }
247 }
248
249 m_original_deco = m_deco_list-> currentItem ( ); 193 m_original_deco = m_deco_list-> currentItem ( );
@@ -258,10 +202,7 @@ QWidget *Appearance::createDecoTab ( QWidget *parent )
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
@@ -276,10 +217,6 @@ QWidget *Appearance::createFontTab ( QWidget *parent )
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 );
@@ -290,3 +227,15 @@ QWidget *Appearance::createColorTab ( QWidget *parent )
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 );
@@ -311,14 +260,80 @@ QWidget *Appearance::createColorTab ( QWidget *parent )
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 );
316 267
317 QWidget *tab = new QWidget( parent, "AdvancedTab" ); 268 m_force = new QCheckBox ( tr( "Force styling for all applications." ), tab );
318 QVBoxLayout *vertLayout = new QVBoxLayout( tab, 4, 4 ); 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 );
333
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
@@ -364,3 +379,3 @@ Appearance::Appearance( QWidget* parent, const char* name, WFlags )
364 379
365 QVBoxLayout *top = new QVBoxLayout ( this, 4, 4 ); 380 QVBoxLayout *top = new QVBoxLayout ( this, 3, 3 );
366 381
@@ -372,7 +387,7 @@ Appearance::Appearance( QWidget* parent, const char* name, WFlags )
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
@@ -382,3 +397,4 @@ Appearance::Appearance( QWidget* parent, const char* name, WFlags )
382 tw-> setCurrentTab ( styletab ); 397 tw-> setCurrentTab ( styletab );
383 398 connect ( tw, SIGNAL( currentChanged ( QWidget * )), this, SLOT( tabChanged ( QWidget * )));
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;
@@ -390,2 +406,12 @@ Appearance::~Appearance()
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 ( )
@@ -429,3 +455,15 @@ 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
@@ -433,3 +471,3 @@ void Appearance::accept ( )
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()" );
@@ -464,3 +502,3 @@ void Appearance::styleSettingsClicked ( )
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
@@ -564,4 +602,5 @@ void Appearance::saveSchemeClicked()
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
@@ -580,3 +619,4 @@ void Appearance::saveSchemeClicked()
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 }
@@ -602,3 +642,3 @@ void Appearance::deleteSchemeClicked()
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 }
@@ -611 +651,104 @@ void Appearance::deleteSchemeClicked()
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