summaryrefslogtreecommitdiff
authorkergoth <kergoth>2003-04-18 22:17:38 (UTC)
committer kergoth <kergoth>2003-04-18 22:17:38 (UTC)
commit6e7112a3610c4e562f991ba6d6f33ca2fe0c605d (patch) (unidiff)
treeae90d7b8c36c49f109e3c2f231a119fc7fd5b799
parentd0852e67c15c5a973b7bc7f7bee238a6fd00dee6 (diff)
downloadopie-6e7112a3610c4e562f991ba6d6f33ca2fe0c605d.zip
opie-6e7112a3610c4e562f991ba6d6f33ca2fe0c605d.tar.gz
opie-6e7112a3610c4e562f991ba6d6f33ca2fe0c605d.tar.bz2
Make appearance and rotate applet use the new rotation method of odevice.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/applets/rotateapplet/rotate.cpp25
-rw-r--r--noncore/settings/appearance2/appearance.cpp27
2 files changed, 33 insertions, 19 deletions
diff --git a/core/applets/rotateapplet/rotate.cpp b/core/applets/rotateapplet/rotate.cpp
index 04270f1..62567ed 100644
--- a/core/applets/rotateapplet/rotate.cpp
+++ b/core/applets/rotateapplet/rotate.cpp
@@ -1,167 +1,174 @@
1/* 1/*
2               =. This file is part of the OPIE Project 2               =. This file is part of the OPIE Project
3             .=l. Copyright (c) 2003 Maximilian Reiss <harlekin@handhelds.org> 3             .=l. Copyright (c) 2003 Maximilian Reiss <harlekin@handhelds.org>
4           .>+-= 4           .>+-=
5 _;:,     .>    :=|. This library is free software; you can 5 _;:,     .>    :=|. This library is free software; you can
6.> <,   >  .   <= redistribute it and/or modify it under 6.> <,   >  .   <= redistribute it and/or modify it under
7:=1 )Y*s>-.--   : the terms of the GNU Library General Public 7:=1 )Y*s>-.--   : the terms of the GNU Library General Public
8.="- .-=="i,     .._ License as published by the Free Software 8.="- .-=="i,     .._ License as published by the Free Software
9 - .   .-<_>     .<> Foundation; either version 2 of the License, 9 - .   .-<_>     .<> Foundation; either version 2 of the License,
10     ._= =}       : or (at your option) any later version. 10     ._= =}       : or (at your option) any later version.
11    .%+i>       _;_. 11    .%+i>       _;_.
12    .i_,=:_.      -<s. This library is distributed in the hope that 12    .i_,=:_.      -<s. This library is distributed in the hope that
13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 13     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
14    : ..    .:,     . . . without even the implied warranty of 14    : ..    .:,     . . . without even the implied warranty of
15    =_        +     =;=| MERCHANTABILITY or FITNESS FOR A 15    =_        +     =;=| MERCHANTABILITY or FITNESS FOR A
16  _.=:.       :    :=>: PARTICULAR PURPOSE. See the GNU 16  _.=:.       :    :=>: PARTICULAR PURPOSE. See the GNU
17..}^=.=       =       ; Library General Public License for more 17..}^=.=       =       ; Library General Public License for more
18++=   -.     .     .: details. 18++=   -.     .     .: details.
19 :     =  ...= . :.=- 19 :     =  ...= . :.=-
20 -.   .:....=;==+<; You should have received a copy of the GNU 20 -.   .:....=;==+<; You should have received a copy of the GNU
21  -_. . .   )=.  = Library General Public License along with 21  -_. . .   )=.  = Library General Public License along with
22    --        :-= this library; see the file COPYING.LIB. 22    --        :-= this library; see the file COPYING.LIB.
23 If not, write to the Free Software Foundation, 23 If not, write to the Free Software Foundation,
24 Inc., 59 Temple Place - Suite 330, 24 Inc., 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA. 25 Boston, MA 02111-1307, USA.
26 26
27*/ 27*/
28 28
29 29
30#include <qpe/resource.h> 30#include <qpe/resource.h>
31#include <qpe/qcopenvelope_qws.h> 31#include <qpe/qcopenvelope_qws.h>
32 32
33#include <qpe/qpeapplication.h> 33#include <qpe/qpeapplication.h>
34#include <qpe/config.h> 34#include <qpe/config.h>
35#include <qiconset.h> 35#include <qiconset.h>
36#include <qpopupmenu.h> 36#include <qpopupmenu.h>
37 37
38#include <opie/odevice.h>
39
38#include "rotate.h" 40#include "rotate.h"
39 41
42using namespace Opie;
43
40 44
41RotateApplet::RotateApplet ( ) 45RotateApplet::RotateApplet ( )
42 : QObject ( 0, "RotateApplet" ), ref ( 0 ), m_flipped( false ) 46 : QObject ( 0, "RotateApplet" ), ref ( 0 ), m_flipped( false )
43{ 47{
44 48
45#if defined(Q_WS_QWS) 49#if defined(Q_WS_QWS)
46#if !defined(QT_NO_COP) 50#if !defined(QT_NO_COP)
47 QCopChannel *rotateChannel = new QCopChannel( "QPE/Rotation" , this ); 51 QCopChannel *rotateChannel = new QCopChannel( "QPE/Rotation" , this );
48 connect ( rotateChannel, SIGNAL( received( const QCString &, const QByteArray &) ), 52 connect ( rotateChannel, SIGNAL( received( const QCString &, const QByteArray &) ),
49 this, SLOT ( channelReceived( const QCString &, const QByteArray &) ) ); 53 this, SLOT ( channelReceived( const QCString &, const QByteArray &) ) );
50#endif 54#endif
51#endif 55#endif
52 56
53} 57}
54 58
55RotateApplet::~RotateApplet ( ) 59RotateApplet::~RotateApplet ( )
56{ 60{
57} 61}
58 62
59 63
60/** 64/**
61 * Qcop receive method. 65 * Qcop receive method.
62 */ 66 */
63void RotateApplet::channelReceived( const QCString &msg, const QByteArray & data ) { 67void RotateApplet::channelReceived( const QCString &msg, const QByteArray & data ) {
64 QDataStream stream( data, IO_ReadOnly ); 68 QDataStream stream( data, IO_ReadOnly );
65 if ( msg == "flip()" ) { 69 if ( msg == "flip()" ) {
66 activated ( ); 70 activated ( );
67 } 71 }
68} 72}
69 73
70 74
71int RotateApplet::position ( ) const 75int RotateApplet::position ( ) const
72{ 76{
73 return 3; 77 return 3;
74} 78}
75 79
76QString RotateApplet::name ( ) const 80QString RotateApplet::name ( ) const
77{ 81{
78 return tr( "Rotate shortcut" ); 82 return tr( "Rotate shortcut" );
79} 83}
80 84
81QString RotateApplet::text ( ) const 85QString RotateApplet::text ( ) const
82{ 86{
83 return tr( "Rotate" ); 87 return tr( "Rotate" );
84} 88}
85 89
86/*QString RotateApplet::tr( const char* s ) const 90/*QString RotateApplet::tr( const char* s ) const
87{ 91{
88 return qApp->translate( "RotateApplet", s, 0 ); 92 return qApp->translate( "RotateApplet", s, 0 );
89} 93}
90 94
91QString RotateApplet::tr( const char* s, const char* p ) const 95QString RotateApplet::tr( const char* s, const char* p ) const
92{ 96{
93 return qApp->translate( "RotateApplet", s, p ); 97 return qApp->translate( "RotateApplet", s, p );
94} 98}
95*/ 99*/
96 100
97QIconSet RotateApplet::icon ( ) const 101QIconSet RotateApplet::icon ( ) const
98{ 102{
99 QPixmap pix; 103 QPixmap pix;
100 QImage img = Resource::loadImage ( "Rotation" ); 104 QImage img = Resource::loadImage ( "Rotation" );
101 105
102 if ( !img. isNull ( )) 106 if ( !img. isNull ( ))
103 pix. convertFromImage ( img. smoothScale ( 14, 14 )); 107 pix. convertFromImage ( img. smoothScale ( 14, 14 ));
104 return pix; 108 return pix;
105} 109}
106 110
107QPopupMenu *RotateApplet::popup ( QWidget * ) const 111QPopupMenu *RotateApplet::popup ( QWidget * ) const
108{ 112{
109 return 0; 113 return 0;
110} 114}
111 115
112void RotateApplet::activated ( ) 116void RotateApplet::activated ( )
113{ 117{
114 118
115 int defaultRotation = QPEApplication::defaultRotation(); 119 int defaultRotation = QPEApplication::defaultRotation();
116 120 int newRotation = defaultRotation;
117 int newRotation;
118 121
119 Config cfg( "qpe" ); 122 Config cfg( "qpe" );
120 cfg.setGroup( "Appearance" ); 123 cfg.setGroup( "Appearance" );
121 124
122 // 0 -> 90° clockwise, 1 -> 90° counterclockwise 125 int rotDirection = cfg.readNumEntry( "rotatedir" );
123 int rotDirection = cfg.readNumEntry( "rotatedir", 0 ); 126 ODirection rot = CW;
127
128 if (rotDirection == -1) {
129 rot = ODevice::inst ( )-> direction ( );
130 } else {
131 rot = (ODirection)rotDirection;
132 }
124 133
125 // hide inputs methods before rotation 134 // hide inputs methods before rotation
126 QCopEnvelope en( "QPE/TaskBar", "hideInputMethod()" ); 135 QCopEnvelope en( "QPE/TaskBar", "hideInputMethod()" );
127 136
128 if ( m_flipped ) { 137 if ( m_flipped ) {
129 // if flipped, flip back to the original state, 138 // if flipped, flip back to the original state,
130 // regardless of rotation direction 139 // regardless of rotation direction
131 newRotation = defaultRotation; 140 newRotation = defaultRotation;
132 } else { 141 } else {
133 if ( rotDirection == 1 ) { 142 if ( rot == CCW ) {
134 newRotation = ( defaultRotation + 90 ) % 360; 143 newRotation = ( defaultRotation + 90 ) % 360;
135 } else if ( rotDirection == 0 ) { 144 } else if ( rot == CW ) {
136 newRotation = ( defaultRotation + 270 ) % 360; 145 newRotation = ( defaultRotation + 270 ) % 360;
137 } else { 146 } else if ( rot == Flip ) {
138 newRotation = ( defaultRotation + 180 ) % 360; 147 newRotation = ( defaultRotation + 180 ) % 360;
139 } 148 }
140 } 149 }
141 150
142 QCopEnvelope env( "QPE/System", "setCurrentRotation(int)" ); 151 QCopEnvelope env( "QPE/System", "setCurrentRotation(int)" );
143 env << newRotation; 152 env << newRotation;
144 153
145 m_flipped = !m_flipped; 154 m_flipped = !m_flipped;
146} 155}
147 156
148 157
149QRESULT RotateApplet::queryInterface ( const QUuid &uuid, QUnknownInterface **iface ) 158QRESULT RotateApplet::queryInterface ( const QUuid &uuid, QUnknownInterface **iface )
150{ 159{
151 *iface = 0; 160 *iface = 0;
152 if ( uuid == IID_QUnknown ) 161 if ( uuid == IID_QUnknown )
153 *iface = this; 162 *iface = this;
154 else if ( uuid == IID_MenuApplet ) 163 else if ( uuid == IID_MenuApplet )
155 *iface = this; 164 *iface = this;
156 165
157 if ( *iface ) 166 if ( *iface )
158 (*iface)-> addRef ( ); 167 (*iface)-> addRef ( );
159 return QS_OK; 168 return QS_OK;
160} 169}
161 170
162Q_EXPORT_INTERFACE( ) 171Q_EXPORT_INTERFACE( )
163{ 172{
164 Q_CREATE_INSTANCE( RotateApplet ) 173 Q_CREATE_INSTANCE( RotateApplet )
165} 174}
166
167
diff --git a/noncore/settings/appearance2/appearance.cpp b/noncore/settings/appearance2/appearance.cpp
index 83532de..c376ec7 100644
--- a/noncore/settings/appearance2/appearance.cpp
+++ b/noncore/settings/appearance2/appearance.cpp
@@ -1,852 +1,859 @@
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 <qbuttongroup.h> 30#include <qbuttongroup.h>
31#include <qcheckbox.h> 31#include <qcheckbox.h>
32#include <qcombobox.h> 32#include <qcombobox.h>
33#include <qdialog.h> 33#include <qdialog.h>
34#include <qdir.h> 34#include <qdir.h>
35#include <qlabel.h> 35#include <qlabel.h>
36#include <qlayout.h> 36#include <qlayout.h>
37#include <qlineedit.h> 37#include <qlineedit.h>
38#include <qlistbox.h> 38#include <qlistbox.h>
39#include <qmessagebox.h> 39#include <qmessagebox.h>
40#include <qpushbutton.h> 40#include <qpushbutton.h>
41#include <qradiobutton.h> 41#include <qradiobutton.h>
42#if QT_VERSION >= 300 42#if QT_VERSION >= 300
43#include <qstylefactory.h> 43#include <qstylefactory.h>
44#endif 44#endif
45#include <qtoolbutton.h> 45#include <qtoolbutton.h>
46#include <qwindowsstyle.h> 46#include <qwindowsstyle.h>
47#include <qlistview.h> 47#include <qlistview.h>
48#include <qheader.h> 48#include <qheader.h>
49#include <qvbox.h> 49#include <qvbox.h>
50#include <qwhatsthis.h> 50#include <qwhatsthis.h>
51 51
52#include <qpe/config.h> 52#include <qpe/config.h>
53#include <qpe/global.h> 53#include <qpe/global.h>
54#include <qpe/resource.h> 54#include <qpe/resource.h>
55#include <qpe/qpeapplication.h> 55#include <qpe/qpeapplication.h>
56#include <qpe/qpemessagebox.h> 56#include <qpe/qpemessagebox.h>
57#include <qpe/qcopenvelope_qws.h> 57#include <qpe/qcopenvelope_qws.h>
58#include <qpe/qpestyle.h> 58#include <qpe/qpestyle.h>
59#include <qpe/lightstyle.h> 59#include <qpe/lightstyle.h>
60#include <qpe/qlibrary.h> 60#include <qpe/qlibrary.h>
61#include <qpe/styleinterface.h> 61#include <qpe/styleinterface.h>
62 62
63#include <opie/ofontselector.h> 63#include <opie/ofontselector.h>
64#include <opie/odevice.h> 64#include <opie/odevice.h>
65#include <opie/ofiledialog.h> 65#include <opie/ofiledialog.h>
66#include <opie/otabwidget.h> 66#include <opie/otabwidget.h>
67 67
68#include "appearance.h" 68#include "appearance.h"
69#include "editScheme.h" 69#include "editScheme.h"
70#include "stylelistitem.h" 70#include "stylelistitem.h"
71#include "decolistitem.h" 71#include "decolistitem.h"
72#include "colorlistitem.h" 72#include "colorlistitem.h"
73#include "exceptlistitem.h" 73#include "exceptlistitem.h"
74#include "sample.h" 74#include "sample.h"
75 75
76 76
77using namespace Opie; 77using namespace Opie;
78 78
79 79
80class DefaultWindowDecoration : public WindowDecorationInterface 80class DefaultWindowDecoration : public WindowDecorationInterface
81{ 81{
82public: 82public:
83 DefaultWindowDecoration() : ref(0) {} 83 DefaultWindowDecoration() : ref(0) {}
84 QString name() const { 84 QString name() const {
85 return "Default"; 85 return "Default";
86 } 86 }
87 QPixmap icon() const { 87 QPixmap icon() const {
88 return QPixmap(); 88 return QPixmap();
89 } 89 }
90 QRESULT queryInterface( const QUuid &uuid, QUnknownInterface **iface ) { 90 QRESULT queryInterface( const QUuid &uuid, QUnknownInterface **iface ) {
91 *iface = 0; 91 *iface = 0;
92 if ( uuid == IID_QUnknown ) 92 if ( uuid == IID_QUnknown )
93 *iface = this; 93 *iface = this;
94 else if ( uuid == IID_WindowDecoration ) 94 else if ( uuid == IID_WindowDecoration )
95 *iface = this; 95 *iface = this;
96 96
97 if ( *iface ) 97 if ( *iface )
98 (*iface)->addRef(); 98 (*iface)->addRef();
99 return QS_OK; 99 return QS_OK;
100 } 100 }
101 Q_REFCOUNT 101 Q_REFCOUNT
102 102
103private: 103private:
104 ulong ref; 104 ulong ref;
105}; 105};
106 106
107 107
108 108
109 109
110 110
111 111
112 112
113QWidget *Appearance::createStyleTab ( QWidget *parent, Config &cfg ) 113QWidget *Appearance::createStyleTab ( QWidget *parent, Config &cfg )
114{ 114{
115 QWidget* tab = new QWidget( parent, "StyleTab" ); 115 QWidget* tab = new QWidget( parent, "StyleTab" );
116 QVBoxLayout* vertLayout = new QVBoxLayout( tab, 3, 3 ); 116 QVBoxLayout* vertLayout = new QVBoxLayout( tab, 3, 3 );
117 117
118 m_style_list = new QListBox( tab, "m_style_list" ); 118 m_style_list = new QListBox( tab, "m_style_list" );
119 vertLayout->addWidget( m_style_list ); 119 vertLayout->addWidget( m_style_list );
120 QWhatsThis::add( m_style_list, tr( "Styles control the way items such as buttons and scroll bars appear in all applications.\n\nClick here to select an available style." ) ); 120 QWhatsThis::add( m_style_list, tr( "Styles control the way items such as buttons and scroll bars appear in all applications.\n\nClick here to select an available style." ) );
121 121
122 m_style_settings = new QPushButton ( tr( "Settings..." ), tab ); 122 m_style_settings = new QPushButton ( tr( "Settings..." ), tab );
123 connect ( m_style_settings, SIGNAL( clicked ( )), this, SLOT( styleSettingsClicked ( ))); 123 connect ( m_style_settings, SIGNAL( clicked ( )), this, SLOT( styleSettingsClicked ( )));
124 vertLayout-> addWidget ( m_style_settings ); 124 vertLayout-> addWidget ( m_style_settings );
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." ) ); 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." ) );
126 126
127 QString s = cfg. readEntry ( "Style", "Light" ); 127 QString s = cfg. readEntry ( "Style", "Light" );
128 128
129 129
130#if QT_VERSION >= 300 130#if QT_VERSION >= 300
131 m_style_list->insertStringList(QStyleFactory::styles()); 131 m_style_list->insertStringList(QStyleFactory::styles());
132#else 132#else
133 m_style_list-> insertItem ( new StyleListItem ( "Windows", new QWindowsStyle ( ))); 133 m_style_list-> insertItem ( new StyleListItem ( "Windows", new QWindowsStyle ( )));
134 m_style_list-> insertItem ( new StyleListItem ( "Light", new LightStyle ( ))); 134 m_style_list-> insertItem ( new StyleListItem ( "Light", new LightStyle ( )));
135 m_style_list-> insertItem ( new StyleListItem ( "QPE", new QPEStyle ( ))); 135 m_style_list-> insertItem ( new StyleListItem ( "QPE", new QPEStyle ( )));
136#endif 136#endif
137 { 137 {
138 QString path = QPEApplication::qpeDir ( ); 138 QString path = QPEApplication::qpeDir ( );
139 path.append( "/plugins/styles/" ); 139 path.append( "/plugins/styles/" );
140 QStringList sl = QDir ( path, "lib*.so" ). entryList ( ); 140 QStringList sl = QDir ( path, "lib*.so" ). entryList ( );
141 141
142 for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) { 142 for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) {
143 QString libstr = path; 143 QString libstr = path;
144 libstr.append( "/" ); 144 libstr.append( "/" );
145 libstr.append( *it ); 145 libstr.append( *it );
146 QLibrary *lib = new QLibrary ( libstr ); 146 QLibrary *lib = new QLibrary ( libstr );
147 StyleInterface *iface; 147 StyleInterface *iface;
148 148
149 if (( lib-> queryInterface ( IID_Style, (QUnknownInterface **) &iface ) == QS_OK ) && iface ) { 149 if (( lib-> queryInterface ( IID_Style, (QUnknownInterface **) &iface ) == QS_OK ) && iface ) {
150 StyleListItem *slit = new StyleListItem ( lib, iface ); 150 StyleListItem *slit = new StyleListItem ( lib, iface );
151 m_style_list-> insertItem ( slit ); 151 m_style_list-> insertItem ( slit );
152 152
153 if ( slit-> key ( ) == s ) 153 if ( slit-> key ( ) == s )
154 m_style_list-> setCurrentItem ( slit ); 154 m_style_list-> setCurrentItem ( slit );
155 } 155 }
156 else 156 else
157 delete lib; 157 delete lib;
158 } 158 }
159 } 159 }
160 160
161 m_original_style = m_style_list-> currentItem ( ); 161 m_original_style = m_style_list-> currentItem ( );
162 styleClicked ( m_original_style ); 162 styleClicked ( m_original_style );
163 163
164 connect( m_style_list, SIGNAL( highlighted( int ) ), this, SLOT( styleClicked( int ) ) ); 164 connect( m_style_list, SIGNAL( highlighted( int ) ), this, SLOT( styleClicked( int ) ) );
165 165
166 return tab; 166 return tab;
167} 167}
168 168
169QWidget *Appearance::createDecoTab ( QWidget *parent, Config &cfg ) 169QWidget *Appearance::createDecoTab ( QWidget *parent, Config &cfg )
170{ 170{
171 QWidget* tab = new QWidget( parent, "DecoTab" ); 171 QWidget* tab = new QWidget( parent, "DecoTab" );
172 QVBoxLayout* vertLayout = new QVBoxLayout( tab, 3, 3 ); 172 QVBoxLayout* vertLayout = new QVBoxLayout( tab, 3, 3 );
173 173
174 m_deco_list = new QListBox( tab, "m_deco_list" ); 174 m_deco_list = new QListBox( tab, "m_deco_list" );
175 vertLayout->addWidget( m_deco_list ); 175 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." ) ); 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." ) );
177 177
178 QString s = cfg. readEntry ( "Decoration" ); 178 QString s = cfg. readEntry ( "Decoration" );
179 179
180 m_deco_list-> insertItem ( new DecoListItem ( "QPE" )); 180 m_deco_list-> insertItem ( new DecoListItem ( "QPE" ));
181 181
182 { 182 {
183 QString path = QPEApplication::qpeDir(); 183 QString path = QPEApplication::qpeDir();
184 path.append( "/plugins/decorations/" ); 184 path.append( "/plugins/decorations/" );
185 QStringList sl = QDir ( path, "lib*.so" ). entryList ( ); 185 QStringList sl = QDir ( path, "lib*.so" ). entryList ( );
186 186
187 for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) { 187 for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) {
188 QString libstr = path; 188 QString libstr = path;
189 libstr.append( "/" ); 189 libstr.append( "/" );
190 libstr.append( *it ); 190 libstr.append( *it );
191 QLibrary *lib = new QLibrary ( libstr ); 191 QLibrary *lib = new QLibrary ( libstr );
192 WindowDecorationInterface *iface; 192 WindowDecorationInterface *iface;
193 193
194 if ( lib-> queryInterface ( IID_WindowDecoration, (QUnknownInterface **) &iface ) == QS_OK ) { 194 if ( lib-> queryInterface ( IID_WindowDecoration, (QUnknownInterface **) &iface ) == QS_OK ) {
195 DecoListItem *dlit = new DecoListItem ( lib, iface ); 195 DecoListItem *dlit = new DecoListItem ( lib, iface );
196 m_deco_list-> insertItem ( dlit ); 196 m_deco_list-> insertItem ( dlit );
197 197
198 if ( dlit-> key ( ) == s ) 198 if ( dlit-> key ( ) == s )
199 m_deco_list-> setCurrentItem ( dlit ); 199 m_deco_list-> setCurrentItem ( dlit );
200 } 200 }
201 else 201 else
202 delete lib; 202 delete lib;
203 } 203 }
204 } 204 }
205 205
206 m_original_deco = m_deco_list-> currentItem ( ); 206 m_original_deco = m_deco_list-> currentItem ( );
207 if ( m_deco_list-> currentItem ( ) < 0 ) 207 if ( m_deco_list-> currentItem ( ) < 0 )
208 m_deco_list-> setCurrentItem ( 0 ); 208 m_deco_list-> setCurrentItem ( 0 );
209 decoClicked ( m_original_deco ); 209 decoClicked ( m_original_deco );
210 210
211 connect( m_deco_list, SIGNAL( highlighted( int ) ), this, SLOT( decoClicked( int ) ) ); 211 connect( m_deco_list, SIGNAL( highlighted( int ) ), this, SLOT( decoClicked( int ) ) );
212 212
213 return tab; 213 return tab;
214} 214}
215 215
216QWidget *Appearance::createFontTab ( QWidget *parent, Config &cfg ) 216QWidget *Appearance::createFontTab ( QWidget *parent, Config &cfg )
217{ 217{
218 QString familyStr = cfg. readEntry ( "FontFamily", "Helvetica" ); 218 QString familyStr = cfg. readEntry ( "FontFamily", "Helvetica" );
219 QString styleStr = cfg. readEntry ( "FontStyle", "Regular" ); 219 QString styleStr = cfg. readEntry ( "FontStyle", "Regular" );
220 int size = cfg. readNumEntry ( "FontSize", 10 ); 220 int size = cfg. readNumEntry ( "FontSize", 10 );
221 221
222 m_fontselect = new OFontSelector ( false, parent, "FontTab" ); 222 m_fontselect = new OFontSelector ( false, parent, "FontTab" );
223 m_fontselect-> setSelectedFont ( familyStr, styleStr, size ); 223 m_fontselect-> setSelectedFont ( familyStr, styleStr, size );
224 QWhatsThis::add( m_fontselect, tr( "Select the desired name, style and size of the default font applications will use." ) ); 224 QWhatsThis::add( m_fontselect, tr( "Select the desired name, style and size of the default font applications will use." ) );
225 225
226 connect( m_fontselect, SIGNAL( fontSelected ( const QFont & )), 226 connect( m_fontselect, SIGNAL( fontSelected ( const QFont & )),
227 this, SLOT( fontClicked ( const QFont & ))); 227 this, SLOT( fontClicked ( const QFont & )));
228 228
229 return m_fontselect; 229 return m_fontselect;
230} 230}
231 231
232QWidget *Appearance::createColorTab ( QWidget *parent, Config &cfg ) 232QWidget *Appearance::createColorTab ( QWidget *parent, Config &cfg )
233{ 233{
234 QWidget *tab = new QWidget( parent, "ColorTab" ); 234 QWidget *tab = new QWidget( parent, "ColorTab" );
235 QGridLayout *gridLayout = new QGridLayout( tab, 0, 0, 3, 3 ); 235 QGridLayout *gridLayout = new QGridLayout( tab, 0, 0, 3, 3 );
236 gridLayout->setRowStretch ( 3, 10 ); 236 gridLayout->setRowStretch ( 3, 10 );
237 237
238 m_color_list = new QListBox ( tab ); 238 m_color_list = new QListBox ( tab );
239 gridLayout->addMultiCellWidget ( m_color_list, 0, 3, 0, 0 ); 239 gridLayout->addMultiCellWidget ( m_color_list, 0, 3, 0, 0 );
240 connect( m_color_list, SIGNAL( highlighted( int ) ), this, SLOT( colorClicked( int ) ) ); 240 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." ) ); 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." ) );
242 242
243 m_color_list-> insertItem ( new ColorListItem ( tr( "Current scheme" ), cfg )); 243 m_color_list-> insertItem ( new ColorListItem ( tr( "Current scheme" ), cfg ));
244 244
245 QString path = QPEApplication::qpeDir ( ); 245 QString path = QPEApplication::qpeDir ( );
246 path.append( "/etc/colors/" ); 246 path.append( "/etc/colors/" );
247 QStringList sl = QDir ( path ). entryList ( "*.scheme" ); 247 QStringList sl = QDir ( path ). entryList ( "*.scheme" );
248 248
249 for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) { 249 for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) {
250 QString name = (*it). left ((*it). find ( ".scheme" )); 250 QString name = (*it). left ((*it). find ( ".scheme" ));
251 QString pathstr = path; 251 QString pathstr = path;
252 pathstr.append( *it ); 252 pathstr.append( *it );
253 Config config ( pathstr, Config::File ); 253 Config config ( pathstr, Config::File );
254 config. setGroup ( "Colors" ); 254 config. setGroup ( "Colors" );
255 255
256 m_color_list-> insertItem ( new ColorListItem ( name, config )); 256 m_color_list-> insertItem ( new ColorListItem ( name, config ));
257 } 257 }
258 258
259 m_color_list-> setCurrentItem ( 0 ); 259 m_color_list-> setCurrentItem ( 0 );
260 260
261 QPushButton* tempButton = new QPushButton( tab, "editSchemeButton" ); 261 QPushButton* tempButton = new QPushButton( tab, "editSchemeButton" );
262 tempButton->setText( tr( "Edit..." ) ); 262 tempButton->setText( tr( "Edit..." ) );
263 connect( tempButton, SIGNAL( clicked() ), this, SLOT( editSchemeClicked() ) ); 263 connect( tempButton, SIGNAL( clicked() ), this, SLOT( editSchemeClicked() ) );
264 gridLayout->addWidget( tempButton, 0, 1 ); 264 gridLayout->addWidget( tempButton, 0, 1 );
265 QWhatsThis::add( tempButton, tr( "Click here to change the colors in the current color scheme." ) ); 265 QWhatsThis::add( tempButton, tr( "Click here to change the colors in the current color scheme." ) );
266 266
267 tempButton = new QPushButton( tab, "deleteSchemeButton" ); 267 tempButton = new QPushButton( tab, "deleteSchemeButton" );
268 tempButton->setText( tr( "Delete" ) ); 268 tempButton->setText( tr( "Delete" ) );
269 connect( tempButton, SIGNAL( clicked() ), this, SLOT( deleteSchemeClicked() ) ); 269 connect( tempButton, SIGNAL( clicked() ), this, SLOT( deleteSchemeClicked() ) );
270 gridLayout->addWidget( tempButton, 1, 1 ); 270 gridLayout->addWidget( tempButton, 1, 1 );
271 QWhatsThis::add( tempButton, tr( "Click here to delete the color scheme selected in the list to the left." ) ); 271 QWhatsThis::add( tempButton, tr( "Click here to delete the color scheme selected in the list to the left." ) );
272 272
273 tempButton = new QPushButton( tab, "saveSchemeButton" ); 273 tempButton = new QPushButton( tab, "saveSchemeButton" );
274 tempButton->setText( tr( "Save" ) ); 274 tempButton->setText( tr( "Save" ) );
275 connect( tempButton, SIGNAL( clicked() ), this, SLOT( saveSchemeClicked() ) ); 275 connect( tempButton, SIGNAL( clicked() ), this, SLOT( saveSchemeClicked() ) );
276 gridLayout->addWidget( tempButton, 2, 1 ); 276 gridLayout->addWidget( tempButton, 2, 1 );
277 QWhatsThis::add( tempButton, tr( "Click here to name and save the current color scheme." ) ); 277 QWhatsThis::add( tempButton, tr( "Click here to name and save the current color scheme." ) );
278 278
279 return tab; 279 return tab;
280} 280}
281 281
282QWidget *Appearance::createAdvancedTab ( QWidget *parent, Config &cfg ) 282QWidget *Appearance::createAdvancedTab ( QWidget *parent, Config &cfg )
283{ 283{
284 QWidget *tab = new QWidget ( parent ); 284 QWidget *tab = new QWidget ( parent );
285 QVBoxLayout *vertLayout = new QVBoxLayout( tab, 3, 3 ); 285 QVBoxLayout *vertLayout = new QVBoxLayout( tab, 3, 3 );
286 286
287 QGridLayout *lay = new QGridLayout ( vertLayout, 0, 0, 3, 0 ); 287 QGridLayout *lay = new QGridLayout ( vertLayout, 0, 0, 3, 0 );
288 288
289 m_force = new QCheckBox ( tr( "Force styling for all applications." ), tab ); 289 m_force = new QCheckBox ( tr( "Force styling for all applications." ), tab );
290 m_force-> setChecked ( cfg. readBoolEntry ( "ForceStyle" )); 290 m_force-> setChecked ( cfg. readBoolEntry ( "ForceStyle" ));
291 lay-> addMultiCellWidget ( m_force, 0, 0, 0, 1 ); 291 lay-> addMultiCellWidget ( m_force, 0, 0, 0, 1 );
292 QWhatsThis::add( m_force, tr( "Click here to allow all applications to use global appearance settings." ) ); 292 QWhatsThis::add( m_force, tr( "Click here to allow all applications to use global appearance settings." ) );
293 293
294 QLabel *l = new QLabel ( tab ); 294 QLabel *l = new QLabel ( tab );
295 l-> setText ( QString ( "<p>%1</p>" ). arg ( tr( "Disable styling for these applications ( <b>*</b> can be used as a wildcard):" ))); 295 l-> setText ( QString ( "<p>%1</p>" ). arg ( tr( "Disable styling for these applications ( <b>*</b> can be used as a wildcard):" )));
296 lay-> addMultiCellWidget ( l, 1, 1, 0, 1 ); 296 lay-> addMultiCellWidget ( l, 1, 1, 0, 1 );
297 QWhatsThis::add( l, tr( "If some applications do not display correctly with the global appearance settings, certain features can be turned off for that application.\n\nThis area allows you to select an application and which settings you wish to disable." ) ); 297 QWhatsThis::add( l, tr( "If some applications do not display correctly with the global appearance settings, certain features can be turned off for that application.\n\nThis area allows you to select an application and which settings you wish to disable." ) );
298 298
299 m_except = new QListView ( tab ); 299 m_except = new QListView ( tab );
300 m_except-> addColumn ( Resource::loadIconSet ( "appearance" ), "", 24 ); 300 m_except-> addColumn ( Resource::loadIconSet ( "appearance" ), "", 24 );
301 m_except-> addColumn ( Resource::loadIconSet ( "font" ), "", 24 ); 301 m_except-> addColumn ( Resource::loadIconSet ( "font" ), "", 24 );
302 m_except-> addColumn ( Resource::loadIconSet ( "appearance/deco" ), "", 24 ); 302 m_except-> addColumn ( Resource::loadIconSet ( "appearance/deco" ), "", 24 );
303 m_except-> addColumn ( tr( "Binary file(s)" )); 303 m_except-> addColumn ( tr( "Binary file(s)" ));
304 m_except-> setColumnAlignment ( 0, AlignCenter ); 304 m_except-> setColumnAlignment ( 0, AlignCenter );
305 m_except-> setColumnAlignment ( 1, AlignCenter ); 305 m_except-> setColumnAlignment ( 1, AlignCenter );
306 m_except-> setColumnAlignment ( 2, AlignCenter ); 306 m_except-> setColumnAlignment ( 2, AlignCenter );
307 m_except-> setAllColumnsShowFocus ( true ); 307 m_except-> setAllColumnsShowFocus ( true );
308 m_except-> setMinimumHeight ( 30 ); 308 m_except-> setMinimumHeight ( 30 );
309 m_except-> header ( )-> setClickEnabled ( false ); 309 m_except-> header ( )-> setClickEnabled ( false );
310 m_except-> header ( )-> setResizeEnabled ( false ); 310 m_except-> header ( )-> setResizeEnabled ( false );
311 m_except-> header ( )-> setMovingEnabled ( false ); 311 m_except-> header ( )-> setMovingEnabled ( false );
312 m_except-> setSorting ( -1 ); 312 m_except-> setSorting ( -1 );
313 lay-> addMultiCellWidget ( m_except, 2, 6, 0, 0 ); 313 lay-> addMultiCellWidget ( m_except, 2, 6, 0, 0 );
314 QWhatsThis::add( m_except, tr( "If some applications do not display correctly with the global appearance settings, certain features can be turned off for that application.\n\nThis area allows you to select an application and which settings you wish to disable." ) ); 314 QWhatsThis::add( m_except, tr( "If some applications do not display correctly with the global appearance settings, certain features can be turned off for that application.\n\nThis area allows you to select an application and which settings you wish to disable." ) );
315 315
316 connect ( m_except, SIGNAL( clicked ( QListViewItem *, const QPoint &, int )), this, SLOT( clickedExcept ( QListViewItem *, const QPoint &, int ))); 316 connect ( m_except, SIGNAL( clicked ( QListViewItem *, const QPoint &, int )), this, SLOT( clickedExcept ( QListViewItem *, const QPoint &, int )));
317 317
318 QToolButton *tb = new QToolButton ( tab ); 318 QToolButton *tb = new QToolButton ( tab );
319 tb-> setIconSet ( Resource::loadIconSet ( "appearance/add" )); 319 tb-> setIconSet ( Resource::loadIconSet ( "appearance/add" ));
320 tb-> setFocusPolicy ( QWidget::StrongFocus ); 320 tb-> setFocusPolicy ( QWidget::StrongFocus );
321 lay-> addWidget ( tb, 2, 1 ); 321 lay-> addWidget ( tb, 2, 1 );
322 connect ( tb, SIGNAL( clicked ( )), this, SLOT( addExcept ( ))); 322 connect ( tb, SIGNAL( clicked ( )), this, SLOT( addExcept ( )));
323 QWhatsThis::add( tb, tr( "Click here to add an application to the list above." ) ); 323 QWhatsThis::add( tb, tr( "Click here to add an application to the list above." ) );
324 324
325 tb = new QToolButton ( tab ); 325 tb = new QToolButton ( tab );
326 tb-> setIconSet ( Resource::loadIconSet ( "editdelete" )); 326 tb-> setIconSet ( Resource::loadIconSet ( "editdelete" ));
327 tb-> setFocusPolicy ( QWidget::StrongFocus ); 327 tb-> setFocusPolicy ( QWidget::StrongFocus );
328 lay-> addWidget ( tb, 3, 1 ); 328 lay-> addWidget ( tb, 3, 1 );
329 connect ( tb, SIGNAL( clicked ( )), this, SLOT( delExcept ( ))); 329 connect ( tb, SIGNAL( clicked ( )), this, SLOT( delExcept ( )));
330 QWhatsThis::add( tb, tr( "Click here to delete the currently selected application." ) ); 330 QWhatsThis::add( tb, tr( "Click here to delete the currently selected application." ) );
331 331
332 tb = new QToolButton ( tab ); 332 tb = new QToolButton ( tab );
333 tb-> setIconSet ( Resource::loadIconSet ( "up" )); 333 tb-> setIconSet ( Resource::loadIconSet ( "up" ));
334 tb-> setFocusPolicy ( QWidget::StrongFocus ); 334 tb-> setFocusPolicy ( QWidget::StrongFocus );
335 lay-> addWidget ( tb, 4, 1 ); 335 lay-> addWidget ( tb, 4, 1 );
336 connect ( tb, SIGNAL( clicked ( )), this, SLOT( upExcept ( ))); 336 connect ( tb, SIGNAL( clicked ( )), this, SLOT( upExcept ( )));
337 QWhatsThis::add( tb, tr( "Click here to move the currently selected application up in the list." ) ); 337 QWhatsThis::add( tb, tr( "Click here to move the currently selected application up in the list." ) );
338 338
339 tb = new QToolButton ( tab ); 339 tb = new QToolButton ( tab );
340 tb-> setIconSet ( Resource::loadIconSet ( "down" )); 340 tb-> setIconSet ( Resource::loadIconSet ( "down" ));
341 tb-> setFocusPolicy ( QWidget::StrongFocus ); 341 tb-> setFocusPolicy ( QWidget::StrongFocus );
342 lay-> addWidget ( tb, 5, 1 ); 342 lay-> addWidget ( tb, 5, 1 );
343 connect ( tb, SIGNAL( clicked ( )), this, SLOT( downExcept ( ))); 343 connect ( tb, SIGNAL( clicked ( )), this, SLOT( downExcept ( )));
344 QWhatsThis::add( tb, tr( "Click here to move the currently selected application down in the list." ) ); 344 QWhatsThis::add( tb, tr( "Click here to move the currently selected application down in the list." ) );
345 345
346 lay-> setRowStretch ( 6, 10 ); 346 lay-> setRowStretch ( 6, 10 );
347 lay-> setColStretch ( 0, 10 ); 347 lay-> setColStretch ( 0, 10 );
348 348
349 QStringList sl = cfg. readListEntry ( "NoStyle", ';' ); 349 QStringList sl = cfg. readListEntry ( "NoStyle", ';' );
350 QListViewItem *lvit = 0; 350 QListViewItem *lvit = 0;
351 for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) { 351 for ( QStringList::Iterator it = sl. begin ( ); it != sl. end ( ); ++it ) {
352 int fl = ( *it ). left ( 1 ). toInt ( 0, 32 ); 352 int fl = ( *it ). left ( 1 ). toInt ( 0, 32 );
353 353
354 lvit = new ExceptListItem ( m_except, lvit, ( *it ). mid ( 1 ), fl & 0x01, fl & 0x02, fl & 0x04 ); 354 lvit = new ExceptListItem ( m_except, lvit, ( *it ). mid ( 1 ), fl & 0x01, fl & 0x02, fl & 0x04 );
355 } 355 }
356 356
357 357
358 vertLayout-> addSpacing ( 3 ); 358 vertLayout-> addSpacing ( 3 );
359 QFrame *f = new QFrame ( tab ); 359 QFrame *f = new QFrame ( tab );
360 f-> setFrameStyle ( QFrame::HLine | QFrame::Sunken ); 360 f-> setFrameStyle ( QFrame::HLine | QFrame::Sunken );
361 vertLayout-> addWidget ( f ); 361 vertLayout-> addWidget ( f );
362 vertLayout-> addSpacing ( 3 ); 362 vertLayout-> addSpacing ( 3 );
363 363
364 364
365 QGridLayout* gridLayout = new QGridLayout ( vertLayout, 0, 0, 3, 0 ); 365 QGridLayout* gridLayout = new QGridLayout ( vertLayout, 0, 0, 3, 0 );
366 366
367 int style = cfg. readNumEntry ( "TabStyle", 2 ) - 1; 367 int style = cfg. readNumEntry ( "TabStyle", 2 ) - 1;
368 bool tabtop = ( cfg. readEntry ( "TabPosition", "Top" ) == "Top" ); 368 bool tabtop = ( cfg. readEntry ( "TabPosition", "Top" ) == "Top" );
369 369
370 QLabel* label = new QLabel( tr( "Tab style:" ), tab ); 370 QLabel* label = new QLabel( tr( "Tab style:" ), tab );
371 gridLayout-> addWidget ( label, 0, 0 ); 371 gridLayout-> addWidget ( label, 0, 0 );
372 QWhatsThis::add( label, tr( "Click here to select a desired style for tabbed dialogs (such as this application). The styles available are:\n\n1. Tabs - normal tabs with text labels only\n2. Tabs w/icons - tabs with icons for each tab, text label only appears on current tab\n3. Drop down list - a vertical listing of tabs\n4. Drop down list w/icons - a vertical listing of tabs with icons" ) ); 372 QWhatsThis::add( label, tr( "Click here to select a desired style for tabbed dialogs (such as this application). The styles available are:\n\n1. Tabs - normal tabs with text labels only\n2. Tabs w/icons - tabs with icons for each tab, text label only appears on current tab\n3. Drop down list - a vertical listing of tabs\n4. Drop down list w/icons - a vertical listing of tabs with icons" ) );
373 373
374 QButtonGroup* btngrp = new QButtonGroup( tab, "buttongroup" ); 374 QButtonGroup* btngrp = new QButtonGroup( tab, "buttongroup" );
375 btngrp-> hide ( ); 375 btngrp-> hide ( );
376 btngrp-> setExclusive ( true ); 376 btngrp-> setExclusive ( true );
377 377
378 m_tabstyle_list = new QComboBox ( false, tab, "tabstyle" ); 378 m_tabstyle_list = new QComboBox ( false, tab, "tabstyle" );
379 m_tabstyle_list-> insertItem ( tr( "Tabs" )); 379 m_tabstyle_list-> insertItem ( tr( "Tabs" ));
380 m_tabstyle_list-> insertItem ( tr( "Tabs w/icons" )); 380 m_tabstyle_list-> insertItem ( tr( "Tabs w/icons" ));
381 m_tabstyle_list-> insertItem ( tr( "Drop down list" )); 381 m_tabstyle_list-> insertItem ( tr( "Drop down list" ));
382 m_tabstyle_list-> insertItem ( tr( "Drop down list w/icons" )); 382 m_tabstyle_list-> insertItem ( tr( "Drop down list w/icons" ));
383 m_tabstyle_list-> setCurrentItem ( style ); 383 m_tabstyle_list-> setCurrentItem ( style );
384 gridLayout-> addMultiCellWidget ( m_tabstyle_list, 0, 0, 1, 2 ); 384 gridLayout-> addMultiCellWidget ( m_tabstyle_list, 0, 0, 1, 2 );
385 QWhatsThis::add( m_tabstyle_list, tr( "Click here to select a desired style for tabbed dialogs (such as this application). The styles available are:\n\n1. Tabs - normal tabs with text labels only\n2. Tabs w/icons - tabs with icons for each tab, text label only appears on current tab\n3. Drop down list - a vertical listing of tabs\n4. Drop down list w/icons - a vertical listing of tabs with icons" ) ); 385 QWhatsThis::add( m_tabstyle_list, tr( "Click here to select a desired style for tabbed dialogs (such as this application). The styles available are:\n\n1. Tabs - normal tabs with text labels only\n2. Tabs w/icons - tabs with icons for each tab, text label only appears on current tab\n3. Drop down list - a vertical listing of tabs\n4. Drop down list w/icons - a vertical listing of tabs with icons" ) );
386 386
387 m_tabstyle_top = new QRadioButton( tr( "Top" ), tab, "tabpostop" ); 387 m_tabstyle_top = new QRadioButton( tr( "Top" ), tab, "tabpostop" );
388 btngrp-> insert ( m_tabstyle_top ); 388 btngrp-> insert ( m_tabstyle_top );
389 gridLayout-> addWidget( m_tabstyle_top, 1, 1 ); 389 gridLayout-> addWidget( m_tabstyle_top, 1, 1 );
390 QWhatsThis::add( m_tabstyle_top, tr( "Click here so that tabs appear at the top of the window." ) ); 390 QWhatsThis::add( m_tabstyle_top, tr( "Click here so that tabs appear at the top of the window." ) );
391 391
392 m_tabstyle_bottom = new QRadioButton( tr( "Bottom" ), tab, "tabposbottom" ); 392 m_tabstyle_bottom = new QRadioButton( tr( "Bottom" ), tab, "tabposbottom" );
393 btngrp-> insert ( m_tabstyle_bottom ); 393 btngrp-> insert ( m_tabstyle_bottom );
394 gridLayout-> addWidget( m_tabstyle_bottom, 1, 2 ); 394 gridLayout-> addWidget( m_tabstyle_bottom, 1, 2 );
395 QWhatsThis::add( m_tabstyle_bottom, tr( "Click here so that tabs appear at the bottom of the window." ) ); 395 QWhatsThis::add( m_tabstyle_bottom, tr( "Click here so that tabs appear at the bottom of the window." ) );
396 396
397 m_tabstyle_top-> setChecked ( tabtop ); 397 m_tabstyle_top-> setChecked ( tabtop );
398 m_tabstyle_bottom-> setChecked ( !tabtop ); 398 m_tabstyle_bottom-> setChecked ( !tabtop );
399 399
400 m_original_tabstyle = style; 400 m_original_tabstyle = style;
401 m_original_tabpos = tabtop; 401 m_original_tabpos = tabtop;
402 402
403 vertLayout-> addSpacing ( 3 ); 403 vertLayout-> addSpacing ( 3 );
404 QHBoxLayout *rotLay = new QHBoxLayout ( vertLayout, 3 ); 404 QHBoxLayout *rotLay = new QHBoxLayout ( vertLayout, 3 );
405 405
406 QLabel* rotlabel = new QLabel( tr( "Rotation direction:" ), tab ); 406 QLabel* rotlabel = new QLabel( tr( "Rotation direction:" ), tab );
407 m_rotdir_cw = new QRadioButton( tab, "rotdir_cw" ); 407 m_rotdir_cw = new QRadioButton( tab, "rotdir_cw" );
408 QPixmap cw1 = Resource::loadIconSet("redo"). pixmap( ); 408 QPixmap cw1 = Resource::loadIconSet("redo"). pixmap( );
409 m_rotdir_ccw = new QRadioButton( tab, "rotdir_ccw" ); 409 m_rotdir_ccw = new QRadioButton( tab, "rotdir_ccw" );
410 QImage ccwImage = cw1. convertToImage( ). mirror( 1, 0 ); 410 QImage ccwImage = cw1. convertToImage( ). mirror( 1, 0 );
411 QPixmap ccw1; 411 QPixmap ccw1;
412 m_rotdir_flip = new QRadioButton( tab, "rotdir_flip" ); 412 m_rotdir_flip = new QRadioButton( tab, "rotdir_flip" );
413 QPixmap flip1 = Resource::loadIconSet("pass"). pixmap( ); 413 QPixmap flip1 = Resource::loadIconSet("pass"). pixmap( );
414 QButtonGroup* rotbtngrp = new QButtonGroup( tab, "rotbuttongroup" ); 414 QButtonGroup* rotbtngrp = new QButtonGroup( tab, "rotbuttongroup" );
415 415
416 rotbtngrp-> hide ( ); 416 rotbtngrp-> hide ( );
417 rotbtngrp-> setExclusive ( true ); 417 rotbtngrp-> setExclusive ( true );
418 rotbtngrp-> insert ( m_rotdir_cw ); 418 rotbtngrp-> insert ( m_rotdir_cw );
419 rotbtngrp-> insert ( m_rotdir_ccw ); 419 rotbtngrp-> insert ( m_rotdir_ccw );
420 rotbtngrp-> insert ( m_rotdir_flip ); 420 rotbtngrp-> insert ( m_rotdir_flip );
421 421
422 ccw1. convertFromImage( ccwImage ); 422 ccw1. convertFromImage( ccwImage );
423 m_rotdir_cw-> setPixmap( cw1 ); 423 m_rotdir_cw-> setPixmap( cw1 );
424 m_rotdir_ccw-> setPixmap( ccw1 ); 424 m_rotdir_ccw-> setPixmap( ccw1 );
425 m_rotdir_flip-> setPixmap( flip1 ); 425 m_rotdir_flip-> setPixmap( flip1 );
426 426
427 rotLay-> addWidget ( rotlabel, 0 ); 427 rotLay-> addWidget ( rotlabel, 0 );
428 rotLay-> addWidget ( m_rotdir_cw, 0 ); 428 rotLay-> addWidget ( m_rotdir_cw, 0 );
429 rotLay-> addWidget ( m_rotdir_ccw, 0 ); 429 rotLay-> addWidget ( m_rotdir_ccw, 0 );
430 rotLay-> addWidget ( m_rotdir_flip, 0 ); 430 rotLay-> addWidget ( m_rotdir_flip, 0 );
431 431
432 int rot = cfg. readNumEntry ( "rotatedir", 0 ); 432 int rotDirection = cfg.readNumEntry( "rotatedir" );
433 m_rotdir_cw-> setChecked ( rot == 0 ); 433 ODirection rot = CW;
434 m_rotdir_ccw-> setChecked ( rot == 1 ); 434
435 m_rotdir_flip-> setChecked ( rot == 2 ); 435 if (rotDirection == -1) {
436 rot = ODevice::inst ( )-> direction ( );
437 } else {
438 rot = (ODirection)rotDirection;
439 }
440
441 m_rotdir_cw-> setChecked ( rot == CW );
442 m_rotdir_ccw-> setChecked ( rot == CCW );
443 m_rotdir_flip-> setChecked ( rot == Flip );
436 444
437 return tab; 445 return tab;
438} 446}
439 447
440 448
441Appearance::Appearance( QWidget* parent, const char* name, WFlags ) 449Appearance::Appearance( QWidget* parent, const char* name, WFlags )
442 : QDialog ( parent, name, true, WStyle_ContextHelp ) 450 : QDialog ( parent, name, true, WStyle_ContextHelp )
443{ 451{
444 setCaption( tr( "Appearance Settings" ) ); 452 setCaption( tr( "Appearance Settings" ) );
445 453
446 Config config( "qpe" ); 454 Config config( "qpe" );
447 config.setGroup( "Appearance" ); 455 config.setGroup( "Appearance" );
448 456
449 QVBoxLayout *top = new QVBoxLayout ( this, 3, 3 ); 457 QVBoxLayout *top = new QVBoxLayout ( this, 3, 3 );
450 458
451 m_sample = new SampleWindow ( this ); 459 m_sample = new SampleWindow ( this );
452 m_sample-> setDecoration ( new DefaultWindowDecoration ( )); 460 m_sample-> setDecoration ( new DefaultWindowDecoration ( ));
453 QWhatsThis::add( m_sample, tr( "This is a preview window. Look here to see your new appearance as options are changed." ) ); 461 QWhatsThis::add( m_sample, tr( "This is a preview window. Look here to see your new appearance as options are changed." ) );
454 462
455 OTabWidget* tw = new OTabWidget ( this, "tabwidget", OTabWidget::Global, OTabWidget::Bottom ); 463 OTabWidget* tw = new OTabWidget ( this, "tabwidget", OTabWidget::Global, OTabWidget::Bottom );
456 QWidget *styletab; 464 QWidget *styletab;
457 465
458 m_color_list = 0; 466 m_color_list = 0;
459 467
460 tw-> addTab ( styletab = createStyleTab ( tw, config ), "appearance", tr( "Style" )); 468 tw-> addTab ( styletab = createStyleTab ( tw, config ), "appearance", tr( "Style" ));
461 tw-> addTab ( createFontTab ( tw, config ), "font", tr( "Font" )); 469 tw-> addTab ( createFontTab ( tw, config ), "font", tr( "Font" ));
462 tw-> addTab ( createColorTab ( tw, config ), "appearance/color", tr( "Colors" ) ); 470 tw-> addTab ( createColorTab ( tw, config ), "appearance/color", tr( "Colors" ) );
463 tw-> addTab ( createDecoTab ( tw, config ), "appearance/deco", tr( "Windows" ) ); 471 tw-> addTab ( createDecoTab ( tw, config ), "appearance/deco", tr( "Windows" ) );
464 tw-> addTab ( m_advtab = createAdvancedTab ( tw, config ), "SettingsIcon", tr( "Advanced" ) ); 472 tw-> addTab ( m_advtab = createAdvancedTab ( tw, config ), "SettingsIcon", tr( "Advanced" ) );
465 473
466 top-> addWidget ( tw, 10 ); 474 top-> addWidget ( tw, 10 );
467 top-> addWidget ( m_sample, 1 ); 475 top-> addWidget ( m_sample, 1 );
468 476
469 tw-> setCurrentTab ( styletab ); 477 tw-> setCurrentTab ( styletab );
470 connect ( tw, SIGNAL( currentChanged ( QWidget * )), this, SLOT( tabChanged ( QWidget * ))); 478 connect ( tw, SIGNAL( currentChanged ( QWidget * )), this, SLOT( tabChanged ( QWidget * )));
471 479
472 m_style_changed = m_font_changed = m_color_changed = m_deco_changed = false; 480 m_style_changed = m_font_changed = m_color_changed = m_deco_changed = false;
473} 481}
474 482
475Appearance::~Appearance() 483Appearance::~Appearance()
476{ 484{
477} 485}
478 486
479void Appearance::tabChanged ( QWidget *w ) 487void Appearance::tabChanged ( QWidget *w )
480{ 488{
481 if ( w == m_advtab ) { 489 if ( w == m_advtab ) {
482 m_sample-> hide ( ); 490 m_sample-> hide ( );
483 updateGeometry ( ); // shouldn't be necessary ... 491 updateGeometry ( ); // shouldn't be necessary ...
484 } 492 }
485 else 493 else
486 m_sample-> show ( ); 494 m_sample-> show ( );
487} 495}
488 496
489void Appearance::accept ( ) 497void Appearance::accept ( )
490{ 498{
491 bool newtabpos = m_tabstyle_top-> isChecked ( ); 499 bool newtabpos = m_tabstyle_top-> isChecked ( );
492 int newtabstyle = m_tabstyle_list-> currentItem ( ); 500 int newtabstyle = m_tabstyle_list-> currentItem ( );
493 501
494 Config config ( "qpe" ); 502 Config config ( "qpe" );
495 config. setGroup ( "Appearance" ); 503 config. setGroup ( "Appearance" );
496 504
497 if ( m_style_changed ) { 505 if ( m_style_changed ) {
498 StyleListItem *item = (StyleListItem *) m_style_list-> item ( m_style_list-> currentItem ( )); 506 StyleListItem *item = (StyleListItem *) m_style_list-> item ( m_style_list-> currentItem ( ));
499 if ( item ) 507 if ( item )
500 config.writeEntry( "Style", item-> key ( )); 508 config.writeEntry( "Style", item-> key ( ));
501 } 509 }
502 510
503 if ( m_deco_changed ) { 511 if ( m_deco_changed ) {
504 DecoListItem *item = (DecoListItem *) m_deco_list-> item ( m_deco_list-> currentItem ( )); 512 DecoListItem *item = (DecoListItem *) m_deco_list-> item ( m_deco_list-> currentItem ( ));
505 if ( item ) 513 if ( item )
506 config.writeEntry( "Decoration", item-> key ( )); 514 config.writeEntry( "Decoration", item-> key ( ));
507 } 515 }
508 516
509 if (( newtabstyle != m_original_tabstyle ) || ( newtabpos != m_original_tabpos )) { 517 if (( newtabstyle != m_original_tabstyle ) || ( newtabpos != m_original_tabpos )) {
510 config. writeEntry ( "TabStyle", newtabstyle + 1 ); 518 config. writeEntry ( "TabStyle", newtabstyle + 1 );
511 config. writeEntry ( "TabPosition", newtabpos ? "Top" : "Bottom" ); 519 config. writeEntry ( "TabPosition", newtabpos ? "Top" : "Bottom" );
512 } 520 }
513 521
514 if ( m_font_changed ) { 522 if ( m_font_changed ) {
515 config. writeEntry ( "FontFamily", m_fontselect-> fontFamily ( )); 523 config. writeEntry ( "FontFamily", m_fontselect-> fontFamily ( ));
516 config. writeEntry ( "FontStyle", m_fontselect-> fontStyle ( )); 524 config. writeEntry ( "FontStyle", m_fontselect-> fontStyle ( ));
517 config. writeEntry ( "FontSize", m_fontselect-> fontSize ( )); 525 config. writeEntry ( "FontSize", m_fontselect-> fontSize ( ));
518 } 526 }
519 527
520 528
521 if ( m_color_changed ) 529 if ( m_color_changed )
522 { 530 {
523 ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); 531 ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( ));
524 532
525 if ( item ) 533 if ( item )
526 item-> save ( config ); 534 item-> save ( config );
527 } 535 }
528 536
529 bool is_rotdir_ccw = m_rotdir_ccw-> isChecked ( ); 537 ODirection rot;
530 int rotval;
531 if (m_rotdir_ccw-> isChecked ( )) { 538 if (m_rotdir_ccw-> isChecked ( )) {
532 rotval = 1; 539 rot = CCW;
533 } else if (m_rotdir_cw-> isChecked ( )) { 540 } else if (m_rotdir_cw-> isChecked ( )) {
534 rotval = 0; 541 rot = CW;
535 } else { 542 } else {
536 rotval = 2; 543 rot = Flip;
537 } 544 }
538 config. writeEntry ( "rotatedir", rotval ); 545 config. writeEntry ( "rotatedir", (int)rot );
539 546
540 m_except-> setFocus ( ); // if the focus was on the embedded line-edit, we have to move it away first, so the contents are updated 547 m_except-> setFocus ( ); // if the focus was on the embedded line-edit, we have to move it away first, so the contents are updated
541 548
542 QStringList sl; 549 QStringList sl;
543 QString exceptstr; 550 QString exceptstr;
544 for ( ExceptListItem *it = (ExceptListItem *) m_except-> firstChild ( ); it; it = (ExceptListItem *) it-> nextSibling ( )) { 551 for ( ExceptListItem *it = (ExceptListItem *) m_except-> firstChild ( ); it; it = (ExceptListItem *) it-> nextSibling ( )) {
545 int fl = 0; 552 int fl = 0;
546 fl |= ( it-> noStyle ( ) ? 0x01 : 0 ); 553 fl |= ( it-> noStyle ( ) ? 0x01 : 0 );
547 fl |= ( it-> noFont ( ) ? 0x02 : 0 ); 554 fl |= ( it-> noFont ( ) ? 0x02 : 0 );
548 fl |= ( it-> noDeco ( ) ? 0x04 : 0 ); 555 fl |= ( it-> noDeco ( ) ? 0x04 : 0 );
549 exceptstr = QString::number ( fl, 32 ); 556 exceptstr = QString::number ( fl, 32 );
550 exceptstr.append( it-> pattern ( )); 557 exceptstr.append( it-> pattern ( ));
551 sl << exceptstr; 558 sl << exceptstr;
552 } 559 }
553 config. writeEntry ( "NoStyle", sl, ';' ); 560 config. writeEntry ( "NoStyle", sl, ';' );
554 config. writeEntry ( "ForceStyle", m_force-> isChecked ( )); 561 config. writeEntry ( "ForceStyle", m_force-> isChecked ( ));
555 562
556 config. write ( ); // need to flush the config info first 563 config. write ( ); // need to flush the config info first
557 Global::applyStyle ( ); 564 Global::applyStyle ( );
558 565
559 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 ) { 566 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 ) {
560 QCopEnvelope e( "QPE/System", "restart()" ); 567 QCopEnvelope e( "QPE/System", "restart()" );
561 } 568 }
562 569
563 QDialog::accept ( ); 570 QDialog::accept ( );
564} 571}
565 572
566void Appearance::done ( int r ) 573void Appearance::done ( int r )
567{ 574{
568 QDialog::done ( r ); 575 QDialog::done ( r );
569 close ( ); 576 close ( );
570} 577}
571 578
572 579
573void Appearance::styleClicked ( int index ) 580void Appearance::styleClicked ( int index )
574{ 581{
575 StyleListItem *sli = (StyleListItem *) m_style_list-> item ( index ); 582 StyleListItem *sli = (StyleListItem *) m_style_list-> item ( index );
576 m_style_settings-> setEnabled ( sli ? sli-> hasSettings ( ) : false ); 583 m_style_settings-> setEnabled ( sli ? sli-> hasSettings ( ) : false );
577 584
578 if ( m_sample && sli && sli-> style ( )) { 585 if ( m_sample && sli && sli-> style ( )) {
579 int ci = m_color_list ? m_color_list-> currentItem ( ) : -1; 586 int ci = m_color_list ? m_color_list-> currentItem ( ) : -1;
580 587
581 m_sample-> setStyle2 ( sli-> style ( ), ci < 0 ? palette ( ) : ((ColorListItem *) m_color_list-> item ( ci ))-> palette ( )); 588 m_sample-> setStyle2 ( sli-> style ( ), ci < 0 ? palette ( ) : ((ColorListItem *) m_color_list-> item ( ci ))-> palette ( ));
582 } 589 }
583 590
584 m_style_changed |= ( index != m_original_style ); 591 m_style_changed |= ( index != m_original_style );
585} 592}
586 593
587void Appearance::styleSettingsClicked ( ) 594void Appearance::styleSettingsClicked ( )
588{ 595{
589 StyleListItem *item = (StyleListItem *) m_style_list-> item ( m_style_list-> currentItem ( )); 596 StyleListItem *item = (StyleListItem *) m_style_list-> item ( m_style_list-> currentItem ( ));
590 597
591 if ( item && item-> hasSettings ( )) { 598 if ( item && item-> hasSettings ( )) {
592 QDialog *d = new QDialog ( this, "SETTINGS-DLG", true ); 599 QDialog *d = new QDialog ( this, "SETTINGS-DLG", true );
593 QVBoxLayout *vbox = new QVBoxLayout ( d, 3, 0 ); 600 QVBoxLayout *vbox = new QVBoxLayout ( d, 3, 0 );
594 601
595 QWidget *w = item-> settings ( d ); 602 QWidget *w = item-> settings ( d );
596 603
597 if ( w ) { 604 if ( w ) {
598 vbox-> addWidget ( w ); 605 vbox-> addWidget ( w );
599 606
600 d-> setCaption ( w-> caption ( )); 607 d-> setCaption ( w-> caption ( ));
601 608
602 d-> showMaximized ( ); 609 d-> showMaximized ( );
603 bool accepted = ( d-> exec ( ) == QDialog::Accepted ); 610 bool accepted = ( d-> exec ( ) == QDialog::Accepted );
604 611
605 if ( item-> setSettings ( accepted )) 612 if ( item-> setSettings ( accepted ))
606 m_style_changed = true; 613 m_style_changed = true;
607 } 614 }
608 delete d; 615 delete d;
609 } 616 }
610} 617}
611 618
612void Appearance::decoClicked ( int index ) 619void Appearance::decoClicked ( int index )
613{ 620{
614 DecoListItem *dli = (DecoListItem *) m_deco_list-> item ( index ); 621 DecoListItem *dli = (DecoListItem *) m_deco_list-> item ( index );
615 622
616 if ( m_sample ) { 623 if ( m_sample ) {
617 if ( dli && dli-> interface ( )) 624 if ( dli && dli-> interface ( ))
618 m_sample-> setDecoration ( dli-> interface ( )); 625 m_sample-> setDecoration ( dli-> interface ( ));
619 else 626 else
620 m_sample-> setDecoration ( new DefaultWindowDecoration ( )); 627 m_sample-> setDecoration ( new DefaultWindowDecoration ( ));
621 m_sample-> repaint ( ); 628 m_sample-> repaint ( );
622 } 629 }
623 m_deco_changed |= ( index != m_original_deco ); 630 m_deco_changed |= ( index != m_original_deco );
624} 631}
625 632
626void Appearance::fontClicked ( const QFont &f ) 633void Appearance::fontClicked ( const QFont &f )
627{ 634{
628 m_font_changed |= ( f != m_sample-> font ( )); 635 m_font_changed |= ( f != m_sample-> font ( ));
629 m_sample-> setFont ( f ); 636 m_sample-> setFont ( f );
630} 637}
631 638
632void Appearance::colorClicked ( int index ) 639void Appearance::colorClicked ( int index )
633{ 640{
634 ColorListItem *item = (ColorListItem *) m_color_list-> item ( index ); 641 ColorListItem *item = (ColorListItem *) m_color_list-> item ( index );
635 642
636 if ( item ) 643 if ( item )
637 m_sample-> setPalette ( item-> palette ( )); 644 m_sample-> setPalette ( item-> palette ( ));
638 645
639 m_color_changed |= ( item-> palette ( ) != qApp-> palette ( )); 646 m_color_changed |= ( item-> palette ( ) != qApp-> palette ( ));
640} 647}
641 648
642 649
643void Appearance::editSchemeClicked ( ) 650void Appearance::editSchemeClicked ( )
644{ 651{
645 ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); 652 ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( ));
646 653
647 int cnt = 0; 654 int cnt = 0;
648 QString labels [QColorGroup::NColorRoles]; 655 QString labels [QColorGroup::NColorRoles];
649 QColor colors [QColorGroup::NColorRoles]; 656 QColor colors [QColorGroup::NColorRoles];
650 657
651 for ( QColorGroup::ColorRole role = (QColorGroup::ColorRole) 0; role != QColorGroup::NColorRoles; ((int) role )++ ) { 658 for ( QColorGroup::ColorRole role = (QColorGroup::ColorRole) 0; role != QColorGroup::NColorRoles; ((int) role )++ ) {
652 QColor col = item-> color ( role ); 659 QColor col = item-> color ( role );
653 660
654 if ( col. isValid ( )) { 661 if ( col. isValid ( )) {
655 labels [cnt] = item-> label ( role ); 662 labels [cnt] = item-> label ( role );
656 colors [cnt] = col; 663 colors [cnt] = col;
657 664
658 cnt++; 665 cnt++;
659 } 666 }
660 } 667 }
661 668
662 EditScheme* editdlg = new EditScheme( cnt, labels, colors, this, "editScheme", true ); 669 EditScheme* editdlg = new EditScheme( cnt, labels, colors, this, "editScheme", true );
663 editdlg-> showMaximized ( ); 670 editdlg-> showMaximized ( );
664 if ( editdlg-> exec ( ) == QDialog::Accepted ) { 671 if ( editdlg-> exec ( ) == QDialog::Accepted ) {
665 ColorListItem *citem = (ColorListItem *) m_color_list-> item ( 0 ); 672 ColorListItem *citem = (ColorListItem *) m_color_list-> item ( 0 );
666 cnt = 0; 673 cnt = 0;
667 674
668 for ( QColorGroup::ColorRole role = (QColorGroup::ColorRole) 0; role != QColorGroup::NColorRoles; ((int) role )++ ) { 675 for ( QColorGroup::ColorRole role = (QColorGroup::ColorRole) 0; role != QColorGroup::NColorRoles; ((int) role )++ ) {
669 if ( item-> color ( role ). isValid ( )) { 676 if ( item-> color ( role ). isValid ( )) {
670 citem-> setColor ( role, colors [cnt] ); 677 citem-> setColor ( role, colors [cnt] );
671 cnt++; 678 cnt++;
672 } 679 }
673 } 680 }
674 681
675 m_color_list-> setCurrentItem ( 0 ); 682 m_color_list-> setCurrentItem ( 0 );
676 colorClicked ( 0 ); 683 colorClicked ( 0 );
677 684
678 m_color_changed = true; 685 m_color_changed = true;
679 } 686 }
680 delete editdlg; 687 delete editdlg;
681} 688}
682 689
683 690
684void Appearance::saveSchemeClicked() 691void Appearance::saveSchemeClicked()
685{ 692{
686 ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); 693 ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( ));
687 694
688 if ( !item ) 695 if ( !item )
689 return; 696 return;
690 697
691 QDialog *d = new QDialog ( this, 0, true ); 698 QDialog *d = new QDialog ( this, 0, true );
692 d-> setCaption ( tr( "Save Scheme" )); 699 d-> setCaption ( tr( "Save Scheme" ));
693 QLineEdit *ed = new QLineEdit ( d ); 700 QLineEdit *ed = new QLineEdit ( d );
694 ( new QVBoxLayout ( d, 3, 3 ))-> addWidget ( ed ); 701 ( new QVBoxLayout ( d, 3, 3 ))-> addWidget ( ed );
695 ed-> setFocus ( ); 702 ed-> setFocus ( );
696 703
697 if ( d-> exec ( ) == QDialog::Accepted ) { 704 if ( d-> exec ( ) == QDialog::Accepted ) {
698 QString schemename = ed-> text ( ); 705 QString schemename = ed-> text ( );
699 QString filestr = QPEApplication::qpeDir(); 706 QString filestr = QPEApplication::qpeDir();
700 filestr.append( "/etc/colors/" ); 707 filestr.append( "/etc/colors/" );
701 filestr.append( schemename ); 708 filestr.append( schemename );
702 filestr.append( ".scheme" ); 709 filestr.append( ".scheme" );
703 QFile file ( filestr ); 710 QFile file ( filestr );
704 if ( !file. exists ( )) 711 if ( !file. exists ( ))
705 { 712 {
706 QPalette p = item-> palette ( ); 713 QPalette p = item-> palette ( );
707 714
708 Config config ( file.name(), Config::File ); 715 Config config ( file.name(), Config::File );
709 config. setGroup( "Colors" ); 716 config. setGroup( "Colors" );
710 717
711 item-> save ( config ); 718 item-> save ( config );
712 719
713 config. write ( ); // need to flush the config info first 720 config. write ( ); // need to flush the config info first
714 721
715 m_color_list-> insertItem ( new ColorListItem ( schemename, config )); 722 m_color_list-> insertItem ( new ColorListItem ( schemename, config ));
716 } 723 }
717 else 724 else
718 { 725 {
719 QMessageBox::information ( this, tr( "Save scheme" ), tr( "Scheme does already exist." )); 726 QMessageBox::information ( this, tr( "Save scheme" ), tr( "Scheme does already exist." ));
720 } 727 }
721 } 728 }
722 delete d; 729 delete d;
723} 730}
724 731
725void Appearance::deleteSchemeClicked() 732void Appearance::deleteSchemeClicked()
726{ 733{
727 ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( )); 734 ColorListItem *item = (ColorListItem *) m_color_list-> item ( m_color_list-> currentItem ( ));
728 735
729 if ( !item ) 736 if ( !item )
730 return; 737 return;
731 738
732 if ( m_color_list-> currentItem ( ) > 0 ) 739 if ( m_color_list-> currentItem ( ) > 0 )
733 { 740 {
734 if ( QPEMessageBox::confirmDelete ( this, tr( "Delete scheme" ), item-> text ( ) ) ) 741 if ( QPEMessageBox::confirmDelete ( this, tr( "Delete scheme" ), item-> text ( ) ) )
735 { 742 {
736 QString filestr = QPEApplication::qpeDir ( ); 743 QString filestr = QPEApplication::qpeDir ( );
737 filestr.append( "/etc/colors/" ); 744 filestr.append( "/etc/colors/" );
738 filestr.append( item-> text ( ) ); 745 filestr.append( item-> text ( ) );
739 filestr.append( ".scheme" ); 746 filestr.append( ".scheme" );
740 QFile::remove ( filestr ); 747 QFile::remove ( filestr );
741 delete item; 748 delete item;
742 } 749 }
743 } 750 }
744 else 751 else
745 { 752 {
746 QMessageBox::information( this, tr( "Delete scheme" ), tr( "Unable to delete current scheme." )); 753 QMessageBox::information( this, tr( "Delete scheme" ), tr( "Unable to delete current scheme." ));
747 } 754 }
748} 755}
749 756
750 757
751void Appearance::addExcept ( ) 758void Appearance::addExcept ( )
752{ 759{
753 ExceptListItem *it = new ExceptListItem ( m_except, 0, tr( "<new>" ), true, true, true ); 760 ExceptListItem *it = new ExceptListItem ( m_except, 0, tr( "<new>" ), true, true, true );
754 m_except-> ensureItemVisible ( it ); 761 m_except-> ensureItemVisible ( it );
755 m_except-> setSelected ( it, true ); 762 m_except-> setSelected ( it, true );
756} 763}
757 764
758void Appearance::delExcept ( ) 765void Appearance::delExcept ( )
759{ 766{
760 if ( m_except-> selectedItem ( )) { 767 if ( m_except-> selectedItem ( )) {
761 m_except-> setFocus ( ); 768 m_except-> setFocus ( );
762 delete m_except-> selectedItem ( ); 769 delete m_except-> selectedItem ( );
763 } 770 }
764} 771}
765 772
766void Appearance::upExcept ( ) 773void Appearance::upExcept ( )
767{ 774{
768 ExceptListItem *it = (ExceptListItem *) m_except-> selectedItem ( ); 775 ExceptListItem *it = (ExceptListItem *) m_except-> selectedItem ( );
769 776
770 if ( it && it-> itemAbove ( )) 777 if ( it && it-> itemAbove ( ))
771 it-> itemAbove ( )-> moveItem ( it ); 778 it-> itemAbove ( )-> moveItem ( it );
772} 779}
773 780
774void Appearance::downExcept ( ) 781void Appearance::downExcept ( )
775{ 782{
776 ExceptListItem *it = (ExceptListItem *) m_except-> selectedItem ( ); 783 ExceptListItem *it = (ExceptListItem *) m_except-> selectedItem ( );
777 784
778 if ( it && it-> itemBelow ( )) 785 if ( it && it-> itemBelow ( ))
779 it-> moveItem ( it-> itemBelow ( )); 786 it-> moveItem ( it-> itemBelow ( ));
780} 787}
781 788
782class ExEdit : public QLineEdit { 789class ExEdit : public QLineEdit {
783public: 790public:
784 ExEdit ( ExceptListItem *item ) 791 ExEdit ( ExceptListItem *item )
785 : QLineEdit ( item-> listView ( )-> viewport ( ), "exedit" ), it ( item ) 792 : QLineEdit ( item-> listView ( )-> viewport ( ), "exedit" ), it ( item )
786 { 793 {
787 setFrame ( false ); 794 setFrame ( false );
788 795
789 QRect r = it-> listView ( )-> itemRect ( it ); 796 QRect r = it-> listView ( )-> itemRect ( it );
790 797
791 int x = it-> listView ( )-> header ( )-> cellPos ( 3 ) - 1; 798 int x = it-> listView ( )-> header ( )-> cellPos ( 3 ) - 1;
792 int y = r. y ( ); 799 int y = r. y ( );
793 int w = it-> listView ( )-> viewport ( )-> width ( ) - x; 800 int w = it-> listView ( )-> viewport ( )-> width ( ) - x;
794 int h = r. height ( ); // + 2; 801 int h = r. height ( ); // + 2;
795 802
796 setText ( it-> pattern ( )); 803 setText ( it-> pattern ( ));
797 setGeometry ( x, y, w, h ); 804 setGeometry ( x, y, w, h );
798 805
799 qDebug ( "ExEdit: [%s] at %d,%d %d,%d", it->text(2).latin1(),x,y,w,h); 806 qDebug ( "ExEdit: [%s] at %d,%d %d,%d", it->text(2).latin1(),x,y,w,h);
800 807
801 m_out = true; 808 m_out = true;
802 809
803 show ( ); 810 show ( );
804 setFocus ( ); 811 setFocus ( );
805 selectAll ( ); 812 selectAll ( );
806 end ( true ); 813 end ( true );
807 } 814 }
808 815
809 virtual void focusOutEvent ( QFocusEvent * ) 816 virtual void focusOutEvent ( QFocusEvent * )
810 { 817 {
811 hide ( ); 818 hide ( );
812 if ( m_out ) 819 if ( m_out )
813 it-> setPattern ( text ( )); 820 it-> setPattern ( text ( ));
814 delete this; 821 delete this;
815 } 822 }
816 823
817 virtual void keyPressEvent ( QKeyEvent *e ) 824 virtual void keyPressEvent ( QKeyEvent *e )
818 { 825 {
819 if ( e-> key ( ) == Key_Return ) 826 if ( e-> key ( ) == Key_Return )
820 it-> listView ( )-> setFocus ( ); 827 it-> listView ( )-> setFocus ( );
821 else if ( e-> key ( ) == Key_Escape ) { 828 else if ( e-> key ( ) == Key_Escape ) {
822 m_out = false; 829 m_out = false;
823 it-> listView ( )-> setFocus ( ); 830 it-> listView ( )-> setFocus ( );
824 } 831 }
825 else 832 else
826 QLineEdit::keyPressEvent ( e ); 833 QLineEdit::keyPressEvent ( e );
827 } 834 }
828 835
829private: 836private:
830 ExceptListItem *it; 837 ExceptListItem *it;
831 bool m_out; 838 bool m_out;
832}; 839};
833 840
834void Appearance::clickedExcept ( QListViewItem *item, const QPoint &, int c ) 841void Appearance::clickedExcept ( QListViewItem *item, const QPoint &, int c )
835{ 842{
836 if ( !item || c < 0 || c > 3 ) 843 if ( !item || c < 0 || c > 3 )
837 return; 844 return;
838 845
839 ExceptListItem *it = (ExceptListItem *) item; 846 ExceptListItem *it = (ExceptListItem *) item;
840 847
841 if ( c == 0 ) 848 if ( c == 0 )
842 it-> setNoStyle ( !it-> noStyle ( )); 849 it-> setNoStyle ( !it-> noStyle ( ));
843 else if ( c == 1 ) 850 else if ( c == 1 )
844 it-> setNoFont ( !it-> noFont ( )); 851 it-> setNoFont ( !it-> noFont ( ));
845 else if ( c == 2 ) 852 else if ( c == 2 )
846 it-> setNoDeco ( !it-> noDeco ( )); 853 it-> setNoDeco ( !it-> noDeco ( ));
847 else if ( c == 3 ) { 854 else if ( c == 3 ) {
848 m_except-> ensureItemVisible ( it ); 855 m_except-> ensureItemVisible ( it );
849 new ExEdit ( it ); 856 new ExEdit ( it );
850 } 857 }
851} 858}
852 859