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