summaryrefslogtreecommitdiff
authorsandman <sandman>2002-07-06 16:42:29 (UTC)
committer sandman <sandman>2002-07-06 16:42:29 (UTC)
commit3a422983abc7342c9229dccac825d0608fca10f3 (patch) (unidiff)
treefd0d71eab4df0b286b78efe24184525ae4c819a3
parent8beb5fcdbca8110dc586a7e620bf8eae892087fb (diff)
downloadopie-3a422983abc7342c9229dccac825d0608fca10f3.zip
opie-3a422983abc7342c9229dccac825d0608fca10f3.tar.gz
opie-3a422983abc7342c9229dccac825d0608fca10f3.tar.bz2
Complete renovation of the external style API:
- created two QCom interfaces in "styleinterface.h" - moved the liquid/theme settings apps into the plugins - modified the plugin interface for all three styles - extended appearance to fully support the new API (replaces the settings apps) Additional work: - made a workaround in appearance for a Qt Bug -- now a QDialog again (this should really be fixed in Qt, but Z won't work that way)
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--Makefile4
-rw-r--r--apps/Settings/Liquid.desktop7
-rw-r--r--apps/Settings/Theme.desktop7
-rw-r--r--library/qpeapplication.cpp2294
-rw-r--r--library/styleinterface.h68
-rw-r--r--noncore/styles/liquid/liquid.pro6
-rw-r--r--noncore/styles/liquid/liquidset.cpp (renamed from noncore/styles/liquid/settings/liquidset.cpp)26
-rw-r--r--noncore/styles/liquid/liquidset.h (renamed from noncore/styles/liquid/settings/liquidset.h)7
-rw-r--r--noncore/styles/liquid/opie-liquid.control2
-rw-r--r--noncore/styles/liquid/plugin.cpp108
-rw-r--r--noncore/styles/liquid/plugin.h46
-rw-r--r--noncore/styles/liquid/settings/.cvsignore2
-rw-r--r--noncore/styles/liquid/settings/main.cpp34
-rw-r--r--noncore/styles/liquid/settings/settings.pro24
-rw-r--r--noncore/styles/metal/metal.pro2
-rw-r--r--noncore/styles/metal/plugin.cpp54
-rw-r--r--noncore/styles/metal/plugin.h27
-rw-r--r--noncore/styles/theme/opie-theme.control2
-rw-r--r--noncore/styles/theme/plugin.cpp118
-rw-r--r--noncore/styles/theme/plugin.h46
-rw-r--r--noncore/styles/theme/settings/main.cpp34
-rw-r--r--noncore/styles/theme/settings/settings.pro24
-rw-r--r--noncore/styles/theme/settings/themeset.h20
-rw-r--r--noncore/styles/theme/theme.pro5
-rw-r--r--noncore/styles/theme/themeset.cpp (renamed from noncore/styles/theme/settings/themeset.cpp)11
-rw-r--r--noncore/styles/theme/themeset.h20
-rw-r--r--pics/liquid/Liquid.pngbin2771 -> 0 bytes
-rw-r--r--pics/theme/Theme.pngbin2771 -> 0 bytes
28 files changed, 1697 insertions, 1301 deletions
diff --git a/Makefile b/Makefile
index 0dfa22e..8fa60d8 100644
--- a/Makefile
+++ b/Makefile
@@ -51,7 +51,5 @@ NONCORETOOLS = noncore/tools/calculator noncore/tools/clock \
51 noncore/tools/remote noncore/tools/opie-sh noncore/apps/advancedfm 51 noncore/tools/remote noncore/tools/opie-sh noncore/apps/advancedfm
52 52
53NONCORESTYLES = noncore/styles/liquid noncore/styles/liquid/settings \ 53NONCORESTYLES = noncore/styles/liquid noncore/styles/theme noncore/styles/metal
54 noncore/styles/theme noncore/styles/theme/settings \
55 noncore/styles/metal
56 54
57GAMES = noncore/games/minesweep noncore/games/solitaire \ 55GAMES = noncore/games/minesweep noncore/games/solitaire \
diff --git a/apps/Settings/Liquid.desktop b/apps/Settings/Liquid.desktop
deleted file mode 100644
index 8a1727f..0000000
--- a/apps/Settings/Liquid.desktop
+++ b/dev/null
@@ -1,7 +0,0 @@
1[Desktop Entry]
2Type=Application
3Exec=liquid-settings
4Icon=liquid/Liquid
5Name=Liquid-Settings
6Name[de]=Liquid-Einstellungen
7
diff --git a/apps/Settings/Theme.desktop b/apps/Settings/Theme.desktop
deleted file mode 100644
index 197184f..0000000
--- a/apps/Settings/Theme.desktop
+++ b/dev/null
@@ -1,7 +0,0 @@
1[Desktop Entry]
2Type=Application
3Exec=theme-settings
4Icon=theme/Theme
5Name=Theme-Settings
6Name[de]=Thema-Einstellungen
7
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp
index dff8235..187a7e2 100644
--- a/library/qpeapplication.cpp
+++ b/library/qpeapplication.cpp
@@ -59,5 +59,5 @@
59#define VESA_POWERDOWN 3 59#define VESA_POWERDOWN 3
60 60
61#define FBIOBLANK 0x4611 61#define FBIOBLANK 0x4611
62 62
63 63
@@ -65,4 +65,5 @@
65#include "qpeapplication.h" 65#include "qpeapplication.h"
66#include "qpestyle.h" 66#include "qpestyle.h"
67#include "styleinterface.h"
67#if QT_VERSION >= 300 68#if QT_VERSION >= 300
68#include <qstylefactory.h> 69#include <qstylefactory.h>
@@ -75,5 +76,4 @@
75 76
76#include <qpe/qlibrary.h> 77#include <qpe/qlibrary.h>
77#include <dlfcn.h>
78#endif 78#endif
79#include "global.h" 79#include "global.h"
@@ -106,120 +106,127 @@
106 106
107 107
108class QPEApplicationData { 108class QPEApplicationData
109{
109public: 110public:
110 QPEApplicationData() : presstimer(0), presswidget(0), rightpressed(FALSE), 111 QPEApplicationData() : presstimer( 0 ), presswidget( 0 ), rightpressed( FALSE ),
111 kbgrabber(0), kbregrab(FALSE), notbusysent(FALSE), preloaded(FALSE), 112 kbgrabber( 0 ), kbregrab( FALSE ), notbusysent( FALSE ), preloaded( FALSE ),
112 forceshow(FALSE), nomaximize(FALSE), qpe_main_widget(0), 113 forceshow( FALSE ), nomaximize( FALSE ), qpe_main_widget( 0 ),
113 keep_running(TRUE) 114 keep_running( TRUE )
114 { 115 {
115 qcopq.setAutoDelete(TRUE); 116 qcopq.setAutoDelete( TRUE );
116 } 117 }
117 118
118 int presstimer; 119 int presstimer;
119 QWidget* presswidget; 120 QWidget* presswidget;
120 QPoint presspos; 121 QPoint presspos;
121 bool rightpressed; 122 bool rightpressed;
122 int kbgrabber; 123 int kbgrabber;
123 bool kbregrab; 124 bool kbregrab;
124 bool notbusysent; 125 bool notbusysent;
125 QString appName; 126 QString appName;
126 struct QCopRec { 127 struct QCopRec
127 QCopRec(const QCString &ch, const QCString &msg, 128 {
128 const QByteArray &d) : 129 QCopRec( const QCString &ch, const QCString &msg,
129 channel(ch), message(msg), data(d) { } 130 const QByteArray &d ) :
130 131 channel( ch ), message( msg ), data( d )
131 QCString channel; 132 { }
132 QCString message; 133
133 QByteArray data; 134 QCString channel;
134 }; 135 QCString message;
135 bool preloaded; 136 QByteArray data;
136 bool forceshow; 137 };
137 bool nomaximize; 138 bool preloaded;
138 QWidget* qpe_main_widget; 139 bool forceshow;
139 bool keep_running; 140 bool nomaximize;
140 QList<QCopRec> qcopq; 141 QWidget* qpe_main_widget;
141 142 bool keep_running;
142 void enqueueQCop(const QCString &ch, const QCString &msg, 143 QList<QCopRec> qcopq;
143 const QByteArray &data) 144
144 { 145 void enqueueQCop( const QCString &ch, const QCString &msg,
145 qcopq.append(new QCopRec(ch,msg,data)); 146 const QByteArray &data )
146 } 147 {
147 void sendQCopQ() 148 qcopq.append( new QCopRec( ch, msg, data ) );
148 { 149 }
149 QCopRec* r; 150 void sendQCopQ()
150 for (QListIterator<QCopRec> it(qcopq); (r=it.current()); ++it) 151 {
151 QCopChannel::sendLocally(r->channel,r->message,r->data); 152 QCopRec * r;
152 qcopq.clear(); 153 for ( QListIterator<QCopRec> it( qcopq ); ( r = it.current() ); ++it )
153 } 154 QCopChannel::sendLocally( r->channel, r->message, r->data );
155 qcopq.clear();
156 }
154}; 157};
155 158
156class ResourceMimeFactory : public QMimeSourceFactory { 159class ResourceMimeFactory : public QMimeSourceFactory
160{
157public: 161public:
158 ResourceMimeFactory() 162 ResourceMimeFactory()
159 { 163 {
160 setFilePath( Global::helpPath() ); 164 setFilePath( Global::helpPath() );
161 setExtensionType("html","text/html;charset=UTF-8"); 165 setExtensionType( "html", "text/html;charset=UTF-8" );
162 } 166 }
163 167
164 const QMimeSource* data(const QString& abs_name) const 168 const QMimeSource* data( const QString& abs_name ) const
165 { 169 {
166 const QMimeSource* r = QMimeSourceFactory::data(abs_name); 170 const QMimeSource * r = QMimeSourceFactory::data( abs_name );
167 if ( !r ) { 171 if ( !r ) {
168 int sl = abs_name.length(); 172 int sl = abs_name.length();
169 do { 173 do {
170 sl = abs_name.findRev('/',sl-1); 174 sl = abs_name.findRev( '/', sl - 1 );
171 QString name = sl>=0 ? abs_name.mid(sl+1) : abs_name; 175 QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name;
172 int dot = name.findRev('.'); 176 int dot = name.findRev( '.' );
173 if ( dot >= 0 ) 177 if ( dot >= 0 )
174 name = name.left(dot); 178 name = name.left( dot );
175 QImage img = Resource::loadImage(name); 179 QImage img = Resource::loadImage( name );
176 if ( !img.isNull() ) 180 if ( !img.isNull() )
177 r = new QImageDrag(img); 181 r = new QImageDrag( img );
178 } while (!r && sl>0); 182 }
179 } 183 while ( !r && sl > 0 );
180 return r; 184 }
181 } 185 return r;
186 }
182}; 187};
183 188
184static int muted=0; 189static int muted = 0;
185static int micMuted=0; 190static int micMuted = 0;
186 191
187static void setVolume(int t=0, int percent=-1) 192static void setVolume( int t = 0, int percent = -1 )
188{ 193{
189 switch (t) { 194 switch ( t ) {
190 case 0: { 195 case 0: {
191 Config cfg("qpe"); 196 Config cfg( "qpe" );
192 cfg.setGroup("Volume"); 197 cfg.setGroup( "Volume" );
193 if ( percent < 0 ) 198 if ( percent < 0 )
194 percent = cfg.readNumEntry("VolumePercent",50); 199 percent = cfg.readNumEntry( "VolumePercent", 50 );
195 int fd = 0; 200 int fd = 0;
196 if ((fd = open("/dev/mixer", O_RDWR))>=0) { 201 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
197 int vol = muted ? 0 : percent; 202 int vol = muted ? 0 : percent;
198 // set both channels to same volume 203 // set both channels to same volume
199 vol |= vol << 8; 204 vol |= vol << 8;
200 ioctl(fd, MIXER_WRITE(0), &vol); 205 ioctl( fd, MIXER_WRITE( 0 ), &vol );
201 ::close(fd); 206 ::close( fd );
202 } 207 }
203 } break; 208 }
204 } 209 break;
210 }
205} 211}
206 212
207static void setMic(int t=0, int percent=-1) 213static void setMic( int t = 0, int percent = -1 )
208{ 214{
209 switch (t) { 215 switch ( t ) {
210 case 0: { 216 case 0: {
211 Config cfg("qpe"); 217 Config cfg( "qpe" );
212 cfg.setGroup("Volume"); 218 cfg.setGroup( "Volume" );
213 if ( percent < 0 ) 219 if ( percent < 0 )
214 percent = cfg.readNumEntry("Mic",50); 220 percent = cfg.readNumEntry( "Mic", 50 );
215 221
216 int fd = 0; 222 int fd = 0;
217 int mic = micMuted ? 0 : percent; 223 int mic = micMuted ? 0 : percent;
218 if ((fd = open("/dev/mixer", O_RDWR))>=0) { 224 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
219 ioctl(fd, MIXER_WRITE(SOUND_MIXER_MIC), &mic); 225 ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic );
220 ::close(fd); 226 ::close( fd );
221 } 227 }
222 } break; 228 }
223 } 229 break;
230 }
224} 231}
225 232
@@ -227,82 +234,92 @@ int qpe_sysBrightnessSteps()
227{ 234{
228#if defined(QT_QWS_IPAQ) 235#if defined(QT_QWS_IPAQ)
229 return 255; 236 return 255;
230#elif defined(QT_QWS_EBX) 237#elif defined(QT_QWS_EBX)
231 return 4; 238
239 return 4;
232#else 240#else
233 return 255; // ? 241
242 return 255; // ?
234#endif 243#endif
235} 244}
236 245
237 246
238static int& hack(int& i) 247static int& hack( int& i )
239{ 248{
240#if QT_VERSION <= 230 && defined(QT_NO_CODECS) 249#if QT_VERSION <= 230 && defined(QT_NO_CODECS)
241 // These should be created, but aren't in Qt 2.3.0 250 // These should be created, but aren't in Qt 2.3.0
242 (void)new QUtf8Codec; 251 ( void ) new QUtf8Codec;
243 (void)new QUtf16Codec; 252 ( void ) new QUtf16Codec;
244#endif 253#endif
245 return i; 254
255 return i;
246} 256}
247 257
248static bool forced_off = FALSE; 258static bool forced_off = FALSE;
249static int curbl=-1; 259static int curbl = -1;
250 260
251static int backlight() 261static int backlight()
252{ 262{
253 if ( curbl == -1 ) { 263 if ( curbl == -1 ) {
254 // Read from config 264 // Read from config
255 Config config( "qpe" ); 265 Config config( "qpe" );
256 config.setGroup( "Screensaver" ); 266 config.setGroup( "Screensaver" );
257 curbl = config.readNumEntry("Brightness",255); 267 curbl = config.readNumEntry( "Brightness", 255 );
258 } 268 }
259 return curbl; 269 return curbl;
260} 270}
261 271
262static void setBacklight(int bright) 272static void setBacklight( int bright )
263{ 273{
264 if ( bright == -3 ) { 274 if ( bright == -3 ) {
265 // Forced on 275 // Forced on
266 forced_off = FALSE; 276 forced_off = FALSE;
267 bright = -1; 277 bright = -1;
268 } 278 }
269 if ( forced_off && bright != -2 ) 279 if ( forced_off && bright != -2 )
270 return; 280 return ;
271 if ( bright == -2 ) { 281 if ( bright == -2 ) {
272 // Toggle between off and on 282 // Toggle between off and on
273 bright = curbl ? 0 : -1; 283 bright = curbl ? 0 : -1;
274 forced_off = !bright; 284 forced_off = !bright;
275 } 285 }
276 if ( bright == -1 ) { 286 if ( bright == -1 ) {
277 // Read from config 287 // Read from config
278 Config config( "qpe" ); 288 Config config( "qpe" );
279 config.setGroup( "Screensaver" ); 289 config.setGroup( "Screensaver" );
280 bright = config.readNumEntry("Brightness",255); 290 bright = config.readNumEntry( "Brightness", 255 );
281 } 291 }
282#if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) 292#if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX)
283 if ( QFile::exists("/usr/bin/bl") ) { 293 if ( QFile::exists( "/usr/bin/bl" ) ) {
284 QString cmd = "/usr/bin/bl 1 "; 294 QString cmd = "/usr/bin/bl 1 ";
285 cmd += bright<=0 ? "0 " : "1 "; 295 cmd += bright <= 0 ? "0 " : "1 ";
286 cmd += QString::number(bright); 296 cmd += QString::number( bright );
287 system(cmd.latin1()); 297 system( cmd.latin1() );
288#if defined(QT_QWS_EBX) 298#if defined(QT_QWS_EBX)
289 } else if ( QFile::exists("/dev/fl") ) { 299
300 }
301 else if ( QFile::exists( "/dev/fl" ) ) {
290#define FL_IOCTL_STEP_CONTRAST 100 302#define FL_IOCTL_STEP_CONTRAST 100
291 int fd = open("/dev/fl", O_WRONLY); 303 int fd = open( "/dev/fl", O_WRONLY );
292 if (fd >= 0 ) { 304 if ( fd >= 0 ) {
293 int steps = qpe_sysBrightnessSteps(); 305 int steps = qpe_sysBrightnessSteps();
294 int bl = ( bright * steps + 127 ) / 255; 306 int bl = ( bright * steps + 127 ) / 255;
295 if ( bright && !bl ) bl = 1; 307 if ( bright && !bl )
296 bl = ioctl(fd, FL_IOCTL_STEP_CONTRAST, bl); 308 bl = 1;
297 close(fd); 309 bl = ioctl( fd, FL_IOCTL_STEP_CONTRAST, bl );
298 } 310 close( fd );
299 } 311 }
312 }
300#elif defined(QT_QWS_IPAQ) 313#elif defined(QT_QWS_IPAQ)
301 } else if ( QFile::exists("/dev/ts") || QFile::exists("/dev/h3600_ts") ) { 314
302 typedef struct { 315 }
303 unsigned char mode; 316 else if ( QFile::exists( "/dev/ts" ) || QFile::exists( "/dev/h3600_ts" ) )
304 unsigned char pwr; 317 {
305 unsigned char brightness; 318 typedef struct {
306 } FLITE_IN; 319 unsigned char mode;
320 unsigned char pwr;
321 unsigned char brightness;
322 }
323 FLITE_IN;
307# ifndef FLITE_ON 324# ifndef FLITE_ON
308# ifndef _LINUX_IOCTL_H 325# ifndef _LINUX_IOCTL_H
@@ -311,24 +328,27 @@ static void setBacklight(int bright)
311# define FLITE_ON _IOW('f', 7, FLITE_IN) 328# define FLITE_ON _IOW('f', 7, FLITE_IN)
312# endif 329# endif
313 int fd; 330
314 if ( QFile::exists("/dev/ts") ) 331 int fd;
315 fd = open("/dev/ts", O_WRONLY); 332 if ( QFile::exists( "/dev/ts" ) )
316 else 333 fd = open( "/dev/ts", O_WRONLY );
317 fd = open("/dev/h3600_ts", O_WRONLY); 334 else
318 if (fd >= 0 ) { 335 fd = open( "/dev/h3600_ts", O_WRONLY );
319 FLITE_IN bl; 336 if ( fd >= 0 ) {
320 bl.mode = 1; 337 FLITE_IN bl;
321 bl.pwr = bright ? 1 : 0; 338 bl.mode = 1;
322 bl.brightness = bright; 339 bl.pwr = bright ? 1 : 0;
323 ioctl(fd, FLITE_ON, &bl); 340 bl.brightness = bright;
324 close(fd); 341 ioctl( fd, FLITE_ON, &bl );
325 } 342 close( fd );
326 } 343 }
344 }
327#endif 345#endif
328#endif 346#endif
329 curbl = bright; 347 curbl = bright;
330} 348}
331 349
332void qpe_setBacklight(int bright) { setBacklight(bright); } 350void qpe_setBacklight( int bright ) {
351 setBacklight( bright );
352}
333 353
334static bool dim_on = FALSE; 354static bool dim_on = FALSE;
@@ -338,10 +358,10 @@ static int disable_suspend = 100;
338static bool powerOnline() 358static bool powerOnline()
339{ 359{
340 return PowerStatusManager::readStatus().acStatus() == PowerStatus::Online; 360 return PowerStatusManager::readStatus().acStatus() == PowerStatus::Online;
341} 361}
342 362
343static bool networkOnline() 363static bool networkOnline()
344{ 364{
345 return Network::networkOnline(); 365 return Network::networkOnline();
346} 366}
347 367
@@ -349,105 +369,116 @@ class QPEScreenSaver : public QWSScreenSaver
349{ 369{
350private: 370private:
351 int LcdOn; 371 int LcdOn;
352 372
353public: 373public:
354 QPEScreenSaver() 374 QPEScreenSaver()
355 { 375 {
356 int fd; 376 int fd;
357 377
358 LcdOn = TRUE; 378 LcdOn = TRUE;
359 // Make sure the LCD is in fact on, (if opie was killed while the LCD is off it would still be off) 379 // Make sure the LCD is in fact on, (if opie was killed while the LCD is off it would still be off)
360 fd=open("/dev/fb0",O_RDWR); 380 fd = open( "/dev/fb0", O_RDWR );
361 if (fd != -1) { ioctl(fd,FBIOBLANK,VESA_NO_BLANKING); close(fd); } 381 if ( fd != -1 ) {
362 } 382 ioctl( fd, FBIOBLANK, VESA_NO_BLANKING );
363 void restore() 383 close( fd );
364 { 384 }
365 if (!LcdOn) // We must have turned it off 385 }
366 { 386 void restore()
367 int fd; 387 {
368 fd=open("/dev/fb0",O_RDWR); 388 if ( !LcdOn ) // We must have turned it off
369 if (fd != -1) { ioctl(fd,FBIOBLANK,VESA_NO_BLANKING); close(fd); } 389 {
370 } 390 int fd;
371 setBacklight(-1); 391 fd = open( "/dev/fb0", O_RDWR );
372 } 392 if ( fd != -1 )
373 bool save(int level) 393 {
374 { 394 ioctl( fd, FBIOBLANK, VESA_NO_BLANKING );
375 int fd; 395 close( fd );
376 396 }
377 switch ( level ) { 397 }
378 case 0: 398 setBacklight( -1 );
379 if ( disable_suspend > 0 && dim_on ) { 399 }
380 if (backlight() > 1) 400 bool save( int level )
381 setBacklight(1); // lowest non-off 401 {
382 } 402 int fd;
383 return TRUE; 403
384 break; 404 switch ( level ) {
385 case 1: 405 case 0:
386 if ( disable_suspend > 1 && lightoff_on ) { 406 if ( disable_suspend > 0 && dim_on ) {
387 setBacklight(0); // off 407 if ( backlight() > 1 )
388 } 408 setBacklight( 1 ); // lowest non-off
389 return TRUE; 409 }
390 break; 410 return TRUE;
391 case 2: 411 break;
392 Config config( "qpe" ); 412 case 1:
393 config.setGroup( "Screensaver" ); 413 if ( disable_suspend > 1 && lightoff_on ) {
394 if (config.readNumEntry("LcdOffOnly",0) != 0) // We're only turning off the LCD 414 setBacklight( 0 ); // off
395 { 415 }
396 fd=open("/dev/fb0",O_RDWR); 416 return TRUE;
397 if (fd != -1) { ioctl(fd,FBIOBLANK,VESA_POWERDOWN); close(fd); } 417 break;
398 LcdOn = FALSE; 418 case 2:
399 } 419 Config config( "qpe" );
400 else // We're going to suspend the whole machine 420 config.setGroup( "Screensaver" );
401 { 421 if ( config.readNumEntry( "LcdOffOnly", 0 ) != 0 ) // We're only turning off the LCD
402 if ( disable_suspend > 2 && !powerOnline() && !networkOnline() ) { 422 {
403 QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE ); 423 fd = open( "/dev/fb0", O_RDWR );
404 return TRUE; 424 if ( fd != -1 )
405 } 425 {
406 } 426 ioctl( fd, FBIOBLANK, VESA_POWERDOWN );
407 break; 427 close( fd );
408 } 428 }
409 return FALSE; 429 LcdOn = FALSE;
410 } 430 }
431 else // We're going to suspend the whole machine
432 {
433 if ( disable_suspend > 2 && !powerOnline() && !networkOnline() ) {
434 QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE );
435 return TRUE;
436 }
437 }
438 break;
439 }
440 return FALSE;
441 }
411}; 442};
412 443
413static int ssi(int interval, Config &config, const QString &enable, const QString& value, int def) 444static int ssi( int interval, Config & config, const QString & enable, const QString & value, int def )
414{ 445{
415 if ( !enable.isEmpty() && config.readNumEntry(enable,0) == 0 ) 446 if ( !enable.isEmpty() && config.readNumEntry( enable, 0 ) == 0 )
416 return 0; 447 return 0;
417 448
418 if ( interval < 0 ) { 449 if ( interval < 0 ) {
419 // Restore screen blanking and power saving state 450 // Restore screen blanking and power saving state
420 interval = config.readNumEntry( value, def ); 451 interval = config.readNumEntry( value, def );
421 } 452 }
422 return interval; 453 return interval;
423} 454}
424 455
425static void setScreenSaverIntervals(int i1, int i2, int i3) 456static void setScreenSaverIntervals( int i1, int i2, int i3 )
426{ 457{
427 Config config( "qpe" ); 458 Config config( "qpe" );
428 config.setGroup( "Screensaver" ); 459 config.setGroup( "Screensaver" );
429 460
430 int v[4]; 461 int v[ 4 ];
431 i1 = ssi(i1, config, "Dim","Interval_Dim", 30); 462 i1 = ssi( i1, config, "Dim", "Interval_Dim", 30 );
432 i2 = ssi(i2, config, "LightOff","Interval_LightOff", 20); 463 i2 = ssi( i2, config, "LightOff", "Interval_LightOff", 20 );
433 i3 = ssi(i3, config, "","Interval", 60); 464 i3 = ssi( i3, config, "", "Interval", 60 );
434 465
435 //qDebug("screen saver intervals: %d %d %d", i1, i2, i3); 466 //qDebug("screen saver intervals: %d %d %d", i1, i2, i3);
436 467
437 v[0] = QMAX( 1000*i1, 100); 468 v[ 0 ] = QMAX( 1000 * i1, 100 );
438 v[1] = QMAX( 1000*i2, 100); 469 v[ 1 ] = QMAX( 1000 * i2, 100 );
439 v[2] = QMAX( 1000*i3, 100); 470 v[ 2 ] = QMAX( 1000 * i3, 100 );
440 v[3] = 0; 471 v[ 3 ] = 0;
441 dim_on = ( (i1 != 0) ? config.readNumEntry("Dim",1) : FALSE ); 472 dim_on = ( ( i1 != 0 ) ? config.readNumEntry( "Dim", 1 ) : FALSE );
442 lightoff_on = ( (i2 != 0 ) ? config.readNumEntry("LightOff",1) : FALSE ); 473 lightoff_on = ( ( i2 != 0 ) ? config.readNumEntry( "LightOff", 1 ) : FALSE );
443 if ( !i1 && !i2 && !i3 ) 474 if ( !i1 && !i2 && !i3 )
444 QWSServer::setScreenSaverInterval(0); 475 QWSServer::setScreenSaverInterval( 0 );
445 else 476 else
446 QWSServer::setScreenSaverIntervals(v); 477 QWSServer::setScreenSaverIntervals( v );
447} 478}
448 479
449static void setScreenSaverInterval(int interval) 480static void setScreenSaverInterval( int interval )
450{ 481{
451 setScreenSaverIntervals(-1,-1,interval); 482 setScreenSaverIntervals( -1, -1, interval );
452} 483}
453 484
@@ -457,5 +488,5 @@ static void setScreenSaverInterval(int interval)
457 \brief The QPEApplication class implements various system services 488 \brief The QPEApplication class implements various system services
458 that are available to all Qtopia applications. 489 that are available to all Qtopia applications.
459 490
460 Simply by using QPEApplication instead of QApplication, a plain Qt 491 Simply by using QPEApplication instead of QApplication, a plain Qt
461 application becomes a Qtopia application. It automatically follows 492 application becomes a Qtopia application. It automatically follows
@@ -467,5 +498,5 @@ static void setScreenSaverInterval(int interval)
467/*! 498/*!
468 \fn void QPEApplication::clientMoused() 499 \fn void QPEApplication::clientMoused()
469 500
470 \internal 501 \internal
471*/ 502*/
@@ -473,5 +504,5 @@ static void setScreenSaverInterval(int interval)
473/*! 504/*!
474 \fn void QPEApplication::timeChanged(); 505 \fn void QPEApplication::timeChanged();
475 506
476 This signal is emitted when the time jumps forward or backwards 507 This signal is emitted when the time jumps forward or backwards
477 by more than the normal passage of time. 508 by more than the normal passage of time.
@@ -480,5 +511,5 @@ static void setScreenSaverInterval(int interval)
480/*! 511/*!
481 \fn void QPEApplication::clockChanged( bool ampm ); 512 \fn void QPEApplication::clockChanged( bool ampm );
482 513
483 This signal is emitted when the user changes the style 514 This signal is emitted when the user changes the style
484 of clock. If \a ampm is TRUE, the user wants a 12-hour 515 of clock. If \a ampm is TRUE, the user wants a 12-hour
@@ -488,11 +519,11 @@ static void setScreenSaverInterval(int interval)
488/*! 519/*!
489 \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data ) 520 \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data )
490 521
491 This signal is emitted when a message is received on the 522 This signal is emitted when a message is received on the
492 QPE/Application/<i>appname</i> QCop channel for this application. 523 QPE/Application/<i>appname</i> QCop channel for this application.
493 524
494 The slot to which you connect this signal uses \a msg and \a data 525 The slot to which you connect this signal uses \a msg and \a data
495 in the following way: 526 in the following way:
496 527
497\code 528\code
498 void MyWidget::receive( const QCString& msg, const QByteArray& data ) 529 void MyWidget::receive( const QCString& msg, const QByteArray& data )
@@ -508,5 +539,5 @@ static void setScreenSaverInterval(int interval)
508 } 539 }
509\endcode 540\endcode
510 541
511 \sa qcop.html 542 \sa qcop.html
512*/ 543*/
@@ -516,144 +547,146 @@ static void setScreenSaverInterval(int interval)
516 a QApplication, passing \a argc, \a argv, and \a t. 547 a QApplication, passing \a argc, \a argv, and \a t.
517*/ 548*/
518QPEApplication::QPEApplication( int& argc, char **argv, Type t ) 549QPEApplication::QPEApplication( int & argc, char **argv, Type t )
519 : QApplication( hack(argc), argv, t ) 550 : QApplication( hack( argc ), argv, t )
520{ 551{
521 int dw = desktop()->width(); 552 int dw = desktop() ->width();
522 if ( dw < 200 ) { 553 if ( dw < 200 ) {
523// setFont( QFont( "helvetica", 8 ) ); 554 // setFont( QFont( "helvetica", 8 ) );
524 AppLnk::setSmallIconSize(10); 555 AppLnk::setSmallIconSize( 10 );
525 AppLnk::setBigIconSize(28); 556 AppLnk::setBigIconSize( 28 );
526 } 557 }
527 558
528 d = new QPEApplicationData; 559 d = new QPEApplicationData;
529 QMimeSourceFactory::setDefaultFactory(new ResourceMimeFactory); 560 QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory );
530 561
531 connect(this, SIGNAL(lastWindowClosed()), this, SLOT(hideOrQuit())); 562 connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) );
532#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 563#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
533 564
534 QString qcopfn("/tmp/qcop-msg-"); 565 QString qcopfn( "/tmp/qcop-msg-" );
535 qcopfn += QString(argv[0]); // append command name 566 qcopfn += QString( argv[ 0 ] ); // append command name
536
537 QFile f(qcopfn);
538 if ( f.open(IO_ReadOnly) ) {
539 flock(f.handle(), LOCK_EX);
540 }
541 567
542 sysChannel = new QCopChannel( "QPE/System", this ); 568 QFile f( qcopfn );
543 connect( sysChannel, SIGNAL(received(const QCString &, const QByteArray &)), 569 if ( f.open( IO_ReadOnly ) ) {
544 this, SLOT(systemMessage( const QCString &, const QByteArray &)) ); 570 flock( f.handle(), LOCK_EX );
545 571 }
546 QCString channel = QCString(argv[0]);
547 channel.replace(QRegExp(".*/"),"");
548 d->appName = channel;
549 channel = "QPE/Application/" + channel;
550 pidChannel = new QCopChannel( channel, this);
551 connect( pidChannel, SIGNAL(received(const QCString &, const QByteArray &)),
552 this, SLOT(pidMessage(const QCString &, const QByteArray &)));
553
554 if ( f.isOpen() ) {
555 d->keep_running = FALSE;
556 QDataStream ds(&f);
557 QCString channel, message;
558 QByteArray data;
559 while(!ds.atEnd()) {
560 ds >> channel >> message >> data;
561 d->enqueueQCop(channel,message,data);
562 }
563 572
564 flock(f.handle(), LOCK_UN); 573 sysChannel = new QCopChannel( "QPE/System", this );
565 f.close(); 574 connect( sysChannel, SIGNAL( received( const QCString &, const QByteArray & ) ),
566 f.remove(); 575 this, SLOT( systemMessage( const QCString &, const QByteArray & ) ) );
567 } 576
577 QCString channel = QCString( argv[ 0 ] );
578 channel.replace( QRegExp( ".*/" ), "" );
579 d->appName = channel;
580 channel = "QPE/Application/" + channel;
581 pidChannel = new QCopChannel( channel, this );
582 connect( pidChannel, SIGNAL( received( const QCString &, const QByteArray & ) ),
583 this, SLOT( pidMessage( const QCString &, const QByteArray & ) ) );
584
585 if ( f.isOpen() ) {
586 d->keep_running = FALSE;
587 QDataStream ds( &f );
588 QCString channel, message;
589 QByteArray data;
590 while ( !ds.atEnd() ) {
591 ds >> channel >> message >> data;
592 d->enqueueQCop( channel, message, data );
593 }
594
595 flock( f.handle(), LOCK_UN );
596 f.close();
597 f.remove();
598 }
568 599
569 for (int a=0; a<argc; a++) { 600 for ( int a = 0; a < argc; a++ ) {
570 if ( qstrcmp(argv[a],"-preload")==0 ) { 601 if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) {
571 argv[a] = argv[a+1]; 602 argv[ a ] = argv[ a + 1 ];
572 a++; 603 a++;
573 d->preloaded = TRUE; 604 d->preloaded = TRUE;
574 argc-=1; 605 argc -= 1;
575 } else if ( qstrcmp(argv[a],"-preload-show")==0 ) { 606 }
576 argv[a] = argv[a+1]; 607 else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) {
577 a++; 608 argv[ a ] = argv[ a + 1 ];
578 d->preloaded = TRUE; 609 a++;
579 d->forceshow = TRUE; 610 d->preloaded = TRUE;
580 argc-=1; 611 d->forceshow = TRUE;
581 } 612 argc -= 1;
582 } 613 }
614 }
583 615
584 /* overide stored arguments */ 616 /* overide stored arguments */
585 setArgs(argc, argv); 617 setArgs( argc, argv );
586 618
587#endif 619#endif
588 620
589 qwsSetDecoration( new QPEDecoration() ); 621 qwsSetDecoration( new QPEDecoration() );
590 622
591#ifndef QT_NO_TRANSLATION 623#ifndef QT_NO_TRANSLATION
592 QStringList langs = Global::languageList(); 624
593 for (QStringList::ConstIterator it = langs.begin(); it!=langs.end(); ++it) { 625 QStringList langs = Global::languageList();
594 QString lang = *it; 626 for ( QStringList::ConstIterator it = langs.begin(); it != langs.end(); ++it ) {
595 627 QString lang = *it;
596 QTranslator * trans; 628
597 QString tfn; 629 QTranslator * trans;
598 630 QString tfn;
599 trans = new QTranslator(this); 631
600 tfn = qpeDir()+"/i18n/"+lang+"/libqpe.qm"; 632 trans = new QTranslator( this );
601 if ( trans->load( tfn )) 633 tfn = qpeDir() + "/i18n/" + lang + "/libqpe.qm";
602 installTranslator( trans ); 634 if ( trans->load( tfn ) )
603 else 635 installTranslator( trans );
604 delete trans; 636 else
605 637 delete trans;
606 trans = new QTranslator(this); 638
607 tfn = qpeDir()+"/i18n/"+lang+"/"+d->appName+".qm"; 639 trans = new QTranslator( this );
608 if ( trans->load( tfn )) 640 tfn = qpeDir() + "/i18n/" + lang + "/" + d->appName + ".qm";
609 installTranslator( trans ); 641 if ( trans->load( tfn ) )
610 else 642 installTranslator( trans );
611 delete trans; 643 else
612 644 delete trans;
613 //###language/font hack; should look it up somewhere 645
614 if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) { 646 //###language/font hack; should look it up somewhere
615 QFont fn = FontManager::unicodeFont( FontManager::Proportional ); 647 if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) {
616 setFont( fn ); 648 QFont fn = FontManager::unicodeFont( FontManager::Proportional );
617 } 649 setFont( fn );
618 else { 650 }
619 Config config( "qpe" ); 651 else {
620 config.setGroup( "Appearance" ); 652 Config config( "qpe" );
621 QString familyStr = config.readEntry( "FontFamily", "helvetica" ); 653 config.setGroup( "Appearance" );
622 QString styleStr = config.readEntry( "FontStyle", "Regular" ); 654 QString familyStr = config.readEntry( "FontFamily", "helvetica" );
623 QString sizeStr = config.readEntry( "FontSize", "10" ); 655 QString styleStr = config.readEntry( "FontStyle", "Regular" );
624 QString charSetStr = config.readEntry( "FontCharSet", QString::null ); 656 QString sizeStr = config.readEntry( "FontSize", "10" );
625 bool ok; 657 QString charSetStr = config.readEntry( "FontCharSet", QString::null );
626 int i_size = sizeStr.toInt( &ok, 10 ); 658 bool ok;
627 FontDatabase fdb; 659 int i_size = sizeStr.toInt( &ok, 10 );
628 QFont selectedFont = fdb.font( familyStr, styleStr, i_size, charSetStr ); 660 FontDatabase fdb;
629 setFont( selectedFont ); 661 QFont selectedFont = fdb.font( familyStr, styleStr, i_size, charSetStr );
630 } 662 setFont( selectedFont );
631 } 663 }
664 }
632 665
633#endif 666#endif
634 667
635 applyStyle(); 668 applyStyle();
636 669
637 if ( type() == GuiServer ) { 670 if ( type() == GuiServer ) {
638 setScreenSaverInterval(-1); 671 setScreenSaverInterval( -1 );
639 setVolume(); 672 setVolume();
640 QWSServer::setScreenSaver(new QPEScreenSaver); 673 QWSServer::setScreenSaver( new QPEScreenSaver );
641 } 674 }
642 675
643 installEventFilter( this ); 676 installEventFilter( this );
644 677
645 QPEMenuToolFocusManager::initialize(); 678 QPEMenuToolFocusManager::initialize();
646 679
647#ifdef QT_NO_QWS_CURSOR 680#ifdef QT_NO_QWS_CURSOR
648 // if we have no cursor, probably don't want tooltips 681 // if we have no cursor, probably don't want tooltips
649 QToolTip::setEnabled( FALSE ); 682 QToolTip::setEnabled( FALSE );
650#endif 683#endif
651} 684}
652 685
653static QPtrDict<void>* inputMethodDict=0; 686static QPtrDict<void>* inputMethodDict = 0;
654static void createInputMethodDict() 687static void createInputMethodDict()
655{ 688{
656 if ( !inputMethodDict ) 689 if ( !inputMethodDict )
657 inputMethodDict = new QPtrDict<void>; 690 inputMethodDict = new QPtrDict<void>;
658} 691}
659 692
@@ -661,17 +694,17 @@ static void createInputMethodDict()
661 Returns the currently set hint to the system as to whether 694 Returns the currently set hint to the system as to whether
662 \a w has any use for text input methods. 695 \a w has any use for text input methods.
663 696
664 \sa setInputMethodHint() 697 \sa setInputMethodHint()
665*/ 698*/
666QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget* w ) 699QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w )
667{ 700{
668 if ( inputMethodDict && w ) 701 if ( inputMethodDict && w )
669 return (InputMethodHint)(int)inputMethodDict->find(w); 702 return ( InputMethodHint ) ( int ) inputMethodDict->find( w );
670 return Normal; 703 return Normal;
671} 704}
672 705
673/*! 706/*!
674 \enum QPEApplication::InputMethodHint 707 \enum QPEApplication::InputMethodHint
675 708
676 \value Normal the application sometimes needs text input (the default). 709 \value Normal the application sometimes needs text input (the default).
677 \value AlwaysOff the application never needs text input. 710 \value AlwaysOff the application never needs text input.
@@ -682,15 +715,17 @@ QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget* w )
682 Hints to the system that \a w has use for text input methods 715 Hints to the system that \a w has use for text input methods
683 as specified by \a mode. 716 as specified by \a mode.
684 717
685 \sa inputMethodHint() 718 \sa inputMethodHint()
686*/ 719*/
687void QPEApplication::setInputMethodHint( QWidget* w, InputMethodHint mode ) 720void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode )
688{ 721{
689 createInputMethodDict(); 722 createInputMethodDict();
690 if ( mode == Normal ) { 723 if ( mode == Normal ) {
691 inputMethodDict->remove(w); 724 inputMethodDict->remove
692 } else { 725 ( w );
693 inputMethodDict->insert(w,(void*)mode); 726 }
694 } 727 else {
728 inputMethodDict->insert( w, ( void* ) mode );
729 }
695} 730}
696 731
@@ -698,22 +733,28 @@ class HackDialog : public QDialog
698{ 733{
699public: 734public:
700 void acceptIt() { accept(); } 735 void acceptIt()
701 void rejectIt() { reject(); } 736 {
737 accept();
738 }
739 void rejectIt()
740 {
741 reject();
742 }
702}; 743};
703 744
704 745
705void QPEApplication::mapToDefaultAction( QWSKeyEvent *ke, int key ) 746void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key )
706{ 747{
707 // specialised actions for certain widgets. May want to 748 // specialised actions for certain widgets. May want to
708 // add more stuff here. 749 // add more stuff here.
709 if ( activePopupWidget() && activePopupWidget()->inherits( "QListBox" ) 750 if ( activePopupWidget() && activePopupWidget() ->inherits( "QListBox" )
710 && activePopupWidget()->parentWidget() 751 && activePopupWidget() ->parentWidget()
711 && activePopupWidget()->parentWidget()->inherits( "QComboBox" ) ) 752 && activePopupWidget() ->parentWidget() ->inherits( "QComboBox" ) )
712 key = Qt::Key_Return; 753 key = Qt::Key_Return;
713 754
714 if ( activePopupWidget() && activePopupWidget()->inherits( "QPopupMenu" ) ) 755 if ( activePopupWidget() && activePopupWidget() ->inherits( "QPopupMenu" ) )
715 key = Qt::Key_Return; 756 key = Qt::Key_Return;
716 757
717 ke->simpleData.keycode = key; 758 ke->simpleData.keycode = key;
718} 759}
719 760
@@ -721,6 +762,8 @@ class HackWidget : public QWidget
721{ 762{
722public: 763public:
723 bool needsOk() 764 bool needsOk()
724 { return (getWState() & WState_Reserved1 ); } 765 {
766 return ( getWState() & WState_Reserved1 );
767 }
725}; 768};
726 769
@@ -728,111 +771,118 @@ public:
728 \internal 771 \internal
729*/ 772*/
730bool QPEApplication::qwsEventFilter( QWSEvent *e ) 773bool QPEApplication::qwsEventFilter( QWSEvent * e )
731{ 774{
732 if ( !d->notbusysent && e->type == QWSEvent::Focus ) { 775 if ( !d->notbusysent && e->type == QWSEvent::Focus ) {
733 if ( qApp->type() != QApplication::GuiServer ) { 776 if ( qApp->type() != QApplication::GuiServer ) {
734 QCopEnvelope e("QPE/System", "notBusy(QString)" ); 777 QCopEnvelope e( "QPE/System", "notBusy(QString)" );
735 e << d->appName; 778 e << d->appName;
736 } 779 }
737 d->notbusysent=TRUE; 780 d->notbusysent = TRUE;
738 } 781 }
739 if ( type() == GuiServer ) { 782 if ( type() == GuiServer ) {
740 switch ( e->type ) { 783 switch ( e->type ) {
741 case QWSEvent::Mouse: 784 case QWSEvent::Mouse:
742 if ( e->asMouse()->simpleData.state && !QWidget::find(e->window()) ) 785 if ( e->asMouse() ->simpleData.state && !QWidget::find( e->window() ) )
743 emit clientMoused(); 786 emit clientMoused();
744 } 787 }
745 } 788 }
746 if ( e->type == QWSEvent::Key ) { 789 if ( e->type == QWSEvent::Key ) {
747 if ( d->kbgrabber == 1 ) 790 if ( d->kbgrabber == 1 )
748 return TRUE; 791 return TRUE;
749 QWSKeyEvent *ke = (QWSKeyEvent *)e; 792 QWSKeyEvent *ke = ( QWSKeyEvent * ) e;
750 if ( ke->simpleData.keycode == Qt::Key_F33 ) { 793 if ( ke->simpleData.keycode == Qt::Key_F33 ) {
751 // Use special "OK" key to press "OK" on top level widgets 794 // Use special "OK" key to press "OK" on top level widgets
752 QWidget *active = activeWindow(); 795 QWidget * active = activeWindow();
753 QWidget *popup = 0; 796 QWidget *popup = 0;
754 if ( active && active->isPopup() ) { 797 if ( active && active->isPopup() ) {
755 popup = active; 798 popup = active;
756 active = active->parentWidget(); 799 active = active->parentWidget();
757 } 800 }
758 if ( active && (int)active->winId() == ke->simpleData.window && 801 if ( active && ( int ) active->winId() == ke->simpleData.window &&
759 !active->testWFlags( WStyle_Customize|WType_Popup|WType_Desktop )) { 802 !active->testWFlags( WStyle_Customize | WType_Popup | WType_Desktop ) ) {
760 if ( ke->simpleData.is_press ) { 803 if ( ke->simpleData.is_press ) {
761 if ( popup ) 804 if ( popup )
762 popup->close(); 805 popup->close();
763 if ( active->inherits( "QDialog" ) ) { 806 if ( active->inherits( "QDialog" ) ) {
764 HackDialog *d = (HackDialog *)active; 807 HackDialog * d = ( HackDialog * ) active;
765 d->acceptIt(); 808 d->acceptIt();
766 return TRUE; 809 return TRUE;
767 } else if ( ((HackWidget *)active)->needsOk() ) { 810 }
768 QSignal s; 811 else if ( ( ( HackWidget * ) active ) ->needsOk() ) {
769 s.connect( active, SLOT( accept() ) ); 812 QSignal s;
770 s.activate(); 813 s.connect( active, SLOT( accept() ) );
771 } else { 814 s.activate();
772 // do the same as with the select key: Map to the default action of the widget: 815 }
773 mapToDefaultAction( ke, Qt::Key_Return ); 816 else {
774 } 817 // do the same as with the select key: Map to the default action of the widget:
775 } 818 mapToDefaultAction( ke, Qt::Key_Return );
776 } 819 }
777 } else if ( ke->simpleData.keycode == Qt::Key_F30 ) { 820 }
778 // Use special "select" key to do whatever default action a widget has 821 }
779 mapToDefaultAction( ke, Qt::Key_Space ); 822 }
780 } else if ( ke->simpleData.keycode == Qt::Key_Escape && 823 else if ( ke->simpleData.keycode == Qt::Key_F30 ) {
781 ke->simpleData.is_press ) { 824 // Use special "select" key to do whatever default action a widget has
782 // Escape key closes app if focus on toplevel 825 mapToDefaultAction( ke, Qt::Key_Space );
783 QWidget *active = activeWindow(); 826 }
784 if ( active && active->testWFlags( WType_TopLevel ) && 827 else if ( ke->simpleData.keycode == Qt::Key_Escape &&
785 (int)active->winId() == ke->simpleData.window && 828 ke->simpleData.is_press ) {
786 !active->testWFlags( WStyle_Dialog|WStyle_Customize|WType_Popup|WType_Desktop )) { 829 // Escape key closes app if focus on toplevel
787 if ( active->inherits( "QDialog" ) ) { 830 QWidget * active = activeWindow();
788 HackDialog *d = (HackDialog *)active; 831 if ( active && active->testWFlags( WType_TopLevel ) &&
789 d->rejectIt(); 832 ( int ) active->winId() == ke->simpleData.window &&
790 return TRUE; 833 !active->testWFlags( WStyle_Dialog | WStyle_Customize | WType_Popup | WType_Desktop ) ) {
791 } else if ( strcmp( argv()[0], "embeddedkonsole") != 0 ) { 834 if ( active->inherits( "QDialog" ) ) {
792 active->close(); 835 HackDialog * d = ( HackDialog * ) active;
793 } 836 d->rejectIt();
794 } 837 return TRUE;
795 } 838 }
839 else if ( strcmp( argv() [ 0 ], "embeddedkonsole" ) != 0 ) {
840 active->close();
841 }
842 }
843 }
796 844
797#if QT_VERSION < 231 845#if QT_VERSION < 231
798 // Filter out the F4/Launcher key from apps 846 // Filter out the F4/Launcher key from apps
799 // ### The launcher key may not always be F4 on all devices 847 // ### The launcher key may not always be F4 on all devices
800 if ( ((QWSKeyEvent *)e)->simpleData.keycode == Qt::Key_F4 ) 848 if ( ( ( QWSKeyEvent * ) e ) ->simpleData.keycode == Qt::Key_F4 )
801 return TRUE; 849 return TRUE;
802#endif 850#endif
803 } 851
804 if ( e->type == QWSEvent::Focus ) { 852 }
805 QWSFocusEvent *fe = (QWSFocusEvent*)e; 853 if ( e->type == QWSEvent::Focus ) {
806 QWidget* nfw = QWidget::find(e->window()); 854 QWSFocusEvent * fe = ( QWSFocusEvent* ) e;
807 if ( !fe->simpleData.get_focus ) { 855 QWidget* nfw = QWidget::find( e->window() );
808 QWidget *active = activeWindow(); 856 if ( !fe->simpleData.get_focus ) {
809 while ( active && active->isPopup() ) { 857 QWidget * active = activeWindow();
810 active->close(); 858 while ( active && active->isPopup() ) {
811 active = activeWindow(); 859 active->close();
812 } 860 active = activeWindow();
813 if ( !nfw && d->kbgrabber == 2 ) { 861 }
814 ungrabKeyboard(); 862 if ( !nfw && d->kbgrabber == 2 ) {
815 d->kbregrab = TRUE; // want kb back when we're active 863 ungrabKeyboard();
816 } 864 d->kbregrab = TRUE; // want kb back when we're active
817 } else { 865 }
818 // make sure our modal widget is ALWAYS on top 866 }
819 QWidget *topm = activeModalWidget(); 867 else {
820 if ( topm ) { 868 // make sure our modal widget is ALWAYS on top
821 topm->raise(); 869 QWidget *topm = activeModalWidget();
822 } 870 if ( topm ) {
823 if ( d->kbregrab ) { 871 topm->raise();
824 grabKeyboard(); 872 }
825 d->kbregrab = FALSE; 873 if ( d->kbregrab ) {
826 } 874 grabKeyboard();
827 } 875 d->kbregrab = FALSE;
828 if ( fe->simpleData.get_focus && inputMethodDict ) { 876 }
829 InputMethodHint m = inputMethodHint( QWidget::find(e->window()) ); 877 }
830 if ( m == AlwaysOff ) 878 if ( fe->simpleData.get_focus && inputMethodDict ) {
831 Global::hideInputMethod(); 879 InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) );
832 if ( m == AlwaysOn ) 880 if ( m == AlwaysOff )
833 Global::showInputMethod(); 881 Global::hideInputMethod();
834 } 882 if ( m == AlwaysOn )
835 } 883 Global::showInputMethod();
836 return QApplication::qwsEventFilter( e ); 884 }
885 }
886 return QApplication::qwsEventFilter( e );
837} 887}
838 888
@@ -842,12 +892,13 @@ bool QPEApplication::qwsEventFilter( QWSEvent *e )
842QPEApplication::~QPEApplication() 892QPEApplication::~QPEApplication()
843{ 893{
844 ungrabKeyboard(); 894 ungrabKeyboard();
845#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 895#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
846 // Need to delete QCopChannels early, since the display will 896 // Need to delete QCopChannels early, since the display will
847 // be gone by the time we get to ~QObject(). 897 // be gone by the time we get to ~QObject().
848 delete sysChannel; 898 delete sysChannel;
849 delete pidChannel; 899 delete pidChannel;
850#endif 900#endif
851 delete d; 901
902 delete d;
852} 903}
853 904
@@ -857,9 +908,9 @@ QPEApplication::~QPEApplication()
857QString QPEApplication::qpeDir() 908QString QPEApplication::qpeDir()
858{ 909{
859 const char *base = getenv( "OPIEDIR" ); 910 const char * base = getenv( "OPIEDIR" );
860 if ( base ) 911 if ( base )
861 return QString( base ) + "/"; 912 return QString( base ) + "/";
862 913
863 return QString( "../" ); 914 return QString( "../" );
864} 915}
865 916
@@ -869,12 +920,12 @@ QString QPEApplication::qpeDir()
869QString QPEApplication::documentDir() 920QString QPEApplication::documentDir()
870{ 921{
871 const char *base = getenv( "HOME" ); 922 const char * base = getenv( "HOME" );
872 if ( base ) 923 if ( base )
873 return QString( base ) + "/Documents/"; 924 return QString( base ) + "/Documents/";
874 925
875 return QString( "../Documents/" ); 926 return QString( "../Documents/" );
876} 927}
877 928
878static int deforient=-1; 929static int deforient = -1;
879 930
880/*! 931/*!
@@ -883,17 +934,20 @@ static int deforient=-1;
883int QPEApplication::defaultRotation() 934int QPEApplication::defaultRotation()
884{ 935{
885 if ( deforient < 0 ) { 936 if ( deforient < 0 ) {
886 QString d = getenv("QWS_DISPLAY"); 937 QString d = getenv( "QWS_DISPLAY" );
887 if ( d.contains("Rot90") ) { 938 if ( d.contains( "Rot90" ) ) {
888 deforient = 90; 939 deforient = 90;
889 } else if ( d.contains("Rot180") ) { 940 }
890 deforient = 180; 941 else if ( d.contains( "Rot180" ) ) {
891 } else if ( d.contains("Rot270") ) { 942 deforient = 180;
892 deforient = 270; 943 }
893 } else { 944 else if ( d.contains( "Rot270" ) ) {
894 deforient=0; 945 deforient = 270;
895 } 946 }
896 } 947 else {
897 return deforient; 948 deforient = 0;
949 }
950 }
951 return deforient;
898} 952}
899 953
@@ -901,12 +955,13 @@ int QPEApplication::defaultRotation()
901 \internal 955 \internal
902*/ 956*/
903void QPEApplication::setDefaultRotation(int r) 957void QPEApplication::setDefaultRotation( int r )
904{ 958{
905 if ( qApp->type() == GuiServer ) { 959 if ( qApp->type() == GuiServer ) {
906 deforient = r; 960 deforient = r;
907 setenv("QWS_DISPLAY", QString("Transformed:Rot%1:0").arg(r).latin1(), 1); 961 setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 );
908 } else { 962 }
909 QCopEnvelope("QPE/System", "setDefaultRotation(int)") << r; 963 else {
910 } 964 QCopEnvelope( "QPE/System", "setDefaultRotation(int)" ) << r;
965 }
911} 966}
912 967
@@ -916,173 +971,196 @@ void QPEApplication::setDefaultRotation(int r)
916void QPEApplication::applyStyle() 971void QPEApplication::applyStyle()
917{ 972{
918 Config config( "qpe" ); 973 Config config( "qpe" );
919 974
920 config.setGroup( "Appearance" ); 975 config.setGroup( "Appearance" );
921 976
922 // Widget style 977 // Widget style
923 QString style = config.readEntry( "Style", "Light" ); 978 QString style = config.readEntry( "Style", "Light" );
924 internalSetStyle( style ); 979 internalSetStyle( style );
925 980
926 // Colors 981 // Colors
927 QColor bgcolor( config.readEntry( "Background", "#E5E1D5" ) ); 982 QColor bgcolor( config.readEntry( "Background", "#E5E1D5" ) );
928 QColor btncolor( config.readEntry( "Button", "#D6CDBB" ) ); 983 QColor btncolor( config.readEntry( "Button", "#D6CDBB" ) );
929 QPalette pal( btncolor, bgcolor ); 984 QPalette pal( btncolor, bgcolor );
930 QString color = config.readEntry( "Highlight", "#800000" ); 985 QString color = config.readEntry( "Highlight", "#800000" );
931 pal.setColor( QColorGroup::Highlight, QColor(color) ); 986 pal.setColor( QColorGroup::Highlight, QColor( color ) );
932 color = config.readEntry( "HighlightedText", "#FFFFFF" ); 987 color = config.readEntry( "HighlightedText", "#FFFFFF" );
933 pal.setColor( QColorGroup::HighlightedText, QColor(color) ); 988 pal.setColor( QColorGroup::HighlightedText, QColor( color ) );
934 color = config.readEntry( "Text", "#000000" ); 989 color = config.readEntry( "Text", "#000000" );
935 pal.setColor( QColorGroup::Text, QColor(color) ); 990 pal.setColor( QColorGroup::Text, QColor( color ) );
936 color = config.readEntry( "ButtonText", "#000000" ); 991 color = config.readEntry( "ButtonText", "#000000" );
937 pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor(color) ); 992 pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) );
938 color = config.readEntry( "Base", "#FFFFFF" ); 993 color = config.readEntry( "Base", "#FFFFFF" );
939 pal.setColor( QColorGroup::Base, QColor(color) ); 994 pal.setColor( QColorGroup::Base, QColor( color ) );
940 995
941 pal.setColor( QPalette::Disabled, QColorGroup::Text, 996 pal.setColor( QPalette::Disabled, QColorGroup::Text,
942 pal.color(QPalette::Active, QColorGroup::Background).dark() ); 997 pal.color( QPalette::Active, QColorGroup::Background ).dark() );
943 998
944 setPalette( pal, TRUE ); 999 setPalette( pal, TRUE );
945} 1000}
946 1001
947void QPEApplication::systemMessage( const QCString &msg, const QByteArray &data) 1002void QPEApplication::systemMessage( const QCString & msg, const QByteArray & data )
948{ 1003{
949#ifdef Q_WS_QWS 1004#ifdef Q_WS_QWS
950 QDataStream stream( data, IO_ReadOnly ); 1005 QDataStream stream( data, IO_ReadOnly );
951 if ( msg == "applyStyle()" ) { 1006 if ( msg == "applyStyle()" ) {
952 applyStyle(); 1007 applyStyle();
953 } else if ( msg == "setScreenSaverInterval(int)" ) { 1008 }
954 if ( type() == GuiServer ) { 1009 else if ( msg == "setScreenSaverInterval(int)" ) {
955 int time; 1010 if ( type() == GuiServer ) {
956 stream >> time; 1011 int time;
957 setScreenSaverInterval(time); 1012 stream >> time;
958 } 1013 setScreenSaverInterval( time );
959 } else if ( msg == "setScreenSaverIntervals(int,int,int)" ) { 1014 }
960 if ( type() == GuiServer ) { 1015 }
961 int t1,t2,t3; 1016 else if ( msg == "setScreenSaverIntervals(int,int,int)" ) {
962 stream >> t1 >> t2 >> t3; 1017 if ( type() == GuiServer ) {
963 setScreenSaverIntervals(t1,t2,t3); 1018 int t1, t2, t3;
964 } 1019 stream >> t1 >> t2 >> t3;
965 } else if ( msg == "setBacklight(int)" ) { 1020 setScreenSaverIntervals( t1, t2, t3 );
966 if ( type() == GuiServer ) { 1021 }
967 int bright; 1022 }
968 stream >> bright; 1023 else if ( msg == "setBacklight(int)" ) {
969 setBacklight(bright); 1024 if ( type() == GuiServer ) {
970 } 1025 int bright;
971 } else if ( msg == "setDefaultRotation(int)" ) { 1026 stream >> bright;
972 if ( type() == GuiServer ) { 1027 setBacklight( bright );
973 int r; 1028 }
974 stream >> r; 1029 }
975 setDefaultRotation(r); 1030 else if ( msg == "setDefaultRotation(int)" ) {
976 } 1031 if ( type() == GuiServer ) {
977 } else if ( msg == "shutdown()" ) { 1032 int r;
978 if ( type() == GuiServer ) 1033 stream >> r;
979 shutdown(); 1034 setDefaultRotation( r );
980 } else if ( msg == "quit()" ) { 1035 }
981 if ( type() != GuiServer ) 1036 }
982 tryQuit(); 1037 else if ( msg == "shutdown()" ) {
983 } else if ( msg == "forceQuit()" ) { 1038 if ( type() == GuiServer )
984 if ( type() != GuiServer ) 1039 shutdown();
985 quit(); 1040 }
986 } else if ( msg == "restart()" ) { 1041 else if ( msg == "quit()" ) {
987 if ( type() == GuiServer ) 1042 if ( type() != GuiServer )
988 restart(); 1043 tryQuit();
989 } else if ( msg == "grabKeyboard(QString)" ) { 1044 }
990 QString who; 1045 else if ( msg == "forceQuit()" ) {
991 stream >> who; 1046 if ( type() != GuiServer )
992 if ( who.isEmpty() ) 1047 quit();
993 d->kbgrabber = 0; 1048 }
994 else if ( who != d->appName ) 1049 else if ( msg == "restart()" ) {
995 d->kbgrabber = 1; 1050 if ( type() == GuiServer )
996 else 1051 restart();
997 d->kbgrabber = 2; 1052 }
998 } else if ( msg == "language(QString)" ) { 1053 else if ( msg == "grabKeyboard(QString)" ) {
999 if ( type() == GuiServer ) { 1054 QString who;
1000 QString l; 1055 stream >> who;
1001 stream >> l; 1056 if ( who.isEmpty() )
1002 QString cl = getenv("LANG"); 1057 d->kbgrabber = 0;
1003 if ( cl != l ) { 1058 else if ( who != d->appName )
1004 if ( l.isNull() ) 1059 d->kbgrabber = 1;
1005 unsetenv( "LANG" ); 1060 else
1006 else 1061 d->kbgrabber = 2;
1007 setenv( "LANG", l.latin1(), 1 ); 1062 }
1008 restart(); 1063 else if ( msg == "language(QString)" ) {
1009 } 1064 if ( type() == GuiServer ) {
1010 } 1065 QString l;
1011 } else if ( msg == "timeChange(QString)" ) { 1066 stream >> l;
1012 QString t; 1067 QString cl = getenv( "LANG" );
1013 stream >> t; 1068 if ( cl != l ) {
1014 if ( t.isNull() ) 1069 if ( l.isNull() )
1015 unsetenv( "TZ" ); 1070 unsetenv( "LANG" );
1016 else 1071 else
1017 setenv( "TZ", t.latin1(), 1 ); 1072 setenv( "LANG", l.latin1(), 1 );
1018 // emit the signal so everyone else knows... 1073 restart();
1019 emit timeChanged(); 1074 }
1020 } else if ( msg == "execute(QString)" ) { 1075 }
1021 if ( type() == GuiServer ) { 1076 }
1022 QString t; 1077 else if ( msg == "timeChange(QString)" ) {
1023 stream >> t; 1078 QString t;
1024 Global::execute( t ); 1079 stream >> t;
1025 } 1080 if ( t.isNull() )
1026 } else if ( msg == "execute(QString,QString)" ) { 1081 unsetenv( "TZ" );
1027 if ( type() == GuiServer ) { 1082 else
1028 QString t,d; 1083 setenv( "TZ", t.latin1(), 1 );
1029 stream >> t >> d; 1084 // emit the signal so everyone else knows...
1030 Global::execute( t, d ); 1085 emit timeChanged();
1031 } 1086 }
1032 } else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) { 1087 else if ( msg == "execute(QString)" ) {
1033 if ( type() == GuiServer ) { 1088 if ( type() == GuiServer ) {
1034 QDateTime when; 1089 QString t;
1035 QCString channel, message; 1090 stream >> t;
1036 int data; 1091 Global::execute( t );
1037 stream >> when >> channel >> message >> data; 1092 }
1038 AlarmServer::addAlarm( when, channel, message, data ); 1093 }
1039 } 1094 else if ( msg == "execute(QString,QString)" ) {
1040 } else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) { 1095 if ( type() == GuiServer ) {
1041 if ( type() == GuiServer ) { 1096 QString t, d;
1042 QDateTime when; 1097 stream >> t >> d;
1043 QCString channel, message; 1098 Global::execute( t, d );
1044 int data; 1099 }
1045 stream >> when >> channel >> message >> data; 1100 }
1046 AlarmServer::deleteAlarm( when, channel, message, data ); 1101 else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) {
1047 } 1102 if ( type() == GuiServer ) {
1048 } else if ( msg == "clockChange(bool)" ) { 1103 QDateTime when;
1049 int tmp; 1104 QCString channel, message;
1050 stream >> tmp; 1105 int data;
1051 emit clockChanged( tmp ); 1106 stream >> when >> channel >> message >> data;
1052 } else if ( msg == "weekChange(bool)" ) { 1107 AlarmServer::addAlarm( when, channel, message, data );
1053 int tmp; 1108 }
1054 stream >> tmp; 1109 }
1055 emit weekChanged( tmp ); 1110 else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) {
1056 } else if ( msg == "setDateFormat(DateFormat)" ) { 1111 if ( type() == GuiServer ) {
1057 DateFormat tmp; 1112 QDateTime when;
1058 stream >> tmp; 1113 QCString channel, message;
1059 emit dateFormatChanged( tmp ); 1114 int data;
1060 } else if ( msg == "setVolume(int,int)" ) { 1115 stream >> when >> channel >> message >> data;
1061 int t,v; 1116 AlarmServer::deleteAlarm( when, channel, message, data );
1062 stream >> t >> v; 1117 }
1063 setVolume(t,v); 1118 }
1064 emit volumeChanged( muted ); 1119 else if ( msg == "clockChange(bool)" ) {
1065 } else if ( msg == "volumeChange(bool)" ) { 1120 int tmp;
1066 stream >> muted; 1121 stream >> tmp;
1067 setVolume(); 1122 emit clockChanged( tmp );
1068 emit volumeChanged( muted ); 1123 }
1069 } else if ( msg == "setMic(int,int)") { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> 1124 else if ( msg == "weekChange(bool)" ) {
1070 int t,v; 1125 int tmp;
1071 stream >> t >> v; 1126 stream >> tmp;
1072 setMic(t,v); 1127 emit weekChanged( tmp );
1073 emit micChanged( micMuted ); 1128 }
1074 } else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> 1129 else if ( msg == "setDateFormat(DateFormat)" ) {
1075 stream >> micMuted; 1130 DateFormat tmp;
1076 setMic(); 1131 stream >> tmp;
1077 emit micChanged( micMuted ); 1132 emit dateFormatChanged( tmp );
1078 } else if ( msg == "setScreenSaverMode(int)" ) { 1133 }
1079 if ( type() == GuiServer ) { 1134 else if ( msg == "setVolume(int,int)" ) {
1080 int old = disable_suspend; 1135 int t, v;
1081 stream >> disable_suspend; 1136 stream >> t >> v;
1082 //qDebug("setScreenSaverMode(%d)", disable_suspend ); 1137 setVolume( t, v );
1083 if ( disable_suspend > old ) 1138 emit volumeChanged( muted );
1084 setScreenSaverInterval( -1 ); 1139 }
1085 } 1140 else if ( msg == "volumeChange(bool)" ) {
1086 } 1141 stream >> muted;
1142 setVolume();
1143 emit volumeChanged( muted );
1144 }
1145 else if ( msg == "setMic(int,int)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com>
1146 int t, v;
1147 stream >> t >> v;
1148 setMic( t, v );
1149 emit micChanged( micMuted );
1150 }
1151 else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com>
1152 stream >> micMuted;
1153 setMic();
1154 emit micChanged( micMuted );
1155 }
1156 else if ( msg == "setScreenSaverMode(int)" ) {
1157 if ( type() == GuiServer ) {
1158 int old = disable_suspend;
1159 stream >> disable_suspend;
1160 //qDebug("setScreenSaverMode(%d)", disable_suspend );
1161 if ( disable_suspend > old )
1162 setScreenSaverInterval( -1 );
1163 }
1164 }
1087#endif 1165#endif
1088} 1166}
@@ -1093,77 +1171,90 @@ void QPEApplication::systemMessage( const QCString &msg, const QByteArray &data)
1093bool QPEApplication::raiseAppropriateWindow() 1171bool QPEApplication::raiseAppropriateWindow()
1094{ 1172{
1095 bool r=FALSE; 1173 bool r = FALSE;
1096 // ########## raise()ing main window should raise and set active 1174 // ########## raise()ing main window should raise and set active
1097 // ########## it and then all childen. This belongs in Qt/Embedded 1175 // ########## it and then all childen. This belongs in Qt/Embedded
1098 QWidget *top = d->qpe_main_widget; 1176 QWidget *top = d->qpe_main_widget;
1099 if ( !top ) top =mainWidget(); 1177 if ( !top )
1100 if ( top && d->keep_running ) { 1178 top = mainWidget();
1101 if ( top->isVisible() ) 1179 if ( top && d->keep_running ) {
1102 r = TRUE; 1180 if ( top->isVisible() )
1181 r = TRUE;
1103#ifdef Q_WS_QWS 1182#ifdef Q_WS_QWS
1104 if ( !d->nomaximize ) 1183
1105 top->showMaximized(); 1184 if ( !d->nomaximize )
1106 else 1185 top->showMaximized();
1186 else
1107#endif 1187#endif
1108 top->show(); 1188
1109 top->raise(); 1189 top->show();
1110 top->setActiveWindow(); 1190 top->raise();
1111 } 1191 top->setActiveWindow();
1112 QWidget *topm = activeModalWidget(); 1192 }
1113 if ( topm && topm != top ) { 1193 QWidget *topm = activeModalWidget();
1114 topm->show(); 1194 if ( topm && topm != top ) {
1115 topm->raise(); 1195 topm->show();
1116 topm->setActiveWindow(); 1196 topm->raise();
1117 r = FALSE; 1197 topm->setActiveWindow();
1118 } 1198 r = FALSE;
1119 return r; 1199 }
1200 return r;
1120} 1201}
1121 1202
1122void QPEApplication::pidMessage( const QCString &msg, const QByteArray & data) 1203void QPEApplication::pidMessage( const QCString &msg, const QByteArray & data )
1123{ 1204{
1124#ifdef Q_WS_QWS 1205#ifdef Q_WS_QWS
1125 1206
1126 if ( msg == "quit()" ) { 1207 if ( msg == "quit()" ) {
1127 tryQuit(); 1208 tryQuit();
1128 } else if ( msg == "quitIfInvisible()" ) { 1209 }
1129 if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() ) 1210 else if ( msg == "quitIfInvisible()" ) {
1130 quit(); 1211 if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() )
1131 } else if ( msg == "close()" ) { 1212 quit();
1132 hideOrQuit(); 1213 }
1133 } else if ( msg == "disablePreload()" ) { 1214 else if ( msg == "close()" ) {
1134 d->preloaded = FALSE; 1215 hideOrQuit();
1135 d->keep_running = TRUE; 1216 }
1136 /* so that quit will quit */ 1217 else if ( msg == "disablePreload()" ) {
1137 } else if ( msg == "enablePreload()" ) { 1218 d->preloaded = FALSE;
1138 d->preloaded = TRUE; 1219 d->keep_running = TRUE;
1139 d->keep_running = TRUE; 1220 /* so that quit will quit */
1140 /* so next quit won't quit */ 1221 }
1141 } else if ( msg == "raise()" ) { 1222 else if ( msg == "enablePreload()" ) {
1142 d->keep_running = TRUE; 1223 d->preloaded = TRUE;
1143 d->notbusysent = FALSE; 1224 d->keep_running = TRUE;
1144 raiseAppropriateWindow(); 1225 /* so next quit won't quit */
1145 } else if ( msg == "flush()" ) { 1226 }
1146 emit flush(); 1227 else if ( msg == "raise()" ) {
1147 // we need to tell the desktop 1228 d->keep_running = TRUE;
1148 QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" ); 1229 d->notbusysent = FALSE;
1149 e << d->appName; 1230 raiseAppropriateWindow();
1150 } else if ( msg == "reload()" ) { 1231 }
1151 emit reload(); 1232 else if ( msg == "flush()" ) {
1152 } else if ( msg == "setDocument(QString)" ) { 1233 emit flush();
1153 d->keep_running = TRUE; 1234 // we need to tell the desktop
1154 QDataStream stream( data, IO_ReadOnly ); 1235 QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" );
1155 QString doc; 1236 e << d->appName;
1156 stream >> doc; 1237 }
1157 QWidget *mw = mainWidget(); 1238 else if ( msg == "reload()" ) {
1158 if ( !mw ) 1239 emit reload();
1159 mw = d->qpe_main_widget; 1240 }
1160 if ( mw ) 1241 else if ( msg == "setDocument(QString)" ) {
1161 Global::setDocument( mw, doc ); 1242 d->keep_running = TRUE;
1162 } else if ( msg == "nextView()" ) { 1243 QDataStream stream( data, IO_ReadOnly );
1163 if ( raiseAppropriateWindow() ) 1244 QString doc;
1164 emit appMessage( msg, data); 1245 stream >> doc;
1165 } else { 1246 QWidget *mw = mainWidget();
1166 emit appMessage( msg, data); 1247 if ( !mw )
1167 } 1248 mw = d->qpe_main_widget;
1249 if ( mw )
1250 Global::setDocument( mw, doc );
1251 }
1252 else if ( msg == "nextView()" ) {
1253 if ( raiseAppropriateWindow() )
1254 emit appMessage( msg, data );
1255 }
1256 else {
1257 emit appMessage( msg, data );
1258 }
1168#endif 1259#endif
1169} 1260}
@@ -1172,23 +1263,23 @@ void QPEApplication::pidMessage( const QCString &msg, const QByteArray & data)
1172static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) 1263static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ )
1173{ 1264{
1174/* 1265 /*
1175 // This works but disable it for now until it is safe to apply 1266 // This works but disable it for now until it is safe to apply
1176 // What is does is scan the .desktop files of all the apps for 1267 // What is does is scan the .desktop files of all the apps for
1177 // the applnk that has the corresponding argv[0] as this program 1268 // the applnk that has the corresponding argv[0] as this program
1178 // then it uses the name stored in the .desktop file as the caption 1269 // then it uses the name stored in the .desktop file as the caption
1179 // for the main widget. This saves duplicating translations for 1270 // for the main widget. This saves duplicating translations for
1180 // the app name in the program and in the .desktop files. 1271 // the app name in the program and in the .desktop files.
1181 1272
1182 AppLnkSet apps( appsPath ); 1273 AppLnkSet apps( appsPath );
1183 1274
1184 QList<AppLnk> appsList = apps.children(); 1275 QList<AppLnk> appsList = apps.children();
1185 for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { 1276 for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) {
1186 if ( (*it)->exec() == appName ) { 1277 if ( (*it)->exec() == appName ) {
1187 mw->setCaption( (*it)->name() ); 1278 mw->setCaption( (*it)->name() );
1188 return TRUE; 1279 return TRUE;
1189 } 1280 }
1190 } 1281 }
1191*/ 1282 */
1192 return FALSE; 1283 return FALSE;
1193} 1284}
1194 1285
@@ -1197,31 +1288,34 @@ static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appNa
1197 Sets \a mw as the mainWidget() and shows it. For small windows, 1288 Sets \a mw as the mainWidget() and shows it. For small windows,
1198 consider passing TRUE for \a nomaximize rather than the default FALSE. 1289 consider passing TRUE for \a nomaximize rather than the default FALSE.
1199 1290
1200 \sa showMainDocumentWidget() 1291 \sa showMainDocumentWidget()
1201*/ 1292*/
1202void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize ) 1293void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize )
1203{ 1294{
1204 setWidgetCaptionFromAppName( mw, d->appName, qpeDir() + "apps" ); 1295 setWidgetCaptionFromAppName( mw, d->appName, qpeDir() + "apps" );
1205 1296
1206 d->nomaximize = nomaximize; 1297 d->nomaximize = nomaximize;
1207 d->qpe_main_widget = mw; 1298 d->qpe_main_widget = mw;
1208 d->sendQCopQ(); 1299 d->sendQCopQ();
1209 if ( d->preloaded ) { 1300 if ( d->preloaded ) {
1210 if(d->forceshow) { 1301 if ( d->forceshow ) {
1211#ifdef Q_WS_QWS 1302#ifdef Q_WS_QWS
1212 if ( !nomaximize ) 1303 if ( !nomaximize )
1213 mw->showMaximized(); 1304 mw->showMaximized();
1214 else 1305 else
1215#endif 1306#endif
1216 mw->show(); 1307
1217 } 1308 mw->show();
1218 } else if ( d->keep_running ) { 1309 }
1310 }
1311 else if ( d->keep_running ) {
1219#ifdef Q_WS_QWS 1312#ifdef Q_WS_QWS
1220 if ( !nomaximize ) 1313 if ( !nomaximize )
1221 mw->showMaximized(); 1314 mw->showMaximized();
1222 else 1315 else
1223#endif 1316#endif
1224 mw->show(); 1317
1225 } 1318 mw->show();
1319 }
1226} 1320}
1227 1321
@@ -1229,38 +1323,41 @@ void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize )
1229 Sets \a mw as the mainWidget() and shows it. For small windows, 1323 Sets \a mw as the mainWidget() and shows it. For small windows,
1230 consider passing TRUE for \a nomaximize rather than the default FALSE. 1324 consider passing TRUE for \a nomaximize rather than the default FALSE.
1231 1325
1232 This calls designates the application as 1326 This calls designates the application as
1233 a \link docwidget.html document-oriented\endlink application. 1327 a \link docwidget.html document-oriented\endlink application.
1234 1328
1235 The \a mw widget must have a slot: setDocument(const QString&). 1329 The \a mw widget must have a slot: setDocument(const QString&).
1236 1330
1237 \sa showMainWidget() 1331 \sa showMainWidget()
1238*/ 1332*/
1239void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize ) 1333void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize )
1240{ 1334{
1241 setWidgetCaptionFromAppName( mw, d->appName, qpeDir() + "apps" ); 1335 setWidgetCaptionFromAppName( mw, d->appName, qpeDir() + "apps" );
1242 1336
1243 if ( mw && argc() == 2 ) 1337 if ( mw && argc() == 2 )
1244 Global::setDocument( mw, QString::fromUtf8(argv()[1]) ); 1338 Global::setDocument( mw, QString::fromUtf8( argv() [ 1 ] ) );
1245 d->nomaximize = nomaximize; 1339 d->nomaximize = nomaximize;
1246 d->qpe_main_widget = mw; 1340 d->qpe_main_widget = mw;
1247 d->sendQCopQ(); 1341 d->sendQCopQ();
1248 if ( d->preloaded ) { 1342 if ( d->preloaded ) {
1249 if(d->forceshow) { 1343 if ( d->forceshow ) {
1250#ifdef Q_WS_QWS 1344#ifdef Q_WS_QWS
1251 if ( !nomaximize ) 1345 if ( !nomaximize )
1252 mw->showMaximized(); 1346 mw->showMaximized();
1253 else 1347 else
1254#endif 1348#endif
1255 mw->show(); 1349
1256 } 1350 mw->show();
1257 } else if ( d->keep_running ) { 1351 }
1352 }
1353 else if ( d->keep_running ) {
1258#ifdef Q_WS_QWS 1354#ifdef Q_WS_QWS
1259 if ( !nomaximize ) 1355 if ( !nomaximize )
1260 mw->showMaximized(); 1356 mw->showMaximized();
1261 else 1357 else
1262#endif 1358#endif
1263 mw->show(); 1359
1264 } 1360 mw->show();
1361 }
1265} 1362}
1266 1363
@@ -1272,13 +1369,13 @@ void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize )
1272 processing the qcop message it calls this function, then the application 1369 processing the qcop message it calls this function, then the application
1273 will show and start proper once it has finished processing qcop messages. 1370 will show and start proper once it has finished processing qcop messages.
1274 1371
1275 \sa keepRunning() 1372 \sa keepRunning()
1276*/ 1373*/
1277void QPEApplication::setKeepRunning() 1374void QPEApplication::setKeepRunning()
1278{ 1375{
1279 if ( qApp && qApp->inherits( "QPEApplication" ) ) { 1376 if ( qApp && qApp->inherits( "QPEApplication" ) ) {
1280 QPEApplication *qpeApp = (QPEApplication*)qApp; 1377 QPEApplication * qpeApp = ( QPEApplication* ) qApp;
1281 qpeApp->d->keep_running = TRUE; 1378 qpeApp->d->keep_running = TRUE;
1282 } 1379 }
1283} 1380}
1284 1381
@@ -1286,10 +1383,10 @@ void QPEApplication::setKeepRunning()
1286 Returns whether the application will quit after processing the current 1383 Returns whether the application will quit after processing the current
1287 list of qcop messages. 1384 list of qcop messages.
1288 1385
1289 \sa setKeepRunning() 1386 \sa setKeepRunning()
1290*/ 1387*/
1291bool QPEApplication::keepRunning() const 1388bool QPEApplication::keepRunning() const
1292{ 1389{
1293 return d->keep_running; 1390 return d->keep_running;
1294} 1391}
1295 1392
@@ -1300,81 +1397,118 @@ void QPEApplication::internalSetStyle( const QString &style )
1300{ 1397{
1301#if QT_VERSION >= 300 1398#if QT_VERSION >= 300
1302 if ( style == "QPE" ) { 1399 if ( style == "QPE" ) {
1303 setStyle( new QPEStyle ); 1400 setStyle( new QPEStyle );
1304 } else { 1401 }
1305 QStyle *s = QStyleFactory::create(style); 1402 else {
1306 if ( s ) setStyle(s); 1403 QStyle *s = QStyleFactory::create( style );
1307 } 1404 if ( s )
1405 setStyle( s );
1406 }
1308#else 1407#else
1309 if ( style == "Windows" ) { 1408 if ( style == "Windows" ) {
1310 setStyle( new QWindowsStyle ); 1409 setStyle( new QWindowsStyle );
1311 } else if ( style == "QPE" ) { 1410 }
1312 setStyle( new QPEStyle ); 1411 else if ( style == "QPE" ) {
1313 } else if ( style == "Light" ) { 1412 setStyle( new QPEStyle );
1314 setStyle( new LightStyle ); 1413 }
1315 } 1414 else if ( style == "Light" ) {
1415 setStyle( new LightStyle );
1416 }
1316#ifndef QT_NO_STYLE_PLATINUM 1417#ifndef QT_NO_STYLE_PLATINUM
1317 else if ( style == "Platinum" ) { 1418 else if ( style == "Platinum" ) {
1318 setStyle( new QPlatinumStyle ); 1419 setStyle( new QPlatinumStyle );
1319 } 1420 }
1320#endif 1421#endif
1321#ifndef QT_NO_STYLE_MOTIF 1422#ifndef QT_NO_STYLE_MOTIF
1322 else if ( style == "Motif" ) { 1423 else if ( style == "Motif" ) {
1323 setStyle( new QMotifStyle ); 1424 setStyle( new QMotifStyle );
1324 } 1425 }
1325#endif 1426#endif
1326#ifndef QT_NO_STYLE_MOTIFPLUS 1427#ifndef QT_NO_STYLE_MOTIFPLUS
1327 else if ( style == "MotifPlus" ) { 1428 else if ( style == "MotifPlus" ) {
1328 setStyle( new QMotifPlusStyle ); 1429 setStyle( new QMotifPlusStyle );
1329 } 1430 }
1330#endif 1431#endif
1331 1432
1332 // HACK for Qt2 only 1433 // HACK for Qt2 only
1333 else { 1434 else {
1435 QStyle *sty = 0;
1436 QString path = QPEApplication::qpeDir ( ) + "/plugins/styles/lib" + style. lower ( ) + ".so";
1437
1438 static QLibrary *lastlib = 0;
1439 static StyleInterface *lastiface = 0;
1440
1441 QLibrary *lib = new QLibrary ( path );
1442 StyleInterface *iface = 0;
1443
1444 if ( lib-> queryInterface ( IID_Style, ( QUnknownInterface ** ) &iface ) == QS_OK )
1445 sty = iface-> create ( );
1446
1447 if ( sty ) {
1448 setStyle ( sty );
1449
1450 qDebug ( "Got Style: %p -- iface: %p, lib: %p\n", sty, iface, lib );
1451
1452 if ( lastiface )
1453 lastiface-> release ( );
1454 lastiface = iface;
1455
1456
1457 if ( lastlib ) {
1458 lastlib-> unload ( );
1459 delete lastlib;
1460 }
1461 lastlib = lib;
1462 }
1463 else {
1464 if ( iface )
1465 iface-> release ( );
1466 delete lib;
1467
1468 setStyle ( new QPEStyle ( ));
1469 }
1470
1471#if 0
1334 // style == "Liquid Style (libliquid.so)" (or "Windows XP (libxp.so)" 1472 // style == "Liquid Style (libliquid.so)" (or "Windows XP (libxp.so)"
1335 1473
1336 int p2 = style. findRev ( ']' ); 1474 int p2 = style. findRev ( ']' );
1337 int p1 = style. findRev ( '[' ); 1475 int p1 = style. findRev ( '[' );
1338 QString style2; 1476 QString style2;
1339 1477
1340 if (( p1 > 0 ) && ( p2 > 0 ) && (( p1 + 1 ) < p2 )) 1478 if ( ( p1 > 0 ) && ( p2 > 0 ) && ( ( p1 + 1 ) < p2 ) )
1341 style2 = "lib" + style. mid ( p1 + 1, p2 - p1 - 1 ). lower ( ) + ".so"; 1479 style2 = "lib" + style. mid ( p1 + 1, p2 - p1 - 1 ). lower ( ) + ".so";
1342 else 1480 else
1343 style2 = "lib" + style. lower ( ) + ".so"; 1481 style2 = "lib" + style. lower ( ) + ".so";
1344 1482
1345 // static QLibrary *currentlib = 0; 1483 static QLibrary *currentlib = 0;
1346 static void *currentlib = 0;
1347 1484
1348 QString path = QPEApplication::qpeDir ( ) + "/plugins/styles/" + style2; 1485 QString path = QPEApplication::qpeDir ( ) + "/plugins/styles/" + style2;
1349 1486
1350 do { // try/catch simulation 1487 do { // try/catch simulation
1351 // QLibrary *lib = new QLibrary ( path, QLibrary::Immediately ); 1488 QLibrary *lib = new QLibrary ( path, QLibrary::Immediately );
1352 void *lib = ::dlopen ( path. local8Bit ( ), RTLD_LAZY | RTLD_GLOBAL ); 1489
1353
1354 if ( lib ) { 1490 if ( lib ) {
1355 //QStyle * (*fpa) ( ) = (QStyle * (*) ( )) lib-> resolve ( "allocate" ); 1491 QStyle * ( *fpa ) ( ) = ( QStyle * ( * ) ( ) ) lib-> resolve ( "allocate" );
1356 QStyle * (*fpa) ( ) = (QStyle * (*) ( )) ::dlsym ( lib, "allocate" );
1357 1492
1358 if ( fpa ) { 1493 if ( fpa ) {
1359 QStyle *sty = ( *fpa ) ( ); 1494 QStyle * sty = ( *fpa ) ( );
1360 1495
1361 if ( sty ) { 1496 if ( sty ) {
1362 setStyle ( sty ); 1497 setStyle ( sty );
1363 1498
1364 if ( currentlib ) { 1499 if ( currentlib )
1365 //delete currentlib; 1500 delete currentlib;
1366 ::dlclose ( currentlib );
1367 }
1368 currentlib = lib; 1501 currentlib = lib;
1369 1502
1370 break; 1503 break;
1371 } 1504 }
1372 } 1505 }
1373 //delete lib; 1506 delete lib;
1374 ::dlclose ( lib );
1375 } 1507 }
1376 } while ( false ); 1508 }
1509 while ( false );
1510 // HACK for Qt2 only
1511#endif
1377 } 1512 }
1378 // HACK for Qt2 only
1379#endif 1513#endif
1380} 1514}
@@ -1383,23 +1517,24 @@ void QPEApplication::internalSetStyle( const QString &style )
1383 \internal 1517 \internal
1384*/ 1518*/
1385void QPEApplication::prepareForTermination(bool willrestart) 1519void QPEApplication::prepareForTermination( bool willrestart )
1386{ 1520{
1387 if ( willrestart ) { 1521 if ( willrestart ) {
1388 // Draw a big wait icon, the image can be altered in later revisions 1522 // Draw a big wait icon, the image can be altered in later revisions
1389// QWidget *d = QApplication::desktop(); 1523 // QWidget *d = QApplication::desktop();
1390 QImage img = Resource::loadImage( "launcher/new_wait" ); 1524 QImage img = Resource::loadImage( "launcher/new_wait" );
1391 QPixmap pix; 1525 QPixmap pix;
1392 pix.convertFromImage(img.smoothScale(1*img.width(), 1*img.height())); 1526 pix.convertFromImage( img.smoothScale( 1 * img.width(), 1 * img.height() ) );
1393 QLabel *lblWait = new QLabel(0, "wait hack!", QWidget::WStyle_Customize | 1527 QLabel *lblWait = new QLabel( 0, "wait hack!", QWidget::WStyle_Customize |
1394 QWidget::WStyle_NoBorder | QWidget::WStyle_Tool ); 1528 QWidget::WStyle_NoBorder | QWidget::WStyle_Tool );
1395 lblWait->setPixmap( pix ); 1529 lblWait->setPixmap( pix );
1396 lblWait->setAlignment( QWidget::AlignCenter ); 1530 lblWait->setAlignment( QWidget::AlignCenter );
1397 lblWait->show(); 1531 lblWait->show();
1398 lblWait->showMaximized(); 1532 lblWait->showMaximized();
1399 } 1533 }
1400#ifndef SINGLE_APP 1534#ifndef SINGLE_APP
1401 { QCopEnvelope envelope("QPE/System", "forceQuit()"); } 1535 { QCopEnvelope envelope( "QPE/System", "forceQuit()" );
1402 processEvents(); // ensure the message goes out. 1536 }
1403 sleep(1); // You have 1 second to comply. 1537 processEvents(); // ensure the message goes out.
1538 sleep( 1 ); // You have 1 second to comply.
1404#endif 1539#endif
1405} 1540}
@@ -1410,5 +1545,5 @@ void QPEApplication::prepareForTermination(bool willrestart)
1410void QPEApplication::shutdown() 1545void QPEApplication::shutdown()
1411{ 1546{
1412 // Implement in server's QPEApplication subclass 1547 // Implement in server's QPEApplication subclass
1413} 1548}
1414 1549
@@ -1418,34 +1553,34 @@ void QPEApplication::shutdown()
1418void QPEApplication::restart() 1553void QPEApplication::restart()
1419{ 1554{
1420 // Implement in server's QPEApplication subclass 1555 // Implement in server's QPEApplication subclass
1421} 1556}
1422 1557
1423static QPtrDict<void>* stylusDict=0; 1558static QPtrDict<void>* stylusDict = 0;
1424static void createDict() 1559static void createDict()
1425{ 1560{
1426 if ( !stylusDict ) 1561 if ( !stylusDict )
1427 stylusDict = new QPtrDict<void>; 1562 stylusDict = new QPtrDict<void>;
1428} 1563}
1429 1564
1430/*! 1565/*!
1431 Returns the current StylusMode for \a w. 1566 Returns the current StylusMode for \a w.
1432 1567
1433 \sa setStylusOperation() 1568 \sa setStylusOperation()
1434*/ 1569*/
1435QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w ) 1570QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget * w )
1436{ 1571{
1437 if ( stylusDict ) 1572 if ( stylusDict )
1438 return (StylusMode)(int)stylusDict->find(w); 1573 return ( StylusMode ) ( int ) stylusDict->find( w );
1439 return LeftOnly; 1574 return LeftOnly;
1440} 1575}
1441 1576
1442/*! 1577/*!
1443 \enum QPEApplication::StylusMode 1578 \enum QPEApplication::StylusMode
1444 1579
1445 \value LeftOnly the stylus only generates LeftButton 1580 \value LeftOnly the stylus only generates LeftButton
1446 events (the default). 1581 events (the default).
1447 \value RightOnHold the stylus generates RightButton events 1582 \value RightOnHold the stylus generates RightButton events
1448 if the user uses the press-and-hold gesture. 1583 if the user uses the press-and-hold gesture.
1449 1584
1450 See setStylusOperation(). 1585 See setStylusOperation().
1451*/ 1586*/
@@ -1453,18 +1588,20 @@ QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w )
1453/*! 1588/*!
1454 Causes \a w to receive mouse events according to \a mode. 1589 Causes \a w to receive mouse events according to \a mode.
1455 1590
1456 \sa stylusOperation() 1591 \sa stylusOperation()
1457*/ 1592*/
1458void QPEApplication::setStylusOperation( QWidget* w, StylusMode mode ) 1593void QPEApplication::setStylusOperation( QWidget * w, StylusMode mode )
1459{ 1594{
1460 createDict(); 1595 createDict();
1461 if ( mode == LeftOnly ) { 1596 if ( mode == LeftOnly ) {
1462 stylusDict->remove(w); 1597 stylusDict->remove
1463 w->removeEventFilter(qApp); 1598 ( w );
1464 } else { 1599 w->removeEventFilter( qApp );
1465 stylusDict->insert(w,(void*)mode); 1600 }
1466 connect(w,SIGNAL(destroyed()),qApp,SLOT(removeSenderFromStylusDict())); 1601 else {
1467 w->installEventFilter(qApp); 1602 stylusDict->insert( w, ( void* ) mode );
1468 } 1603 connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) );
1604 w->installEventFilter( qApp );
1605 }
1469} 1606}
1470 1607
@@ -1475,58 +1612,59 @@ void QPEApplication::setStylusOperation( QWidget* w, StylusMode mode )
1475bool QPEApplication::eventFilter( QObject *o, QEvent *e ) 1612bool QPEApplication::eventFilter( QObject *o, QEvent *e )
1476{ 1613{
1477 if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) { 1614 if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) {
1478 QMouseEvent* me = (QMouseEvent*)e; 1615 QMouseEvent * me = ( QMouseEvent* ) e;
1479 if ( me->button() == LeftButton ) { 1616 if ( me->button() == LeftButton ) {
1480 StylusMode mode = (StylusMode)(int)stylusDict->find(o); 1617 StylusMode mode = ( StylusMode ) ( int ) stylusDict->find( o );
1481 switch (mode) { 1618 switch ( mode ) {
1482 case RightOnHold: 1619 case RightOnHold:
1483 switch ( me->type() ) { 1620 switch ( me->type() ) {
1484 case QEvent::MouseButtonPress: 1621 case QEvent::MouseButtonPress:
1485 d->presstimer = startTimer(500); // #### pref. 1622 d->presstimer = startTimer( 500 ); // #### pref.
1486 d->presswidget = (QWidget*)o; 1623 d->presswidget = ( QWidget* ) o;
1487 d->presspos = me->pos(); 1624 d->presspos = me->pos();
1488 d->rightpressed = FALSE; 1625 d->rightpressed = FALSE;
1489 break; 1626 break;
1490 case QEvent::MouseButtonRelease: 1627 case QEvent::MouseButtonRelease:
1491 if ( d->presstimer ) { 1628 if ( d->presstimer ) {
1492 killTimer(d->presstimer); 1629 killTimer( d->presstimer );
1493 d->presstimer = 0; 1630 d->presstimer = 0;
1494 } 1631 }
1495 if ( d->rightpressed && d->presswidget ) { 1632 if ( d->rightpressed && d->presswidget ) {
1496 // Right released 1633 // Right released
1497 postEvent( d->presswidget, 1634 postEvent( d->presswidget,
1498 new QMouseEvent( QEvent::MouseButtonRelease, me->pos(), 1635 new QMouseEvent( QEvent::MouseButtonRelease, me->pos(),
1499 RightButton, LeftButton+RightButton ) ); 1636 RightButton, LeftButton + RightButton ) );
1500 // Left released, off-widget 1637 // Left released, off-widget
1501 postEvent( d->presswidget, 1638 postEvent( d->presswidget,
1502 new QMouseEvent( QEvent::MouseMove, QPoint(-1,-1), 1639 new QMouseEvent( QEvent::MouseMove, QPoint( -1, -1 ),
1503 LeftButton, LeftButton ) ); 1640 LeftButton, LeftButton ) );
1504 postEvent( d->presswidget, 1641 postEvent( d->presswidget,
1505 new QMouseEvent( QEvent::MouseButtonRelease, QPoint(-1,-1), 1642 new QMouseEvent( QEvent::MouseButtonRelease, QPoint( -1, -1 ),
1506 LeftButton, LeftButton ) ); 1643 LeftButton, LeftButton ) );
1507 d->rightpressed = FALSE; 1644 d->rightpressed = FALSE;
1508 return TRUE; // don't send the real Left release 1645 return TRUE; // don't send the real Left release
1509 } 1646 }
1510 break; 1647 break;
1511 default: 1648 default:
1512 break; 1649 break;
1513 } 1650 }
1514 break; 1651 break;
1515 default: 1652 default:
1516 ; 1653 ;
1517 } 1654 }
1518 } 1655 }
1519 } else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { 1656 }
1520 QKeyEvent *ke = (QKeyEvent *)e; 1657 else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) {
1521 if ( ke->key() == Key_Enter ) { 1658 QKeyEvent * ke = ( QKeyEvent * ) e;
1522 if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) { 1659 if ( ke->key() == Key_Enter ) {
1523 postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ', 1660 if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) {
1524 ke->state(), " ", ke->isAutoRepeat(), ke->count() ) ); 1661 postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ',
1525 return TRUE; 1662 ke->state(), " ", ke->isAutoRepeat(), ke->count() ) );
1526 } 1663 return TRUE;
1527 } 1664 }
1528 } 1665 }
1666 }
1529 1667
1530 return FALSE; 1668 return FALSE;
1531} 1669}
1532 1670
@@ -1536,20 +1674,21 @@ bool QPEApplication::eventFilter( QObject *o, QEvent *e )
1536void QPEApplication::timerEvent( QTimerEvent *e ) 1674void QPEApplication::timerEvent( QTimerEvent *e )
1537{ 1675{
1538 if ( e->timerId() == d->presstimer && d->presswidget ) { 1676 if ( e->timerId() == d->presstimer && d->presswidget ) {
1539 // Right pressed 1677 // Right pressed
1540 postEvent( d->presswidget, 1678 postEvent( d->presswidget,
1541 new QMouseEvent( QEvent::MouseButtonPress, d->presspos, 1679 new QMouseEvent( QEvent::MouseButtonPress, d->presspos,
1542 RightButton, LeftButton ) ); 1680 RightButton, LeftButton ) );
1543 killTimer( d->presstimer ); 1681 killTimer( d->presstimer );
1544 d->presstimer = 0; 1682 d->presstimer = 0;
1545 d->rightpressed = TRUE; 1683 d->rightpressed = TRUE;
1546 } 1684 }
1547} 1685}
1548 1686
1549void QPEApplication::removeSenderFromStylusDict() 1687void QPEApplication::removeSenderFromStylusDict()
1550{ 1688{
1551 stylusDict->remove((void*)sender()); 1689 stylusDict->remove
1552 if ( d->presswidget == sender() ) 1690 ( ( void* ) sender() );
1553 d->presswidget = 0; 1691 if ( d->presswidget == sender() )
1692 d->presswidget = 0;
1554} 1693}
1555 1694
@@ -1559,5 +1698,5 @@ void QPEApplication::removeSenderFromStylusDict()
1559bool QPEApplication::keyboardGrabbed() const 1698bool QPEApplication::keyboardGrabbed() const
1560{ 1699{
1561 return d->kbgrabber; 1700 return d->kbgrabber;
1562} 1701}
1563 1702
@@ -1569,11 +1708,11 @@ bool QPEApplication::keyboardGrabbed() const
1569void QPEApplication::ungrabKeyboard() 1708void QPEApplication::ungrabKeyboard()
1570{ 1709{
1571 QPEApplicationData* d = ((QPEApplication*)qApp)->d; 1710 QPEApplicationData * d = ( ( QPEApplication* ) qApp ) ->d;
1572 if ( d->kbgrabber == 2 ) { 1711 if ( d->kbgrabber == 2 ) {
1573 QCopEnvelope e("QPE/System", "grabKeyboard(QString)" ); 1712 QCopEnvelope e( "QPE/System", "grabKeyboard(QString)" );
1574 e << QString::null; 1713 e << QString::null;
1575 d->kbregrab = FALSE; 1714 d->kbregrab = FALSE;
1576 d->kbgrabber = 0; 1715 d->kbgrabber = 0;
1577 } 1716 }
1578} 1717}
1579 1718
@@ -1582,17 +1721,17 @@ void QPEApplication::ungrabKeyboard()
1582 keys no longer work, and instead they are receivable by this 1721 keys no longer work, and instead they are receivable by this
1583 application. 1722 application.
1584 1723
1585 \sa ungrabKeyboard() 1724 \sa ungrabKeyboard()
1586*/ 1725*/
1587void QPEApplication::grabKeyboard() 1726void QPEApplication::grabKeyboard()
1588{ 1727{
1589 QPEApplicationData* d = ((QPEApplication*)qApp)->d; 1728 QPEApplicationData * d = ( ( QPEApplication* ) qApp ) ->d;
1590 if ( qApp->type() == QApplication::GuiServer ) 1729 if ( qApp->type() == QApplication::GuiServer )
1591 d->kbgrabber = 0; 1730 d->kbgrabber = 0;
1592 else { 1731 else {
1593 QCopEnvelope e("QPE/System", "grabKeyboard(QString)" ); 1732 QCopEnvelope e( "QPE/System", "grabKeyboard(QString)" );
1594 e << d->appName; 1733 e << d->appName;
1595 d->kbgrabber = 2; // me 1734 d->kbgrabber = 2; // me
1596 } 1735 }
1597} 1736}
1598 1737
@@ -1602,15 +1741,15 @@ void QPEApplication::grabKeyboard()
1602int QPEApplication::exec() 1741int QPEApplication::exec()
1603{ 1742{
1604 d->sendQCopQ(); 1743 d->sendQCopQ();
1605 if ( d->keep_running) 1744 if ( d->keep_running )
1606 //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() ) 1745 //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() )
1607 return QApplication::exec(); 1746 return QApplication::exec();
1608 1747
1609 { 1748 {
1610 QCopEnvelope e("QPE/System", "closing(QString)" ); 1749 QCopEnvelope e( "QPE/System", "closing(QString)" );
1611 e << d->appName; 1750 e << d->appName;
1612 } 1751 }
1613 processEvents(); 1752 processEvents();
1614 return 0; 1753 return 0;
1615} 1754}
1616 1755
@@ -1622,13 +1761,13 @@ int QPEApplication::exec()
1622void QPEApplication::tryQuit() 1761void QPEApplication::tryQuit()
1623{ 1762{
1624 if ( activeModalWidget() || strcmp( argv()[0], "embeddedkonsole") == 0 ) 1763 if ( activeModalWidget() || strcmp( argv() [ 0 ], "embeddedkonsole" ) == 0 )
1625 return; // Inside modal loop or konsole. Too hard to save state. 1764 return ; // Inside modal loop or konsole. Too hard to save state.
1626 { 1765 {
1627 QCopEnvelope e("QPE/System", "closing(QString)" ); 1766 QCopEnvelope e( "QPE/System", "closing(QString)" );
1628 e << d->appName; 1767 e << d->appName;
1629 } 1768 }
1630 processEvents(); 1769 processEvents();
1631 1770
1632 quit(); 1771 quit();
1633} 1772}
1634 1773
@@ -1641,14 +1780,14 @@ void QPEApplication::tryQuit()
1641void QPEApplication::hideOrQuit() 1780void QPEApplication::hideOrQuit()
1642{ 1781{
1643 // notify of our demise :) 1782 // notify of our demise :)
1644 { 1783 {
1645 QCopEnvelope e("QPE/System", "closing(QString)" ); 1784 QCopEnvelope e( "QPE/System", "closing(QString)" );
1646 e << d->appName; 1785 e << d->appName;
1647 } 1786 }
1648 processEvents(); 1787 processEvents();
1649 if ( d->preloaded && d->qpe_main_widget ) 1788 if ( d->preloaded && d->qpe_main_widget )
1650 d->qpe_main_widget->hide(); 1789 d->qpe_main_widget->hide();
1651 else 1790 else
1652 quit(); 1791 quit();
1653} 1792}
1654 1793
@@ -1660,32 +1799,32 @@ void QPEApplication::hideOrQuit()
1660// functions. 1799// functions.
1661 1800
1662void* operator new[](size_t size) 1801void* operator new[] ( size_t size )
1663{ 1802{
1664 return malloc(size); 1803 return malloc( size );
1665} 1804}
1666 1805
1667void* operator new(size_t size) 1806void* operator new( size_t size )
1668{ 1807{
1669 return malloc(size); 1808 return malloc( size );
1670} 1809}
1671 1810
1672void operator delete[](void* p) 1811void operator delete[] ( void* p )
1673{ 1812{
1674 free(p); 1813 free( p );
1675} 1814}
1676 1815
1677void operator delete[](void* p, size_t /*size*/) 1816void operator delete[] ( void* p, size_t /*size*/ )
1678{ 1817{
1679 free(p); 1818 free( p );
1680} 1819}
1681 1820
1682void operator delete(void* p) 1821void operator delete( void* p )
1683{ 1822{
1684 free(p); 1823 free( p );
1685} 1824}
1686 1825
1687void operator delete(void* p, size_t /*size*/) 1826void operator delete( void* p, size_t /*size*/ )
1688{ 1827{
1689 free(p); 1828 free( p );
1690} 1829}
1691 1830
@@ -1696,21 +1835,20 @@ void operator delete(void* p, size_t /*size*/)
1696#include <qgfx_qws.h> 1835#include <qgfx_qws.h>
1697extern QRect qt_maxWindowRect; 1836extern QRect qt_maxWindowRect;
1698void qt_setMaxWindowRect(const QRect& r) 1837void qt_setMaxWindowRect( const QRect & r )
1699{ 1838{
1700 qt_maxWindowRect = qt_screen->mapFromDevice(r, 1839 qt_maxWindowRect = qt_screen->mapFromDevice( r,
1701 qt_screen->mapToDevice(QSize(qt_screen->width(),qt_screen->height()))); 1840 qt_screen->mapToDevice( QSize( qt_screen->width(), qt_screen->height() ) ) );
1702 // Re-resize any maximized windows 1841 // Re-resize any maximized windows
1703 QWidgetList* l = QApplication::topLevelWidgets(); 1842 QWidgetList* l = QApplication::topLevelWidgets();
1704 if ( l ) { 1843 if ( l ) {
1705 QWidget *w = l->first(); 1844 QWidget * w = l->first();
1706 while ( w ) { 1845 while ( w ) {
1707 if ( w->isVisible() && w->isMaximized() ) 1846 if ( w->isVisible() && w->isMaximized() ) {
1708 { 1847 w->showMaximized();
1709 w->showMaximized(); 1848 }
1710 } 1849 w = l->next();
1711 w = l->next(); 1850 }
1712 } 1851 delete l;
1713 delete l; 1852 }
1714 }
1715} 1853}
1716#endif 1854#endif
diff --git a/library/styleinterface.h b/library/styleinterface.h
new file mode 100644
index 0000000..9fea636
--- a/dev/null
+++ b/library/styleinterface.h
@@ -0,0 +1,68 @@
1/**********************************************************************
2** Copyright (C) 2002 Robert Griebl. All rights reserved.
3**
4** This file is part of OPIE (http://www.opie.info).
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13**
14**********************************************************************/
15
16#ifndef STYLEINTERFACE_H
17#define STYLEINTERFACE_H
18
19#include <qpe/qcom.h>
20
21#ifndef QT_NO_COMPONENT
22
23// {6C33B4F9-D529-453A-8FB3-DA42B21872BD}
24# ifndef IID_Style
25# define IID_Style QUuid( 0x6c33b4f9, 0xd529, 0x453a, 0x8f, 0xb3, 0xda, 0x42, 0xb2, 0x18, 0x72, 0xbd)
26#endif
27
28// {9757A252-3FD4-438F-A756-80BE4A9FB8DC}
29# ifndef IID_StyleSettings
30# define IID_StyleSettings QUuid( 0x9757a252, 0x3fd4, 0x438f, 0xa7, 0x56, 0x80, 0xbe, 0x4a, 0x9f, 0xb8, 0xdc)
31# endif
32
33#endif
34
35class QWidget;
36class QStyle;
37
38struct StyleInterface : public QUnknownInterface
39{
40 //! Return a new style.
41 virtual QStyle *create ( ) = 0;
42
43 //! Return a (longer) description for the style.
44 virtual QString description ( ) = 0;
45
46 //! Return a short name for the style.
47 virtual QString name ( ) = 0;
48
49 //! Return the library basename (libliquid.so => liquid)
50 virtual QCString key ( ) = 0;
51
52 //! QT_VERSION like 1.2.3 == 123
53 virtual unsigned int version ( ) = 0;
54};
55
56struct StyleSettingsInterface : public QUnknownInterface
57{
58 //! Return a new settings page.
59 virtual QWidget *create ( QWidget *parent, const char *name = 0 ) = 0;
60
61 //! Callback for appearance app when OK is clicked (return true when style has to re-applied).
62 virtual bool accept ( ) = 0;
63
64 //! Callback for appeaeance app when Cancel is clicked.
65 virtual void reject ( ) = 0;
66};
67
68#endif
diff --git a/noncore/styles/liquid/liquid.pro b/noncore/styles/liquid/liquid.pro
index 23dce09..a07eaf2 100644
--- a/noncore/styles/liquid/liquid.pro
+++ b/noncore/styles/liquid/liquid.pro
@@ -4,9 +4,13 @@ SOURCES = liquid.cpp \
4 liquiddeco.cpp \ 4 liquiddeco.cpp \
5 effects.cpp \ 5 effects.cpp \
6 liquidset.cpp \
6 plugin.cpp 7 plugin.cpp
7 8
8HEADERS = liquid.h \ 9HEADERS = liquid.h \
9 liquiddeco.h \ 10 liquiddeco.h \
10 effects.h 11 effects.h \
12 liquidset.h \
13 plugin.h
14
11LIBS += -lqpe 15LIBS += -lqpe
12INCLUDEPATH += $(OPIEDIR)/include 16INCLUDEPATH += $(OPIEDIR)/include
diff --git a/noncore/styles/liquid/settings/liquidset.cpp b/noncore/styles/liquid/liquidset.cpp
index 1479ac0..5ae19ba 100644
--- a/noncore/styles/liquid/settings/liquidset.cpp
+++ b/noncore/styles/liquid/liquidset.cpp
@@ -22,5 +22,5 @@
22 22
23#include "liquidset.h" 23#include "liquidset.h"
24#include "../liquid.h" 24#include "liquid.h"
25 25
26#include <qpe/qpeapplication.h> 26#include <qpe/qpeapplication.h>
@@ -58,6 +58,6 @@ static void changeButtonColor ( QWidget *btn, const QColor &col )
58 58
59 59
60LiquidSet::LiquidSet ( QWidget* parent, const char *name, WFlags fl ) 60LiquidSettings::LiquidSettings ( QWidget* parent, const char *name, WFlags fl )
61 : QDialog ( parent, name, fl ) 61 : QWidget ( parent, name, fl )
62{ 62{
63 setCaption ( tr( "Liquid Style" ) ); 63 setCaption ( tr( "Liquid Style" ) );
@@ -123,5 +123,5 @@ LiquidSet::LiquidSet ( QWidget* parent, const char *name, WFlags fl )
123 QPopupMenu *popup; 123 QPopupMenu *popup;
124 124
125 popup = new ColorPopupMenu ( m_menucol, this ); 125 popup = new ColorPopupMenu ( m_menucol, 0 );
126 m_menubtn-> setPopup ( popup ); 126 m_menubtn-> setPopup ( popup );
127 m_menubtn-> setPopupDelay ( 0 ); 127 m_menubtn-> setPopupDelay ( 0 );
@@ -132,5 +132,5 @@ LiquidSet::LiquidSet ( QWidget* parent, const char *name, WFlags fl )
132 grid-> addWidget ( m_textbtn, 0, 5 ); 132 grid-> addWidget ( m_textbtn, 0, 5 );
133 133
134 popup = new ColorPopupMenu ( m_textcol, this ); 134 popup = new ColorPopupMenu ( m_textcol, 0 );
135 m_textbtn-> setPopup ( popup ); 135 m_textbtn-> setPopup ( popup );
136 m_textbtn-> setPopupDelay ( 0 ); 136 m_textbtn-> setPopupDelay ( 0 );
@@ -177,5 +177,5 @@ LiquidSet::LiquidSet ( QWidget* parent, const char *name, WFlags fl )
177} 177}
178 178
179void LiquidSet::changeType ( int t ) 179void LiquidSettings::changeType ( int t )
180{ 180{
181 bool custom = ( t == Custom ); 181 bool custom = ( t == Custom );
@@ -191,5 +191,5 @@ void LiquidSet::changeType ( int t )
191} 191}
192 192
193void LiquidSet::changeMenuColor ( const QColor &col ) 193void LiquidSettings::changeMenuColor ( const QColor &col )
194{ 194{
195 changeButtonColor ( m_menubtn, col ); 195 changeButtonColor ( m_menubtn, col );
@@ -197,5 +197,5 @@ void LiquidSet::changeMenuColor ( const QColor &col )
197} 197}
198 198
199void LiquidSet::changeTextColor ( const QColor &col ) 199void LiquidSettings::changeTextColor ( const QColor &col )
200{ 200{
201 changeButtonColor ( m_textbtn, col ); 201 changeButtonColor ( m_textbtn, col );
@@ -203,10 +203,10 @@ void LiquidSet::changeTextColor ( const QColor &col )
203} 203}
204 204
205void LiquidSet::changeShadow ( bool b ) 205void LiquidSettings::changeShadow ( bool b )
206{ 206{
207 m_shadow = b; 207 m_shadow = b;
208} 208}
209 209
210void LiquidSet::changeDeco ( bool b ) 210void LiquidSettings::changeDeco ( bool b )
211{ 211{
212 m_deco = b; 212 m_deco = b;
@@ -214,5 +214,5 @@ void LiquidSet::changeDeco ( bool b )
214 214
215 215
216void LiquidSet::accept ( ) 216bool LiquidSettings::writeConfig ( )
217{ 217{
218 Config config ( "qpe" ); 218 Config config ( "qpe" );
@@ -228,7 +228,5 @@ void LiquidSet::accept ( )
228 config. write ( ); 228 config. write ( );
229 229
230 Global::applyStyle ( ); 230 return true;
231
232 QDialog::accept ( );
233} 231}
234 232
diff --git a/noncore/styles/liquid/settings/liquidset.h b/noncore/styles/liquid/liquidset.h
index a0f590a..7843513 100644
--- a/noncore/styles/liquid/settings/liquidset.h
+++ b/noncore/styles/liquid/liquidset.h
@@ -9,9 +9,9 @@ class QToolButton;
9class QSlider; 9class QSlider;
10 10
11class LiquidSet : public QDialog { 11class LiquidSettings : public QWidget {
12 Q_OBJECT 12 Q_OBJECT
13 13
14public: 14public:
15 LiquidSet ( QWidget *parent = 0, const char *name = 0, WFlags fl = 0 ); 15 LiquidSettings ( QWidget *parent = 0, const char *name = 0, WFlags fl = 0 );
16 16
17public slots: 17public slots:
@@ -22,6 +22,5 @@ public slots:
22 void changeDeco ( bool b ); 22 void changeDeco ( bool b );
23 23
24protected: 24 virtual bool writeConfig ( );
25 virtual void accept ( );
26 25
27private: 26private:
diff --git a/noncore/styles/liquid/opie-liquid.control b/noncore/styles/liquid/opie-liquid.control
index 6311dee..7b6ae71 100644
--- a/noncore/styles/liquid/opie-liquid.control
+++ b/noncore/styles/liquid/opie-liquid.control
@@ -1,3 +1,3 @@
1Files: plugins/styles/libliquid.so* bin/liquid-settings apps/Settings/Liquid.desktop pics/liquid/Liquid.png 1Files: plugins/styles/libliquid.so*
2Priority: optional 2Priority: optional
3Section: opie/system 3Section: opie/system
diff --git a/noncore/styles/liquid/plugin.cpp b/noncore/styles/liquid/plugin.cpp
index d9aa8ef..f149c29 100644
--- a/noncore/styles/liquid/plugin.cpp
+++ b/noncore/styles/liquid/plugin.cpp
@@ -1,29 +1,111 @@
1#include "liquid.h" 1#include "liquid.h"
2#include "liquidset.h"
3#include "plugin.h"
2 4
3 5
4extern "C" { 6
5 QStyle* allocate ( ); 7LiquidInterface::LiquidInterface ( ) : ref ( 0 )
6 int minor_version ( ); 8{
7 int major_version ( ); 9}
8 const char *description ( ); 10
11LiquidInterface::~LiquidInterface ( )
12{
13}
14
15QStyle *LiquidInterface::create ( )
16{
17 return new LiquidStyle ( );
18}
19
20QString LiquidInterface::name ( )
21{
22 return QObject::tr( "Liquid", "name" );
23}
24
25QString LiquidInterface::description ( )
26{
27 return QObject::tr( "High Performance Liquid style by Mosfet", "description" );
28}
29
30QCString LiquidInterface::key ( )
31{
32 return QCString ( "liquid" );
33}
34
35unsigned int LiquidInterface::version ( )
36{
37 return 100; // 1.0.0 (\d+.\d.\d)
38}
39
40QRESULT LiquidInterface::queryInterface ( const QUuid &uuid, QUnknownInterface **iface )
41{
42 static LiquidSettingsInterface *setiface = 0;
43
44 *iface = 0;
45
46 if ( uuid == IID_QUnknown )
47 *iface = this;
48 else if ( uuid == IID_Style )
49 *iface = this;
50 else if ( uuid == IID_StyleSettings ) {
51 if ( !setiface )
52 setiface = new LiquidSettingsInterface ( );
53 *iface = setiface;
54 }
55
56 if ( *iface )
57 (*iface)-> addRef ( );
58
59 return QS_OK;
60}
61
62Q_EXPORT_INTERFACE()
63{
64 Q_CREATE_INSTANCE( LiquidInterface )
9} 65}
10 66
11QStyle* allocate ( ) 67
68LiquidSettingsInterface::LiquidSettingsInterface ( ) : ref ( 0 )
69{
70 m_widget = 0;
71}
72
73LiquidSettingsInterface::~LiquidSettingsInterface ( )
12{ 74{
13 return new LiquidStyle ( ); 75}
76
77QWidget *LiquidSettingsInterface::create ( QWidget *parent, const char *name )
78{
79 m_widget = new LiquidSettings ( parent, name ? name : "LIQUID-SETTINGS" );
80
81 return m_widget;
14} 82}
15 83
16int minor_version ( ) 84bool LiquidSettingsInterface::accept ( )
17{ 85{
18 return 0; 86 if ( !m_widget )
87 return false;
88
89 return m_widget-> writeConfig ( );
19} 90}
20 91
21int major_version ( ) 92void LiquidSettingsInterface::reject ( )
22{ 93{
23 return 1;
24} 94}
25 95
26const char *description ( ) 96QRESULT LiquidSettingsInterface::queryInterface ( const QUuid &uuid, QUnknownInterface **iface )
27{ 97{
28 return "High Performance Liquid"; 98 *iface = 0;
99
100
101 if ( uuid == IID_QUnknown )
102 *iface = this;
103 else if ( uuid == IID_StyleSettings )
104 *iface = this;
105
106 if ( *iface )
107 (*iface)-> addRef ( );
108
109 return QS_OK;
29} 110}
111
diff --git a/noncore/styles/liquid/plugin.h b/noncore/styles/liquid/plugin.h
new file mode 100644
index 0000000..759577f
--- a/dev/null
+++ b/noncore/styles/liquid/plugin.h
@@ -0,0 +1,46 @@
1#ifndef __OPIE_LIQUID_PLUGIN_H__
2#define __OPIE_LIQUID_PLUGIN_H__
3
4#include <qpe/styleinterface.h>
5
6class LiquidSettings;
7
8class LiquidInterface : public StyleInterface {
9public:
10 LiquidInterface ( );
11 virtual ~LiquidInterface ( );
12
13 QRESULT queryInterface ( const QUuid &, QUnknownInterface ** );
14 Q_REFCOUNT
15
16 virtual QStyle *create ( );
17
18 virtual QString description ( );
19 virtual QString name ( );
20 virtual QCString key ( );
21
22 virtual unsigned int version ( );
23
24private:
25 ulong ref;
26};
27
28class LiquidSettingsInterface : public StyleSettingsInterface {
29public:
30 LiquidSettingsInterface ( );
31 virtual ~LiquidSettingsInterface ( );
32
33 QRESULT queryInterface ( const QUuid &, QUnknownInterface ** );
34 Q_REFCOUNT
35
36 virtual QWidget *create ( QWidget *parent, const char *name = 0 );
37
38 virtual bool accept ( );
39 virtual void reject ( );
40
41private:
42 LiquidSettings *m_widget;
43 ulong ref;
44};
45
46#endif
diff --git a/noncore/styles/liquid/settings/.cvsignore b/noncore/styles/liquid/settings/.cvsignore
deleted file mode 100644
index c13418b..0000000
--- a/noncore/styles/liquid/settings/.cvsignore
+++ b/dev/null
@@ -1,2 +0,0 @@
1Makefile*
2moc_*
diff --git a/noncore/styles/liquid/settings/main.cpp b/noncore/styles/liquid/settings/main.cpp
deleted file mode 100644
index fd69007..0000000
--- a/noncore/styles/liquid/settings/main.cpp
+++ b/dev/null
@@ -1,34 +0,0 @@
1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3**
4** This file is part of Qtopia Environment.
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20
21#include "liquidset.h"
22
23#include <qpe/qpeapplication.h>
24
25
26int main ( int argc, char** argv )
27{
28 QPEApplication a ( argc, argv );
29
30 LiquidSet dlg;
31 a. showMainWidget ( &dlg );
32
33 return a. exec ( );
34}
diff --git a/noncore/styles/liquid/settings/settings.pro b/noncore/styles/liquid/settings/settings.pro
deleted file mode 100644
index bfda7a4..0000000
--- a/noncore/styles/liquid/settings/settings.pro
+++ b/dev/null
@@ -1,24 +0,0 @@
1 TEMPLATE= app
2 CONFIG += qt warn_on release
3 DESTDIR = $(OPIEDIR)/bin
4 HEADERS = liquidset.h
5 SOURCES = liquidset.cpp main.cpp
6INCLUDEPATH += $(OPIEDIR)/include
7 DEPENDPATH+= ../$(OPIEDIR)/include
8LIBS += -lqpe -lopie
9 TARGET = liquid-settings
10
11TRANSLATIONS = ../../../../i18n/de/liquid-settings.ts \
12 ../../../../i18n/en/liquid-settings.ts \
13 ../../../../i18n/es/liquid-settings.ts \
14 ../../../../i18n/fr/liquid-settings.ts \
15 ../../../../i18n/hu/liquid-settings.ts \
16 ../../../../i18n/ja/liquid-settings.ts \
17 ../../../../i18n/ko/liquid-settings.ts \
18 ../../../../i18n/no/liquid-settings.ts \
19 ../../../../i18n/pl/liquid-settings.ts \
20 ../../../../i18n/pt/liquid-settings.ts \
21 ../../../../i18n/pt_BR/liquid-settings.ts \
22 ../../../../i18n/sl/liquid-settings.ts \
23 ../../../../i18n/zh_CN/liquid-settings.ts \
24 ../../../../i18n/zh_TW/liquid-settings.ts
diff --git a/noncore/styles/metal/metal.pro b/noncore/styles/metal/metal.pro
index 6e99389..cf15f33 100644
--- a/noncore/styles/metal/metal.pro
+++ b/noncore/styles/metal/metal.pro
@@ -3,5 +3,5 @@ CONFIG = qt embedded release warn_on
3SOURCES = metal.cpp plugin.cpp 3SOURCES = metal.cpp plugin.cpp
4 4
5HEADERS = metal.h 5HEADERS = metal.h plugin.h
6LIBS += -lqpe 6LIBS += -lqpe
7INCLUDEPATH += $(OPIEDIR)/include 7INCLUDEPATH += $(OPIEDIR)/include
diff --git a/noncore/styles/metal/plugin.cpp b/noncore/styles/metal/plugin.cpp
index e5bee10..1db4aac 100644
--- a/noncore/styles/metal/plugin.cpp
+++ b/noncore/styles/metal/plugin.cpp
@@ -1,29 +1,57 @@
1#include "metal.h" 1#include "metal.h"
2#include "plugin.h"
2 3
3 4
4extern "C" { 5MetalInterface::MetalInterface ( ) : ref ( 0 )
5 QStyle* allocate ( ); 6{
6 int minor_version ( ); 7}
7 int major_version ( ); 8
8 const char *description ( ); 9MetalInterface::~MetalInterface ( )
10{
11}
12
13QStyle *MetalInterface::create ( )
14{
15 return new MetalStyle ( );
16}
17
18QString MetalInterface::name ( )
19{
20 return QObject::tr( "Metal", "name" );
21}
22
23QString MetalInterface::description ( )
24{
25 return QObject::tr( "Metal style", "description" );
9} 26}
10 27
11QStyle* allocate ( ) 28QCString MetalInterface::key ( )
12{ 29{
13 return new MetalStyle ( ); 30 return QCString ( "metal" );
14} 31}
15 32
16int minor_version ( ) 33unsigned int MetalInterface::version ( )
17{ 34{
18 return 0; 35 return 100; // 1.0.0 (\d+.\d.\d)
19} 36}
20 37
21int major_version ( ) 38QRESULT MetalInterface::queryInterface ( const QUuid &uuid, QUnknownInterface **iface )
22{ 39{
23 return 1; 40 *iface = 0;
41
42 if ( uuid == IID_QUnknown )
43 *iface = this;
44 else if ( uuid == IID_Style )
45 *iface = this;
46
47 if ( *iface )
48 (*iface)-> addRef ( );
49
50 return QS_OK;
24} 51}
25 52
26const char *description ( ) 53Q_EXPORT_INTERFACE()
27{ 54{
28 return "Metal style plugin"; 55 Q_CREATE_INSTANCE( MetalInterface )
29} 56}
57
diff --git a/noncore/styles/metal/plugin.h b/noncore/styles/metal/plugin.h
new file mode 100644
index 0000000..f61c833
--- a/dev/null
+++ b/noncore/styles/metal/plugin.h
@@ -0,0 +1,27 @@
1#ifndef __OPIE_METAL_PLUGIN_H__
2#define __OPIE_METAL_PLUGIN_H__
3
4#include <qpe/styleinterface.h>
5
6
7class MetalInterface : public StyleInterface {
8public:
9 MetalInterface ( );
10 virtual ~MetalInterface ( );
11
12 QRESULT queryInterface ( const QUuid &, QUnknownInterface ** );
13 Q_REFCOUNT
14
15 virtual QStyle *create ( );
16
17 virtual QString description ( );
18 virtual QString name ( );
19 virtual QCString key ( );
20
21 virtual unsigned int version ( );
22
23private:
24 ulong ref;
25};
26
27#endif
diff --git a/noncore/styles/theme/opie-theme.control b/noncore/styles/theme/opie-theme.control
index 02739fb..adb4f4b 100644
--- a/noncore/styles/theme/opie-theme.control
+++ b/noncore/styles/theme/opie-theme.control
@@ -1,3 +1,3 @@
1Files: plugins/styles/libtheme.so* bin/theme-settings apps/Settings/Theme.desktop pics/theme/Theme.png 1Files: plugins/styles/libtheme.so*
2Priority: optional 2Priority: optional
3Section: opie/system 3Section: opie/system
diff --git a/noncore/styles/theme/plugin.cpp b/noncore/styles/theme/plugin.cpp
index b334357..4383693 100644
--- a/noncore/styles/theme/plugin.cpp
+++ b/noncore/styles/theme/plugin.cpp
@@ -1,19 +1,111 @@
1//#include <klocale.h>
2#include "othemestyle.h" 1#include "othemestyle.h"
2#include "themeset.h"
3#include "plugin.h"
3 4
4extern "C" 5
6
7ThemeInterface::ThemeInterface ( ) : ref ( 0 )
5{ 8{
6 QStyle * allocate() { 9}
7 return new OThemeStyle ( "" ); 10
8 } 11ThemeInterface::~ThemeInterface ( )
9 int minor_version() { 12{
10 return 0; 13}
11 } 14
12 int major_version() { 15QStyle *ThemeInterface::create ( )
13 return 1; 16{
14 } 17 return new OThemeStyle ( "" );
15 const char * description() { 18}
16 return ( "Theme Style" ); 19
20QString ThemeInterface::name ( )
21{
22 return QObject::tr( "Themed style", "name" );
23}
24
25QString ThemeInterface::description ( )
26{
27 return QObject::tr( "KDE2 theme compatible style engine", "description" );
28}
29
30QCString ThemeInterface::key ( )
31{
32 return QCString ( "theme" );
33}
34
35unsigned int ThemeInterface::version ( )
36{
37 return 100; // 1.0.0 (\d+.\d.\d)
38}
39
40QRESULT ThemeInterface::queryInterface ( const QUuid &uuid, QUnknownInterface **iface )
41{
42 static ThemeSettingsInterface *setiface = 0;
43
44 *iface = 0;
45
46 if ( uuid == IID_QUnknown )
47 *iface = this;
48 else if ( uuid == IID_Style )
49 *iface = this;
50 else if ( uuid == IID_StyleSettings ) {
51 if ( !setiface )
52 setiface = new ThemeSettingsInterface ( );
53 *iface = setiface;
17 } 54 }
55
56 if ( *iface )
57 (*iface)-> addRef ( );
58
59 return QS_OK;
60}
61
62Q_EXPORT_INTERFACE()
63{
64 Q_CREATE_INSTANCE( ThemeInterface )
65}
66
67
68ThemeSettingsInterface::ThemeSettingsInterface ( ) : ref ( 0 )
69{
70 m_widget = 0;
71}
72
73ThemeSettingsInterface::~ThemeSettingsInterface ( )
74{
75}
76
77QWidget *ThemeSettingsInterface::create ( QWidget *parent, const char *name )
78{
79 m_widget = new ThemeSettings ( parent, name ? name : "THEME-SETTINGS" );
80
81 return m_widget;
82}
83
84bool ThemeSettingsInterface::accept ( )
85{
86 if ( !m_widget )
87 return false;
88
89 return m_widget-> writeConfig ( );
90}
91
92void ThemeSettingsInterface::reject ( )
93{
94}
95
96QRESULT ThemeSettingsInterface::queryInterface ( const QUuid &uuid, QUnknownInterface **iface )
97{
98 *iface = 0;
99
100
101 if ( uuid == IID_QUnknown )
102 *iface = this;
103 else if ( uuid == IID_StyleSettings )
104 *iface = this;
105
106 if ( *iface )
107 (*iface)-> addRef ( );
108
109 return QS_OK;
18} 110}
19 111
diff --git a/noncore/styles/theme/plugin.h b/noncore/styles/theme/plugin.h
new file mode 100644
index 0000000..d13fc5d
--- a/dev/null
+++ b/noncore/styles/theme/plugin.h
@@ -0,0 +1,46 @@
1#ifndef __OPIE_THEME_PLUGIN_H__
2#define __OPIE_THEME_PLUGIN_H__
3
4#include <qpe/styleinterface.h>
5
6class ThemeSettings;
7
8class ThemeInterface : public StyleInterface {
9public:
10 ThemeInterface ( );
11 virtual ~ThemeInterface ( );
12
13 QRESULT queryInterface ( const QUuid &, QUnknownInterface ** );
14 Q_REFCOUNT
15
16 virtual QStyle *create ( );
17
18 virtual QString description ( );
19 virtual QString name ( );
20 virtual QCString key ( );
21
22 virtual unsigned int version ( );
23
24private:
25 ulong ref;
26};
27
28class ThemeSettingsInterface : public StyleSettingsInterface {
29public:
30 ThemeSettingsInterface ( );
31 virtual ~ThemeSettingsInterface ( );
32
33 QRESULT queryInterface ( const QUuid &, QUnknownInterface ** );
34 Q_REFCOUNT
35
36 virtual QWidget *create ( QWidget *parent, const char *name = 0 );
37
38 virtual bool accept ( );
39 virtual void reject ( );
40
41private:
42 ThemeSettings *m_widget;
43 ulong ref;
44};
45
46#endif
diff --git a/noncore/styles/theme/settings/main.cpp b/noncore/styles/theme/settings/main.cpp
deleted file mode 100644
index 94d40f3..0000000
--- a/noncore/styles/theme/settings/main.cpp
+++ b/dev/null
@@ -1,34 +0,0 @@
1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3**
4** This file is part of Qtopia Environment.
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20
21#include "themeset.h"
22
23#include <qpe/qpeapplication.h>
24
25
26int main ( int argc, char** argv )
27{
28 QPEApplication a ( argc, argv );
29
30 ThemeSet dlg;
31 a. showMainWidget ( &dlg );
32
33 return a. exec ( );
34}
diff --git a/noncore/styles/theme/settings/settings.pro b/noncore/styles/theme/settings/settings.pro
deleted file mode 100644
index 85d1f7a..0000000
--- a/noncore/styles/theme/settings/settings.pro
+++ b/dev/null
@@ -1,24 +0,0 @@
1 TEMPLATE= app
2 CONFIG += qt warn_on release
3 DESTDIR = $(OPIEDIR)/bin
4 HEADERS = themeset.h
5 SOURCES = themeset.cpp main.cpp
6INCLUDEPATH += $(OPIEDIR)/include
7 DEPENDPATH+= ../$(OPIEDIR)/include
8LIBS += -lqpe
9 TARGET = theme-settings
10
11TRANSLATIONS = ../../../../i18n/de/theme-settings.ts \
12 ../../../../i18n/en/theme-settings.ts \
13 ../../../../i18n/es/theme-settings.ts \
14 ../../../../i18n/fr/theme-settings.ts \
15 ../../../../i18n/hu/theme-settings.ts \
16 ../../../../i18n/ja/theme-settings.ts \
17 ../../../../i18n/ko/theme-settings.ts \
18 ../../../../i18n/no/theme-settings.ts \
19 ../../../../i18n/pl/theme-settings.ts \
20 ../../../../i18n/pt/theme-settings.ts \
21 ../../../../i18n/pt_BR/theme-settings.ts \
22 ../../../../i18n/sl/theme-settings.ts \
23 ../../../../i18n/zh_CN/theme-settings.ts \
24 ../../../../i18n/zh_TW/theme-settings.ts
diff --git a/noncore/styles/theme/settings/themeset.h b/noncore/styles/theme/settings/themeset.h
deleted file mode 100644
index 24804ce..0000000
--- a/noncore/styles/theme/settings/themeset.h
+++ b/dev/null
@@ -1,20 +0,0 @@
1#ifndef __OPIE_THEME_SET_H__
2#define __OPIE_THEME_SET_H__
3
4#include <qdialog.h>
5
6class QListView;
7
8class ThemeSet : public QDialog {
9 Q_OBJECT
10
11public:
12 ThemeSet ( QWidget *parent = 0, const char *name = 0, WFlags fl = 0 );
13
14protected:
15 virtual void accept ( );
16
17private:
18 QListView *m_list;
19};
20#endif
diff --git a/noncore/styles/theme/theme.pro b/noncore/styles/theme/theme.pro
index fdcd20e..49c4103 100644
--- a/noncore/styles/theme/theme.pro
+++ b/noncore/styles/theme/theme.pro
@@ -4,9 +4,12 @@ SOURCES = ogfxeffect.cpp \
4 othemestyle.cpp \ 4 othemestyle.cpp \
5 othemebase.cpp \ 5 othemebase.cpp \
6 themeset.cpp \
6 plugin.cpp 7 plugin.cpp
7 8
8HEADERS = ogfxeffect.h \ 9HEADERS = ogfxeffect.h \
9 othemebase.h \ 10 othemebase.h \
10 othemestyle.h 11 othemestyle.h \
12 themeset.h \
13 plugin.h
11 14
12 15
diff --git a/noncore/styles/theme/settings/themeset.cpp b/noncore/styles/theme/themeset.cpp
index 046618e..4a4efcb 100644
--- a/noncore/styles/theme/settings/themeset.cpp
+++ b/noncore/styles/theme/themeset.cpp
@@ -60,6 +60,6 @@ public:
60 60
61 61
62ThemeSet::ThemeSet ( QWidget* parent, const char *name, WFlags fl ) 62ThemeSettings::ThemeSettings ( QWidget* parent, const char *name, WFlags fl )
63 : QDialog ( parent, name, fl ) 63 : QWidget ( parent, name, fl )
64{ 64{
65 setCaption ( tr( "Theme Style" ) ); 65 setCaption ( tr( "Theme Style" ) );
@@ -110,5 +110,5 @@ ThemeSet::ThemeSet ( QWidget* parent, const char *name, WFlags fl )
110} 110}
111 111
112void ThemeSet::accept ( ) 112bool ThemeSettings::writeConfig ( )
113{ 113{
114 Config config ( "qpe" ); 114 Config config ( "qpe" );
@@ -117,8 +117,7 @@ void ThemeSet::accept ( )
117 MyItem *it = (MyItem *) m_list-> selectedItem ( ); 117 MyItem *it = (MyItem *) m_list-> selectedItem ( );
118 config. writeEntry ( "Theme", it ? it-> m_theme : QString ( "" )); 118 config. writeEntry ( "Theme", it ? it-> m_theme : QString ( "" ));
119 config. write ( );
119 120
120 Global::applyStyle ( ); 121 return true;
121
122 QDialog::accept ( );
123} 122}
124 123
diff --git a/noncore/styles/theme/themeset.h b/noncore/styles/theme/themeset.h
new file mode 100644
index 0000000..c337cfa
--- a/dev/null
+++ b/noncore/styles/theme/themeset.h
@@ -0,0 +1,20 @@
1#ifndef __OPIE_THEME_SETTINGS_H__
2#define __OPIE_THEME_SETTINGS_H__
3
4#include <qdialog.h>
5
6class QListView;
7
8class ThemeSettings : public QWidget {
9 Q_OBJECT
10
11public:
12 ThemeSettings ( QWidget *parent = 0, const char *name = 0, WFlags fl = 0 );
13
14public:
15 virtual bool writeConfig ( );
16
17private:
18 QListView *m_list;
19};
20#endif
diff --git a/pics/liquid/Liquid.png b/pics/liquid/Liquid.png
deleted file mode 100644
index 67647d0..0000000
--- a/pics/liquid/Liquid.png
+++ b/dev/null
Binary files differ
diff --git a/pics/theme/Theme.png b/pics/theme/Theme.png
deleted file mode 100644
index 67647d0..0000000
--- a/pics/theme/Theme.png
+++ b/dev/null
Binary files differ