summaryrefslogtreecommitdiff
path: root/library
authorsandman <sandman>2002-06-29 00:25:26 (UTC)
committer sandman <sandman>2002-06-29 00:25:26 (UTC)
commit971f94ceb114149efbf8d90b607d25dcbd358435 (patch) (unidiff)
treedf106209331f0e8a8c79c839ccfb4a8a8c7ac97c /library
parent0552cd7f5762939ccdf05b9bf4fdae9b3e79b0a5 (diff)
downloadopie-971f94ceb114149efbf8d90b607d25dcbd358435.zip
opie-971f94ceb114149efbf8d90b607d25dcbd358435.tar.gz
opie-971f94ceb114149efbf8d90b607d25dcbd358435.tar.bz2
Modified my "liquid only hack" - appearance now scans plugins/styles for
external styles and qpeapplication tries to load them
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
@@ -1,232 +1,234 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved. 2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of Qtopia Environment. 4** This file is part of Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 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 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 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 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. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19** $Id$ 19** $Id$
20** 20**
21**********************************************************************/ 21**********************************************************************/
22#define QTOPIA_INTERNAL_LANGLIST 22#define QTOPIA_INTERNAL_LANGLIST
23#include <stdlib.h> 23#include <stdlib.h>
24#include <unistd.h> 24#include <unistd.h>
25#include <qfile.h> 25#include <qfile.h>
26#ifdef Q_WS_QWS 26#ifdef Q_WS_QWS
27#ifndef QT_NO_COP 27#ifndef QT_NO_COP
28#if QT_VERSION <= 231 28#if QT_VERSION <= 231
29#define private public 29#define private public
30#define sendLocally processEvent 30#define sendLocally processEvent
31#include "qcopenvelope_qws.h" 31#include "qcopenvelope_qws.h"
32#undef private 32#undef private
33#else 33#else
34#include "qcopenvelope_qws.h" 34#include "qcopenvelope_qws.h"
35#endif 35#endif
36#endif 36#endif
37#include <qwindowsystem_qws.h> 37#include <qwindowsystem_qws.h>
38#endif 38#endif
39#include <qtextstream.h> 39#include <qtextstream.h>
40#include <qpalette.h> 40#include <qpalette.h>
41#include <qbuffer.h> 41#include <qbuffer.h>
42#include <qptrdict.h> 42#include <qptrdict.h>
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;
137 bool keep_running; 139 bool keep_running;
138 QList<QCopRec> qcopq; 140 QList<QCopRec> qcopq;
139 141
140 void enqueueQCop(const QCString &ch, const QCString &msg, 142 void enqueueQCop(const QCString &ch, const QCString &msg,
141 const QByteArray &data) 143 const QByteArray &data)
142 { 144 {
143 qcopq.append(new QCopRec(ch,msg,data)); 145 qcopq.append(new QCopRec(ch,msg,data));
144 } 146 }
145 void sendQCopQ() 147 void sendQCopQ()
146 { 148 {
147 QCopRec* r; 149 QCopRec* r;
148 for (QListIterator<QCopRec> it(qcopq); (r=it.current()); ++it) 150 for (QListIterator<QCopRec> it(qcopq); (r=it.current()); ++it)
149 QCopChannel::sendLocally(r->channel,r->message,r->data); 151 QCopChannel::sendLocally(r->channel,r->message,r->data);
150 qcopq.clear(); 152 qcopq.clear();
151 } 153 }
152}; 154};
153 155
154class ResourceMimeFactory : public QMimeSourceFactory { 156class ResourceMimeFactory : public QMimeSourceFactory {
155public: 157public:
156 ResourceMimeFactory() 158 ResourceMimeFactory()
157 { 159 {
158 setFilePath( Global::helpPath() ); 160 setFilePath( Global::helpPath() );
159 setExtensionType("html","text/html;charset=UTF-8"); 161 setExtensionType("html","text/html;charset=UTF-8");
160 } 162 }
161 163
162 const QMimeSource* data(const QString& abs_name) const 164 const QMimeSource* data(const QString& abs_name) const
163 { 165 {
164 const QMimeSource* r = QMimeSourceFactory::data(abs_name); 166 const QMimeSource* r = QMimeSourceFactory::data(abs_name);
165 if ( !r ) { 167 if ( !r ) {
166 int sl = abs_name.length(); 168 int sl = abs_name.length();
167 do { 169 do {
168 sl = abs_name.findRev('/',sl-1); 170 sl = abs_name.findRev('/',sl-1);
169 QString name = sl>=0 ? abs_name.mid(sl+1) : abs_name; 171 QString name = sl>=0 ? abs_name.mid(sl+1) : abs_name;
170 int dot = name.findRev('.'); 172 int dot = name.findRev('.');
171 if ( dot >= 0 ) 173 if ( dot >= 0 )
172 name = name.left(dot); 174 name = name.left(dot);
173 QImage img = Resource::loadImage(name); 175 QImage img = Resource::loadImage(name);
174 if ( !img.isNull() ) 176 if ( !img.isNull() )
175 r = new QImageDrag(img); 177 r = new QImageDrag(img);
176 } while (!r && sl>0); 178 } while (!r && sl>0);
177 } 179 }
178 return r; 180 return r;
179 } 181 }
180}; 182};
181 183
182static int muted=0; 184static int muted=0;
183static int micMuted=0; 185static int micMuted=0;
184 186
185static void setVolume(int t=0, int percent=-1) 187static void setVolume(int t=0, int percent=-1)
186{ 188{
187 switch (t) { 189 switch (t) {
188 case 0: { 190 case 0: {
189 Config cfg("qpe"); 191 Config cfg("qpe");
190 cfg.setGroup("Volume"); 192 cfg.setGroup("Volume");
191 if ( percent < 0 ) 193 if ( percent < 0 )
192 percent = cfg.readNumEntry("VolumePercent",50); 194 percent = cfg.readNumEntry("VolumePercent",50);
193 int fd = 0; 195 int fd = 0;
194 if ((fd = open("/dev/mixer", O_RDWR))>=0) { 196 if ((fd = open("/dev/mixer", O_RDWR))>=0) {
195 int vol = muted ? 0 : percent; 197 int vol = muted ? 0 : percent;
196 // set both channels to same volume 198 // set both channels to same volume
197 vol |= vol << 8; 199 vol |= vol << 8;
198 ioctl(fd, MIXER_WRITE(0), &vol); 200 ioctl(fd, MIXER_WRITE(0), &vol);
199 ::close(fd); 201 ::close(fd);
200 } 202 }
201 } break; 203 } break;
202 } 204 }
203} 205}
204 206
205static void setMic(int t=0, int percent=-1) 207static void setMic(int t=0, int percent=-1)
206{ 208{
207 switch (t) { 209 switch (t) {
208 case 0: { 210 case 0: {
209 Config cfg("qpe"); 211 Config cfg("qpe");
210 cfg.setGroup("Volume"); 212 cfg.setGroup("Volume");
211 if ( percent < 0 ) 213 if ( percent < 0 )
212 percent = cfg.readNumEntry("Mic",50); 214 percent = cfg.readNumEntry("Mic",50);
213 215
214 int fd = 0; 216 int fd = 0;
215 int mic = micMuted ? 0 : percent; 217 int mic = micMuted ? 0 : percent;
216 if ((fd = open("/dev/mixer", O_RDWR))>=0) { 218 if ((fd = open("/dev/mixer", O_RDWR))>=0) {
217 ioctl(fd, MIXER_WRITE(SOUND_MIXER_MIC), &mic); 219 ioctl(fd, MIXER_WRITE(SOUND_MIXER_MIC), &mic);
218 ::close(fd); 220 ::close(fd);
219 } 221 }
220 } break; 222 } break;
221 } 223 }
222} 224}
223 225
224int qpe_sysBrightnessSteps() 226int qpe_sysBrightnessSteps()
225{ 227{
226#if defined(QT_QWS_IPAQ) 228#if defined(QT_QWS_IPAQ)
227 return 255; 229 return 255;
228#elif defined(QT_QWS_EBX) 230#elif defined(QT_QWS_EBX)
229 return 4; 231 return 4;
230#else 232#else
231 return 255; // ? 233 return 255; // ?
232#endif 234#endif
@@ -1203,273 +1205,300 @@ void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize )
1203 1205
1204 d->nomaximize = nomaximize; 1206 d->nomaximize = nomaximize;
1205 d->qpe_main_widget = mw; 1207 d->qpe_main_widget = mw;
1206 d->sendQCopQ(); 1208 d->sendQCopQ();
1207 if ( d->preloaded ) { 1209 if ( d->preloaded ) {
1208 if(d->forceshow) { 1210 if(d->forceshow) {
1209#ifdef Q_WS_QWS 1211#ifdef Q_WS_QWS
1210 if ( !nomaximize ) 1212 if ( !nomaximize )
1211 mw->showMaximized(); 1213 mw->showMaximized();
1212 else 1214 else
1213#endif 1215#endif
1214 mw->show(); 1216 mw->show();
1215 } 1217 }
1216 } else if ( d->keep_running ) { 1218 } else if ( d->keep_running ) {
1217#ifdef Q_WS_QWS 1219#ifdef Q_WS_QWS
1218 if ( !nomaximize ) 1220 if ( !nomaximize )
1219 mw->showMaximized(); 1221 mw->showMaximized();
1220 else 1222 else
1221#endif 1223#endif
1222 mw->show(); 1224 mw->show();
1223 } 1225 }
1224} 1226}
1225 1227
1226/*! 1228/*!
1227 Sets \a mw as the mainWidget() and shows it. For small windows, 1229 Sets \a mw as the mainWidget() and shows it. For small windows,
1228 consider passing TRUE for \a nomaximize rather than the default FALSE. 1230 consider passing TRUE for \a nomaximize rather than the default FALSE.
1229 1231
1230 This calls designates the application as 1232 This calls designates the application as
1231 a \link docwidget.html document-oriented\endlink application. 1233 a \link docwidget.html document-oriented\endlink application.
1232 1234
1233 The \a mw widget must have a slot: setDocument(const QString&). 1235 The \a mw widget must have a slot: setDocument(const QString&).
1234 1236
1235 \sa showMainWidget() 1237 \sa showMainWidget()
1236*/ 1238*/
1237void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize ) 1239void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize )
1238{ 1240{
1239 setWidgetCaptionFromAppName( mw, d->appName, qpeDir() + "apps" ); 1241 setWidgetCaptionFromAppName( mw, d->appName, qpeDir() + "apps" );
1240 1242
1241 if ( mw && argc() == 2 ) 1243 if ( mw && argc() == 2 )
1242 Global::setDocument( mw, QString::fromUtf8(argv()[1]) ); 1244 Global::setDocument( mw, QString::fromUtf8(argv()[1]) );
1243 d->nomaximize = nomaximize; 1245 d->nomaximize = nomaximize;
1244 d->qpe_main_widget = mw; 1246 d->qpe_main_widget = mw;
1245 d->sendQCopQ(); 1247 d->sendQCopQ();
1246 if ( d->preloaded ) { 1248 if ( d->preloaded ) {
1247 if(d->forceshow) { 1249 if(d->forceshow) {
1248#ifdef Q_WS_QWS 1250#ifdef Q_WS_QWS
1249 if ( !nomaximize ) 1251 if ( !nomaximize )
1250 mw->showMaximized(); 1252 mw->showMaximized();
1251 else 1253 else
1252#endif 1254#endif
1253 mw->show(); 1255 mw->show();
1254 } 1256 }
1255 } else if ( d->keep_running ) { 1257 } else if ( d->keep_running ) {
1256#ifdef Q_WS_QWS 1258#ifdef Q_WS_QWS
1257 if ( !nomaximize ) 1259 if ( !nomaximize )
1258 mw->showMaximized(); 1260 mw->showMaximized();
1259 else 1261 else
1260#endif 1262#endif
1261 mw->show(); 1263 mw->show();
1262 } 1264 }
1263} 1265}
1264 1266
1265 1267
1266/*! 1268/*!
1267 Sets that the application should continue running after processing 1269 Sets that the application should continue running after processing
1268 qcop messages. Normally if an application is started via a qcop message, 1270 qcop messages. Normally if an application is started via a qcop message,
1269 the application will process the qcop message and then quit. If while 1271 the application will process the qcop message and then quit. If while
1270 processing the qcop message it calls this function, then the application 1272 processing the qcop message it calls this function, then the application
1271 will show and start proper once it has finished processing qcop messages. 1273 will show and start proper once it has finished processing qcop messages.
1272 1274
1273 \sa keepRunning() 1275 \sa keepRunning()
1274*/ 1276*/
1275void QPEApplication::setKeepRunning() 1277void QPEApplication::setKeepRunning()
1276{ 1278{
1277 if ( qApp && qApp->inherits( "QPEApplication" ) ) { 1279 if ( qApp && qApp->inherits( "QPEApplication" ) ) {
1278 QPEApplication *qpeApp = (QPEApplication*)qApp; 1280 QPEApplication *qpeApp = (QPEApplication*)qApp;
1279 qpeApp->d->keep_running = TRUE; 1281 qpeApp->d->keep_running = TRUE;
1280 } 1282 }
1281} 1283}
1282 1284
1283/*! 1285/*!
1284 Returns whether the application will quit after processing the current 1286 Returns whether the application will quit after processing the current
1285 list of qcop messages. 1287 list of qcop messages.
1286 1288
1287 \sa setKeepRunning() 1289 \sa setKeepRunning()
1288*/ 1290*/
1289bool QPEApplication::keepRunning() const 1291bool QPEApplication::keepRunning() const
1290{ 1292{
1291 return d->keep_running; 1293 return d->keep_running;
1292} 1294}
1293 1295
1294/*! 1296/*!
1295 \internal 1297 \internal
1296*/ 1298*/
1297void QPEApplication::internalSetStyle( const QString &style ) 1299void QPEApplication::internalSetStyle( const QString &style )
1298{ 1300{
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
1380*/ 1409*/
1381void QPEApplication::shutdown() 1410void QPEApplication::shutdown()
1382{ 1411{
1383 // Implement in server's QPEApplication subclass 1412 // Implement in server's QPEApplication subclass
1384} 1413}
1385 1414
1386/*! 1415/*!
1387 \internal 1416 \internal
1388*/ 1417*/
1389void QPEApplication::restart() 1418void QPEApplication::restart()
1390{ 1419{
1391 // Implement in server's QPEApplication subclass 1420 // Implement in server's QPEApplication subclass
1392} 1421}
1393 1422
1394static QPtrDict<void>* stylusDict=0; 1423static QPtrDict<void>* stylusDict=0;
1395static void createDict() 1424static void createDict()
1396{ 1425{
1397 if ( !stylusDict ) 1426 if ( !stylusDict )
1398 stylusDict = new QPtrDict<void>; 1427 stylusDict = new QPtrDict<void>;
1399} 1428}
1400 1429
1401/*! 1430/*!
1402 Returns the current StylusMode for \a w. 1431 Returns the current StylusMode for \a w.
1403 1432
1404 \sa setStylusOperation() 1433 \sa setStylusOperation()
1405*/ 1434*/
1406QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w ) 1435QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w )
1407{ 1436{
1408 if ( stylusDict ) 1437 if ( stylusDict )
1409 return (StylusMode)(int)stylusDict->find(w); 1438 return (StylusMode)(int)stylusDict->find(w);
1410 return LeftOnly; 1439 return LeftOnly;
1411} 1440}
1412 1441
1413/*! 1442/*!
1414 \enum QPEApplication::StylusMode 1443 \enum QPEApplication::StylusMode
1415 1444
1416 \value LeftOnly the stylus only generates LeftButton 1445 \value LeftOnly the stylus only generates LeftButton
1417 events (the default). 1446 events (the default).
1418 \value RightOnHold the stylus generates RightButton events 1447 \value RightOnHold the stylus generates RightButton events
1419 if the user uses the press-and-hold gesture. 1448 if the user uses the press-and-hold gesture.
1420 1449
1421 See setStylusOperation(). 1450 See setStylusOperation().
1422*/ 1451*/
1423 1452
1424/*! 1453/*!
1425 Causes \a w to receive mouse events according to \a mode. 1454 Causes \a w to receive mouse events according to \a mode.
1426 1455
1427 \sa stylusOperation() 1456 \sa stylusOperation()
1428*/ 1457*/
1429void QPEApplication::setStylusOperation( QWidget* w, StylusMode mode ) 1458void QPEApplication::setStylusOperation( QWidget* w, StylusMode mode )
1430{ 1459{
1431 createDict(); 1460 createDict();
1432 if ( mode == LeftOnly ) { 1461 if ( mode == LeftOnly ) {
1433 stylusDict->remove(w); 1462 stylusDict->remove(w);
1434 w->removeEventFilter(qApp); 1463 w->removeEventFilter(qApp);
1435 } else { 1464 } else {
1436 stylusDict->insert(w,(void*)mode); 1465 stylusDict->insert(w,(void*)mode);
1437 connect(w,SIGNAL(destroyed()),qApp,SLOT(removeSenderFromStylusDict())); 1466 connect(w,SIGNAL(destroyed()),qApp,SLOT(removeSenderFromStylusDict()));
1438 w->installEventFilter(qApp); 1467 w->installEventFilter(qApp);
1439 } 1468 }
1440} 1469}
1441 1470
1442 1471
1443/*! 1472/*!
1444 \reimp 1473 \reimp
1445*/ 1474*/
1446bool QPEApplication::eventFilter( QObject *o, QEvent *e ) 1475bool QPEApplication::eventFilter( QObject *o, QEvent *e )
1447{ 1476{
1448 if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) { 1477 if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) {
1449 QMouseEvent* me = (QMouseEvent*)e; 1478 QMouseEvent* me = (QMouseEvent*)e;
1450 if ( me->button() == LeftButton ) { 1479 if ( me->button() == LeftButton ) {
1451 StylusMode mode = (StylusMode)(int)stylusDict->find(o); 1480 StylusMode mode = (StylusMode)(int)stylusDict->find(o);
1452 switch (mode) { 1481 switch (mode) {
1453 case RightOnHold: 1482 case RightOnHold:
1454 switch ( me->type() ) { 1483 switch ( me->type() ) {
1455 case QEvent::MouseButtonPress: 1484 case QEvent::MouseButtonPress:
1456 d->presstimer = startTimer(500); // #### pref. 1485 d->presstimer = startTimer(500); // #### pref.
1457 d->presswidget = (QWidget*)o; 1486 d->presswidget = (QWidget*)o;
1458 d->presspos = me->pos(); 1487 d->presspos = me->pos();
1459 d->rightpressed = FALSE; 1488 d->rightpressed = FALSE;
1460 break; 1489 break;
1461 case QEvent::MouseButtonRelease: 1490 case QEvent::MouseButtonRelease:
1462 if ( d->presstimer ) { 1491 if ( d->presstimer ) {
1463 killTimer(d->presstimer); 1492 killTimer(d->presstimer);
1464 d->presstimer = 0; 1493 d->presstimer = 0;
1465 } 1494 }
1466 if ( d->rightpressed && d->presswidget ) { 1495 if ( d->rightpressed && d->presswidget ) {
1467 // Right released 1496 // Right released
1468 postEvent( d->presswidget, 1497 postEvent( d->presswidget,
1469 new QMouseEvent( QEvent::MouseButtonRelease, me->pos(), 1498 new QMouseEvent( QEvent::MouseButtonRelease, me->pos(),
1470 RightButton, LeftButton+RightButton ) ); 1499 RightButton, LeftButton+RightButton ) );
1471 // Left released, off-widget 1500 // Left released, off-widget
1472 postEvent( d->presswidget, 1501 postEvent( d->presswidget,
1473 new QMouseEvent( QEvent::MouseMove, QPoint(-1,-1), 1502 new QMouseEvent( QEvent::MouseMove, QPoint(-1,-1),
1474 LeftButton, LeftButton ) ); 1503 LeftButton, LeftButton ) );
1475 postEvent( d->presswidget, 1504 postEvent( d->presswidget,