summaryrefslogtreecommitdiff
path: root/library
Unidiff
Diffstat (limited to 'library') (more/less context) (ignore whitespace changes)
-rw-r--r--library/qpeapplication.cpp61
1 files changed, 45 insertions, 16 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp
index 76d62ef..6e2db7c 100644
--- a/library/qpeapplication.cpp
+++ b/library/qpeapplication.cpp
@@ -43,94 +43,96 @@
43#include <qregexp.h> 43#include <qregexp.h>
44#include <qdir.h> 44#include <qdir.h>
45#include <qlabel.h> 45#include <qlabel.h>
46#include <qdialog.h> 46#include <qdialog.h>
47#include <qdragobject.h> 47#include <qdragobject.h>
48#include <qevent.h> 48#include <qevent.h>
49#include <qtooltip.h> 49#include <qtooltip.h>
50#include <qsignal.h> 50#include <qsignal.h>
51 51
52 52
53//#include <linux/fb.h> better not rely on kernel headers in userspace ... 53//#include <linux/fb.h> better not rely on kernel headers in userspace ...
54 54
55/* VESA Blanking Levels */ 55/* VESA Blanking Levels */
56#define VESA_NO_BLANKING 0 56#define VESA_NO_BLANKING 0
57#define VESA_VSYNC_SUSPEND 1 57#define VESA_VSYNC_SUSPEND 1
58#define VESA_HSYNC_SUSPEND 2 58#define VESA_HSYNC_SUSPEND 2
59#define VESA_POWERDOWN 3 59#define VESA_POWERDOWN 3
60 60
61#define FBIOBLANK 0x4611 61#define FBIOBLANK 0x4611
62 62
63 63
64#include <qsignal.h> 64#include <qsignal.h>
65#include "qpeapplication.h" 65#include "qpeapplication.h"
66#include "qpestyle.h" 66#include "qpestyle.h"
67#if QT_VERSION >= 300 67#if QT_VERSION >= 300
68#include <qstylefactory.h> 68#include <qstylefactory.h>
69#else 69#else
70#include <qplatinumstyle.h> 70#include <qplatinumstyle.h>
71#include <qwindowsstyle.h> 71#include <qwindowsstyle.h>
72#include <qmotifstyle.h> 72#include <qmotifstyle.h>
73#include <qmotifplusstyle.h> 73#include <qmotifplusstyle.h>
74#include "lightstyle.h" 74#include "lightstyle.h"
75
76#include <qpe/qlibrary.h>
77#include <dlfcn.h>
75#endif 78#endif
76#include "global.h" 79#include "global.h"
77#include "resource.h" 80#include "resource.h"
78#if QT_VERSION <= 230 && defined(QT_NO_CODECS) 81#if QT_VERSION <= 230 && defined(QT_NO_CODECS)
79#include "qutfcodec.h" 82#include "qutfcodec.h"
80#endif 83#endif
81#include "config.h" 84#include "config.h"
82#include "network.h" 85#include "network.h"
83#include "fontmanager.h" 86#include "fontmanager.h"
84#include "fontdatabase.h" 87#include "fontdatabase.h"
85 88
86#include "power.h" 89#include "power.h"
87#include "alarmserver.h" 90#include "alarmserver.h"
88#include "applnk.h" 91#include "applnk.h"
89#include "qpemenubar.h" 92#include "qpemenubar.h"
90 93
91#include <unistd.h> 94#include <unistd.h>
92#include <sys/file.h> 95#include <sys/file.h>
93#include <sys/ioctl.h> 96#include <sys/ioctl.h>
94#include <sys/soundcard.h> 97#include <sys/soundcard.h>
95 98
96// for setBacklight() 99// for setBacklight()
97#if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) 100#if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX)
98#include <linux/fb.h> 101#include <linux/fb.h>
99#include <sys/types.h> 102#include <sys/types.h>
100#include <sys/stat.h> 103#include <sys/stat.h>
101#endif 104#endif
102#include <stdlib.h> 105#include <stdlib.h>
103 106
104#include <dlfcn.h> // for Liquid HACK
105 107
106class QPEApplicationData { 108class QPEApplicationData {
107public: 109public:
108 QPEApplicationData() : presstimer(0), presswidget(0), rightpressed(FALSE), 110 QPEApplicationData() : presstimer(0), presswidget(0), rightpressed(FALSE),
109 kbgrabber(0), kbregrab(FALSE), notbusysent(FALSE), preloaded(FALSE), 111 kbgrabber(0), kbregrab(FALSE), notbusysent(FALSE), preloaded(FALSE),
110 forceshow(FALSE), nomaximize(FALSE), qpe_main_widget(0), 112 forceshow(FALSE), nomaximize(FALSE), qpe_main_widget(0),
111 keep_running(TRUE) 113 keep_running(TRUE)
112 { 114 {
113 qcopq.setAutoDelete(TRUE); 115 qcopq.setAutoDelete(TRUE);
114 } 116 }
115 117
116 int presstimer; 118 int presstimer;
117 QWidget* presswidget; 119 QWidget* presswidget;
118 QPoint presspos; 120 QPoint presspos;
119 bool rightpressed; 121 bool rightpressed;
120 int kbgrabber; 122 int kbgrabber;
121 bool kbregrab; 123 bool kbregrab;
122 bool notbusysent; 124 bool notbusysent;
123 QString appName; 125 QString appName;
124 struct QCopRec { 126 struct QCopRec {
125 QCopRec(const QCString &ch, const QCString &msg, 127 QCopRec(const QCString &ch, const QCString &msg,
126 const QByteArray &d) : 128 const QByteArray &d) :
127 channel(ch), message(msg), data(d) { } 129 channel(ch), message(msg), data(d) { }
128 130
129 QCString channel; 131 QCString channel;
130 QCString message; 132 QCString message;
131 QByteArray data; 133 QByteArray data;
132 }; 134 };
133 bool preloaded; 135 bool preloaded;
134 bool forceshow; 136 bool forceshow;
135 bool nomaximize; 137 bool nomaximize;
136 QWidget* qpe_main_widget; 138 QWidget* qpe_main_widget;
@@ -1299,81 +1301,108 @@ void QPEApplication::internalSetStyle( const QString &style )
1299#if QT_VERSION >= 300 1301#if QT_VERSION >= 300
1300 if ( style == "QPE" ) { 1302 if ( style == "QPE" ) {
1301 setStyle( new QPEStyle ); 1303 setStyle( new QPEStyle );
1302 } else { 1304 } else {
1303 QStyle *s = QStyleFactory::create(style); 1305 QStyle *s = QStyleFactory::create(style);
1304 if ( s ) setStyle(s); 1306 if ( s ) setStyle(s);
1305 } 1307 }
1306#else 1308#else
1307 if ( style == "Windows" ) { 1309 if ( style == "Windows" ) {
1308 setStyle( new QWindowsStyle ); 1310 setStyle( new QWindowsStyle );
1309 } else if ( style == "QPE" ) { 1311 } else if ( style == "QPE" ) {
1310 setStyle( new QPEStyle ); 1312 setStyle( new QPEStyle );
1311 } else if ( style == "Light" ) { 1313 } else if ( style == "Light" ) {
1312 setStyle( new LightStyle ); 1314 setStyle( new LightStyle );
1313 } 1315 }
1314#ifndef QT_NO_STYLE_PLATINUM 1316#ifndef QT_NO_STYLE_PLATINUM
1315 else if ( style == "Platinum" ) { 1317 else if ( style == "Platinum" ) {
1316 setStyle( new QPlatinumStyle ); 1318 setStyle( new QPlatinumStyle );
1317 } 1319 }
1318#endif 1320#endif
1319#ifndef QT_NO_STYLE_MOTIF 1321#ifndef QT_NO_STYLE_MOTIF
1320 else if ( style == "Motif" ) { 1322 else if ( style == "Motif" ) {
1321 setStyle( new QMotifStyle ); 1323 setStyle( new QMotifStyle );
1322 } 1324 }
1323#endif 1325#endif
1324#ifndef QT_NO_STYLE_MOTIFPLUS 1326#ifndef QT_NO_STYLE_MOTIFPLUS
1325 else if ( style == "MotifPlus" ) { 1327 else if ( style == "MotifPlus" ) {
1326 setStyle( new QMotifPlusStyle ); 1328 setStyle( new QMotifPlusStyle );
1327 } 1329 }
1328#endif 1330#endif
1329 1331
1330 // HACK for Qt2 only 1332 // HACK for Qt2 only
1331 else if ( style == "Liquid" ) { 1333 else {
1332 static void *lib = 0; 1334 // style == "Liquid Style (libliquid.so)" (or "Windows XP (libxp.so)"
1333 QStyle *sty = 0; 1335
1336 int p2 = style. findRev ( ']' );
1337 int p1 = style. findRev ( '[' );
1338 QString style2;
1334 1339
1335 1340 if (( p1 > 0 ) && ( p2 > 0 ) && (( p1 + 1 ) < p2 ))
1336 if ( !lib ) { 1341 style2 = "lib" + style. mid ( p1 + 1, p2 - p1 - 1 ). lower ( ) + ".so";
1337 QString path = QPEApplication::qpeDir() + "/plugins/styles/" + "libliquid.so"; 1342 else
1338 lib = ::dlopen ( path. local8Bit ( ), RTLD_NOW | RTLD_GLOBAL ); 1343 style2 = "lib" + style. lower ( ) + ".so";
1339 }
1340 if ( lib ) {
1341 void *sym = ::dlsym ( lib, "allocate" );
1342 1344
1343 if ( sym ) 1345 // static QLibrary *currentlib = 0;
1344 sty = ((QStyle * (*) ( )) sym ) ( ); 1346 static void *currentlib = 0;
1345 } 1347
1346 if ( sty ) 1348 QString path = QPEApplication::qpeDir ( ) + "/plugins/styles/" + style2;
1347 setStyle ( sty ); 1349
1350 do { // try/catch simulation
1351 // QLibrary *lib = new QLibrary ( path, QLibrary::Immediately );
1352 void *lib = ::dlopen ( path. local8Bit ( ), RTLD_NOW | RTLD_GLOBAL );
1353
1354 if ( lib ) {
1355 //QStyle * (*fpa) ( ) = (QStyle * (*) ( )) lib-> resolve ( "allocate" );
1356 QStyle * (*fpa) ( ) = (QStyle * (*) ( )) ::dlsym ( lib, "allocate" );
1357
1358 if ( fpa ) {
1359 QStyle *sty = ( *fpa ) ( );
1360
1361 if ( sty ) {
1362 setStyle ( sty );
1363
1364 if ( currentlib ) {
1365 //delete currentlib;
1366 ::dlclose ( currentlib );
1367 }
1368 currentlib = lib;
1369
1370 break;
1371 }
1372 }
1373 //delete lib;
1374 ::dlclose ( lib );
1375 }
1376 } while ( false );
1348 } 1377 }
1349 // HACK for Qt2 only 1378 // HACK for Qt2 only
1350#endif 1379#endif
1351} 1380}
1352 1381
1353/*! 1382/*!
1354 \internal 1383 \internal
1355*/ 1384*/
1356void QPEApplication::prepareForTermination(bool willrestart) 1385void QPEApplication::prepareForTermination(bool willrestart)
1357{ 1386{
1358 if ( willrestart ) { 1387 if ( willrestart ) {
1359 // Draw a big wait icon, the image can be altered in later revisions 1388 // Draw a big wait icon, the image can be altered in later revisions
1360// QWidget *d = QApplication::desktop(); 1389// QWidget *d = QApplication::desktop();
1361 QImage img = Resource::loadImage( "launcher/new_wait" ); 1390 QImage img = Resource::loadImage( "launcher/new_wait" );
1362 QPixmap pix; 1391 QPixmap pix;
1363 pix.convertFromImage(img.smoothScale(1*img.width(), 1*img.height())); 1392 pix.convertFromImage(img.smoothScale(1*img.width(), 1*img.height()));
1364 QLabel *lblWait = new QLabel(0, "wait hack!", QWidget::WStyle_Customize | 1393 QLabel *lblWait = new QLabel(0, "wait hack!", QWidget::WStyle_Customize |
1365 QWidget::WStyle_NoBorder | QWidget::WStyle_Tool ); 1394 QWidget::WStyle_NoBorder | QWidget::WStyle_Tool );
1366 lblWait->setPixmap( pix ); 1395 lblWait->setPixmap( pix );
1367 lblWait->setAlignment( QWidget::AlignCenter ); 1396 lblWait->setAlignment( QWidget::AlignCenter );
1368 lblWait->show(); 1397 lblWait->show();
1369 lblWait->showMaximized(); 1398 lblWait->showMaximized();
1370 } 1399 }
1371#ifndef SINGLE_APP 1400#ifndef SINGLE_APP
1372 { QCopEnvelope envelope("QPE/System", "forceQuit()"); } 1401 { QCopEnvelope envelope("QPE/System", "forceQuit()"); }
1373 processEvents(); // ensure the message goes out. 1402 processEvents(); // ensure the message goes out.
1374 sleep(1); // You have 1 second to comply. 1403 sleep(1); // You have 1 second to comply.
1375#endif 1404#endif
1376} 1405}
1377 1406
1378/*! 1407/*!
1379 \internal 1408 \internal