summaryrefslogtreecommitdiff
path: root/library
Unidiff
Diffstat (limited to 'library') (more/less context) (ignore whitespace changes)
-rw-r--r--library/qlibrary_unix.cpp2
-rw-r--r--library/qpeapplication.cpp2
2 files changed, 2 insertions, 2 deletions
diff --git a/library/qlibrary_unix.cpp b/library/qlibrary_unix.cpp
index 2181153..fee73c2 100644
--- a/library/qlibrary_unix.cpp
+++ b/library/qlibrary_unix.cpp
@@ -1,243 +1,243 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the 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**********************************************************************/ 19**********************************************************************/
20 20
21#include "qlibrary_p.h" 21#include "qlibrary_p.h"
22 22
23#ifndef QT_NO_COMPONENT 23#ifndef QT_NO_COMPONENT
24 24
25/* 25/*
26 The platform dependent implementations of 26 The platform dependent implementations of
27 - loadLibrary 27 - loadLibrary
28 - freeLibrary 28 - freeLibrary
29 - resolveSymbol 29 - resolveSymbol
30 30
31 It's not too hard to guess what the functions do. 31 It's not too hard to guess what the functions do.
32*/ 32*/
33#if defined(Q_OS_HPUX) 33#if defined(Q_OS_HPUX)
34// for HP-UX < 11.x and 32 bit 34// for HP-UX < 11.x and 32 bit
35#include <dl.h> 35#include <dl.h>
36 36
37bool QLibraryPrivate::loadLibrary() 37bool QLibraryPrivate::loadLibrary()
38{ 38{
39 if ( pHnd ) 39 if ( pHnd )
40 return TRUE; 40 return TRUE;
41 41
42 QString filename = library->library(); 42 QString filename = library->library();
43 43
44 pHnd = (void*)shl_load( filename.latin1(), BIND_DEFERRED | BIND_NONFATAL | DYNAMIC_PATH, 0 ); 44 pHnd = (void*)shl_load( filename.latin1(), BIND_DEFERRED | BIND_NONFATAL | DYNAMIC_PATH, 0 );
45#if defined(QT_DEBUG) || defined(QT_DEBUG_COMPONENT) 45#if defined(QT_DEBUG) || defined(QT_DEBUG_COMPONENT)
46 if ( !pHnd ) 46 if ( !pHnd )
47 qDebug( "Failed to load library %s!", filename.latin1() ); 47 qDebug( "Failed to load library %s!", filename.latin1() );
48#endif 48#endif
49 return pHnd != 0; 49 return pHnd != 0;
50} 50}
51 51
52bool QLibraryPrivate::freeLibrary() 52bool QLibraryPrivate::freeLibrary()
53{ 53{
54 if ( !pHnd ) 54 if ( !pHnd )
55 return TRUE; 55 return TRUE;
56 56
57 if ( !shl_unload( (shl_t)pHnd ) ) { 57 if ( !shl_unload( (shl_t)pHnd ) ) {
58 pHnd = 0; 58 pHnd = 0;
59 return TRUE; 59 return TRUE;
60 } 60 }
61 return FALSE; 61 return FALSE;
62} 62}
63 63
64void* QLibraryPrivate::resolveSymbol( const char* symbol ) 64void* QLibraryPrivate::resolveSymbol( const char* symbol )
65{ 65{
66 if ( !pHnd ) 66 if ( !pHnd )
67 return 0; 67 return 0;
68 68
69 void* address = 0; 69 void* address = 0;
70 if ( shl_findsym( (shl_t*)&pHnd, symbol, TYPE_UNDEFINED, address ) < 0 ) { 70 if ( shl_findsym( (shl_t*)&pHnd, symbol, TYPE_UNDEFINED, address ) < 0 ) {
71#if defined(QT_DEBUG) || defined(QT_DEBUG_COMPONENT) 71#if defined(QT_DEBUG) || defined(QT_DEBUG_COMPONENT)
72 qDebug( "Couldn't resolve symbol \"%s\"", symbol ); 72 qDebug( "Couldn't resolve symbol \"%s\"", symbol );
73#endif 73#endif
74 return 0; 74 return 0;
75 } 75 }
76 return address; 76 return address;
77} 77}
78 78
79#elif defined(_NULL_LIB_) 79#elif defined(_NULL_LIB_)
80 80
81bool QLibraryPrivate::loadLibrary() 81bool QLibraryPrivate::loadLibrary()
82{ 82{
83 //qDebug("QLibraryPrivate::loadLibrary\n"); 83 //qDebug("QLibraryPrivate::loadLibrary\n");
84 return FALSE; 84 return FALSE;
85} 85}
86bool QLibraryPrivate::freeLibrary() 86bool QLibraryPrivate::freeLibrary()
87{ 87{
88 //qDebug("QLibraryPrivate::freeLibrary\n"); 88 //qDebug("QLibraryPrivate::freeLibrary\n");
89 return FALSE; 89 return FALSE;
90} 90}
91void* QLibraryPrivate::resolveSymbol( const char* symbol ) 91void* QLibraryPrivate::resolveSymbol( const char* symbol )
92{ 92{
93 //qDebug("QLibraryPrivate::resolveSymbol\n"); 93 //qDebug("QLibraryPrivate::resolveSymbol\n");
94 return FALSE; 94 return FALSE;
95} 95}
96 96
97#elif defined(Q_OS_MACX) 97#elif defined(Q_OS_MACX)
98 98
99#define ENUM_DYLD_BOOL 99#define ENUM_DYLD_BOOL
100enum DYLD_BOOL { 100enum DYLD_BOOL {
101 DYLD_FALSE, 101 DYLD_FALSE,
102 DYLD_TRUE 102 DYLD_TRUE
103}; 103};
104#include <mach-o/dyld.h> 104#include <mach-o/dyld.h>
105typedef struct { 105typedef struct {
106 NSObjectFileImage img; 106 NSObjectFileImage img;
107 NSModule mod; 107 NSModule mod;
108} DyldLibDesc; 108} DyldLibDesc;
109 109
110bool QLibraryPrivate::loadLibrary() 110bool QLibraryPrivate::loadLibrary()
111{ 111{
112 // qDebug("QLibraryPrivate::loadLibrary\n"); 112 // qDebug("QLibraryPrivate::loadLibrary\n");
113 // return FALSE; 113 // return FALSE;
114 if ( pHnd ) 114 if ( pHnd )
115 return TRUE; 115 return TRUE;
116 116
117 QString filename = library->library(); 117 QString filename = library->library();
118 118
119 NSObjectFileImage img = 0; 119 NSObjectFileImage img = 0;
120 NSModule mod = 0; 120 NSModule mod = 0;
121 NSObjectFileImageReturnCode ret = NSCreateObjectFileImageFromFile( filename.latin1() , &img ); 121 NSObjectFileImageReturnCode ret = NSCreateObjectFileImageFromFile( filename.latin1() , &img );
122 if ( ret != NSObjectFileImageSuccess ) { 122 if ( ret != NSObjectFileImageSuccess ) {
123 qWarning( "Error in NSCreateObjectFileImageFromFile(): %d; Filename: %s", ret, filename.latin1() ); 123 qWarning( "Error in NSCreateObjectFileImageFromFile(): %d; Filename: %s", ret, filename.latin1() );
124 if (ret == NSObjectFileImageAccess) { 124 if (ret == NSObjectFileImageAccess) {
125 qWarning ("(NSObjectFileImageAccess)" ); 125 qWarning ("(NSObjectFileImageAccess)" );
126 } 126 }
127 } else { 127 } else {
128 mod = NSLinkModule(img, filename.latin1(), NSLINKMODULE_OPTION_BINDNOW | 128 mod = NSLinkModule(img, filename.latin1(), NSLINKMODULE_OPTION_BINDNOW |
129 NSLINKMODULE_OPTION_PRIVATE | 129 NSLINKMODULE_OPTION_PRIVATE |
130 NSLINKMODULE_OPTION_RETURN_ON_ERROR); 130 NSLINKMODULE_OPTION_RETURN_ON_ERROR);
131 if (mod == 0) { 131 if (mod == 0) {
132 qWarning( "Error in NSLinkModule()" ); 132 qWarning( "Error in NSLinkModule()" );
133 NSDestroyObjectFileImage(img); 133 NSDestroyObjectFileImage(img);
134 } 134 }
135 } 135 }
136 DyldLibDesc* desc = 0; 136 DyldLibDesc* desc = 0;
137 if (img != 0 && mod != 0) { 137 if (img != 0 && mod != 0) {
138 desc = new DyldLibDesc; 138 desc = new DyldLibDesc;
139 desc->img = img; 139 desc->img = img;
140 desc->mod = mod; 140 desc->mod = mod;
141 } 141 }
142 pHnd = desc; 142 pHnd = desc;
143 return pHnd != 0; 143 return pHnd != 0;
144} 144}
145 145
146bool QLibraryPrivate::freeLibrary() 146bool QLibraryPrivate::freeLibrary()
147{ 147{
148 //qDebug("QLibraryPrivate::freeLibrary\n"); 148 //qDebug("QLibraryPrivate::freeLibrary\n");
149 //return FALSE; 149 //return FALSE;
150 if ( !pHnd ) 150 if ( !pHnd )
151 return TRUE; 151 return TRUE;
152 152
153 DyldLibDesc* desc = (DyldLibDesc*) pHnd; 153 DyldLibDesc* desc = (DyldLibDesc*) pHnd;
154 NSModule mod = desc->mod; 154 NSModule mod = desc->mod;
155 NSObjectFileImage img = desc->img; 155 NSObjectFileImage img = desc->img;
156 DYLD_BOOL success = NSUnLinkModule(mod, NSUNLINKMODULE_OPTION_NONE); 156 bool success = NSUnLinkModule(mod, NSUNLINKMODULE_OPTION_NONE);
157 if ( success ) { 157 if ( success ) {
158 NSDestroyObjectFileImage(img); 158 NSDestroyObjectFileImage(img);
159 delete desc; 159 delete desc;
160 pHnd = 0; 160 pHnd = 0;
161 } 161 }
162#if defined(QT_DEBUG) || defined(QT_DEBUG_COMPONENT) 162#if defined(QT_DEBUG) || defined(QT_DEBUG_COMPONENT)
163 else { 163 else {
164 qWarning( "Error in NSUnLinkModule()" ); 164 qWarning( "Error in NSUnLinkModule()" );
165 } 165 }
166#endif 166#endif
167 return pHnd == 0; 167 return pHnd == 0;
168} 168}
169 169
170void* QLibraryPrivate::resolveSymbol( const char* symbol ) 170void* QLibraryPrivate::resolveSymbol( const char* symbol )
171{ 171{
172 //qDebug("QLibraryPrivate::resolveSymbol\n"); 172 //qDebug("QLibraryPrivate::resolveSymbol\n");
173 //return FALSE; 173 //return FALSE;
174 if ( !pHnd ) 174 if ( !pHnd )
175 return 0; 175 return 0;
176 176
177 DyldLibDesc* desc = (DyldLibDesc*) pHnd; 177 DyldLibDesc* desc = (DyldLibDesc*) pHnd;
178 NSSymbol sym = NSLookupSymbolInModule(desc->mod, symbol); 178 NSSymbol sym = NSLookupSymbolInModule(desc->mod, symbol);
179 void* address = 0; 179 void* address = 0;
180 if (sym != 0) { 180 if (sym != 0) {
181 address = NSAddressOfSymbol(sym); 181 address = NSAddressOfSymbol(sym);
182 } 182 }
183#if defined(QT_DEBUG) || defined(QT_DEBUG_COMPONENT) 183#if defined(QT_DEBUG) || defined(QT_DEBUG_COMPONENT)
184 if ( address == 0 ) 184 if ( address == 0 )
185 qWarning( "Cannot find symbol: %s", symbol ); 185 qWarning( "Cannot find symbol: %s", symbol );
186#endif 186#endif
187 return address; 187 return address;
188} 188}
189 189
190#else 190#else
191// Something else, assuming POSIX 191// Something else, assuming POSIX
192#include <dlfcn.h> 192#include <dlfcn.h>
193 193
194bool QLibraryPrivate::loadLibrary() 194bool QLibraryPrivate::loadLibrary()
195{ 195{
196 if ( pHnd ) 196 if ( pHnd )
197 return TRUE; 197 return TRUE;
198 198
199 QString filename = library->library(); 199 QString filename = library->library();
200 200
201 pHnd = dlopen( filename.latin1() , RTLD_LAZY ); 201 pHnd = dlopen( filename.latin1() , RTLD_LAZY );
202// #if defined(QT_DEBUG) || defined(QT_DEBUG_COMPONENT) 202// #if defined(QT_DEBUG) || defined(QT_DEBUG_COMPONENT)
203 if ( !pHnd ) 203 if ( !pHnd )
204 qWarning( "%s", dlerror() ); 204 qWarning( "%s", dlerror() );
205// #endif 205// #endif
206 return pHnd != 0; 206 return pHnd != 0;
207} 207}
208 208
209bool QLibraryPrivate::freeLibrary() 209bool QLibraryPrivate::freeLibrary()
210{ 210{
211 if ( !pHnd ) 211 if ( !pHnd )
212 return TRUE; 212 return TRUE;
213 213
214 int ec = dlclose( pHnd ); 214 int ec = dlclose( pHnd );
215 if ( !ec ) 215 if ( !ec )
216 pHnd = 0; 216 pHnd = 0;
217#if defined(QT_DEBUG) || defined(QT_DEBUG_COMPONENT) 217#if defined(QT_DEBUG) || defined(QT_DEBUG_COMPONENT)
218 else { 218 else {
219 const char* error = dlerror(); 219 const char* error = dlerror();
220 if ( error ) 220 if ( error )
221 qWarning( "%s", error ); 221 qWarning( "%s", error );
222 } 222 }
223#endif 223#endif
224 return pHnd == 0; 224 return pHnd == 0;
225} 225}
226 226
227void* QLibraryPrivate::resolveSymbol( const char* f ) 227void* QLibraryPrivate::resolveSymbol( const char* f )
228{ 228{
229 if ( !pHnd ) 229 if ( !pHnd )
230 return 0; 230 return 0;
231 231
232 void* address = dlsym( pHnd, f ); 232 void* address = dlsym( pHnd, f );
233#if defined(QT_DEBUG) || defined(QT_DEBUG_COMPONENT) 233#if defined(QT_DEBUG) || defined(QT_DEBUG_COMPONENT)
234 const char* error = dlerror(); 234 const char* error = dlerror();
235 if ( error ) 235 if ( error )
236 qWarning( "%s", error ); 236 qWarning( "%s", error );
237#endif 237#endif
238 return address; 238 return address;
239} 239}
240 240
241#endif // POSIX 241#endif // POSIX
242 242
243#endif // QT_NO_COMPONENT 243#endif // QT_NO_COMPONENT
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp
index 19e99f2..dcc1001 100644
--- a/library/qpeapplication.cpp
+++ b/library/qpeapplication.cpp
@@ -162,2129 +162,2129 @@ public:
162 const QByteArray &d ) : 162 const QByteArray &d ) :
163 channel( ch ), message( msg ), data( d ) 163 channel( ch ), message( msg ), data( d )
164 { } 164 { }
165 165
166 QCString channel; 166 QCString channel;
167 QCString message; 167 QCString message;
168 QByteArray data; 168 QByteArray data;
169 }; 169 };
170 QGuardedPtr<QWidget> qpe_main_widget; 170 QGuardedPtr<QWidget> qpe_main_widget;
171 QGuardedPtr<QWidget> lastraised; 171 QGuardedPtr<QWidget> lastraised;
172 QQueue<QCopRec> qcopq; 172 QQueue<QCopRec> qcopq;
173 QString styleName; 173 QString styleName;
174 QString decorationName; 174 QString decorationName;
175 175
176 void enqueueQCop( const QCString &ch, const QCString &msg, 176 void enqueueQCop( const QCString &ch, const QCString &msg,
177 const QByteArray &data ) 177 const QByteArray &data )
178 { 178 {
179 qcopq.enqueue( new QCopRec( ch, msg, data ) ); 179 qcopq.enqueue( new QCopRec( ch, msg, data ) );
180 } 180 }
181 void sendQCopQ() 181 void sendQCopQ()
182 { 182 {
183 if (!qcopQok ) 183 if (!qcopQok )
184 return; 184 return;
185 185
186 QCopRec * r; 186 QCopRec * r;
187 187
188 while((r=qcopq.dequeue())) { 188 while((r=qcopq.dequeue())) {
189 // remove from queue before sending... 189 // remove from queue before sending...
190 // event loop can come around again before getting 190 // event loop can come around again before getting
191 // back from sendLocally 191 // back from sendLocally
192#ifndef QT_NO_COP 192#ifndef QT_NO_COP
193 QCopChannel::sendLocally( r->channel, r->message, r->data ); 193 QCopChannel::sendLocally( r->channel, r->message, r->data );
194#endif 194#endif
195 195
196 delete r; 196 delete r;
197 } 197 }
198 } 198 }
199 199
200 static void show_mx(QWidget* mw, bool nomaximize, QString &strName) { 200 static void show_mx(QWidget* mw, bool nomaximize, QString &strName) {
201 if ( mw->inherits("QMainWindow") || mw->isA("QMainWindow") ) 201 if ( mw->inherits("QMainWindow") || mw->isA("QMainWindow") )
202 { 202 {
203 ( ( QMainWindow* ) mw )->setUsesBigPixmaps( useBigPixmaps ); 203 ( ( QMainWindow* ) mw )->setUsesBigPixmaps( useBigPixmaps );
204 } 204 }
205 QPoint p; 205 QPoint p;
206 QSize s; 206 QSize s;
207 bool max; 207 bool max;
208 208
209 if ( mw->isVisible() ) { 209 if ( mw->isVisible() ) {
210 if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { 210 if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) {
211 mw->resize(s); 211 mw->resize(s);
212 mw->move(p); 212 mw->move(p);
213 } 213 }
214 mw->raise(); 214 mw->raise();
215 } else { 215 } else {
216 216
217 if ( mw->layout() && mw->inherits("QDialog") ) { 217 if ( mw->layout() && mw->inherits("QDialog") ) {
218 if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { 218 if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) {
219 mw->resize(s); 219 mw->resize(s);
220 mw->move(p); 220 mw->move(p);
221 221
222 if ( max && !nomaximize ) { 222 if ( max && !nomaximize ) {
223 mw->showMaximized(); 223 mw->showMaximized();
224 } else { 224 } else {
225 mw->show(); 225 mw->show();
226 } 226 }
227 } else { 227 } else {
228 QPEApplication::showDialog((QDialog*)mw,nomaximize); 228 QPEApplication::showDialog((QDialog*)mw,nomaximize);
229 } 229 }
230 } else { 230 } else {
231 if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { 231 if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) {
232 mw->resize(s); 232 mw->resize(s);
233 mw->move(p); 233 mw->move(p);
234 } else { //no stored rectangle, make an estimation 234 } else { //no stored rectangle, make an estimation
235 int x = (qApp->desktop()->width()-mw->frameGeometry().width())/2; 235 int x = (qApp->desktop()->width()-mw->frameGeometry().width())/2;
236 int y = (qApp->desktop()->height()-mw->frameGeometry().height())/2; 236 int y = (qApp->desktop()->height()-mw->frameGeometry().height())/2;
237 mw->move( QMAX(x,0), QMAX(y,0) ); 237 mw->move( QMAX(x,0), QMAX(y,0) );
238#ifdef Q_WS_QWS 238#ifdef Q_WS_QWS
239 if ( !nomaximize ) 239 if ( !nomaximize )
240 mw->showMaximized(); 240 mw->showMaximized();
241#endif 241#endif
242 } 242 }
243 if ( max && !nomaximize ) 243 if ( max && !nomaximize )
244 mw->showMaximized(); 244 mw->showMaximized();
245 else 245 else
246 mw->show(); 246 mw->show();
247 } 247 }
248 } 248 }
249 } 249 }
250 250
251 static bool read_widget_rect(const QString &app, bool &maximized, QPoint &p, QSize &s) 251 static bool read_widget_rect(const QString &app, bool &maximized, QPoint &p, QSize &s)
252 { 252 {
253#ifndef OPIE_NO_WINDOWED 253#ifndef OPIE_NO_WINDOWED
254 maximized = TRUE; 254 maximized = TRUE;
255 // 350 is the trigger in qwsdefaultdecoration for providing a resize button 255 // 350 is the trigger in qwsdefaultdecoration for providing a resize button
256 if ( qApp->desktop()->width() <= 350 ) 256 if ( qApp->desktop()->width() <= 350 )
257 return FALSE; 257 return FALSE;
258 258
259 Config cfg( "qpe" ); 259 Config cfg( "qpe" );
260 cfg.setGroup("ApplicationPositions"); 260 cfg.setGroup("ApplicationPositions");
261 QString str = cfg.readEntry( app, QString::null ); 261 QString str = cfg.readEntry( app, QString::null );
262 QStringList l = QStringList::split(",", str); 262 QStringList l = QStringList::split(",", str);
263 263
264 if ( l.count() == 5) { 264 if ( l.count() == 5) {
265 p.setX( l[0].toInt() ); 265 p.setX( l[0].toInt() );
266 p.setY( l[1].toInt() ); 266 p.setY( l[1].toInt() );
267 267
268 s.setWidth( l[2].toInt() ); 268 s.setWidth( l[2].toInt() );
269 s.setHeight( l[3].toInt() ); 269 s.setHeight( l[3].toInt() );
270 270
271 maximized = l[4].toInt(); 271 maximized = l[4].toInt();
272 272
273 return TRUE; 273 return TRUE;
274 } 274 }
275#endif 275#endif
276 return FALSE; 276 return FALSE;
277 } 277 }
278 278
279 279
280 static bool validate_widget_size(const QWidget *w, QPoint &p, QSize &s) 280 static bool validate_widget_size(const QWidget *w, QPoint &p, QSize &s)
281 { 281 {
282#ifndef Q_WS_QWS 282#ifndef Q_WS_QWS
283 QRect qt_maxWindowRect = qApp->desktop()->geometry(); 283 QRect qt_maxWindowRect = qApp->desktop()->geometry();
284#endif 284#endif
285 int maxX = qt_maxWindowRect.width(); 285 int maxX = qt_maxWindowRect.width();
286 int maxY = qt_maxWindowRect.height(); 286 int maxY = qt_maxWindowRect.height();
287 int wWidth = s.width() + ( w->frameGeometry().width() - w->geometry().width() ); 287 int wWidth = s.width() + ( w->frameGeometry().width() - w->geometry().width() );
288 int wHeight = s.height() + ( w->frameGeometry().height() - w->geometry().height() ); 288 int wHeight = s.height() + ( w->frameGeometry().height() - w->geometry().height() );
289 289
290 // total window size is not allowed to be larger than desktop window size 290 // total window size is not allowed to be larger than desktop window size
291 if ( ( wWidth >= maxX ) && ( wHeight >= maxY ) ) 291 if ( ( wWidth >= maxX ) && ( wHeight >= maxY ) )
292 return FALSE; 292 return FALSE;
293 293
294 if ( wWidth > maxX ) { 294 if ( wWidth > maxX ) {
295 s.setWidth( maxX - (w->frameGeometry().width() - w->geometry().width() ) ); 295 s.setWidth( maxX - (w->frameGeometry().width() - w->geometry().width() ) );
296 wWidth = maxX; 296 wWidth = maxX;
297 } 297 }
298 298
299 if ( wHeight > maxY ) { 299 if ( wHeight > maxY ) {
300 s.setHeight( maxY - (w->frameGeometry().height() - w->geometry().height() ) ); 300 s.setHeight( maxY - (w->frameGeometry().height() - w->geometry().height() ) );
301 wHeight = maxY; 301 wHeight = maxY;
302 } 302 }
303 303
304 // any smaller than this and the maximize/close/help buttons will be overlapping 304 // any smaller than this and the maximize/close/help buttons will be overlapping
305 if ( wWidth < 80 || wHeight < 60 ) 305 if ( wWidth < 80 || wHeight < 60 )
306 return FALSE; 306 return FALSE;
307 307
308 if ( p.x() < 0 ) 308 if ( p.x() < 0 )
309 p.setX(0); 309 p.setX(0);
310 if ( p.y() < 0 ) 310 if ( p.y() < 0 )
311 p.setY(0); 311 p.setY(0);
312 312
313 if ( p.x() + wWidth > maxX ) 313 if ( p.x() + wWidth > maxX )
314 p.setX( maxX - wWidth ); 314 p.setX( maxX - wWidth );
315 if ( p.y() + wHeight > maxY ) 315 if ( p.y() + wHeight > maxY )
316 p.setY( maxY - wHeight ); 316 p.setY( maxY - wHeight );
317 317
318 return TRUE; 318 return TRUE;
319 } 319 }
320 320
321 static void store_widget_rect(QWidget *w, QString &app) 321 static void store_widget_rect(QWidget *w, QString &app)
322 { 322 {
323 if( !w ) 323 if( !w )
324 return; 324 return;
325#ifndef OPIE_NO_WINDOWED 325#ifndef OPIE_NO_WINDOWED
326 // 350 is the trigger in qwsdefaultdecoration for providing a resize button 326 // 350 is the trigger in qwsdefaultdecoration for providing a resize button
327 if ( qApp->desktop()->width() <= 350 ) 327 if ( qApp->desktop()->width() <= 350 )
328 return; 328 return;
329 // we use these to map the offset of geometry and pos. ( we can only use normalGeometry to 329 // we use these to map the offset of geometry and pos. ( we can only use normalGeometry to
330 // get the non-maximized version, so we have to do it the hard way ) 330 // get the non-maximized version, so we have to do it the hard way )
331 int offsetX = w->x() - w->geometry().left(); 331 int offsetX = w->x() - w->geometry().left();
332 int offsetY = w->y() - w->geometry().top(); 332 int offsetY = w->y() - w->geometry().top();
333 333
334 QRect r; 334 QRect r;
335 if ( w->isMaximized() ) 335 if ( w->isMaximized() )
336 r = ( (HackWidget *) w)->normalGeometry(); 336 r = ( (HackWidget *) w)->normalGeometry();
337 else 337 else
338 r = w->geometry(); 338 r = w->geometry();
339 339
340 // Stores the window placement as pos(), size() (due to the offset mapping) 340 // Stores the window placement as pos(), size() (due to the offset mapping)
341 Config cfg( "qpe" ); 341 Config cfg( "qpe" );
342 cfg.setGroup("ApplicationPositions"); 342 cfg.setGroup("ApplicationPositions");
343 QString s; 343 QString s;
344 s.sprintf("%d,%d,%d,%d,%d", r.left() + offsetX, r.top() + offsetY, r.width(), r.height(), w->isMaximized() ); 344 s.sprintf("%d,%d,%d,%d,%d", r.left() + offsetX, r.top() + offsetY, r.width(), r.height(), w->isMaximized() );
345 cfg.writeEntry( app, s ); 345 cfg.writeEntry( app, s );
346#endif 346#endif
347 } 347 }
348 348
349 static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) 349 static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ )
350 { 350 {
351 /* 351 /*
352 // This works but disable it for now until it is safe to apply 352 // This works but disable it for now until it is safe to apply
353 // What is does is scan the .desktop files of all the apps for 353 // What is does is scan the .desktop files of all the apps for
354 // the applnk that has the corresponding argv[0] as this program 354 // the applnk that has the corresponding argv[0] as this program
355 // then it uses the name stored in the .desktop file as the caption 355 // then it uses the name stored in the .desktop file as the caption
356 // for the main widget. This saves duplicating translations for 356 // for the main widget. This saves duplicating translations for
357 // the app name in the program and in the .desktop files. 357 // the app name in the program and in the .desktop files.
358 358
359 AppLnkSet apps( appsPath ); 359 AppLnkSet apps( appsPath );
360 360
361 QList<AppLnk> appsList = apps.children(); 361 QList<AppLnk> appsList = apps.children();
362 for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { 362 for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) {
363 if ( (*it)->exec() == appName ) { 363 if ( (*it)->exec() == appName ) {
364 mw->setCaption( (*it)->name() ); 364 mw->setCaption( (*it)->name() );
365 return TRUE; 365 return TRUE;
366 } 366 }
367 } 367 }
368 */ 368 */
369 return FALSE; 369 return FALSE;
370 } 370 }
371 371
372 372
373 void show(QWidget* mw, bool nomax) 373 void show(QWidget* mw, bool nomax)
374 { 374 {
375 setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" ); 375 setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" );
376 nomaximize = nomax; 376 nomaximize = nomax;
377 qpe_main_widget = mw; 377 qpe_main_widget = mw;
378 qcopQok = TRUE; 378 qcopQok = TRUE;
379#ifndef QT_NO_COP 379#ifndef QT_NO_COP
380 380
381 sendQCopQ(); 381 sendQCopQ();
382#endif 382#endif
383 383
384 if ( preloaded ) { 384 if ( preloaded ) {
385 if (forceshow) 385 if (forceshow)
386 show_mx(mw, nomax, appName); 386 show_mx(mw, nomax, appName);
387 } 387 }
388 else if ( keep_running ) { 388 else if ( keep_running ) {
389 show_mx(mw, nomax, appName); 389 show_mx(mw, nomax, appName);
390 } 390 }
391 } 391 }
392 392
393 void loadTextCodecs() 393 void loadTextCodecs()
394 { 394 {
395 QString path = QPEApplication::qpeDir() + "plugins/textcodecs"; 395 QString path = QPEApplication::qpeDir() + "plugins/textcodecs";
396#ifdef Q_OS_MACX 396#ifdef Q_OS_MACX
397 QDir dir( path, "lib*.dylib" ); 397 QDir dir( path, "lib*.dylib" );
398#else 398#else
399 QDir dir( path, "lib*.so" ); 399 QDir dir( path, "lib*.so" );
400#endif 400#endif
401 QStringList list; 401 QStringList list;
402 if ( dir. exists ( )) 402 if ( dir. exists ( ))
403 list = dir.entryList(); 403 list = dir.entryList();
404 QStringList::Iterator it; 404 QStringList::Iterator it;
405 for ( it = list.begin(); it != list.end(); ++it ) { 405 for ( it = list.begin(); it != list.end(); ++it ) {
406 TextCodecInterface *iface = 0; 406 TextCodecInterface *iface = 0;
407 QLibrary *lib = new QLibrary( path + "/" + *it ); 407 QLibrary *lib = new QLibrary( path + "/" + *it );
408 if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { 408 if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) {
409 QValueList<int> mibs = iface->mibEnums(); 409 QValueList<int> mibs = iface->mibEnums();
410 for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) { 410 for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) {
411 (void)iface->createForMib(*i); 411 (void)iface->createForMib(*i);
412 // ### it exists now; need to remember if we can delete it 412 // ### it exists now; need to remember if we can delete it
413 } 413 }
414 } 414 }
415 else { 415 else {
416 lib->unload(); 416 lib->unload();
417 delete lib; 417 delete lib;
418 } 418 }
419 } 419 }
420 } 420 }
421 421
422 void loadImageCodecs() 422 void loadImageCodecs()
423 { 423 {
424 QString path = QPEApplication::qpeDir() + "plugins/imagecodecs"; 424 QString path = QPEApplication::qpeDir() + "plugins/imagecodecs";
425#ifdef Q_OS_MACX 425#ifdef Q_OS_MACX
426 QDir dir( path, "lib*.dylib" ); 426 QDir dir( path, "lib*.dylib" );
427#else 427#else
428 QDir dir( path, "lib*.so" ); 428 QDir dir( path, "lib*.so" );
429#endif 429#endif
430 QStringList list; 430 QStringList list;
431 if ( dir. exists ( )) 431 if ( dir. exists ( ))
432 list = dir.entryList(); 432 list = dir.entryList();
433 QStringList::Iterator it; 433 QStringList::Iterator it;
434 for ( it = list.begin(); it != list.end(); ++it ) { 434 for ( it = list.begin(); it != list.end(); ++it ) {
435 ImageCodecInterface *iface = 0; 435 ImageCodecInterface *iface = 0;
436 QLibrary *lib = new QLibrary( path + "/" + *it ); 436 QLibrary *lib = new QLibrary( path + "/" + *it );
437 if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { 437 if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) {
438 QStringList formats = iface->keys(); 438 QStringList formats = iface->keys();
439 for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) { 439 for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) {
440 (void)iface->installIOHandler(*i); 440 (void)iface->installIOHandler(*i);
441 // ### it exists now; need to remember if we can delete it 441 // ### it exists now; need to remember if we can delete it
442 } 442 }
443 } 443 }
444 else { 444 else {
445 lib->unload(); 445 lib->unload();
446 delete lib; 446 delete lib;
447 } 447 }
448 } 448 }
449 } 449 }
450 450
451}; 451};
452 452
453class ResourceMimeFactory : public QMimeSourceFactory 453class ResourceMimeFactory : public QMimeSourceFactory
454{ 454{
455public: 455public:
456 ResourceMimeFactory() : resImage( 0 ) 456 ResourceMimeFactory() : resImage( 0 )
457 { 457 {
458 setFilePath( Global::helpPath() ); 458 setFilePath( Global::helpPath() );
459 setExtensionType( "html", "text/html;charset=UTF-8" ); 459 setExtensionType( "html", "text/html;charset=UTF-8" );
460 } 460 }
461 ~ResourceMimeFactory() { 461 ~ResourceMimeFactory() {
462 delete resImage; 462 delete resImage;
463 } 463 }
464 464
465 const QMimeSource* data( const QString& abs_name ) const 465 const QMimeSource* data( const QString& abs_name ) const
466 { 466 {
467 const QMimeSource * r = QMimeSourceFactory::data( abs_name ); 467 const QMimeSource * r = QMimeSourceFactory::data( abs_name );
468 if ( !r ) { 468 if ( !r ) {
469 int sl = abs_name.length(); 469 int sl = abs_name.length();
470 do { 470 do {
471 sl = abs_name.findRev( '/', sl - 1 ); 471 sl = abs_name.findRev( '/', sl - 1 );
472 QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; 472 QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name;
473 int dot = name.findRev( '.' ); 473 int dot = name.findRev( '.' );
474 if ( dot >= 0 ) 474 if ( dot >= 0 )
475 name = name.left( dot ); 475 name = name.left( dot );
476 QImage img = Resource::loadImage( name ); 476 QImage img = Resource::loadImage( name );
477 if ( !img.isNull() ) { 477 if ( !img.isNull() ) {
478 delete resImage; 478 delete resImage;
479 resImage = new QImageDrag( img ); 479 resImage = new QImageDrag( img );
480 r = resImage; 480 r = resImage;
481 } 481 }
482 } 482 }
483 while ( !r && sl > 0 ); 483 while ( !r && sl > 0 );
484 } 484 }
485 return r; 485 return r;
486 } 486 }
487private: 487private:
488 mutable QImageDrag *resImage; 488 mutable QImageDrag *resImage;
489}; 489};
490 490
491static int& hack(int& i) 491static int& hack(int& i)
492{ 492{
493#if QT_VERSION <= 230 && defined(QT_NO_CODECS) 493#if QT_VERSION <= 230 && defined(QT_NO_CODECS)
494 // These should be created, but aren't in Qt 2.3.0 494 // These should be created, but aren't in Qt 2.3.0
495 (void)new QUtf8Codec; 495 (void)new QUtf8Codec;
496 (void)new QUtf16Codec; 496 (void)new QUtf16Codec;
497#endif 497#endif
498 return i; 498 return i;
499} 499}
500 500
501static int muted = 0; 501static int muted = 0;
502static int micMuted = 0; 502static int micMuted = 0;
503 503
504static void setVolume( int t = 0, int percent = -1 ) 504static void setVolume( int t = 0, int percent = -1 )
505{ 505{
506 switch ( t ) { 506 switch ( t ) {
507 case 0: { 507 case 0: {
508 Config cfg( "qpe" ); 508 Config cfg( "qpe" );
509 cfg.setGroup( "Volume" ); 509 cfg.setGroup( "Volume" );
510 if ( percent < 0 ) 510 if ( percent < 0 )
511 percent = cfg.readNumEntry( "VolumePercent", 50 ); 511 percent = cfg.readNumEntry( "VolumePercent", 50 );
512#ifndef QT_NO_SOUND 512#ifndef QT_NO_SOUND
513 int fd = 0; 513 int fd = 0;
514#ifdef QT_QWS_DEVFS 514#ifdef QT_QWS_DEVFS
515 if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) { 515 if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) {
516#else 516#else
517 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { 517 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
518#endif 518#endif
519 int vol = muted ? 0 : percent; 519 int vol = muted ? 0 : percent;
520 // set both channels to same volume 520 // set both channels to same volume
521 vol |= vol << 8; 521 vol |= vol << 8;
522 ioctl( fd, MIXER_WRITE( SOUND_MIXER_VOLUME ), &vol ); 522 ioctl( fd, MIXER_WRITE( SOUND_MIXER_VOLUME ), &vol );
523 ::close( fd ); 523 ::close( fd );
524 } 524 }
525#endif 525#endif
526 } 526 }
527 break; 527 break;
528 } 528 }
529} 529}
530 530
531static void setMic( int t = 0, int percent = -1 ) 531static void setMic( int t = 0, int percent = -1 )
532{ 532{
533 switch ( t ) { 533 switch ( t ) {
534 case 0: { 534 case 0: {
535 Config cfg( "qpe" ); 535 Config cfg( "qpe" );
536 cfg.setGroup( "Volume" ); 536 cfg.setGroup( "Volume" );
537 if ( percent < 0 ) 537 if ( percent < 0 )
538 percent = cfg.readNumEntry( "Mic", 50 ); 538 percent = cfg.readNumEntry( "Mic", 50 );
539 539
540#ifndef QT_NO_SOUND 540#ifndef QT_NO_SOUND
541 int fd = 0; 541 int fd = 0;
542 int mic = micMuted ? 0 : percent; 542 int mic = micMuted ? 0 : percent;
543#ifdef QT_QWS_DEVFS 543#ifdef QT_QWS_DEVFS
544 if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) { 544 if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) {
545#else 545#else
546 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { 546 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
547#endif 547#endif
548 ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic ); 548 ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic );
549 ::close( fd ); 549 ::close( fd );
550 } 550 }
551#endif 551#endif
552 } 552 }
553 break; 553 break;
554 } 554 }
555} 555}
556 556
557 557
558static void setBass( int t = 0, int percent = -1 ) 558static void setBass( int t = 0, int percent = -1 )
559{ 559{
560 switch ( t ) { 560 switch ( t ) {
561 case 0: { 561 case 0: {
562 Config cfg( "qpe" ); 562 Config cfg( "qpe" );
563 cfg.setGroup( "Volume" ); 563 cfg.setGroup( "Volume" );
564 if ( percent < 0 ) 564 if ( percent < 0 )
565 percent = cfg.readNumEntry( "BassPercent", 50 ); 565 percent = cfg.readNumEntry( "BassPercent", 50 );
566 566
567#ifndef QT_NO_SOUND 567#ifndef QT_NO_SOUND
568 int fd = 0; 568 int fd = 0;
569 int bass = percent; 569 int bass = percent;
570#ifdef QT_QWS_DEVFS 570#ifdef QT_QWS_DEVFS
571 if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) { 571 if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) {
572#else 572#else
573 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { 573 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
574#endif 574#endif
575 ioctl( fd, MIXER_WRITE( SOUND_MIXER_BASS ), &bass ); 575 ioctl( fd, MIXER_WRITE( SOUND_MIXER_BASS ), &bass );
576 ::close( fd ); 576 ::close( fd );
577 } 577 }
578#endif 578#endif
579 } 579 }
580 break; 580 break;
581 } 581 }
582} 582}
583 583
584 584
585static void setTreble( int t = 0, int percent = -1 ) 585static void setTreble( int t = 0, int percent = -1 )
586{ 586{
587 switch ( t ) { 587 switch ( t ) {
588 case 0: { 588 case 0: {
589 Config cfg( "qpe" ); 589 Config cfg( "qpe" );
590 cfg.setGroup( "Volume" ); 590 cfg.setGroup( "Volume" );
591 if ( percent < 0 ) 591 if ( percent < 0 )
592 percent = cfg.readNumEntry( "TreblePercent", 50 ); 592 percent = cfg.readNumEntry( "TreblePercent", 50 );
593 593
594#ifndef QT_NO_SOUND 594#ifndef QT_NO_SOUND
595 int fd = 0; 595 int fd = 0;
596 int treble = percent; 596 int treble = percent;
597#ifdef QT_QWS_DEVFS 597#ifdef QT_QWS_DEVFS
598 if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) { 598 if ( ( fd = open( "/dev/sound/mixer", O_RDWR ) ) >= 0 ) {
599#else 599#else
600 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { 600 if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) {
601#endif 601#endif
602 ioctl( fd, MIXER_WRITE( SOUND_MIXER_TREBLE ), &treble ); 602 ioctl( fd, MIXER_WRITE( SOUND_MIXER_TREBLE ), &treble );
603 ::close( fd ); 603 ::close( fd );
604 } 604 }
605#endif 605#endif
606 } 606 }
607 break; 607 break;
608 } 608 }
609} 609}
610 610
611 611
612/** 612/**
613 \class QPEApplication 613 \class QPEApplication
614 \brief The QPEApplication class implements various system services 614 \brief The QPEApplication class implements various system services
615 that are available to all Qtopia applications. 615 that are available to all Qtopia applications.
616 616
617 Simply by using QPEApplication instead of QApplication, a standard Qt 617 Simply by using QPEApplication instead of QApplication, a standard Qt
618 application becomes a Qtopia application. It automatically follows 618 application becomes a Qtopia application. It automatically follows
619 style changes, quits and raises, and in the 619 style changes, quits and raises, and in the
620 case of \link docwidget.html document-oriented\endlink applications, 620 case of \link docwidget.html document-oriented\endlink applications,
621 changes the currently displayed document in response to the environment. 621 changes the currently displayed document in response to the environment.
622 622
623 To create a \link docwidget.html document-oriented\endlink 623 To create a \link docwidget.html document-oriented\endlink
624 application use showMainDocumentWidget(); to create a 624 application use showMainDocumentWidget(); to create a
625 non-document-oriented application use showMainWidget(). The 625 non-document-oriented application use showMainWidget(). The
626 keepRunning() function indicates whether the application will 626 keepRunning() function indicates whether the application will
627 continue running after it's processed the last \link qcop.html 627 continue running after it's processed the last \link qcop.html
628 QCop\endlink message. This can be changed using setKeepRunning(). 628 QCop\endlink message. This can be changed using setKeepRunning().
629 629
630 A variety of signals are emitted when certain events occur, for 630 A variety of signals are emitted when certain events occur, for
631 example, timeChanged(), clockChanged(), weekChanged(), 631 example, timeChanged(), clockChanged(), weekChanged(),
632 dateFormatChanged() and volumeChanged(). If the application receives 632 dateFormatChanged() and volumeChanged(). If the application receives
633 a \link qcop.html QCop\endlink message on the application's 633 a \link qcop.html QCop\endlink message on the application's
634 QPE/Application/\e{appname} channel, the appMessage() signal is 634 QPE/Application/\e{appname} channel, the appMessage() signal is
635 emitted. There are also flush() and reload() signals, which 635 emitted. There are also flush() and reload() signals, which
636 are emitted when synching begins and ends respectively - upon these 636 are emitted when synching begins and ends respectively - upon these
637 signals, the application should save and reload any data 637 signals, the application should save and reload any data
638 files that are involved in synching. Most of these signals will initially 638 files that are involved in synching. Most of these signals will initially
639 be received and unfiltered through the appMessage() signal. 639 be received and unfiltered through the appMessage() signal.
640 640
641 This class also provides a set of useful static functions. The 641 This class also provides a set of useful static functions. The
642 qpeDir() and documentDir() functions return the respective paths. 642 qpeDir() and documentDir() functions return the respective paths.
643 The grabKeyboard() and ungrabKeyboard() functions are used to 643 The grabKeyboard() and ungrabKeyboard() functions are used to
644 control whether the application takes control of the device's 644 control whether the application takes control of the device's
645 physical buttons (e.g. application launch keys). The stylus' mode of 645 physical buttons (e.g. application launch keys). The stylus' mode of
646 operation is set with setStylusOperation() and retrieved with 646 operation is set with setStylusOperation() and retrieved with
647 stylusOperation(). There are also setInputMethodHint() and 647 stylusOperation(). There are also setInputMethodHint() and
648 inputMethodHint() functions. 648 inputMethodHint() functions.
649 649
650 \ingroup qtopiaemb 650 \ingroup qtopiaemb
651*/ 651*/
652 652
653/*! 653/*!
654 \fn void QPEApplication::clientMoused() 654 \fn void QPEApplication::clientMoused()
655 655
656 \internal 656 \internal
657*/ 657*/
658 658
659/*! 659/*!
660 \fn void QPEApplication::timeChanged(); 660 \fn void QPEApplication::timeChanged();
661 This signal is emitted when the time changes outside the normal 661 This signal is emitted when the time changes outside the normal
662 passage of time, i.e. if the time is set backwards or forwards. 662 passage of time, i.e. if the time is set backwards or forwards.
663*/ 663*/
664 664
665/*! 665/*!
666 \fn void QPEApplication::clockChanged( bool ampm ); 666 \fn void QPEApplication::clockChanged( bool ampm );
667 667
668 This signal is emitted when the user changes the clock's style. If 668 This signal is emitted when the user changes the clock's style. If
669 \a ampm is TRUE, the user wants a 12-hour AM/PM clock, otherwise, 669 \a ampm is TRUE, the user wants a 12-hour AM/PM clock, otherwise,
670 they want a 24-hour clock. 670 they want a 24-hour clock.
671*/ 671*/
672 672
673/*! 673/*!
674 \fn void QPEApplication::volumeChanged( bool muted ) 674 \fn void QPEApplication::volumeChanged( bool muted )
675 675
676 This signal is emitted whenever the mute state is changed. If \a 676 This signal is emitted whenever the mute state is changed. If \a
677 muted is TRUE, then sound output has been muted. 677 muted is TRUE, then sound output has been muted.
678*/ 678*/
679 679
680/*! 680/*!
681 \fn void QPEApplication::weekChanged( bool startOnMonday ) 681 \fn void QPEApplication::weekChanged( bool startOnMonday )
682 682
683 This signal is emitted if the week start day is changed. If \a 683 This signal is emitted if the week start day is changed. If \a
684 startOnMonday is TRUE then the first day of the week is Monday; if 684 startOnMonday is TRUE then the first day of the week is Monday; if
685 \a startOnMonday is FALSE then the first day of the week is 685 \a startOnMonday is FALSE then the first day of the week is
686 Sunday. 686 Sunday.
687*/ 687*/
688 688
689/*! 689/*!
690 \fn void QPEApplication::dateFormatChanged(DateFormat) 690 \fn void QPEApplication::dateFormatChanged(DateFormat)
691 691
692 This signal is emitted whenever the date format is changed. 692 This signal is emitted whenever the date format is changed.
693*/ 693*/
694 694
695/*! 695/*!
696 \fn void QPEApplication::flush() 696 \fn void QPEApplication::flush()
697 697
698 ### 698 ###
699*/ 699*/
700 700
701/*! 701/*!
702 \fn void QPEApplication::reload() 702 \fn void QPEApplication::reload()
703 703
704*/ 704*/
705 705
706 706
707 707
708void QPEApplication::processQCopFile() 708void QPEApplication::processQCopFile()
709{ 709{
710 QString qcopfn("/tmp/qcop-msg-"); 710 QString qcopfn("/tmp/qcop-msg-");
711 qcopfn += d->appName; // append command name 711 qcopfn += d->appName; // append command name
712 712
713 QFile f(qcopfn); 713 QFile f(qcopfn);
714 if ( f.open(IO_ReadWrite) ) { 714 if ( f.open(IO_ReadWrite) ) {
715#ifndef Q_OS_WIN32 715#ifndef Q_OS_WIN32
716 flock(f.handle(), LOCK_EX); 716 flock(f.handle(), LOCK_EX);
717#endif 717#endif
718 QDataStream ds(&f); 718 QDataStream ds(&f);
719 QCString channel, message; 719 QCString channel, message;
720 QByteArray data; 720 QByteArray data;
721 while(!ds.atEnd()) { 721 while(!ds.atEnd()) {
722 ds >> channel >> message >> data; 722 ds >> channel >> message >> data;
723 d->enqueueQCop(channel,message,data); 723 d->enqueueQCop(channel,message,data);
724 } 724 }
725 ::ftruncate(f.handle(), 0); 725 ::ftruncate(f.handle(), 0);
726#ifndef Q_OS_WIN32 726#ifndef Q_OS_WIN32
727 f.flush(); 727 f.flush();
728 flock(f.handle(), LOCK_UN); 728 flock(f.handle(), LOCK_UN);
729#endif 729#endif
730 } 730 }
731#endif 731#endif
732} 732}
733 733
734 734
735/*! 735/*!
736 \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data ) 736 \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data )
737 737
738 This signal is emitted when a message is received on this 738 This signal is emitted when a message is received on this
739 application's QPE/Application/<i>appname</i> \link qcop.html 739 application's QPE/Application/<i>appname</i> \link qcop.html
740 QCop\endlink channel. 740 QCop\endlink channel.
741 741
742 The slot to which you connect this signal uses \a msg and \a data 742 The slot to which you connect this signal uses \a msg and \a data
743 in the following way: 743 in the following way:
744 744
745\code 745\code
746 void MyWidget::receive( const QCString& msg, const QByteArray& data ) 746 void MyWidget::receive( const QCString& msg, const QByteArray& data )
747 { 747 {
748 QDataStream stream( data, IO_ReadOnly ); 748 QDataStream stream( data, IO_ReadOnly );
749 if ( msg == "someMessage(int,int,int)" ) { 749 if ( msg == "someMessage(int,int,int)" ) {
750 int a,b,c; 750 int a,b,c;
751 stream >> a >> b >> c; 751 stream >> a >> b >> c;
752 ... 752 ...
753 } else if ( msg == "otherMessage(QString)" ) { 753 } else if ( msg == "otherMessage(QString)" ) {
754 ... 754 ...
755 } 755 }
756 } 756 }
757\endcode 757\endcode
758 758
759 \sa qcop.html 759 \sa qcop.html
760 Note that messages received here may be processed by qpe application 760 Note that messages received here may be processed by qpe application
761 and emitted as signals, such as flush() and reload(). 761 and emitted as signals, such as flush() and reload().
762*/ 762*/
763 763
764#ifndef QT_NO_TRANSLATION 764#ifndef QT_NO_TRANSLATION
765static void qtopia_loadTranslations( const QStringList& qms ) 765static void qtopia_loadTranslations( const QStringList& qms )
766{ 766{
767 QStringList langs = Global::languageList(); 767 QStringList langs = Global::languageList();
768 768
769 for (QStringList::ConstIterator it = langs.begin(); it!=langs.end(); ++it) { 769 for (QStringList::ConstIterator it = langs.begin(); it!=langs.end(); ++it) {
770 QString lang = *it; 770 QString lang = *it;
771 771
772 QTranslator * trans; 772 QTranslator * trans;
773 QString tfn; 773 QString tfn;
774 774
775 for (QStringList::ConstIterator qmit = qms.begin(); qmit!=qms.end(); ++qmit) { 775 for (QStringList::ConstIterator qmit = qms.begin(); qmit!=qms.end(); ++qmit) {
776 trans = new QTranslator(qApp); 776 trans = new QTranslator(qApp);
777 tfn = QPEApplication::qpeDir() + "i18n/" + lang + "/" + *qmit + ".qm"; 777 tfn = QPEApplication::qpeDir() + "i18n/" + lang + "/" + *qmit + ".qm";
778 if ( trans->load( tfn )) 778 if ( trans->load( tfn ))
779 qApp->installTranslator( trans ); 779 qApp->installTranslator( trans );
780 else 780 else
781 delete trans; 781 delete trans;
782 } 782 }
783 } 783 }
784} 784}
785#endif 785#endif
786 786
787/* 787/*
788 Turn off qDebug in release mode 788 Turn off qDebug in release mode
789 */ 789 */
790static void qtopiaMsgHandler(QtMsgType type, const char* msg) 790static void qtopiaMsgHandler(QtMsgType type, const char* msg)
791{ 791{
792 switch ( type ) { 792 switch ( type ) {
793 case QtDebugMsg: 793 case QtDebugMsg:
794#ifdef QT_DEBUG 794#ifdef QT_DEBUG
795 fprintf( stderr, "Debug: %s\n", msg ); 795 fprintf( stderr, "Debug: %s\n", msg );
796#endif 796#endif
797 break; 797 break;
798 case QtWarningMsg: 798 case QtWarningMsg:
799#ifdef QT_DEBUG 799#ifdef QT_DEBUG
800 fprintf( stderr, "Warning: %s\n", msg ); 800 fprintf( stderr, "Warning: %s\n", msg );
801#endif 801#endif
802 break; 802 break;
803 case QtFatalMsg: 803 case QtFatalMsg:
804 fprintf( stderr, "Fatal: %s\n", msg ); 804 fprintf( stderr, "Fatal: %s\n", msg );
805 abort(); 805 abort();
806 } 806 }
807} 807}
808 808
809/*! 809/*!
810 Constructs a QPEApplication just as you would construct 810 Constructs a QPEApplication just as you would construct
811 a QApplication, passing \a argc, \a argv, and \a t. 811 a QApplication, passing \a argc, \a argv, and \a t.
812 812
813 For applications, \a t should be the default, GuiClient. Only 813 For applications, \a t should be the default, GuiClient. Only
814 the Qtopia server passes GuiServer. 814 the Qtopia server passes GuiServer.
815*/ 815*/
816QPEApplication::QPEApplication( int & argc, char **argv, Type t ) 816QPEApplication::QPEApplication( int & argc, char **argv, Type t )
817 : QApplication( hack(argc), argv, t ), pidChannel( 0 ) 817 : QApplication( hack(argc), argv, t ), pidChannel( 0 )
818{ 818{
819 QPixmapCache::setCacheLimit(256); // sensible default for smaller devices. 819 QPixmapCache::setCacheLimit(256); // sensible default for smaller devices.
820 qInstallMsgHandler(qtopiaMsgHandler); 820 qInstallMsgHandler(qtopiaMsgHandler);
821 821
822 d = new QPEApplicationData; 822 d = new QPEApplicationData;
823 d->loadTextCodecs(); 823 d->loadTextCodecs();
824 d->loadImageCodecs(); 824 d->loadImageCodecs();
825 825
826 setFont( QFont( d->fontFamily, d->fontSize ) ); 826 setFont( QFont( d->fontFamily, d->fontSize ) );
827 AppLnk::setSmallIconSize( d->smallIconSize ); 827 AppLnk::setSmallIconSize( d->smallIconSize );
828 AppLnk::setBigIconSize( d->bigIconSize ); 828 AppLnk::setBigIconSize( d->bigIconSize );
829 829
830 QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory ); 830 QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory );
831 831
832 connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) ); 832 connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) );
833 833
834 834
835 sysChannel = new QCopChannel( "QPE/System", this ); 835 sysChannel = new QCopChannel( "QPE/System", this );
836 connect( sysChannel, SIGNAL( received(const QCString&,const QByteArray&) ), 836 connect( sysChannel, SIGNAL( received(const QCString&,const QByteArray&) ),
837 this, SLOT( systemMessage(const QCString&,const QByteArray&) ) ); 837 this, SLOT( systemMessage(const QCString&,const QByteArray&) ) );
838 838
839/* COde now in initapp */ 839/* COde now in initapp */
840#if 0 840#if 0
841#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 841#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
842 842
843 QString qcopfn( "/tmp/qcop-msg-" ); 843 QString qcopfn( "/tmp/qcop-msg-" );
844 qcopfn += QString( argv[ 0 ] ); // append command name 844 qcopfn += QString( argv[ 0 ] ); // append command name
845 845
846 QFile f( qcopfn ); 846 QFile f( qcopfn );
847 if ( f.open( IO_ReadOnly ) ) { 847 if ( f.open( IO_ReadOnly ) ) {
848 flock( f.handle(), LOCK_EX ); 848 flock( f.handle(), LOCK_EX );
849 } 849 }
850 850
851 851
852 852
853 QCString channel = QCString( argv[ 0 ] ); 853 QCString channel = QCString( argv[ 0 ] );
854 channel.replace( QRegExp( ".*/" ), "" ); 854 channel.replace( QRegExp( ".*/" ), "" );
855 d->appName = channel; 855 d->appName = channel;
856 channel = "QPE/Application/" + channel; 856 channel = "QPE/Application/" + channel;
857 pidChannel = new QCopChannel( channel, this ); 857 pidChannel = new QCopChannel( channel, this );
858 connect( pidChannel, SIGNAL( received(const QCString&,const QByteArray&) ), 858 connect( pidChannel, SIGNAL( received(const QCString&,const QByteArray&) ),
859 this, SLOT( pidMessage(const QCString&,const QByteArray&) ) ); 859 this, SLOT( pidMessage(const QCString&,const QByteArray&) ) );
860 860
861 if ( f.isOpen() ) { 861 if ( f.isOpen() ) {
862 d->keep_running = FALSE; 862 d->keep_running = FALSE;
863 QDataStream ds( &f ); 863 QDataStream ds( &f );
864 QCString channel, message; 864 QCString channel, message;
865 QByteArray data; 865 QByteArray data;
866 while ( !ds.atEnd() ) { 866 while ( !ds.atEnd() ) {
867 ds >> channel >> message >> data; 867 ds >> channel >> message >> data;
868 d->enqueueQCop( channel, message, data ); 868 d->enqueueQCop( channel, message, data );
869 } 869 }
870 870
871 flock( f.handle(), LOCK_UN ); 871 flock( f.handle(), LOCK_UN );
872 f.close(); 872 f.close();
873 f.remove(); 873 f.remove();
874 } 874 }
875 875
876 for ( int a = 0; a < argc; a++ ) { 876 for ( int a = 0; a < argc; a++ ) {
877 if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) { 877 if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) {
878 argv[ a ] = argv[ a + 1 ]; 878 argv[ a ] = argv[ a + 1 ];
879 a++; 879 a++;
880 d->preloaded = TRUE; 880 d->preloaded = TRUE;
881 argc -= 1; 881 argc -= 1;
882 } 882 }
883 else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) { 883 else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) {
884 argv[ a ] = argv[ a + 1 ]; 884 argv[ a ] = argv[ a + 1 ];
885 a++; 885 a++;
886 d->preloaded = TRUE; 886 d->preloaded = TRUE;
887 d->forceshow = TRUE; 887 d->forceshow = TRUE;
888 argc -= 1; 888 argc -= 1;
889 } 889 }
890 } 890 }
891 891
892 /* overide stored arguments */ 892 /* overide stored arguments */
893 setArgs( argc, argv ); 893 setArgs( argc, argv );
894 894
895#endif 895#endif
896#else 896#else
897 initApp( argc, argv ); 897 initApp( argc, argv );
898#endif 898#endif
899#ifdef Q_WS_QWS 899#ifdef Q_WS_QWS
900 /* load the font renderer factories */ 900 /* load the font renderer factories */
901 FontDatabase::loadRenderers(); 901 FontDatabase::loadRenderers();
902#endif 902#endif
903#ifndef QT_NO_TRANSLATION 903#ifndef QT_NO_TRANSLATION
904 QStringList qms; 904 QStringList qms;
905 qms << "libqpe"; 905 qms << "libqpe";
906 qms << "libopie"; 906 qms << "libopie";
907 qms << d->appName; 907 qms << d->appName;
908 908
909 qtopia_loadTranslations(qms); 909 qtopia_loadTranslations(qms);
910#endif 910#endif
911 911
912 applyStyle(); 912 applyStyle();
913 913
914 if ( type() == GuiServer ) { 914 if ( type() == GuiServer ) {
915 setVolume(); 915 setVolume();
916 } 916 }
917 917
918 installEventFilter( this ); 918 installEventFilter( this );
919 919
920 QPEMenuToolFocusManager::initialize(); 920 QPEMenuToolFocusManager::initialize();
921 921
922#ifdef QT_NO_QWS_CURSOR 922#ifdef QT_NO_QWS_CURSOR
923 // if we have no cursor, probably don't want tooltips 923 // if we have no cursor, probably don't want tooltips
924 QToolTip::setEnabled( FALSE ); 924 QToolTip::setEnabled( FALSE );
925#endif 925#endif
926} 926}
927 927
928 928
929#ifdef QTOPIA_INTERNAL_INITAPP 929#ifdef QTOPIA_INTERNAL_INITAPP
930void QPEApplication::initApp( int argc, char **argv ) 930void QPEApplication::initApp( int argc, char **argv )
931{ 931{
932 delete pidChannel; 932 delete pidChannel;
933 d->keep_running = TRUE; 933 d->keep_running = TRUE;
934 d->preloaded = FALSE; 934 d->preloaded = FALSE;
935 d->forceshow = FALSE; 935 d->forceshow = FALSE;
936 936
937 QCString channel = QCString(argv[0]); 937 QCString channel = QCString(argv[0]);
938 938
939 channel.replace(QRegExp(".*/"),""); 939 channel.replace(QRegExp(".*/"),"");
940 d->appName = channel; 940 d->appName = channel;
941 941
942#ifndef QT_NO_TRANSLATION 942#ifndef QT_NO_TRANSLATION
943 qtopia_loadTranslations( QStringList()<<channel ); 943 qtopia_loadTranslations( QStringList()<<channel );
944#endif 944#endif
945 945
946 #if QT_VERSION > 235 946 #if QT_VERSION > 235
947 qt_fbdpy->setIdentity( channel ); // In Qt/E 2.3.6 947 qt_fbdpy->setIdentity( channel ); // In Qt/E 2.3.6
948 #endif 948 #endif
949 949
950 channel = "QPE/Application/" + channel; 950 channel = "QPE/Application/" + channel;
951 pidChannel = new QCopChannel( channel, this); 951 pidChannel = new QCopChannel( channel, this);
952 connect( pidChannel, SIGNAL(received(const QCString&,const QByteArray&)), 952 connect( pidChannel, SIGNAL(received(const QCString&,const QByteArray&)),
953 this, SLOT(pidMessage(const QCString&,const QByteArray&))); 953 this, SLOT(pidMessage(const QCString&,const QByteArray&)));
954 954
955 955
956 956
957 processQCopFile(); 957 processQCopFile();
958 d->keep_running = d->qcopq.isEmpty(); 958 d->keep_running = d->qcopq.isEmpty();
959 959
960 for (int a=0; a<argc; a++) { 960 for (int a=0; a<argc; a++) {
961 if ( qstrcmp(argv[a],"-preload")==0 ) { 961 if ( qstrcmp(argv[a],"-preload")==0 ) {
962 argv[a] = argv[a+1]; 962 argv[a] = argv[a+1];
963 a++; 963 a++;
964 d->preloaded = TRUE; 964 d->preloaded = TRUE;
965 argc-=1; 965 argc-=1;
966 } else if ( qstrcmp(argv[a],"-preload-show")==0 ) { 966 } else if ( qstrcmp(argv[a],"-preload-show")==0 ) {
967 argv[a] = argv[a+1]; 967 argv[a] = argv[a+1];
968 a++; 968 a++;
969 d->preloaded = TRUE; 969 d->preloaded = TRUE;
970 d->forceshow = TRUE; 970 d->forceshow = TRUE;
971 argc-=1; 971 argc-=1;
972 } 972 }
973 } 973 }
974 974
975 /* overide stored arguments */ 975 /* overide stored arguments */
976 setArgs(argc, argv); 976 setArgs(argc, argv);
977} 977}
978#endif 978#endif
979 979
980 980
981static QPtrDict<void>* inputMethodDict = 0; 981static QPtrDict<void>* inputMethodDict = 0;
982static void createInputMethodDict() 982static void createInputMethodDict()
983{ 983{
984 if ( !inputMethodDict ) 984 if ( !inputMethodDict )
985 inputMethodDict = new QPtrDict<void>; 985 inputMethodDict = new QPtrDict<void>;
986} 986}
987 987
988/*! 988/*!
989 Returns the currently set hint to the system as to whether 989 Returns the currently set hint to the system as to whether
990 widget \a w has any use for text input methods. 990 widget \a w has any use for text input methods.
991 991
992 992
993 \sa setInputMethodHint() InputMethodHint 993 \sa setInputMethodHint() InputMethodHint
994*/ 994*/
995QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w ) 995QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w )
996{ 996{
997 if ( inputMethodDict && w ) 997 if ( inputMethodDict && w )
998 return ( InputMethodHint ) ( int ) inputMethodDict->find( w ); 998 return ( InputMethodHint ) ( int ) inputMethodDict->find( w );
999 return Normal; 999 return Normal;
1000} 1000}
1001 1001
1002/*! 1002/*!
1003 \enum QPEApplication::InputMethodHint 1003 \enum QPEApplication::InputMethodHint
1004 1004
1005 \value Normal the application sometimes needs text input (the default). 1005 \value Normal the application sometimes needs text input (the default).
1006 \value AlwaysOff the application never needs text input. 1006 \value AlwaysOff the application never needs text input.
1007 \value AlwaysOn the application always needs text input. 1007 \value AlwaysOn the application always needs text input.
1008*/ 1008*/
1009 1009
1010/*! 1010/*!
1011 Hints to the system that widget \a w has use for text input methods 1011 Hints to the system that widget \a w has use for text input methods
1012 as specified by \a mode. 1012 as specified by \a mode.
1013 1013
1014 \sa inputMethodHint() InputMethodHint 1014 \sa inputMethodHint() InputMethodHint
1015*/ 1015*/
1016void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode ) 1016void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode )
1017{ 1017{
1018 createInputMethodDict(); 1018 createInputMethodDict();
1019 if ( mode == Normal ) { 1019 if ( mode == Normal ) {
1020 inputMethodDict->remove 1020 inputMethodDict->remove
1021 ( w ); 1021 ( w );
1022 } 1022 }
1023 else { 1023 else {
1024 inputMethodDict->insert( w, ( void* ) mode ); 1024 inputMethodDict->insert( w, ( void* ) mode );
1025 } 1025 }
1026} 1026}
1027 1027
1028class HackDialog : public QDialog 1028class HackDialog : public QDialog
1029{ 1029{
1030public: 1030public:
1031 void acceptIt() 1031 void acceptIt()
1032 { 1032 {
1033 accept(); 1033 accept();
1034 } 1034 }
1035 void rejectIt() 1035 void rejectIt()
1036 { 1036 {
1037 reject(); 1037 reject();
1038 } 1038 }
1039}; 1039};
1040 1040
1041 1041
1042void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key ) 1042void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key )
1043{ 1043{
1044 // specialised actions for certain widgets. May want to 1044 // specialised actions for certain widgets. May want to
1045 // add more stuff here. 1045 // add more stuff here.
1046 if ( activePopupWidget() && activePopupWidget() ->inherits( "QListBox" ) 1046 if ( activePopupWidget() && activePopupWidget() ->inherits( "QListBox" )
1047 && activePopupWidget() ->parentWidget() 1047 && activePopupWidget() ->parentWidget()
1048 && activePopupWidget() ->parentWidget() ->inherits( "QComboBox" ) ) 1048 && activePopupWidget() ->parentWidget() ->inherits( "QComboBox" ) )
1049 key = Qt::Key_Return; 1049 key = Qt::Key_Return;
1050 1050
1051 if ( activePopupWidget() && activePopupWidget() ->inherits( "QPopupMenu" ) ) 1051 if ( activePopupWidget() && activePopupWidget() ->inherits( "QPopupMenu" ) )
1052 key = Qt::Key_Return; 1052 key = Qt::Key_Return;
1053 1053
1054#ifdef QWS 1054#ifdef QWS
1055 1055
1056 ke->simpleData.keycode = key; 1056 ke->simpleData.keycode = key;
1057#endif 1057#endif
1058} 1058}
1059 1059
1060 1060
1061/*! 1061/*!
1062 \internal 1062 \internal
1063*/ 1063*/
1064 1064
1065#ifdef QWS 1065#ifdef QWS
1066bool QPEApplication::qwsEventFilter( QWSEvent * e ) 1066bool QPEApplication::qwsEventFilter( QWSEvent * e )
1067{ 1067{
1068 if ( !d->notbusysent && e->type == QWSEvent::Focus ) { 1068 if ( !d->notbusysent && e->type == QWSEvent::Focus ) {
1069 if ( qApp->type() != QApplication::GuiServer ) { 1069 if ( qApp->type() != QApplication::GuiServer ) {
1070 QCopEnvelope e( "QPE/System", "notBusy(QString)" ); 1070 QCopEnvelope e( "QPE/System", "notBusy(QString)" );
1071 e << d->appName; 1071 e << d->appName;
1072 } 1072 }
1073 d->notbusysent = TRUE; 1073 d->notbusysent = TRUE;
1074 } 1074 }
1075 if ( type() == GuiServer ) { 1075 if ( type() == GuiServer ) {
1076 switch ( e->type ) { 1076 switch ( e->type ) {
1077 case QWSEvent::Mouse: 1077 case QWSEvent::Mouse:
1078 if ( e->asMouse() ->simpleData.state && !QWidget::find( e->window() ) ) 1078 if ( e->asMouse() ->simpleData.state && !QWidget::find( e->window() ) )
1079 emit clientMoused(); 1079 emit clientMoused();
1080 break; 1080 break;
1081 default: 1081 default:
1082 break; 1082 break;
1083 } 1083 }
1084 } 1084 }
1085 if ( e->type == QWSEvent::Key ) { 1085 if ( e->type == QWSEvent::Key ) {
1086 QWSKeyEvent *ke = ( QWSKeyEvent * ) e; 1086 QWSKeyEvent *ke = ( QWSKeyEvent * ) e;
1087 if ( ke->simpleData.keycode == Qt::Key_F33 ) { 1087 if ( ke->simpleData.keycode == Qt::Key_F33 ) {
1088 // Use special "OK" key to press "OK" on top level widgets 1088 // Use special "OK" key to press "OK" on top level widgets
1089 QWidget * active = activeWindow(); 1089 QWidget * active = activeWindow();
1090 QWidget *popup = 0; 1090 QWidget *popup = 0;
1091 if ( active && active->isPopup() ) { 1091 if ( active && active->isPopup() ) {
1092 popup = active; 1092 popup = active;
1093 active = active->parentWidget(); 1093 active = active->parentWidget();
1094 } 1094 }
1095 if ( active && ( int ) active->winId() == ke->simpleData.window && 1095 if ( active && ( int ) active->winId() == ke->simpleData.window &&
1096 !active->testWFlags( WStyle_Customize | WType_Popup | WType_Desktop ) ) { 1096 !active->testWFlags( WStyle_Customize | WType_Popup | WType_Desktop ) ) {
1097 if ( ke->simpleData.is_press ) { 1097 if ( ke->simpleData.is_press ) {
1098 if ( popup ) 1098 if ( popup )
1099 popup->close(); 1099 popup->close();
1100 if ( active->inherits( "QDialog" ) ) { 1100 if ( active->inherits( "QDialog" ) ) {
1101 HackDialog * d = ( HackDialog * ) active; 1101 HackDialog * d = ( HackDialog * ) active;
1102 d->acceptIt(); 1102 d->acceptIt();
1103 return TRUE; 1103 return TRUE;
1104 } 1104 }
1105 else if ( ( ( HackWidget * ) active ) ->needsOk() ) { 1105 else if ( ( ( HackWidget * ) active ) ->needsOk() ) {
1106 QSignal s; 1106 QSignal s;
1107 s.connect( active, SLOT( accept() ) ); 1107 s.connect( active, SLOT( accept() ) );
1108 s.activate(); 1108 s.activate();
1109 } 1109 }
1110 else { 1110 else {
1111 // do the same as with the select key: Map to the default action of the widget: 1111 // do the same as with the select key: Map to the default action of the widget:
1112 mapToDefaultAction( ke, Qt::Key_Return ); 1112 mapToDefaultAction( ke, Qt::Key_Return );
1113 } 1113 }
1114 } 1114 }
1115 } 1115 }
1116 } 1116 }
1117 else if ( ke->simpleData.keycode == Qt::Key_F30 ) { 1117 else if ( ke->simpleData.keycode == Qt::Key_F30 ) {
1118 // Use special "select" key to do whatever default action a widget has 1118 // Use special "select" key to do whatever default action a widget has
1119 mapToDefaultAction( ke, Qt::Key_Space ); 1119 mapToDefaultAction( ke, Qt::Key_Space );
1120 } 1120 }
1121 else if ( ke->simpleData.keycode == Qt::Key_Escape && 1121 else if ( ke->simpleData.keycode == Qt::Key_Escape &&
1122 ke->simpleData.is_press ) { 1122 ke->simpleData.is_press ) {
1123 // Escape key closes app if focus on toplevel 1123 // Escape key closes app if focus on toplevel
1124 QWidget * active = activeWindow(); 1124 QWidget * active = activeWindow();
1125 if ( active && active->testWFlags( WType_TopLevel ) && 1125 if ( active && active->testWFlags( WType_TopLevel ) &&
1126 ( int ) active->winId() == ke->simpleData.window && 1126 ( int ) active->winId() == ke->simpleData.window &&
1127 !active->testWFlags( WStyle_Dialog | WStyle_Customize | WType_Popup | WType_Desktop ) ) { 1127 !active->testWFlags( WStyle_Dialog | WStyle_Customize | WType_Popup | WType_Desktop ) ) {
1128 if ( active->inherits( "QDialog" ) ) { 1128 if ( active->inherits( "QDialog" ) ) {
1129 HackDialog * d = ( HackDialog * ) active; 1129 HackDialog * d = ( HackDialog * ) active;
1130 d->rejectIt(); 1130 d->rejectIt();
1131 return TRUE; 1131 return TRUE;
1132 } else /*if ( strcmp( argv() [ 0 ], "embeddedkonsole" ) != 0 )*/ { 1132 } else /*if ( strcmp( argv() [ 0 ], "embeddedkonsole" ) != 0 )*/ {
1133 active->close(); 1133 active->close();
1134 } 1134 }
1135 } 1135 }
1136 1136
1137 } 1137 }
1138 else if ( ke->simpleData.keycode >= Qt::Key_F1 && ke->simpleData.keycode <= Qt::Key_F29 ) { 1138 else if ( ke->simpleData.keycode >= Qt::Key_F1 && ke->simpleData.keycode <= Qt::Key_F29 ) {
1139 // this should be if ( ODevice::inst ( )-> buttonForKeycode ( ... )) 1139 // this should be if ( ODevice::inst ( )-> buttonForKeycode ( ... ))
1140 // but we cannot access libopie function within libqpe :( 1140 // but we cannot access libopie function within libqpe :(
1141 1141
1142 QWidget * active = activeWindow ( ); 1142 QWidget * active = activeWindow ( );
1143 if ( active && ((int) active-> winId ( ) == ke-> simpleData.window )) { 1143 if ( active && ((int) active-> winId ( ) == ke-> simpleData.window )) {
1144 if ( d-> kbgrabbed ) { // we grabbed the keyboard 1144 if ( d-> kbgrabbed ) { // we grabbed the keyboard
1145 QChar ch ( ke-> simpleData.unicode ); 1145 QChar ch ( ke-> simpleData.unicode );
1146 QKeyEvent qke ( ke-> simpleData. is_press ? QEvent::KeyPress : QEvent::KeyRelease, 1146 QKeyEvent qke ( ke-> simpleData. is_press ? QEvent::KeyPress : QEvent::KeyRelease,
1147 ke-> simpleData.keycode, 1147 ke-> simpleData.keycode,
1148 ch. latin1 ( ), 1148 ch. latin1 ( ),
1149 ke-> simpleData.modifiers, 1149 ke-> simpleData.modifiers,
1150 QString ( ch ), 1150 QString ( ch ),
1151 ke-> simpleData.is_auto_repeat, 1 ); 1151 ke-> simpleData.is_auto_repeat, 1 );
1152 1152
1153 QObject *which = QWidget::keyboardGrabber ( ); 1153 QObject *which = QWidget::keyboardGrabber ( );
1154 if ( !which ) 1154 if ( !which )
1155 which = QApplication::focusWidget ( ); 1155 which = QApplication::focusWidget ( );
1156 if ( !which ) 1156 if ( !which )
1157 which = QApplication::activeWindow ( ); 1157 which = QApplication::activeWindow ( );
1158 if ( !which ) 1158 if ( !which )
1159 which = qApp; 1159 which = qApp;
1160 1160
1161 QApplication::sendEvent ( which, &qke ); 1161 QApplication::sendEvent ( which, &qke );
1162 } 1162 }
1163 else { // we didn't grab the keyboard, so send the event to the launcher 1163 else { // we didn't grab the keyboard, so send the event to the launcher
1164 QCopEnvelope e ( "QPE/Launcher", "deviceButton(int,int,int)" ); 1164 QCopEnvelope e ( "QPE/Launcher", "deviceButton(int,int,int)" );
1165 e << int( ke-> simpleData.keycode ) << int( ke-> simpleData. is_press ) << int( ke-> simpleData.is_auto_repeat ); 1165 e << int( ke-> simpleData.keycode ) << int( ke-> simpleData. is_press ) << int( ke-> simpleData.is_auto_repeat );
1166 } 1166 }
1167 } 1167 }
1168 return true; 1168 return true;
1169 } 1169 }
1170 } 1170 }
1171 if ( e->type == QWSEvent::Focus ) { 1171 if ( e->type == QWSEvent::Focus ) {
1172 QWSFocusEvent * fe = ( QWSFocusEvent* ) e; 1172 QWSFocusEvent * fe = ( QWSFocusEvent* ) e;
1173 if ( !fe->simpleData.get_focus ) { 1173 if ( !fe->simpleData.get_focus ) {
1174 QWidget * active = activeWindow(); 1174 QWidget * active = activeWindow();
1175 while ( active && active->isPopup() ) { 1175 while ( active && active->isPopup() ) {
1176 active->close(); 1176 active->close();
1177 active = activeWindow(); 1177 active = activeWindow();
1178 } 1178 }
1179 } 1179 }
1180 else { 1180 else {
1181 // make sure our modal widget is ALWAYS on top 1181 // make sure our modal widget is ALWAYS on top
1182 QWidget *topm = activeModalWidget(); 1182 QWidget *topm = activeModalWidget();
1183 if ( topm && static_cast<int>( topm->winId() ) != fe->simpleData.window) { 1183 if ( topm && static_cast<int>( topm->winId() ) != fe->simpleData.window) {
1184 topm->raise(); 1184 topm->raise();
1185 } 1185 }
1186 } 1186 }
1187 if ( fe->simpleData.get_focus && inputMethodDict ) { 1187 if ( fe->simpleData.get_focus && inputMethodDict ) {
1188 InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) ); 1188 InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) );
1189 if ( m == AlwaysOff ) 1189 if ( m == AlwaysOff )
1190 Global::hideInputMethod(); 1190 Global::hideInputMethod();
1191 if ( m == AlwaysOn ) 1191 if ( m == AlwaysOn )
1192 Global::showInputMethod(); 1192 Global::showInputMethod();
1193 } 1193 }
1194 } 1194 }
1195 1195
1196 1196
1197 return QApplication::qwsEventFilter( e ); 1197 return QApplication::qwsEventFilter( e );
1198} 1198}
1199#endif 1199#endif
1200 1200
1201/*! 1201/*!
1202 Destroys the QPEApplication. 1202 Destroys the QPEApplication.
1203*/ 1203*/
1204QPEApplication::~QPEApplication() 1204QPEApplication::~QPEApplication()
1205{ 1205{
1206 ungrabKeyboard(); 1206 ungrabKeyboard();
1207#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 1207#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
1208 // Need to delete QCopChannels early, since the display will 1208 // Need to delete QCopChannels early, since the display will
1209 // be gone by the time we get to ~QObject(). 1209 // be gone by the time we get to ~QObject().
1210 delete sysChannel; 1210 delete sysChannel;
1211 delete pidChannel; 1211 delete pidChannel;
1212#endif 1212#endif
1213 1213
1214#ifdef OPIE_WITHROHFEEDBACK 1214#ifdef OPIE_WITHROHFEEDBACK
1215 if( d->RoH ) 1215 if( d->RoH )
1216 delete d->RoH; 1216 delete d->RoH;
1217#endif 1217#endif
1218 delete d; 1218 delete d;
1219} 1219}
1220 1220
1221/*! 1221/*!
1222 Returns <tt>$OPIEDIR/</tt>. 1222 Returns <tt>$OPIEDIR/</tt>.
1223*/ 1223*/
1224QString QPEApplication::qpeDir() 1224QString QPEApplication::qpeDir()
1225{ 1225{
1226 QString base, dir; 1226 QString base, dir;
1227 1227
1228 if (getenv( "OPIEDIR" )) 1228 if (getenv( "OPIEDIR" ))
1229 base = QString(getenv("OPIEDIR")).stripWhiteSpace(); 1229 base = QString(getenv("OPIEDIR")).stripWhiteSpace();
1230 if ( !base.isNull() && (base.length() > 0 )){ 1230 if ( !base.isNull() && (base.length() > 0 )){
1231#ifdef Q_OS_WIN32 1231#ifdef Q_OS_WIN32
1232 QString temp(base); 1232 QString temp(base);
1233 if (temp[(int)temp.length()-1] != QDir::separator()) 1233 if (temp[(int)temp.length()-1] != QDir::separator())
1234 temp.append(QDir::separator()); 1234 temp.append(QDir::separator());
1235 dir = temp; 1235 dir = temp;
1236#else 1236#else
1237 dir = QString( base ) + "/"; 1237 dir = QString( base ) + "/";
1238#endif 1238#endif
1239 }else{ 1239 }else{
1240 dir = QString( ".." ) + QDir::separator(); 1240 dir = QString( ".." ) + QDir::separator();
1241 } 1241 }
1242 1242
1243 return dir; 1243 return dir;
1244} 1244}
1245 1245
1246/*! 1246/*!
1247 Returns the user's current Document directory. There is a trailing "/". 1247 Returns the user's current Document directory. There is a trailing "/".
1248 .. well, it does now,, and there's no trailing '/' 1248 .. well, it does now,, and there's no trailing '/'
1249*/ 1249*/
1250QString QPEApplication::documentDir() 1250QString QPEApplication::documentDir()
1251{ 1251{
1252 const char* base = getenv( "HOME"); 1252 const char* base = getenv( "HOME");
1253 if ( base ) 1253 if ( base )
1254 return QString( base ) + "/Documents"; 1254 return QString( base ) + "/Documents";
1255 1255
1256 return QString( "../Documents" ); 1256 return QString( "../Documents" );
1257} 1257}
1258 1258
1259static int deforient = -1; 1259static int deforient = -1;
1260 1260
1261/*! 1261/*!
1262 \internal 1262 \internal
1263*/ 1263*/
1264int QPEApplication::defaultRotation() 1264int QPEApplication::defaultRotation()
1265{ 1265{
1266 if ( deforient < 0 ) { 1266 if ( deforient < 0 ) {
1267 QString d = getenv( "QWS_DISPLAY" ); 1267 QString d = getenv( "QWS_DISPLAY" );
1268 if ( d.contains( "Rot90" ) ) { 1268 if ( d.contains( "Rot90" ) ) {
1269 deforient = 90; 1269 deforient = 90;
1270 } 1270 }
1271 else if ( d.contains( "Rot180" ) ) { 1271 else if ( d.contains( "Rot180" ) ) {
1272 deforient = 180; 1272 deforient = 180;
1273 } 1273 }
1274 else if ( d.contains( "Rot270" ) ) { 1274 else if ( d.contains( "Rot270" ) ) {
1275 deforient = 270; 1275 deforient = 270;
1276 } 1276 }
1277 else { 1277 else {
1278 deforient = 0; 1278 deforient = 0;
1279 } 1279 }
1280 } 1280 }
1281 return deforient; 1281 return deforient;
1282} 1282}
1283 1283
1284/*! 1284/*!
1285 \internal 1285 \internal
1286*/ 1286*/
1287void QPEApplication::setDefaultRotation( int r ) 1287void QPEApplication::setDefaultRotation( int r )
1288{ 1288{
1289 if ( qApp->type() == GuiServer ) { 1289 if ( qApp->type() == GuiServer ) {
1290 deforient = r; 1290 deforient = r;
1291 int j = 0; 1291 int j = 0;
1292 QCString old = getenv( "QWS_DISPLAY" ) ? getenv( "QWS_DISPLAY" ) : "Transformed"; 1292 QCString old = getenv( "QWS_DISPLAY" ) ? getenv( "QWS_DISPLAY" ) : "Transformed";
1293 QString driver( old.left( ( ( j = old.find( ':' ) ) >= 0 ) ? j : old.size() ).data() ); 1293 QString driver( old.left( ( ( j = old.find( ':' ) ) >= 0 ) ? j : old.size() ).data() );
1294 setenv( "QWS_DISPLAY", QString( "%1:Rot%2:0" ).arg(driver).arg( r ).latin1(), 1 ); 1294 setenv( "QWS_DISPLAY", QString( "%1:Rot%2:0" ).arg(driver).arg( r ).latin1(), 1 );
1295 Config config("qpe"); 1295 Config config("qpe");
1296 config.setGroup( "Rotation" ); 1296 config.setGroup( "Rotation" );
1297 config.writeEntry( "Rot", r ); 1297 config.writeEntry( "Rot", r );
1298 } 1298 }
1299 else { 1299 else {
1300#ifndef QT_NO_COP 1300#ifndef QT_NO_COP
1301 { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" ); 1301 { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" );
1302 e << r; 1302 e << r;
1303 } 1303 }
1304#endif 1304#endif
1305 1305
1306 } 1306 }
1307} 1307}
1308 1308
1309#include <qgfx_qws.h> 1309#include <qgfx_qws.h>
1310#include <qwindowsystem_qws.h> 1310#include <qwindowsystem_qws.h>
1311 1311
1312#if QT_VERSION > 236 1312#if QT_VERSION > 236
1313extern void qws_clearLoadedFonts(); 1313extern void qws_clearLoadedFonts();
1314#endif 1314#endif
1315 1315
1316void QPEApplication::setCurrentMode( int x, int y, int depth ) 1316void QPEApplication::setCurrentMode( int x, int y, int depth )
1317{ 1317{
1318 // Reset the caches 1318 // Reset the caches
1319#if QT_VERSION > 236 1319#if QT_VERSION > 236
1320 qws_clearLoadedFonts(); 1320 qws_clearLoadedFonts();
1321#endif 1321#endif
1322 QPixmapCache::clear(); 1322 QPixmapCache::clear();
1323 1323
1324 // Change the screen mode 1324 // Change the screen mode
1325 qt_screen->setMode(x, y, depth); 1325 qt_screen->setMode(x, y, depth);
1326 1326
1327 if ( qApp->type() == GuiServer ) { 1327 if ( qApp->type() == GuiServer ) {
1328#if QT_VERSION > 236 1328#if QT_VERSION > 236
1329 // Reconfigure the GuiServer 1329 // Reconfigure the GuiServer
1330 qwsServer->beginDisplayReconfigure(); 1330 qwsServer->beginDisplayReconfigure();
1331 qwsServer->endDisplayReconfigure(); 1331 qwsServer->endDisplayReconfigure();
1332#endif 1332#endif
1333 // Get all the running apps to reset 1333 // Get all the running apps to reset
1334 QCopEnvelope env( "QPE/System", "reset()" ); 1334 QCopEnvelope env( "QPE/System", "reset()" );
1335 } 1335 }
1336} 1336}
1337 1337
1338void QPEApplication::reset() { 1338void QPEApplication::reset() {
1339 // Reconnect to the screen 1339 // Reconnect to the screen
1340 qt_screen->disconnect(); 1340 qt_screen->disconnect();
1341 qt_screen->connect( QString::null ); 1341 qt_screen->connect( QString::null );
1342 1342
1343 // Redraw everything 1343 // Redraw everything
1344 applyStyle(); 1344 applyStyle();
1345} 1345}
1346 1346
1347#if (QT_VERSION < 238) && defined Q_OS_MACX 1347#if (QT_VERSION < 238) && defined Q_OS_MACX
1348bool qt_left_hand_scrollbars = false; 1348bool qt_left_hand_scrollbars = false;
1349#else 1349#else
1350extern bool qt_left_hand_scrollbars QPE_WEAK_SYMBOL; 1350extern bool qt_left_hand_scrollbars QPE_WEAK_SYMBOL;
1351#endif 1351#endif
1352 1352
1353/*! 1353/*!
1354 \internal 1354 \internal
1355*/ 1355*/
1356void QPEApplication::applyStyle() 1356void QPEApplication::applyStyle()
1357{ 1357{
1358 Config config( "qpe" ); 1358 Config config( "qpe" );
1359 config.setGroup( "Appearance" ); 1359 config.setGroup( "Appearance" );
1360 1360
1361#if QT_VERSION > 233 1361#if QT_VERSION > 233
1362 // Widget style 1362 // Widget style
1363 QString style = config.readEntry( "Style", "FlatStyle" ); 1363 QString style = config.readEntry( "Style", "FlatStyle" );
1364 1364
1365 internalSetStyle ( style ); 1365 internalSetStyle ( style );
1366 1366
1367 // Colors - from /etc/colors/Liquid.scheme 1367 // Colors - from /etc/colors/Liquid.scheme
1368 QColor bgcolor( config.readEntry( "Background", "#E0E0E0" ) ); 1368 QColor bgcolor( config.readEntry( "Background", "#E0E0E0" ) );
1369 QColor btncolor( config.readEntry( "Button", "#96c8fa" ) ); 1369 QColor btncolor( config.readEntry( "Button", "#96c8fa" ) );
1370 QPalette pal( btncolor, bgcolor ); 1370 QPalette pal( btncolor, bgcolor );
1371 QString color = config.readEntry( "Highlight", "#73adef" ); 1371 QString color = config.readEntry( "Highlight", "#73adef" );
1372 pal.setColor( QColorGroup::Highlight, QColor( color ) ); 1372 pal.setColor( QColorGroup::Highlight, QColor( color ) );
1373 color = config.readEntry( "HighlightedText", "#FFFFFF" ); 1373 color = config.readEntry( "HighlightedText", "#FFFFFF" );
1374 pal.setColor( QColorGroup::HighlightedText, QColor( color ) ); 1374 pal.setColor( QColorGroup::HighlightedText, QColor( color ) );
1375 color = config.readEntry( "Text", "#000000" ); 1375 color = config.readEntry( "Text", "#000000" );
1376 pal.setColor( QColorGroup::Text, QColor( color ) ); 1376 pal.setColor( QColorGroup::Text, QColor( color ) );
1377 color = config.readEntry( "ButtonText", "#000000" ); 1377 color = config.readEntry( "ButtonText", "#000000" );
1378 pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) ); 1378 pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) );
1379 color = config.readEntry( "Base", "#FFFFFF" ); 1379 color = config.readEntry( "Base", "#FFFFFF" );
1380 pal.setColor( QColorGroup::Base, QColor( color ) ); 1380 pal.setColor( QColorGroup::Base, QColor( color ) );
1381 1381
1382 pal.setColor( QPalette::Disabled, QColorGroup::Text, 1382 pal.setColor( QPalette::Disabled, QColorGroup::Text,
1383 pal.color( QPalette::Active, QColorGroup::Background ).dark() ); 1383 pal.color( QPalette::Active, QColorGroup::Background ).dark() );
1384 1384
1385 setPalette( pal, TRUE ); 1385 setPalette( pal, TRUE );
1386 1386
1387 1387
1388 // Set the ScrollBar on the 'right' side but only if the weak symbol is present 1388 // Set the ScrollBar on the 'right' side but only if the weak symbol is present
1389 if (&qt_left_hand_scrollbars ) 1389 if (&qt_left_hand_scrollbars )
1390 qt_left_hand_scrollbars = config.readBoolEntry( "LeftHand", false ); 1390 qt_left_hand_scrollbars = config.readBoolEntry( "LeftHand", false );
1391 1391
1392 // Window Decoration 1392 // Window Decoration
1393 QString dec = config.readEntry( "Decoration", "Flat" ); 1393 QString dec = config.readEntry( "Decoration", "Flat" );
1394 1394
1395 if ( dec != d->decorationName ) { 1395 if ( dec != d->decorationName ) {
1396 qwsSetDecoration( new QPEDecoration( dec ) ); 1396 qwsSetDecoration( new QPEDecoration( dec ) );
1397 d->decorationName = dec; 1397 d->decorationName = dec;
1398 } 1398 }
1399 1399
1400 // Font 1400 // Font
1401 QString ff = config.readEntry( "FontFamily", font().family() ); 1401 QString ff = config.readEntry( "FontFamily", font().family() );
1402 int fs = config.readNumEntry( "FontSize", font().pointSize() ); 1402 int fs = config.readNumEntry( "FontSize", font().pointSize() );
1403 1403
1404 setFont ( QFont ( ff, fs ), true ); 1404 setFont ( QFont ( ff, fs ), true );
1405#endif 1405#endif
1406} 1406}
1407 1407
1408void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data ) 1408void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data )
1409{ 1409{
1410#ifdef Q_WS_QWS 1410#ifdef Q_WS_QWS
1411 QDataStream stream( data, IO_ReadOnly ); 1411 QDataStream stream( data, IO_ReadOnly );
1412 if ( msg == "applyStyle()" ) { 1412 if ( msg == "applyStyle()" ) {
1413 applyStyle(); 1413 applyStyle();
1414 } 1414 }
1415 else if ( msg == "toggleApplicationMenu()" ) { 1415 else if ( msg == "toggleApplicationMenu()" ) {
1416 QWidget *active = activeWindow ( ); 1416 QWidget *active = activeWindow ( );
1417 1417
1418 if ( active ) { 1418 if ( active ) {
1419 QPEMenuToolFocusManager *man = QPEMenuToolFocusManager::manager ( ); 1419 QPEMenuToolFocusManager *man = QPEMenuToolFocusManager::manager ( );
1420 bool oldactive = man-> isActive ( ); 1420 bool oldactive = man-> isActive ( );
1421 1421
1422 man-> setActive( !man-> isActive() ); 1422 man-> setActive( !man-> isActive() );
1423 1423
1424 if ( !oldactive && !man-> isActive ( )) { // no menubar to toggle -> try O-Menu 1424 if ( !oldactive && !man-> isActive ( )) { // no menubar to toggle -> try O-Menu
1425 QCopEnvelope e ( "QPE/TaskBar", "toggleStartMenu()" ); 1425 QCopEnvelope e ( "QPE/TaskBar", "toggleStartMenu()" );
1426 } 1426 }
1427 } 1427 }
1428 } 1428 }
1429 else if ( msg == "setDefaultRotation(int)" ) { 1429 else if ( msg == "setDefaultRotation(int)" ) {
1430 if ( type() == GuiServer ) { 1430 if ( type() == GuiServer ) {
1431 int r; 1431 int r;
1432 stream >> r; 1432 stream >> r;
1433 setDefaultRotation( r ); 1433 setDefaultRotation( r );
1434 } 1434 }
1435 } 1435 }
1436 else if ( msg == "setCurrentMode(int,int,int)" ) { // Added: 2003-06-11 by Tim Ansell <mithro@mithis.net> 1436 else if ( msg == "setCurrentMode(int,int,int)" ) { // Added: 2003-06-11 by Tim Ansell <mithro@mithis.net>
1437 if ( type() == GuiServer ) { 1437 if ( type() == GuiServer ) {
1438 int x, y, depth; 1438 int x, y, depth;
1439 stream >> x; 1439 stream >> x;
1440 stream >> y; 1440 stream >> y;
1441 stream >> depth; 1441 stream >> depth;
1442 setCurrentMode( x, y, depth ); 1442 setCurrentMode( x, y, depth );
1443 } 1443 }
1444 } 1444 }
1445 else if ( msg == "reset()" ) { 1445 else if ( msg == "reset()" ) {
1446 if ( type() != GuiServer ) 1446 if ( type() != GuiServer )
1447 reset(); 1447 reset();
1448 } 1448 }
1449 else if ( msg == "setCurrentRotation(int)" ) { 1449 else if ( msg == "setCurrentRotation(int)" ) {
1450 int r; 1450 int r;
1451 stream >> r; 1451 stream >> r;
1452 setCurrentRotation( r ); 1452 setCurrentRotation( r );
1453 } 1453 }
1454 else if ( msg == "shutdown()" ) { 1454 else if ( msg == "shutdown()" ) {
1455 if ( type() == GuiServer ) 1455 if ( type() == GuiServer )
1456 shutdown(); 1456 shutdown();
1457 } 1457 }
1458 else if ( msg == "quit()" ) { 1458 else if ( msg == "quit()" ) {
1459 if ( type() != GuiServer ) 1459 if ( type() != GuiServer )
1460 tryQuit(); 1460 tryQuit();
1461 } 1461 }
1462 else if ( msg == "forceQuit()" ) { 1462 else if ( msg == "forceQuit()" ) {
1463 if ( type() != GuiServer ) 1463 if ( type() != GuiServer )
1464 quit(); 1464 quit();
1465 } 1465 }
1466 else if ( msg == "restart()" ) { 1466 else if ( msg == "restart()" ) {
1467 if ( type() == GuiServer ) 1467 if ( type() == GuiServer )
1468 restart(); 1468 restart();
1469 } 1469 }
1470 else if ( msg == "language(QString)" ) { 1470 else if ( msg == "language(QString)" ) {
1471 if ( type() == GuiServer ) { 1471 if ( type() == GuiServer ) {
1472 QString l; 1472 QString l;
1473 stream >> l; 1473 stream >> l;
1474 QString cl = getenv( "LANG" ); 1474 QString cl = getenv( "LANG" );
1475 if ( cl != l ) { 1475 if ( cl != l ) {
1476 if ( l.isNull() ) 1476 if ( l.isNull() )
1477 unsetenv( "LANG" ); 1477 unsetenv( "LANG" );
1478 else 1478 else
1479 setenv( "LANG", l.latin1(), 1 ); 1479 setenv( "LANG", l.latin1(), 1 );
1480 restart(); 1480 restart();
1481 } 1481 }
1482 } 1482 }
1483 } 1483 }
1484 else if ( msg == "timeChange(QString)" ) { 1484 else if ( msg == "timeChange(QString)" ) {
1485 QString t; 1485 QString t;
1486 stream >> t; 1486 stream >> t;
1487 if ( t.isNull() ) 1487 if ( t.isNull() )
1488 unsetenv( "TZ" ); 1488 unsetenv( "TZ" );
1489 else 1489 else
1490 setenv( "TZ", t.latin1(), 1 ); 1490 setenv( "TZ", t.latin1(), 1 );
1491 // emit the signal so everyone else knows... 1491 // emit the signal so everyone else knows...
1492 emit timeChanged(); 1492 emit timeChanged();
1493 } 1493 }
1494 else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) { 1494 else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) {
1495 if ( type() == GuiServer ) { 1495 if ( type() == GuiServer ) {
1496 QDateTime when; 1496 QDateTime when;
1497 QCString channel, message; 1497 QCString channel, message;
1498 int data; 1498 int data;
1499 stream >> when >> channel >> message >> data; 1499 stream >> when >> channel >> message >> data;
1500 AlarmServer::addAlarm( when, channel, message, data ); 1500 AlarmServer::addAlarm( when, channel, message, data );
1501 } 1501 }
1502 } 1502 }
1503 else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) { 1503 else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) {
1504 if ( type() == GuiServer ) { 1504 if ( type() == GuiServer ) {
1505 QDateTime when; 1505 QDateTime when;
1506 QCString channel, message; 1506 QCString channel, message;
1507 int data; 1507 int data;
1508 stream >> when >> channel >> message >> data; 1508 stream >> when >> channel >> message >> data;
1509 AlarmServer::deleteAlarm( when, channel, message, data ); 1509 AlarmServer::deleteAlarm( when, channel, message, data );
1510 } 1510 }
1511 } 1511 }
1512 else if ( msg == "clockChange(bool)" ) { 1512 else if ( msg == "clockChange(bool)" ) {
1513 int tmp; 1513 int tmp;
1514 stream >> tmp; 1514 stream >> tmp;
1515 emit clockChanged( tmp ); 1515 emit clockChanged( tmp );
1516 } 1516 }
1517 else if ( msg == "weekChange(bool)" ) { 1517 else if ( msg == "weekChange(bool)" ) {
1518 int tmp; 1518 int tmp;
1519 stream >> tmp; 1519 stream >> tmp;
1520 emit weekChanged( tmp ); 1520 emit weekChanged( tmp );
1521 } 1521 }
1522 else if ( msg == "setDateFormat(DateFormat)" ) { 1522 else if ( msg == "setDateFormat(DateFormat)" ) {
1523 DateFormat tmp; 1523 DateFormat tmp;
1524 stream >> tmp; 1524 stream >> tmp;
1525 emit dateFormatChanged( tmp ); 1525 emit dateFormatChanged( tmp );
1526 } 1526 }
1527 else if ( msg == "setVolume(int,int)" ) { 1527 else if ( msg == "setVolume(int,int)" ) {
1528 int t, v; 1528 int t, v;
1529 stream >> t >> v; 1529 stream >> t >> v;
1530 setVolume( t, v ); 1530 setVolume( t, v );
1531 emit volumeChanged( muted ); 1531 emit volumeChanged( muted );
1532 } 1532 }
1533 else if ( msg == "volumeChange(bool)" ) { 1533 else if ( msg == "volumeChange(bool)" ) {
1534 stream >> muted; 1534 stream >> muted;
1535 setVolume(); 1535 setVolume();
1536 emit volumeChanged( muted ); 1536 emit volumeChanged( muted );
1537 } 1537 }
1538 else if ( msg == "setMic(int,int)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> 1538 else if ( msg == "setMic(int,int)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com>
1539 int t, v; 1539 int t, v;
1540 stream >> t >> v; 1540 stream >> t >> v;
1541 setMic( t, v ); 1541 setMic( t, v );
1542 emit micChanged( micMuted ); 1542 emit micChanged( micMuted );
1543 } 1543 }
1544 else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> 1544 else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com>
1545 stream >> micMuted; 1545 stream >> micMuted;
1546 setMic(); 1546 setMic();
1547 emit micChanged( micMuted ); 1547 emit micChanged( micMuted );
1548 } 1548 }
1549 else if ( msg == "setBass(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> 1549 else if ( msg == "setBass(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org>
1550 int t, v; 1550 int t, v;
1551 stream >> t >> v; 1551 stream >> t >> v;
1552 setBass( t, v ); 1552 setBass( t, v );
1553 } 1553 }
1554 else if ( msg == "bassChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> 1554 else if ( msg == "bassChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org>
1555 setBass(); 1555 setBass();
1556 } 1556 }
1557 else if ( msg == "setTreble(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> 1557 else if ( msg == "setTreble(int,int)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org>
1558 int t, v; 1558 int t, v;
1559 stream >> t >> v; 1559 stream >> t >> v;
1560 setTreble( t, v ); 1560 setTreble( t, v );
1561 } 1561 }
1562 else if ( msg == "trebleChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org> 1562 else if ( msg == "trebleChange(bool)" ) { // Added: 2002-12-13 by Maximilian Reiss <harlekin@handhelds.org>
1563 setTreble(); 1563 setTreble();
1564 } else if ( msg == "getMarkedText()" ) { 1564 } else if ( msg == "getMarkedText()" ) {
1565 if ( type() == GuiServer ) { 1565 if ( type() == GuiServer ) {
1566 const ushort unicode = 'C'-'@'; 1566 const ushort unicode = 'C'-'@';
1567 const int scan = Key_C; 1567 const int scan = Key_C;
1568 qwsServer->processKeyEvent( unicode, scan, ControlButton, TRUE, FALSE ); 1568 qwsServer->processKeyEvent( unicode, scan, ControlButton, TRUE, FALSE );
1569 qwsServer->processKeyEvent( unicode, scan, ControlButton, FALSE, FALSE ); 1569 qwsServer->processKeyEvent( unicode, scan, ControlButton, FALSE, FALSE );
1570 } 1570 }
1571 } else if ( msg == "newChannel(QString)") { 1571 } else if ( msg == "newChannel(QString)") {
1572 QString myChannel = "QPE/Application/" + d->appName; 1572 QString myChannel = "QPE/Application/" + d->appName;
1573 QString channel; 1573 QString channel;
1574 stream >> channel; 1574 stream >> channel;
1575 if (channel == myChannel) { 1575 if (channel == myChannel) {
1576 processQCopFile(); 1576 processQCopFile();
1577 d->sendQCopQ(); 1577 d->sendQCopQ();
1578 } 1578 }
1579 } 1579 }
1580 1580
1581 1581
1582#endif 1582#endif
1583} 1583}
1584 1584
1585 1585
1586 1586
1587 1587
1588 1588
1589/*! 1589/*!
1590 \internal 1590 \internal
1591*/ 1591*/
1592bool QPEApplication::raiseAppropriateWindow() 1592bool QPEApplication::raiseAppropriateWindow()
1593{ 1593{
1594 bool r=FALSE; 1594 bool r=FALSE;
1595 1595
1596 // 1. Raise the main widget 1596 // 1. Raise the main widget
1597 QWidget *top = d->qpe_main_widget; 1597 QWidget *top = d->qpe_main_widget;
1598 if ( !top ) top = mainWidget(); 1598 if ( !top ) top = mainWidget();
1599 1599
1600 if ( top && d->keep_running ) { 1600 if ( top && d->keep_running ) {
1601 if ( top->isVisible() ) 1601 if ( top->isVisible() )
1602 r = TRUE; 1602 r = TRUE;
1603 else if (d->preloaded) { 1603 else if (d->preloaded) {
1604 // We are preloaded and not visible.. pretend we just started.. 1604 // We are preloaded and not visible.. pretend we just started..
1605#ifndef QT_NO_COP 1605#ifndef QT_NO_COP
1606 QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); 1606 QCopEnvelope e("QPE/System", "fastAppShowing(QString)");
1607 e << d->appName; 1607 e << d->appName;
1608#endif 1608#endif
1609 } 1609 }
1610 1610
1611 d->show_mx(top,d->nomaximize, d->appName); 1611 d->show_mx(top,d->nomaximize, d->appName);
1612 top->raise(); 1612 top->raise();
1613 } 1613 }
1614 1614
1615 QWidget *topm = activeModalWidget(); 1615 QWidget *topm = activeModalWidget();
1616 1616
1617 // 2. Raise any parentless widgets (except top and topm, as they 1617 // 2. Raise any parentless widgets (except top and topm, as they
1618 // are raised before and after this loop). Order from most 1618 // are raised before and after this loop). Order from most
1619 // recently raised as deepest to least recently as top, so 1619 // recently raised as deepest to least recently as top, so
1620 // that repeated calls cycle through widgets. 1620 // that repeated calls cycle through widgets.
1621 QWidgetList *list = topLevelWidgets(); 1621 QWidgetList *list = topLevelWidgets();
1622 if ( list ) { 1622 if ( list ) {
1623 bool foundlast = FALSE; 1623 bool foundlast = FALSE;
1624 QWidget* topsub = 0; 1624 QWidget* topsub = 0;
1625 if ( d->lastraised ) { 1625 if ( d->lastraised ) {
1626 for (QWidget* w = list->first(); w; w = list->next()) { 1626 for (QWidget* w = list->first(); w; w = list->next()) {
1627 if ( !w->parentWidget() && w != topm && w->isVisible() && !w->isDesktop() ) { 1627 if ( !w->parentWidget() && w != topm && w->isVisible() && !w->isDesktop() ) {
1628 if ( w == d->lastraised ) 1628 if ( w == d->lastraised )
1629 foundlast = TRUE; 1629 foundlast = TRUE;
1630 if ( foundlast ) { 1630 if ( foundlast ) {
1631 w->raise(); 1631 w->raise();
1632 topsub = w; 1632 topsub = w;
1633 } 1633 }
1634 } 1634 }
1635 } 1635 }
1636 } 1636 }
1637 for (QWidget* w = list->first(); w; w = list->next()) { 1637 for (QWidget* w = list->first(); w; w = list->next()) {
1638 if ( !w->parentWidget() && w != topm && w->isVisible() && !w->isDesktop() ) { 1638 if ( !w->parentWidget() && w != topm && w->isVisible() && !w->isDesktop() ) {
1639 if ( w == d->lastraised ) 1639 if ( w == d->lastraised )
1640 break; 1640 break;
1641 w->raise(); 1641 w->raise();
1642 topsub = w; 1642 topsub = w;
1643 } 1643 }
1644 } 1644 }
1645 d->lastraised = topsub; 1645 d->lastraised = topsub;
1646 delete list; 1646 delete list;
1647 } 1647 }
1648 1648
1649 // 3. Raise the active modal widget. 1649 // 3. Raise the active modal widget.
1650 if ( topm ) { 1650 if ( topm ) {
1651 topm->show(); 1651 topm->show();
1652 topm->raise(); 1652 topm->raise();
1653 // If we haven't already handled the fastAppShowing message 1653 // If we haven't already handled the fastAppShowing message
1654 if (!top && d->preloaded) { 1654 if (!top && d->preloaded) {
1655#ifndef QT_NO_COP 1655#ifndef QT_NO_COP
1656 QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); 1656 QCopEnvelope e("QPE/System", "fastAppShowing(QString)");
1657 e << d->appName; 1657 e << d->appName;
1658#endif 1658#endif
1659 } 1659 }
1660 r = FALSE; 1660 r = FALSE;
1661 } 1661 }
1662 1662
1663 return r; 1663 return r;
1664} 1664}
1665 1665
1666 1666
1667void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data) 1667void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data)
1668{ 1668{
1669#ifdef Q_WS_QWS 1669#ifdef Q_WS_QWS
1670 1670
1671 if ( msg == "quit()" ) { 1671 if ( msg == "quit()" ) {
1672 tryQuit(); 1672 tryQuit();
1673 } 1673 }
1674 else if ( msg == "quitIfInvisible()" ) { 1674 else if ( msg == "quitIfInvisible()" ) {
1675 if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() ) 1675 if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() )
1676 quit(); 1676 quit();
1677 } 1677 }
1678 else if ( msg == "close()" ) { 1678 else if ( msg == "close()" ) {
1679 hideOrQuit(); 1679 hideOrQuit();
1680 } 1680 }
1681 else if ( msg == "disablePreload()" ) { 1681 else if ( msg == "disablePreload()" ) {
1682 d->preloaded = FALSE; 1682 d->preloaded = FALSE;
1683 d->keep_running = TRUE; 1683 d->keep_running = TRUE;
1684 /* so that quit will quit */ 1684 /* so that quit will quit */
1685 } 1685 }
1686 else if ( msg == "enablePreload()" ) { 1686 else if ( msg == "enablePreload()" ) {
1687 if (d->qpe_main_widget) 1687 if (d->qpe_main_widget)
1688 d->preloaded = TRUE; 1688 d->preloaded = TRUE;
1689 d->keep_running = TRUE; 1689 d->keep_running = TRUE;
1690 /* so next quit won't quit */ 1690 /* so next quit won't quit */
1691 } 1691 }
1692 else if ( msg == "raise()" ) { 1692 else if ( msg == "raise()" ) {
1693 d->keep_running = TRUE; 1693 d->keep_running = TRUE;
1694 d->notbusysent = FALSE; 1694 d->notbusysent = FALSE;
1695 raiseAppropriateWindow(); 1695 raiseAppropriateWindow();
1696 // Tell the system we're still chugging along... 1696 // Tell the system we're still chugging along...
1697 QCopEnvelope e("QPE/System", "appRaised(QString)"); 1697 QCopEnvelope e("QPE/System", "appRaised(QString)");
1698 e << d->appName; 1698 e << d->appName;
1699 } 1699 }
1700 else if ( msg == "flush()" ) { 1700 else if ( msg == "flush()" ) {
1701 emit flush(); 1701 emit flush();
1702 // we need to tell the desktop 1702 // we need to tell the desktop
1703 QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" ); 1703 QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" );
1704 e << d->appName; 1704 e << d->appName;
1705 } 1705 }
1706 else if ( msg == "reload()" ) { 1706 else if ( msg == "reload()" ) {
1707 emit reload(); 1707 emit reload();
1708 } 1708 }
1709 else if ( msg == "setDocument(QString)" ) { 1709 else if ( msg == "setDocument(QString)" ) {
1710 d->keep_running = TRUE; 1710 d->keep_running = TRUE;
1711 QDataStream stream( data, IO_ReadOnly ); 1711 QDataStream stream( data, IO_ReadOnly );
1712 QString doc; 1712 QString doc;
1713 stream >> doc; 1713 stream >> doc;
1714 QWidget *mw = mainWidget(); 1714 QWidget *mw = mainWidget();
1715 if ( !mw ) 1715 if ( !mw )
1716 mw = d->qpe_main_widget; 1716 mw = d->qpe_main_widget;
1717 if ( mw ) 1717 if ( mw )
1718 Global::setDocument( mw, doc ); 1718 Global::setDocument( mw, doc );
1719 1719
1720 } else if ( msg == "QPEProcessQCop()" ) { 1720 } else if ( msg == "QPEProcessQCop()" ) {
1721 processQCopFile(); 1721 processQCopFile();
1722 d->sendQCopQ(); 1722 d->sendQCopQ();
1723 }else 1723 }else
1724 { 1724 {
1725 bool p = d->keep_running; 1725 bool p = d->keep_running;
1726 d->keep_running = FALSE; 1726 d->keep_running = FALSE;
1727 emit appMessage( msg, data); 1727 emit appMessage( msg, data);
1728 if ( d->keep_running ) { 1728 if ( d->keep_running ) {
1729 d->notbusysent = FALSE; 1729 d->notbusysent = FALSE;
1730 raiseAppropriateWindow(); 1730 raiseAppropriateWindow();
1731 if ( !p ) { 1731 if ( !p ) {
1732 // Tell the system we're still chugging along... 1732 // Tell the system we're still chugging along...
1733#ifndef QT_NO_COP 1733#ifndef QT_NO_COP
1734 QCopEnvelope e("QPE/System", "appRaised(QString)"); 1734 QCopEnvelope e("QPE/System", "appRaised(QString)");
1735 e << d->appName; 1735 e << d->appName;
1736#endif 1736#endif
1737 } 1737 }
1738 } 1738 }
1739 if ( p ) 1739 if ( p )
1740 d->keep_running = p; 1740 d->keep_running = p;
1741 } 1741 }
1742#endif 1742#endif
1743} 1743}
1744 1744
1745 1745
1746/*! 1746/*!
1747 Sets widget \a mw as the mainWidget() and shows it. For small windows, 1747 Sets widget \a mw as the mainWidget() and shows it. For small windows,
1748 consider passing TRUE for \a nomaximize rather than the default FALSE. 1748 consider passing TRUE for \a nomaximize rather than the default FALSE.
1749 1749
1750 \sa showMainDocumentWidget() 1750 \sa showMainDocumentWidget()
1751*/ 1751*/
1752void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize ) 1752void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize )
1753{ 1753{
1754// setMainWidget(mw); this breaks FastLoading because lastWindowClose() would quit 1754// setMainWidget(mw); this breaks FastLoading because lastWindowClose() would quit
1755 d->show(mw, nomaximize ); 1755 d->show(mw, nomaximize );
1756} 1756}
1757 1757
1758/*! 1758/*!
1759 Sets widget \a mw as the mainWidget() and shows it. For small windows, 1759 Sets widget \a mw as the mainWidget() and shows it. For small windows,
1760 consider passing TRUE for \a nomaximize rather than the default FALSE. 1760 consider passing TRUE for \a nomaximize rather than the default FALSE.
1761 1761
1762 This calls designates the application as 1762 This calls designates the application as
1763 a \link docwidget.html document-oriented\endlink application. 1763 a \link docwidget.html document-oriented\endlink application.
1764 1764
1765 The \a mw widget \e must have this slot: setDocument(const QString&). 1765 The \a mw widget \e must have this slot: setDocument(const QString&).
1766 1766
1767 \sa showMainWidget() 1767 \sa showMainWidget()
1768*/ 1768*/
1769void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize ) 1769void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize )
1770{ 1770{
1771 if ( mw && argc() == 2 ) 1771 if ( mw && argc() == 2 )
1772 Global::setDocument( mw, QString::fromUtf8(argv()[1]) ); 1772 Global::setDocument( mw, QString::fromUtf8(argv()[1]) );
1773 1773
1774 1774
1775// setMainWidget(mw); see above 1775// setMainWidget(mw); see above
1776 d->show(mw, nomaximize ); 1776 d->show(mw, nomaximize );
1777} 1777}
1778 1778
1779 1779
1780/*! 1780/*!
1781 If an application is started via a \link qcop.html QCop\endlink 1781 If an application is started via a \link qcop.html QCop\endlink
1782 message, the application will process the \link qcop.html 1782 message, the application will process the \link qcop.html
1783 QCop\endlink message and then quit. If the application calls this 1783 QCop\endlink message and then quit. If the application calls this
1784 function while processing a \link qcop.html QCop\endlink message, 1784 function while processing a \link qcop.html QCop\endlink message,
1785 after processing its outstanding \link qcop.html QCop\endlink 1785 after processing its outstanding \link qcop.html QCop\endlink
1786 messages the application will start 'properly' and show itself. 1786 messages the application will start 'properly' and show itself.
1787 1787
1788 \sa keepRunning() 1788 \sa keepRunning()
1789*/ 1789*/
1790void QPEApplication::setKeepRunning() 1790void QPEApplication::setKeepRunning()
1791{ 1791{
1792 if ( qApp && qApp->inherits( "QPEApplication" ) ) { 1792 if ( qApp && qApp->inherits( "QPEApplication" ) ) {
1793 QPEApplication * qpeApp = ( QPEApplication* ) qApp; 1793 QPEApplication * qpeApp = ( QPEApplication* ) qApp;
1794 qpeApp->d->keep_running = TRUE; 1794 qpeApp->d->keep_running = TRUE;
1795 } 1795 }
1796} 1796}
1797 1797
1798/*! 1798/*!
1799 Returns TRUE if the application will quit after processing the 1799 Returns TRUE if the application will quit after processing the
1800 current list of qcop messages; otherwise returns FALSE. 1800 current list of qcop messages; otherwise returns FALSE.
1801 1801
1802 \sa setKeepRunning() 1802 \sa setKeepRunning()
1803*/ 1803*/
1804bool QPEApplication::keepRunning() const 1804bool QPEApplication::keepRunning() const
1805{ 1805{
1806 return d->keep_running; 1806 return d->keep_running;
1807} 1807}
1808 1808
1809/*! 1809/*!
1810 \internal 1810 \internal
1811*/ 1811*/
1812void QPEApplication::internalSetStyle( const QString &style ) 1812void QPEApplication::internalSetStyle( const QString &style )
1813{ 1813{
1814#if QT_VERSION >= 0x030000 1814#if QT_VERSION >= 0x030000
1815 if ( style == "QPE" ) { 1815 if ( style == "QPE" ) {
1816 setStyle( new QPEStyle ); 1816 setStyle( new QPEStyle );
1817 } 1817 }
1818 else { 1818 else {
1819 QStyle *s = QStyleFactory::create( style ); 1819 QStyle *s = QStyleFactory::create( style );
1820 if ( s ) 1820 if ( s )
1821 setStyle( s ); 1821 setStyle( s );
1822 } 1822 }
1823#else 1823#else
1824 if ( style == "Windows" ) { 1824 if ( style == "Windows" ) {
1825 setStyle( new QWindowsStyle ); 1825 setStyle( new QWindowsStyle );
1826 } 1826 }
1827 else if ( style == "QPE" ) { 1827 else if ( style == "QPE" ) {
1828 setStyle( new QPEStyle ); 1828 setStyle( new QPEStyle );
1829 } 1829 }
1830 else if ( style == "Light" ) { 1830 else if ( style == "Light" ) {
1831 setStyle( new LightStyle ); 1831 setStyle( new LightStyle );
1832 } 1832 }
1833#ifndef QT_NO_STYLE_PLATINUM 1833#ifndef QT_NO_STYLE_PLATINUM
1834 else if ( style == "Platinum" ) { 1834 else if ( style == "Platinum" ) {
1835 setStyle( new QPlatinumStyle ); 1835 setStyle( new QPlatinumStyle );
1836 } 1836 }
1837#endif 1837#endif
1838#ifndef QT_NO_STYLE_MOTIF 1838#ifndef QT_NO_STYLE_MOTIF
1839 else if ( style == "Motif" ) { 1839 else if ( style == "Motif" ) {
1840 setStyle( new QMotifStyle ); 1840 setStyle( new QMotifStyle );
1841 } 1841 }
1842#endif 1842#endif
1843#ifndef QT_NO_STYLE_MOTIFPLUS 1843#ifndef QT_NO_STYLE_MOTIFPLUS
1844 else if ( style == "MotifPlus" ) { 1844 else if ( style == "MotifPlus" ) {
1845 setStyle( new QMotifPlusStyle ); 1845 setStyle( new QMotifPlusStyle );
1846 } 1846 }
1847#endif 1847#endif
1848 1848
1849 else { 1849 else {
1850 QStyle *sty = 0; 1850 QStyle *sty = 0;
1851 QString path = QPEApplication::qpeDir ( ) + "plugins/styles/"; 1851 QString path = QPEApplication::qpeDir ( ) + "plugins/styles/";
1852 1852
1853#ifdef Q_OS_MACX 1853#ifdef Q_OS_MACX
1854 if ( style. find ( ".dylib" ) > 0 ) 1854 if ( style. find ( ".dylib" ) > 0 )
1855 path += style; 1855 path += style;
1856 else 1856 else
1857 path = path + "lib" + style. lower ( ) + ".dylib"; // compatibility 1857 path = path + "lib" + style. lower ( ) + ".dylib"; // compatibility
1858#else 1858#else
1859 if ( style. find ( ".so" ) > 0 ) 1859 if ( style. find ( ".so" ) > 0 )
1860 path += style; 1860 path += style;
1861 else 1861 else
1862 path = path + "lib" + style. lower ( ) + ".so"; // compatibility 1862 path = path + "lib" + style. lower ( ) + ".so"; // compatibility
1863#endif 1863#endif
1864 static QLibrary *lastlib = 0; 1864 static QLibrary *lastlib = 0;
1865 static StyleInterface *lastiface = 0; 1865 static StyleInterface *lastiface = 0;
1866 1866
1867 QLibrary *lib = new QLibrary ( path ); 1867 QLibrary *lib = new QLibrary ( path );
1868 StyleInterface *iface = 0; 1868 StyleInterface *iface = 0;
1869 1869
1870 if (( lib-> queryInterface ( IID_Style, ( QUnknownInterface ** ) &iface ) == QS_OK ) && iface ) 1870 if (( lib-> queryInterface ( IID_Style, ( QUnknownInterface ** ) &iface ) == QS_OK ) && iface )
1871 sty = iface-> style ( ); 1871 sty = iface-> style ( );
1872 1872
1873 if ( sty ) { 1873 if ( sty ) {
1874 setStyle ( sty ); 1874 setStyle ( sty );
1875 1875
1876 if ( lastiface ) 1876 if ( lastiface )
1877 lastiface-> release ( ); 1877 lastiface-> release ( );
1878 lastiface = iface; 1878 lastiface = iface;
1879 1879
1880 if ( lastlib ) { 1880 if ( lastlib ) {
1881 lastlib-> unload ( ); 1881 lastlib-> unload ( );
1882 delete lastlib; 1882 delete lastlib;
1883 } 1883 }
1884 lastlib = lib; 1884 lastlib = lib;
1885 } 1885 }
1886 else { 1886 else {
1887 if ( iface ) 1887 if ( iface )
1888 iface-> release ( ); 1888 iface-> release ( );
1889 delete lib; 1889 delete lib;
1890 1890
1891 setStyle ( new LightStyle ( )); 1891 setStyle ( new LightStyle ( ));
1892 } 1892 }
1893 } 1893 }
1894#endif 1894#endif
1895} 1895}
1896 1896
1897/*! 1897/*!
1898 \internal 1898 \internal
1899*/ 1899*/
1900void QPEApplication::prepareForTermination( bool willrestart ) 1900void QPEApplication::prepareForTermination( bool willrestart )
1901{ 1901{
1902 if ( willrestart ) { 1902 if ( willrestart ) {
1903 QLabel *lblWait = new QLabel( tr( "Please wait..." ), 0, "wait hack", QWidget::WStyle_Customize | 1903 QLabel *lblWait = new QLabel( tr( "Please wait..." ), 0, "wait hack", QWidget::WStyle_Customize |
1904 QWidget::WStyle_NoBorder | QWidget::WStyle_Tool ); 1904 QWidget::WStyle_NoBorder | QWidget::WStyle_Tool );
1905 lblWait->setAlignment( QWidget::AlignCenter ); 1905 lblWait->setAlignment( QWidget::AlignCenter );
1906 lblWait->show(); 1906 lblWait->show();
1907 lblWait->showMaximized(); 1907 lblWait->showMaximized();
1908 } 1908 }
1909 { QCopEnvelope envelope( "QPE/System", "forceQuit()" ); 1909 { QCopEnvelope envelope( "QPE/System", "forceQuit()" );
1910 } 1910 }
1911 processEvents(); // ensure the message goes out. 1911 processEvents(); // ensure the message goes out.
1912} 1912}
1913 1913
1914/*! 1914/*!
1915 \internal 1915 \internal
1916*/ 1916*/
1917void QPEApplication::shutdown() 1917void QPEApplication::shutdown()
1918{ 1918{
1919 // Implement in server's QPEApplication subclass 1919 // Implement in server's QPEApplication subclass
1920} 1920}
1921 1921
1922/*! 1922/*!
1923 \internal 1923 \internal
1924*/ 1924*/
1925void QPEApplication::restart() 1925void QPEApplication::restart()
1926{ 1926{
1927 // Implement in server's QPEApplication subclass 1927 // Implement in server's QPEApplication subclass
1928} 1928}
1929 1929
1930static QPtrDict<void>* stylusDict = 0; 1930static QPtrDict<void>* stylusDict = 0;
1931static void createDict() 1931static void createDict()
1932{ 1932{
1933 if ( !stylusDict ) 1933 if ( !stylusDict )
1934 stylusDict = new QPtrDict<void>; 1934 stylusDict = new QPtrDict<void>;
1935} 1935}
1936 1936
1937/*! 1937/*!
1938 Returns the current StylusMode for widget \a w. 1938 Returns the current StylusMode for widget \a w.
1939 1939
1940 \sa setStylusOperation() StylusMode 1940 \sa setStylusOperation() StylusMode
1941*/ 1941*/
1942QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w ) 1942QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w )
1943{ 1943{
1944 if ( stylusDict ) 1944 if ( stylusDict )
1945 return ( StylusMode ) ( int ) stylusDict->find( w ); 1945 return ( StylusMode ) ( int ) stylusDict->find( w );
1946 return LeftOnly; 1946 return LeftOnly;
1947} 1947}
1948 1948
1949/*! 1949/*!
1950 \enum QPEApplication::StylusMode 1950 \enum QPEApplication::StylusMode
1951 1951
1952 \value LeftOnly the stylus only generates LeftButton 1952 \value LeftOnly the stylus only generates LeftButton
1953 events (the default). 1953 events (the default).
1954 \value RightOnHold the stylus generates RightButton events 1954 \value RightOnHold the stylus generates RightButton events
1955 if the user uses the press-and-hold gesture. 1955 if the user uses the press-and-hold gesture.
1956 1956
1957 \sa setStylusOperation() stylusOperation() 1957 \sa setStylusOperation() stylusOperation()
1958*/ 1958*/
1959 1959
1960/*! 1960/*!
1961 Causes widget \a w to receive mouse events according to the stylus 1961 Causes widget \a w to receive mouse events according to the stylus
1962 \a mode. 1962 \a mode.
1963 1963
1964 \sa stylusOperation() StylusMode 1964 \sa stylusOperation() StylusMode
1965*/ 1965*/
1966void QPEApplication::setStylusOperation( QWidget * w, StylusMode mode ) 1966void QPEApplication::setStylusOperation( QWidget * w, StylusMode mode )
1967{ 1967{
1968 createDict(); 1968 createDict();
1969 if ( mode == LeftOnly ) { 1969 if ( mode == LeftOnly ) {
1970 stylusDict->remove 1970 stylusDict->remove
1971 ( w ); 1971 ( w );
1972 w->removeEventFilter( qApp ); 1972 w->removeEventFilter( qApp );
1973 } 1973 }
1974 else { 1974 else {
1975 stylusDict->insert( w, ( void* ) mode ); 1975 stylusDict->insert( w, ( void* ) mode );
1976 connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) ); 1976 connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) );
1977 w->installEventFilter( qApp ); 1977 w->installEventFilter( qApp );
1978 } 1978 }
1979} 1979}
1980 1980
1981 1981
1982/*! 1982/*!
1983 \reimp 1983 \reimp
1984*/ 1984*/
1985bool QPEApplication::eventFilter( QObject *o, QEvent *e ) 1985bool QPEApplication::eventFilter( QObject *o, QEvent *e )
1986{ 1986{
1987 if ( !o->isWidgetType() ) 1987 if ( !o->isWidgetType() )
1988 return FALSE; 1988 return FALSE;
1989 1989
1990 if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) { 1990 if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) {
1991 QMouseEvent * me = ( QMouseEvent* ) e; 1991 QMouseEvent * me = ( QMouseEvent* ) e;
1992 StylusMode mode = (StylusMode)(int)stylusDict->find(o); 1992 StylusMode mode = (StylusMode)(int)stylusDict->find(o);
1993 switch (mode) { 1993 switch (mode) {
1994 case RightOnHold: 1994 case RightOnHold:
1995 switch ( me->type() ) { 1995 switch ( me->type() ) {
1996 case QEvent::MouseButtonPress: 1996 case QEvent::MouseButtonPress:
1997 if ( me->button() == LeftButton ) { 1997 if ( me->button() == LeftButton ) {
1998 static long Pref = 500; // #### pref. 1998 static long Pref = 500; // #### pref.
1999 d->presswidget = (QWidget*)o; 1999 d->presswidget = (QWidget*)o;
2000 d->presspos = me->pos(); 2000 d->presspos = me->pos();
2001 d->rightpressed = FALSE; 2001 d->rightpressed = FALSE;
2002#ifdef OPIE_WITHROHFEEDBACK 2002#ifdef OPIE_WITHROHFEEDBACK
2003 if( ! d->RoH ) 2003 if( ! d->RoH )
2004 d->RoH = new Opie::Internal::RoHFeedback; 2004 d->RoH = new Opie::Internal::RoHFeedback;
2005 2005
2006 d->RoH->init( me->globalPos(), d->presswidget ); 2006 d->RoH->init( me->globalPos(), d->presswidget );
2007 Pref = d->RoH->delay(); 2007 Pref = d->RoH->delay();
2008 2008
2009#endif 2009#endif
2010 if (!d->presstimer ) 2010 if (!d->presstimer )
2011 d->presstimer = startTimer( Pref ); // #### pref. 2011 d->presstimer = startTimer( Pref ); // #### pref.
2012 2012
2013 } 2013 }
2014 break; 2014 break;
2015 case QEvent::MouseMove: 2015 case QEvent::MouseMove:
2016 if (d->presstimer && (me->pos() - d->presspos).manhattanLength() > 8) { 2016 if (d->presstimer && (me->pos() - d->presspos).manhattanLength() > 8) {
2017 killTimer(d->presstimer); 2017 killTimer(d->presstimer);
2018#ifdef OPIE_WITHROHFEEDBACK 2018#ifdef OPIE_WITHROHFEEDBACK
2019 d->RoH->stop(); 2019 d->RoH->stop();
2020#endif 2020#endif
2021 d->presstimer = 0; 2021 d->presstimer = 0;
2022 } 2022 }
2023 break; 2023 break;
2024 case QEvent::MouseButtonRelease: 2024 case QEvent::MouseButtonRelease:
2025 if ( me->button() == LeftButton ) { 2025 if ( me->button() == LeftButton ) {
2026 if ( d->presstimer ) { 2026 if ( d->presstimer ) {
2027 killTimer(d->presstimer); 2027 killTimer(d->presstimer);
2028#ifdef OPIE_WITHROHFEEDBACK 2028#ifdef OPIE_WITHROHFEEDBACK
2029 d->RoH->stop( ); 2029 d->RoH->stop( );
2030#endif 2030#endif
2031 d->presstimer = 0; 2031 d->presstimer = 0;
2032 } 2032 }
2033 if ( d->rightpressed && d->presswidget ) { 2033 if ( d->rightpressed && d->presswidget ) {
2034 printf( "Send ButtonRelease\n" ); 2034 printf( "Send ButtonRelease\n" );
2035 // Right released 2035 // Right released
2036 postEvent( d->presswidget, 2036 postEvent( d->presswidget,
2037 new QMouseEvent( QEvent::MouseButtonRelease, me->pos(), 2037 new QMouseEvent( QEvent::MouseButtonRelease, me->pos(),
2038 RightButton, LeftButton + RightButton ) ); 2038 RightButton, LeftButton + RightButton ) );
2039 // Left released, off-widget 2039 // Left released, off-widget
2040 postEvent( d->presswidget, 2040 postEvent( d->presswidget,
2041 new QMouseEvent( QEvent::MouseMove, QPoint( -1, -1), 2041 new QMouseEvent( QEvent::MouseMove, QPoint( -1, -1),
2042 LeftButton, LeftButton ) ); 2042 LeftButton, LeftButton ) );
2043 postEvent( d->presswidget, 2043 postEvent( d->presswidget,
2044 new QMouseEvent( QEvent::MouseButtonRelease, QPoint( -1, -1), 2044 new QMouseEvent( QEvent::MouseButtonRelease, QPoint( -1, -1),
2045 LeftButton, LeftButton ) ); 2045 LeftButton, LeftButton ) );
2046 d->rightpressed = FALSE; 2046 d->rightpressed = FALSE;
2047 return TRUE; // don't send the real Left release 2047 return TRUE; // don't send the real Left release
2048 } 2048 }
2049 } 2049 }
2050 break; 2050 break;
2051 default: 2051 default:
2052 break; 2052 break;
2053 } 2053 }
2054 break; 2054 break;
2055 default: 2055 default:
2056 ; 2056 ;
2057 } 2057 }
2058 } 2058 }
2059 else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { 2059 else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) {
2060 QKeyEvent *ke = (QKeyEvent *)e; 2060 QKeyEvent *ke = (QKeyEvent *)e;
2061 if ( ke->key() == Key_Enter ) { 2061 if ( ke->key() == Key_Enter ) {
2062 if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) { 2062 if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) {
2063 postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ', 2063 postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ',
2064 ke->state(), " ", ke->isAutoRepeat(), ke->count() ) ); 2064 ke->state(), " ", ke->isAutoRepeat(), ke->count() ) );
2065 return TRUE; 2065 return TRUE;
2066 } 2066 }
2067 } 2067 }
2068 } 2068 }
2069 return FALSE; 2069 return FALSE;
2070} 2070}
2071 2071
2072/*! 2072/*!
2073 \reimp 2073 \reimp
2074*/ 2074*/
2075void QPEApplication::timerEvent( QTimerEvent *e ) 2075void QPEApplication::timerEvent( QTimerEvent *e )
2076{ 2076{
2077 if ( e->timerId() == d->presstimer && d->presswidget ) { 2077 if ( e->timerId() == d->presstimer && d->presswidget ) {
2078 2078
2079 // Right pressed 2079 // Right pressed
2080 postEvent( d->presswidget, 2080 postEvent( d->presswidget,
2081 new QMouseEvent( QEvent::MouseButtonPress, d->presspos, 2081 new QMouseEvent( QEvent::MouseButtonPress, d->presspos,
2082 RightButton, LeftButton ) ); 2082 RightButton, LeftButton ) );
2083 killTimer( d->presstimer ); 2083 killTimer( d->presstimer );
2084 d->presstimer = 0; 2084 d->presstimer = 0;
2085 d->rightpressed = TRUE; 2085 d->rightpressed = TRUE;
2086#ifdef OPIE_WITHROHFEEDBACK 2086#ifdef OPIE_WITHROHFEEDBACK
2087 d->RoH->stop(); 2087 d->RoH->stop();
2088#endif 2088#endif
2089 } 2089 }
2090} 2090}
2091 2091
2092void QPEApplication::removeSenderFromStylusDict() 2092void QPEApplication::removeSenderFromStylusDict()
2093{ 2093{
2094 stylusDict->remove 2094 stylusDict->remove
2095 ( ( void* ) sender() ); 2095 ( ( void* ) sender() );
2096 if ( d->presswidget == sender() ) 2096 if ( d->presswidget == sender() )
2097 d->presswidget = 0; 2097 d->presswidget = 0;
2098} 2098}
2099 2099
2100/*! 2100/*!
2101 \internal 2101 \internal
2102*/ 2102*/
2103bool QPEApplication::keyboardGrabbed() const 2103bool QPEApplication::keyboardGrabbed() const
2104{ 2104{
2105 return d->kbgrabbed; 2105 return d->kbgrabbed;
2106} 2106}
2107 2107
2108 2108
2109/*! 2109/*!
2110 Reverses the effect of grabKeyboard(). This is called automatically 2110 Reverses the effect of grabKeyboard(). This is called automatically
2111 on program exit. 2111 on program exit.
2112*/ 2112*/
2113void QPEApplication::ungrabKeyboard() 2113void QPEApplication::ungrabKeyboard()
2114{ 2114{
2115 ((QPEApplication *) qApp )-> d-> kbgrabbed = false; 2115 ((QPEApplication *) qApp )-> d-> kbgrabbed = false;
2116} 2116}
2117 2117
2118/*! 2118/*!
2119 Grabs the physical keyboard keys, e.g. the application's launching 2119 Grabs the physical keyboard keys, e.g. the application's launching
2120 keys. Instead of launching applications when these keys are pressed 2120 keys. Instead of launching applications when these keys are pressed
2121 the signals emitted are sent to this application instead. Some games 2121 the signals emitted are sent to this application instead. Some games
2122 programs take over the launch keys in this way to make interaction 2122 programs take over the launch keys in this way to make interaction
2123 easier. 2123 easier.
2124 2124
2125 \sa ungrabKeyboard() 2125 \sa ungrabKeyboard()
2126*/ 2126*/
2127void QPEApplication::grabKeyboard() 2127void QPEApplication::grabKeyboard()
2128{ 2128{
2129 ((QPEApplication *) qApp )-> d-> kbgrabbed = true; 2129 ((QPEApplication *) qApp )-> d-> kbgrabbed = true;
2130} 2130}
2131 2131
2132/*! 2132/*!
2133 \reimp 2133 \reimp
2134*/ 2134*/
2135int QPEApplication::exec() 2135int QPEApplication::exec()
2136{ 2136{
2137 d->qcopQok = true; 2137 d->qcopQok = true;
2138#ifndef QT_NO_COP 2138#ifndef QT_NO_COP
2139 d->sendQCopQ(); 2139 d->sendQCopQ();
2140 if ( !d->keep_running ) 2140 if ( !d->keep_running )
2141 processEvents(); // we may have received QCop messages in the meantime. 2141 processEvents(); // we may have received QCop messages in the meantime.
2142#endif 2142#endif
2143 2143
2144 if ( d->keep_running ) 2144 if ( d->keep_running )
2145 //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() ) 2145 //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() )
2146 return QApplication::exec(); 2146 return QApplication::exec();
2147 2147
2148#ifndef QT_NO_COP 2148#ifndef QT_NO_COP
2149 2149
2150 { 2150 {
2151 QCopEnvelope e( "QPE/System", "closing(QString)" ); 2151 QCopEnvelope e( "QPE/System", "closing(QString)" );
2152 e << d->appName; 2152 e << d->appName;
2153 } 2153 }
2154#endif 2154#endif
2155 processEvents(); 2155 processEvents();
2156 return 0; 2156 return 0;
2157} 2157}
2158 2158
2159/*! 2159/*!
2160 \internal 2160 \internal
2161 External request for application to quit. Quits if possible without 2161 External request for application to quit. Quits if possible without
2162 loosing state. 2162 loosing state.
2163*/ 2163*/
2164void QPEApplication::tryQuit() 2164void QPEApplication::tryQuit()
2165{ 2165{
2166 if ( activeModalWidget() ) 2166 if ( activeModalWidget() )
2167 return ; // Inside modal loop or konsole. Too hard to save state. 2167 return ; // Inside modal loop or konsole. Too hard to save state.
2168#ifndef QT_NO_COP 2168#ifndef QT_NO_COP
2169 2169
2170 { 2170 {
2171 QCopEnvelope e( "QPE/System", "closing(QString)" ); 2171 QCopEnvelope e( "QPE/System", "closing(QString)" );
2172 e << d->appName; 2172 e << d->appName;
2173 } 2173 }
2174#endif 2174#endif
2175 if ( d->keep_running ) 2175 if ( d->keep_running )
2176 d->store_widget_rect(d->qpe_main_widget, d->appName); 2176 d->store_widget_rect(d->qpe_main_widget, d->appName);
2177 processEvents(); 2177 processEvents();
2178 2178
2179 quit(); 2179 quit();
2180} 2180}
2181 2181
2182 2182
2183/*! 2183/*!
2184 \internal 2184 \internal
2185 User initiated quit. Makes the window 'Go Away'. If preloaded this means 2185 User initiated quit. Makes the window 'Go Away'. If preloaded this means
2186 hiding the window. If not it means quitting the application. 2186 hiding the window. If not it means quitting the application.
2187 As this is user initiated we don't need to check state. 2187 As this is user initiated we don't need to check state.
2188*/ 2188*/
2189void QPEApplication::hideOrQuit() 2189void QPEApplication::hideOrQuit()
2190{ 2190{
2191 if ( d->keep_running ) 2191 if ( d->keep_running )
2192 d->store_widget_rect(d->qpe_main_widget, d->appName); 2192 d->store_widget_rect(d->qpe_main_widget, d->appName);
2193 processEvents(); 2193 processEvents();
2194 2194
2195 // If we are a preloaded application we don't actually quit, so emit 2195 // If we are a preloaded application we don't actually quit, so emit
2196 // a System message indicating we're quasi-closing. 2196 // a System message indicating we're quasi-closing.
2197 if ( d->preloaded && d->qpe_main_widget ) 2197 if ( d->preloaded && d->qpe_main_widget )
2198#ifndef QT_NO_COP 2198#ifndef QT_NO_COP
2199 2199
2200 { 2200 {
2201 QCopEnvelope e("QPE/System", "fastAppHiding(QString)" ); 2201 QCopEnvelope e("QPE/System", "fastAppHiding(QString)" );
2202 e << d->appName; 2202 e << d->appName;
2203 d->qpe_main_widget->hide(); 2203 d->qpe_main_widget->hide();
2204 } 2204 }
2205#endif 2205#endif
2206 else 2206 else
2207 quit(); 2207 quit();
2208} 2208}
2209 2209
2210#if (__GNUC__ > 2 ) 2210#if (__GNUC__ > 2 ) && !defined(_OS_MACX_)
2211extern "C" void __cxa_pure_virtual(); 2211extern "C" void __cxa_pure_virtual();
2212 2212
2213void __cxa_pure_virtual() 2213void __cxa_pure_virtual()
2214{ 2214{
2215 fprintf( stderr, "Pure virtual called\n"); 2215 fprintf( stderr, "Pure virtual called\n");
2216 abort(); 2216 abort();
2217 2217
2218} 2218}
2219 2219
2220#endif 2220#endif
2221 2221
2222 2222
2223#if defined(OPIE_NEW_MALLOC) 2223#if defined(OPIE_NEW_MALLOC)
2224 2224
2225// The libraries with the skiff package (and possibly others) have 2225// The libraries with the skiff package (and possibly others) have
2226// completely useless implementations of builtin new and delete that 2226// completely useless implementations of builtin new and delete that
2227// use about 50% of your CPU. Here we revert to the simple libc 2227// use about 50% of your CPU. Here we revert to the simple libc
2228// functions. 2228// functions.
2229 2229
2230void* operator new[]( size_t size ) 2230void* operator new[]( size_t size )
2231{ 2231{
2232 return malloc( size ); 2232 return malloc( size );
2233} 2233}
2234 2234
2235void* operator new( size_t size ) 2235void* operator new( size_t size )
2236{ 2236{
2237 return malloc( size ); 2237 return malloc( size );
2238} 2238}
2239 2239
2240void operator delete[]( void* p ) 2240void operator delete[]( void* p )
2241{ 2241{
2242 if ( p ) 2242 if ( p )
2243 free( p ); 2243 free( p );
2244} 2244}
2245 2245
2246void operator delete[]( void* p, size_t /*size*/ ) 2246void operator delete[]( void* p, size_t /*size*/ )
2247{ 2247{
2248 if ( p ) 2248 if ( p )
2249 free( p ); 2249 free( p );
2250} 2250}
2251 2251
2252 2252
2253void operator delete( void* p ) 2253void operator delete( void* p )
2254{ 2254{
2255 if ( p ) 2255 if ( p )
2256 free( p ); 2256 free( p );
2257} 2257}
2258 2258
2259void operator delete( void* p, size_t /*size*/ ) 2259void operator delete( void* p, size_t /*size*/ )
2260{ 2260{
2261 if ( p ) 2261 if ( p )
2262 free( p ); 2262 free( p );
2263} 2263}
2264 2264
2265#endif 2265#endif
2266 2266
2267#if ( QT_VERSION <= 230 ) && !defined(SINGLE_APP) 2267#if ( QT_VERSION <= 230 ) && !defined(SINGLE_APP)
2268#include <qwidgetlist.h> 2268#include <qwidgetlist.h>
2269#ifdef QWS 2269#ifdef QWS
2270#include <qgfx_qws.h> 2270#include <qgfx_qws.h>
2271extern QRect qt_maxWindowRect; 2271extern QRect qt_maxWindowRect;
2272void qt_setMaxWindowRect(const QRect& r ) 2272void qt_setMaxWindowRect(const QRect& r )
2273{ 2273{
2274 qt_maxWindowRect = qt_screen->mapFromDevice( r, 2274 qt_maxWindowRect = qt_screen->mapFromDevice( r,
2275 qt_screen->mapToDevice( QSize( qt_screen->width(), qt_screen->height() ) ) ); 2275 qt_screen->mapToDevice( QSize( qt_screen->width(), qt_screen->height() ) ) );
2276 // Re-resize any maximized windows 2276 // Re-resize any maximized windows
2277 QWidgetList* l = QApplication::topLevelWidgets(); 2277 QWidgetList* l = QApplication::topLevelWidgets();
2278 if ( l ) { 2278 if ( l ) {
2279 QWidget * w = l->first(); 2279 QWidget * w = l->first();
2280 while ( w ) { 2280 while ( w ) {
2281 if ( w->isVisible() && w->isMaximized() ) { 2281 if ( w->isVisible() && w->isMaximized() ) {
2282 w->showMaximized(); 2282 w->showMaximized();
2283 } 2283 }
2284 w = l->next(); 2284 w = l->next();
2285 } 2285 }
2286 delete l; 2286 delete l;
2287 } 2287 }
2288} 2288}
2289#endif 2289#endif
2290#endif 2290#endif