summaryrefslogtreecommitdiff
path: root/x11/libqpe-x11
Unidiff
Diffstat (limited to 'x11/libqpe-x11') (more/less context) (ignore whitespace changes)
-rw-r--r--x11/libqpe-x11/qpe/qpeapplication.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/x11/libqpe-x11/qpe/qpeapplication.cpp b/x11/libqpe-x11/qpe/qpeapplication.cpp
index eb01e50..0a98481 100644
--- a/x11/libqpe-x11/qpe/qpeapplication.cpp
+++ b/x11/libqpe-x11/qpe/qpeapplication.cpp
@@ -1,795 +1,795 @@
1#define QTOPIA_INTERNAL_LANGLIST 1#define QTOPIA_INTERNAL_LANGLIST
2 2
3#include <stdio.h> 3#include <stdio.h>
4#include <stdlib.h> 4#include <stdlib.h>
5#include <unistd.h> 5#include <unistd.h>
6#include <sys/file.h> 6#include <sys/file.h>
7 7
8 8
9#include <qdir.h> 9#include <qdir.h>
10#include <qdialog.h> 10#include <qdialog.h>
11#include <qdragobject.h> 11#include <qdragobject.h>
12#include <qevent.h> 12#include <qevent.h>
13#include <qlabel.h> 13#include <qlabel.h>
14#include <qlist.h> 14#include <qlist.h>
15#include <qtextstream.h> 15#include <qtextstream.h>
16#include <qtextcodec.h> 16#include <qtextcodec.h>
17#include <qpalette.h> 17#include <qpalette.h>
18#include <qptrdict.h> 18#include <qptrdict.h>
19#include <qregexp.h> 19#include <qregexp.h>
20#include <qtimer.h> 20#include <qtimer.h>
21 21
22#include <qpe/alarmserver.h> 22#include <qpe/alarmserver.h>
23#include <qpe/applnk.h> 23#include <qpe/applnk.h>
24#include <qpe/qpemenubar.h> 24#include <qpe/qpemenubar.h>
25#include <qpe/textcodecinterface.h> 25#include <qpe/textcodecinterface.h>
26#include <qpe/imagecodecinterface.h> 26#include <qpe/imagecodecinterface.h>
27#include <qpe/qlibrary.h> 27#include <qpe/qlibrary.h>
28#include <qpe/qpestyle.h> 28#include <qpe/qpestyle.h>
29#include <qpe/styleinterface.h> 29#include <qpe/styleinterface.h>
30#include <qpe/global.h> 30#include <qpe/global.h>
31#include <qpe/resource.h> 31#include <qpe/resource.h>
32#include <qpe/config.h> 32#include <qpe/config.h>
33#include <qpe/network.h> 33#include <qpe/network.h>
34 34
35#include <qpe/qpeapplication.h> 35#include <qpe/qpeapplication.h>
36#include <qpe/timestring.h> 36#include <qpe/timestring.h>
37#include <qpe/qcopenvelope_qws.h> 37#include <qpe/qcopenvelope_qws.h>
38 38
39 39
40#include <X11/Xlib.h> 40#include <X11/Xlib.h>
41#include <X11/Xutil.h> 41#include <X11/Xutil.h>
42 42
43const int XKeyPress = KeyPress; 43const int XKeyPress = KeyPress;
44const int XKeyRelease = KeyRelease; 44const int XKeyRelease = KeyRelease;
45#undef KeyPress 45#undef KeyPress
46#undef KeyRelease 46#undef KeyRelease
47 47
48namespace { 48namespace {
49 struct QCopRec{ 49 struct QCopRec{
50 QCopRec( const QCString& ch, const QCString& msg, const QByteArray& ar ) 50 QCopRec( const QCString& ch, const QCString& msg, const QByteArray& ar )
51 : channel(ch), message(msg), data(ar) { 51 : channel(ch), message(msg), data(ar) {
52 52
53 } 53 }
54 QCString channel; 54 QCString channel;
55 QCString message; 55 QCString message;
56 QByteArray data; 56 QByteArray data;
57 }; 57 };
58}; 58};
59 59
60 60
61class QPEApplication::Private { 61class QPEApplication::Private {
62public: 62public:
63 Private(); 63 Private();
64 ~Private(); 64 ~Private();
65 void enqueueQCop( const QCString& ch, const QCString& msg, 65 void enqueueQCop( const QCString& ch, const QCString& msg,
66 const QByteArray& ); 66 const QByteArray& );
67 void sendQCopQ(); 67 void sendQCopQ();
68 static void show_mx(QWidget* mw, bool nomaximize ); 68 static void show_mx(QWidget* mw, bool nomaximize );
69 void show( QWidget* mw, bool nomax ); 69 void show( QWidget* mw, bool nomax );
70 void loadTextCodecs(); 70 void loadTextCodecs();
71 void loadImageCodecs(); 71 void loadImageCodecs();
72 72
73 int kbgrabber; 73 int kbgrabber;
74 int presstimer; 74 int presstimer;
75 75
76 bool rightpressed : 1; 76 bool rightpressed : 1;
77 bool kbregrab : 1; 77 bool kbregrab : 1;
78 bool notbusysent : 1; 78 bool notbusysent : 1;
79 bool preloaded : 1; 79 bool preloaded : 1;
80 bool forceshow : 1; 80 bool forceshow : 1;
81 bool nomaximize : 1; 81 bool nomaximize : 1;
82 bool keep_running : 1; 82 bool keep_running : 1;
83 83
84 QWidget* presswidget; 84 QWidget* presswidget;
85 QPoint presspos; 85 QPoint presspos;
86 QWidget* qpe_main_widget; 86 QWidget* qpe_main_widget;
87 QString appName; 87 QString appName;
88 QString styleName; 88 QString styleName;
89 QString decorationName; 89 QString decorationName;
90 Atom wm_delete_window; 90 Atom wm_delete_window;
91 Atom wm_take_focus; 91 Atom wm_take_focus;
92 Atom wm_context_help; 92 Atom wm_context_help;
93 Atom wm_context_accept; 93 Atom wm_context_accept;
94 Atom wm_protocols; 94 Atom wm_protocols;
95 95
96private: 96private:
97 QList<QCopRec> qcopq; 97 QList<QCopRec> qcopq;
98}; 98};
99QPEApplication::Private::~Private() { 99QPEApplication::Private::~Private() {
100} 100}
101QPEApplication::Private::Private() 101QPEApplication::Private::Private()
102 : kbgrabber(0 ), presstimer(0 ), rightpressed( FALSE ), kbregrab( FALSE ), notbusysent( FALSE ), 102 : kbgrabber(0 ), presstimer(0 ), rightpressed( FALSE ), kbregrab( FALSE ), notbusysent( FALSE ),
103 preloaded( FALSE ), forceshow( FALSE ), nomaximize( FALSE ), keep_running( TRUE ), 103 preloaded( FALSE ), forceshow( FALSE ), nomaximize( FALSE ), keep_running( TRUE ),
104 presswidget( 0 ), qpe_main_widget(0 ) { 104 presswidget( 0 ), qpe_main_widget(0 ) {
105 105
106 qcopq.setAutoDelete( TRUE ); 106 qcopq.setAutoDelete( TRUE );
107} 107}
108void QPEApplication::Private::enqueueQCop( const QCString& chan, const QCString& msg, 108void QPEApplication::Private::enqueueQCop( const QCString& chan, const QCString& msg,
109 const QByteArray& ar ) { 109 const QByteArray& ar ) {
110 qcopq.append( new QCopRec(chan, msg, ar ) ); 110 qcopq.append( new QCopRec(chan, msg, ar ) );
111} 111}
112void QPEApplication::Private::sendQCopQ() { 112void QPEApplication::Private::sendQCopQ() {
113 QCopRec* r; 113 QCopRec* r;
114 for ( r = qcopq.first(); r; r = qcopq.next() ) { 114 for ( r = qcopq.first(); r; r = qcopq.next() ) {
115 QCopChannel::sendLocally( r->channel, r->message, r->data ); 115 QCopChannel::sendLocally( r->channel, r->message, r->data );
116 } 116 }
117 qcopq.clear(); 117 qcopq.clear();
118} 118}
119void QPEApplication::Private::show_mx(QWidget* mw, bool nomaximize ) { 119void QPEApplication::Private::show_mx(QWidget* mw, bool nomaximize ) {
120 if (mw->layout() && mw->inherits("QDialog") ) { 120 if (mw->layout() && mw->inherits("QDialog") ) {
121 QPEApplication::showDialog( (QDialog*)mw, nomaximize ); 121 QPEApplication::showDialog( (QDialog*)mw, nomaximize );
122 }else { 122 }else {
123 if (!nomaximize ) 123 if (!nomaximize )
124 mw->showMaximized(); 124 mw->showMaximized();
125 else 125 else
126 mw->show(); 126 mw->show();
127 } 127 }
128} 128}
129void QPEApplication::Private::show( QWidget* mw, bool nomax ) { 129void QPEApplication::Private::show( QWidget* mw, bool nomax ) {
130 nomaximize = nomax; 130 nomaximize = nomax;
131 qpe_main_widget = mw; 131 qpe_main_widget = mw;
132 132
133 sendQCopQ(); 133 sendQCopQ();
134 134
135 if ( preloaded ) { 135 if ( preloaded ) {
136 if (forceshow ) 136 if (forceshow )
137 show_mx(mw, nomax ); 137 show_mx(mw, nomax );
138 }else if ( keep_running ) 138 }else if ( keep_running )
139 show_mx( mw, nomax ); 139 show_mx( mw, nomax );
140} 140}
141void QPEApplication::Private::loadTextCodecs() { 141void QPEApplication::Private::loadTextCodecs() {
142 QString path = QPEApplication::qpeDir() + "/plugins/textcodecs"; 142 QString path = QPEApplication::qpeDir() + "/plugins/textcodecs";
143 QDir dir( path, "lib*.so" ); 143 QDir dir( path, "lib*.so" );
144 QStringList list = dir.entryList(); 144 QStringList list = dir.entryList();
145 QStringList::Iterator it; 145 QStringList::Iterator it;
146 for ( it = list.begin(); it != list.end(); ++it ) { 146 for ( it = list.begin(); it != list.end(); ++it ) {
147 TextCodecInterface *iface = 0; 147 TextCodecInterface *iface = 0;
148 QLibrary *lib = new QLibrary( path + "/" + *it ); 148 QLibrary *lib = new QLibrary( path + "/" + *it );
149 if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { 149 if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) {
150 QValueList<int> mibs = iface->mibEnums(); 150 QValueList<int> mibs = iface->mibEnums();
151 for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) { 151 for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) {
152 (void)iface->createForMib(*i); 152 (void)iface->createForMib(*i);
153 // ### it exists now; need to remember if we can delete it 153 // ### it exists now; need to remember if we can delete it
154 } 154 }
155 } 155 }
156 else { 156 else {
157 lib->unload(); 157 lib->unload();
158 delete lib; 158 delete lib;
159 } 159 }
160 } 160 }
161} 161}
162void QPEApplication::Private::loadImageCodecs() { 162void QPEApplication::Private::loadImageCodecs() {
163 QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs"; 163 QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs";
164 QDir dir( path, "lib*.so" ); 164 QDir dir( path, "lib*.so" );
165 QStringList list = dir.entryList(); 165 QStringList list = dir.entryList();
166 QStringList::Iterator it; 166 QStringList::Iterator it;
167 for ( it = list.begin(); it != list.end(); ++it ) { 167 for ( it = list.begin(); it != list.end(); ++it ) {
168 ImageCodecInterface *iface = 0; 168 ImageCodecInterface *iface = 0;
169 QLibrary *lib = new QLibrary( path + "/" + *it ); 169 QLibrary *lib = new QLibrary( path + "/" + *it );
170 if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { 170 if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) {
171 QStringList formats = iface->keys(); 171 QStringList formats = iface->keys();
172 for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) { 172 for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) {
173 (void)iface->installIOHandler(*i); 173 (void)iface->installIOHandler(*i);
174 // ### it exists now; need to remember if we can delete it 174 // ### it exists now; need to remember if we can delete it
175 } 175 }
176 } 176 }
177 else { 177 else {
178 lib->unload(); 178 lib->unload();
179 delete lib; 179 delete lib;
180 } 180 }
181 } 181 }
182} 182}
183 183
184// The Help System hook 184// The Help System hook
185namespace { 185namespace {
186 class ResourceMimeFactory : public QMimeSourceFactory 186 class ResourceMimeFactory : public QMimeSourceFactory
187 { 187 {
188 public: 188 public:
189 ResourceMimeFactory(); 189 ResourceMimeFactory();
190 ~ResourceMimeFactory(); 190 ~ResourceMimeFactory();
191 const QMimeSource* data( const QString& abs_name )const; 191 const QMimeSource* data( const QString& abs_name )const;
192 }; 192 };
193 ResourceMimeFactory::ResourceMimeFactory() 193 ResourceMimeFactory::ResourceMimeFactory()
194 { 194 {
195 setFilePath( Global::helpPath() ); 195 setFilePath( Global::helpPath() );
196 setExtensionType( "html", "text/html;charset=UTF-8" ); 196 setExtensionType( "html", "text/html;charset=UTF-8" );
197 } 197 }
198 ResourceMimeFactory::~ResourceMimeFactory() { 198 ResourceMimeFactory::~ResourceMimeFactory() {
199 } 199 }
200 200
201 const QMimeSource* ResourceMimeFactory::data( const QString& abs_name ) const 201 const QMimeSource* ResourceMimeFactory::data( const QString& abs_name ) const
202 { 202 {
203 const QMimeSource * r = QMimeSourceFactory::data( abs_name ); 203 const QMimeSource * r = QMimeSourceFactory::data( abs_name );
204 if ( !r ) { 204 if ( !r ) {
205 int sl = abs_name.length(); 205 int sl = abs_name.length();
206 do { 206 do {
207 sl = abs_name.findRev( '/', sl - 1 ); 207 sl = abs_name.findRev( '/', sl - 1 );
208 QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; 208 QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name;
209 int dot = name.findRev( '.' ); 209 int dot = name.findRev( '.' );
210 if ( dot >= 0 ) 210 if ( dot >= 0 )
211 name = name.left( dot ); 211 name = name.left( dot );
212 QImage img = Resource::loadImage( name ); 212 QImage img = Resource::loadImage( name );
213 if ( !img.isNull() ) 213 if ( !img.isNull() )
214 r = new QImageDrag( img ); 214 r = new QImageDrag( img );
215 } 215 }
216 while ( !r && sl > 0 ); 216 while ( !r && sl > 0 );
217 } 217 }
218 return r; 218 return r;
219 }; 219 };
220}; 220};
221// QPEApplication 221// QPEApplication
222QPEApplication::~QPEApplication() { 222QPEApplication::~QPEApplication() {
223 qWarning("~QPEApplication"); 223 qWarning("~QPEApplication");
224 ungrabKeyboard(); 224 ungrabKeyboard();
225 qWarning("UngrabKeyboard"); 225 qWarning("UngrabKeyboard");
226 226
227// delete m_sys; 227// delete m_sys;
228// delete m_pid; 228// delete m_pid;
229 229
230 delete d; 230 delete d;
231} 231}
232QPEApplication::QPEApplication(int &arg, char** argv, Type t) 232QPEApplication::QPEApplication(int &arg, char** argv, Type t)
233 : QApplication( arg, argv, t ) { 233 : QApplication( arg, argv, t ) {
234 d = new Private; 234 d = new Private;
235 d->loadTextCodecs(); 235 d->loadTextCodecs();
236 d->loadImageCodecs(); 236 d->loadImageCodecs();
237 237
238 // Init X-Atom 238 // Init X-Atom
239 Atom *atoms[5]; 239 Atom *atoms[5];
240 Atom atoms_re[5]; 240 Atom atoms_re[5];
241 char* names[5]; 241 char* names[5];
242 int n = 0; 242 int n = 0;
243 atoms[n] = &d->wm_delete_window; 243 atoms[n] = &d->wm_delete_window;
244 names[n++] = "WM_DELETE_WINDOW"; 244 names[n++] = "WM_DELETE_WINDOW";
245 245
246 atoms[n] = &d->wm_take_focus; 246 atoms[n] = &d->wm_take_focus;
247 names[n++] = "WM_TAKE_FOCUS"; 247 names[n++] = "WM_TAKE_FOCUS";
248 248
249 atoms[n] = &d->wm_context_help; 249 atoms[n] = &d->wm_context_help;
250 names[n++] = "_NET_WM_CONTEXT_HELP"; 250 names[n++] = "_NET_WM_CONTEXT_HELP";
251 251
252 atoms[n] = &d->wm_context_accept; 252 atoms[n] = &d->wm_context_accept;
253 names[n++] = "_NET_WM_CONTEXT_ACCEPT"; 253 names[n++] = "_NET_WM_CONTEXT_ACCEPT";
254 254
255 atoms[n] = &d->wm_protocols; 255 atoms[n] = &d->wm_protocols;
256 names[n++] = "WM_PROTOCOLS"; 256 names[n++] = "WM_PROTOCOLS";
257 257
258 XInternAtoms( qt_xdisplay(), names, n, FALSE, atoms_re); 258 XInternAtoms( qt_xdisplay(), names, n, FALSE, atoms_re);
259 // now copy the values over to the properties 259 // now copy the values over to the properties
260 for (int i = 0; i < n; i++ ) 260 for (int i = 0; i < n; i++ )
261 *atoms[i] = atoms_re[i]; 261 *atoms[i] = atoms_re[i];
262 // done with X11 Stuff 262 // done with X11 Stuff
263 263
264 int dw = desktop()->width(); 264 int dw = desktop()->width();
265 if ( dw < 200 ) { 265 if ( dw < 200 ) {
266 setFont( QFont( "helvetica", 8 ) ); 266 setFont( QFont( "helvetica", 8 ) );
267 AppLnk::setSmallIconSize( 10 ); 267 AppLnk::setSmallIconSize( 10 );
268 AppLnk::setBigIconSize( 28 ); 268 AppLnk::setBigIconSize( 28 );
269 }else if ( dw > 600 ) { 269 }else if ( dw > 600 ) {
270 setFont( QFont( "helvetica", 12 ) ); 270 setFont( QFont( "helvetica", 12 ) );
271 AppLnk::setSmallIconSize( 24 ); 271 AppLnk::setSmallIconSize( 24 );
272 AppLnk::setBigIconSize( 48 ); 272 AppLnk::setBigIconSize( 48 );
273 }else if ( dw > 200 ) { 273 }else if ( dw > 200 ) {
274 setFont( QFont( "helvetica", 10 ) ); 274 setFont( QFont( "helvetica", 10 ) );
275 AppLnk::setSmallIconSize( 16 ); 275 AppLnk::setSmallIconSize( 16 );
276 AppLnk::setBigIconSize( 32 ); 276 AppLnk::setBigIconSize( 32 );
277 } 277 }
278 QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory ); 278 QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory );
279 279
280 connect( this, SIGNAL( lastWindowClosed() ), this, SLOT(hideOrQuit() ) ); 280 connect( this, SIGNAL( lastWindowClosed() ), this, SLOT(hideOrQuit() ) );
281 281
282 QString qcopfn( "/tmp/qcop-msg-" ); 282 QString qcopfn( "/tmp/qcop-msg-" );
283 qcopfn += QString( argv[0] ); // append command name to the QCOP name 283 qcopfn += QString( argv[0] ); // append command name to the QCOP name
284 QFile file( qcopfn ); 284 QFile file( qcopfn );
285 if (file.open(IO_ReadOnly ) ) { 285 if (file.open(IO_ReadOnly ) ) {
286 flock( file.handle(), LOCK_EX ); 286 flock( file.handle(), LOCK_EX );
287 } 287 }
288 288
289 /* Hmmm damn we need to make the parent 0l otherwise it get's deleted 289 /* Hmmm damn we need to make the parent 0l otherwise it get's deleted
290 * past the QApplication 290 * past the QApplication
291 */ 291 */
292 m_sys = new QCopChannel( "QPE/System", 0l); 292 m_sys = new QCopChannel( "QPE/System", 0l);
293 connect(m_sys, SIGNAL( received( const QCString&, const QByteArray& ) ), 293 connect(m_sys, SIGNAL( received( const QCString&, const QByteArray& ) ),
294 this, SLOT(systemMessage( const QCString&, const QByteArray& ) ) ); 294 this, SLOT(systemMessage( const QCString&, const QByteArray& ) ) );
295 295
296 // private channel QPE/Application/appname 296 // private channel QPE/Application/appname
297 QCString channel = QCString( argv[0] ); 297 QCString channel = QCString( argv[0] );
298 channel.replace( QRegExp( ".*/"), "" ); 298 channel.replace( QRegExp( ".*/"), "" );
299 d->appName = channel; 299 d->appName = channel;
300 channel = "QPE/Application/"+ channel; 300 channel = "QPE/Application/"+ channel;
301 m_pid = new QCopChannel( channel, 0l ); 301 m_pid = new QCopChannel( channel, 0l );
302 connect(m_pid, SIGNAL( received( const QCString&, const QByteArray& ) ), 302 connect(m_pid, SIGNAL( received( const QCString&, const QByteArray& ) ),
303 this, SLOT( pidMessage( const QCString&, const QByteArray& ) ) ); 303 this, SLOT( pidMessage( const QCString&, const QByteArray& ) ) );
304 304
305 // read the Pre QCOP Stuff from the file 305 // read the Pre QCOP Stuff from the file
306 if ( file.isOpen() ) { 306 if ( file.isOpen() ) {
307 d->keep_running = FALSE; 307 d->keep_running = FALSE;
308 QDataStream ds( &file ); 308 QDataStream ds( &file );
309 QCString chanel, message; 309 QCString chanel, message;
310 QByteArray data; 310 QByteArray data;
311 while (!ds.atEnd() ) { 311 while (!ds.atEnd() ) {
312 ds >> chanel >> message >> data; 312 ds >> chanel >> message >> data;
313 d->enqueueQCop( chanel, message, data ); 313 d->enqueueQCop( chanel, message, data );
314 } 314 }
315 flock( file.handle(), LOCK_UN ); 315 flock( file.handle(), LOCK_UN );
316 file.close(); 316 file.close();
317 file.remove(); 317 file.remove();
318 } 318 }
319 319
320 // read in some stuff from the command line 320 // read in some stuff from the command line
321 // we do not have setArgs so we need to take 321 // we do not have setArgs so we need to take
322 // care of that 322 // care of that
323 for ( int a = 0; a < arg; a++ ) { 323 for ( int a = 0; a < arg; a++ ) {
324 if ( qstrcmp( argv[a], "-preload" ) == 0 ) { 324 if ( qstrcmp( argv[a], "-preload" ) == 0 ) {
325 d->preloaded = TRUE; 325 d->preloaded = TRUE;
326 }else if ( qstrcmp( argv[a ] , "-preload-show" ) == 0 ) { 326 }else if ( qstrcmp( argv[a ] , "-preload-show" ) == 0 ) {
327 d->preloaded = TRUE; 327 d->preloaded = TRUE;
328 d->forceshow = TRUE; 328 d->forceshow = TRUE;
329 } 329 }
330 } 330 }
331 initTranslations(); 331 initTranslations();
332 applyStyle(); 332 applyStyle();
333 333
334 if ( type() == GuiServer ) 334 if ( type() == GuiServer )
335 ; 335 ;
336 336
337 installEventFilter( this ); 337 installEventFilter( this );
338 QPEMenuToolFocusManager::initialize(); 338 QPEMenuToolFocusManager::initialize();
339} 339}
340void QPEApplication::initTranslations() { 340void QPEApplication::initTranslations() {
341 // Translations add it 341 // Translations add it
342 QStringList langs = Global::languageList(); 342 QStringList langs = Global::languageList();
343 for ( QStringList::ConstIterator it = langs.begin(); it != langs.end(); ++it ) { 343 for ( QStringList::ConstIterator it = langs.begin(); it != langs.end(); ++it ) {
344 QString lang = *it; 344 QString lang = *it;
345 345
346 QTranslator * trans; 346 QTranslator * trans;
347 QString tfn; 347 QString tfn;
348 348
349 trans = new QTranslator( this ); 349 trans = new QTranslator( this );
350 tfn = qpeDir() + "/i18n/" + lang + "/libqpe.qm"; 350 tfn = qpeDir() + "/i18n/" + lang + "/libqpe.qm";
351 if ( trans->load( tfn ) ) 351 if ( trans->load( tfn ) )
352 installTranslator( trans ); 352 installTranslator( trans );
353 else 353 else
354 delete trans; 354 delete trans;
355 355
356 trans = new QTranslator( this ); 356 trans = new QTranslator( this );
357 tfn = qpeDir() + "/i18n/" + lang + "/" + d->appName + ".qm"; 357 tfn = qpeDir() + "/i18n/" + lang + "/" + d->appName + ".qm";
358 if ( trans->load( tfn ) ) 358 if ( trans->load( tfn ) )
359 installTranslator( trans ); 359 installTranslator( trans );
360 else 360 else
361 delete trans; 361 delete trans;
362 } 362 }
363} 363}
364QString QPEApplication::qpeDir() { 364QString QPEApplication::qpeDir() {
365 const char * base = getenv( "OPIEDIR" ); 365 const char * base = getenv( "OPIEDIR" );
366 if ( base ) 366 if ( base )
367 return QString( base ) + "/"; 367 return QString( base ) + "/";
368 368
369 return QString( "../" ); 369 return QString( "../" );
370} 370}
371QString QPEApplication::documentDir() { 371QString QPEApplication::documentDir() {
372 const char* base = getenv( "HOME"); 372 const char* base = getenv( "HOME");
373 if ( base ) 373 if ( base )
374 return QString( base ) + "/Documents"; 374 return QString( base ) + "/Documents";
375 375
376 return QString( "../Documents" ); 376 return QString( "../Documents" );
377} 377}
378void QPEApplication::applyStyle() { 378void QPEApplication::applyStyle() {
379 Config config( "qpe" ); 379 Config config( "qpe" );
380 380
381 config.setGroup( "Appearance" ); 381 config.setGroup( "Appearance" );
382 382
383 // Widget style 383 // Widget style
384 QString style = config.readEntry( "Style", "Light" ); 384 QString style = config.readEntry( "Style", "Light" );
385 internalSetStyle( style ); 385 internalSetStyle( style );
386 386
387 // Colors 387 // Colors
388 QColor bgcolor( config.readEntry( "Background", "#E5E1D5" ) ); 388 QColor bgcolor( config.readEntry( "Background", "#E5E1D5" ) );
389 QColor btncolor( config.readEntry( "Button", "#D6CDBB" ) ); 389 QColor btncolor( config.readEntry( "Button", "#D6CDBB" ) );
390 QPalette pal( btncolor, bgcolor ); 390 QPalette pal( btncolor, bgcolor );
391 QString color = config.readEntry( "Highlight", "#800000" ); 391 QString color = config.readEntry( "Highlight", "#800000" );
392 pal.setColor( QColorGroup::Highlight, QColor( color ) ); 392 pal.setColor( QColorGroup::Highlight, QColor( color ) );
393 color = config.readEntry( "HighlightedText", "#FFFFFF" ); 393 color = config.readEntry( "HighlightedText", "#FFFFFF" );
394 pal.setColor( QColorGroup::HighlightedText, QColor( color ) ); 394 pal.setColor( QColorGroup::HighlightedText, QColor( color ) );
395 color = config.readEntry( "Text", "#000000" ); 395 color = config.readEntry( "Text", "#000000" );
396 pal.setColor( QColorGroup::Text, QColor( color ) ); 396 pal.setColor( QColorGroup::Text, QColor( color ) );
397 color = config.readEntry( "ButtonText", "#000000" ); 397 color = config.readEntry( "ButtonText", "#000000" );
398 pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) ); 398 pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) );
399 color = config.readEntry( "Base", "#FFFFFF" ); 399 color = config.readEntry( "Base", "#FFFFFF" );
400 pal.setColor( QColorGroup::Base, QColor( color ) ); 400 pal.setColor( QColorGroup::Base, QColor( color ) );
401 401
402 pal.setColor( QPalette::Disabled, QColorGroup::Text, 402 pal.setColor( QPalette::Disabled, QColorGroup::Text,
403 pal.color( QPalette::Active, QColorGroup::Background ).dark() ); 403 pal.color( QPalette::Active, QColorGroup::Background ).dark() );
404 404
405 setPalette( pal, TRUE ); 405 setPalette( pal, TRUE );
406 406
407 407
408 408
409 // Font 409 // Font
410 QString ff = config.readEntry( "FontFamily", font().family() ); 410 QString ff = config.readEntry( "FontFamily", font().family() );
411 int fs = config.readNumEntry( "FontSize", font().pointSize() ); 411 int fs = config.readNumEntry( "FontSize", font().pointSize() );
412 setFont( QFont(ff, fs) ); 412 setFont( QFont(ff, fs) );
413} 413}
414int QPEApplication::defaultRotation() { 414int QPEApplication::defaultRotation() {
415 return 0; 415 return 0;
416} 416}
417void QPEApplication::setDefaultRotation(int r ) { 417void QPEApplication::setDefaultRotation(int r ) {
418 418
419} 419}
420void QPEApplication::grabKeyboard() { 420void QPEApplication::grabKeyboard() {
421 QPEApplication::Private * d = ( ( QPEApplication* ) qApp ) ->d; 421 QPEApplication::Private * d = ( ( QPEApplication* ) qApp ) ->d;
422 if ( qApp->type() == QApplication::GuiServer ) 422 if ( qApp->type() == QApplication::GuiServer )
423 d->kbgrabber = 0; 423 d->kbgrabber = 0;
424 else { 424 else {
425 QCopEnvelope e( "QPE/System", "grabKeyboard(QString)" ); 425 QCopEnvelope e( "QPE/System", "grabKeyboard(QString)" );
426 e << d->appName; 426 e << d->appName;
427 427
428 d->kbgrabber = 2; // me 428 d->kbgrabber = 2; // me
429 } 429 }
430} 430}
431void QPEApplication::ungrabKeyboard() { 431void QPEApplication::ungrabKeyboard() {
432 QPEApplication::Private * d = ( ( QPEApplication* ) qApp ) ->d; 432 QPEApplication::Private * d = ( ( QPEApplication* ) qApp ) ->d;
433 if ( d->kbgrabber == 2 ) { 433 if ( d->kbgrabber == 2 ) {
434 QCopEnvelope e( "QPE/System", "grabKeyboard(QString)" ); 434 QCopEnvelope e( "QPE/System", "grabKeyboard(QString)" );
435 e << QString::null; 435 e << QString::null;
436 436
437 d->kbregrab = FALSE; 437 d->kbregrab = FALSE;
438 d->kbgrabber = 0; 438 d->kbgrabber = 0;
439 } 439 }
440} 440}
441void QPEApplication::showMainWidget( QWidget* wid, bool b) { 441void QPEApplication::showMainWidget( QWidget* wid, bool b) {
442 d->show(wid, b ); 442 d->show(wid, b );
443} 443}
444void QPEApplication::showMainDocumentWidget( QWidget* mw, bool m) { 444void QPEApplication::showMainDocumentWidget( QWidget* mw, bool m) {
445 if ( mw && argc() == 2 ) 445 if ( mw && argc() == 2 )
446 Global::setDocument( mw, QString::fromUtf8(argv()[1] ) ); 446 Global::setDocument( mw, QString::fromUtf8(argv()[1] ) );
447 447
448 d->show(mw, m ); 448 d->show(mw, m );
449} 449}
450void QPEApplication::showDialog( QDialog* d, bool nomax ) { 450void QPEApplication::showDialog( QDialog* d, bool nomax ) {
451 QSize sh = d->sizeHint(); 451 QSize sh = d->sizeHint();
452 int w = QMAX(sh.width(),d->width()); 452 int w = QMAX(sh.width(),d->width());
453 int h = QMAX(sh.height(),d->height()); 453 int h = QMAX(sh.height(),d->height());
454 if ( !nomax 454 if ( !nomax
455 && ( w > qApp->desktop()->width()*3/4 455 && ( w > qApp->desktop()->width()*3/4
456 || h > qApp->desktop()->height()*3/4 ) ) 456 || h > qApp->desktop()->height()*3/4 ) )
457 { 457 {
458 d->showMaximized(); 458 d->showMaximized();
459 } else { 459 } else {
460 d->resize(w,h); 460 d->resize(w,h);
461 d->show(); 461 d->show();
462 } 462 }
463} 463}
464int QPEApplication::execDialog( QDialog* d, bool nomax) { 464int QPEApplication::execDialog( QDialog* d, bool nomax) {
465 showDialog(d,nomax); 465 showDialog(d,nomax);
466 return d->exec(); 466 return d->exec();
467} 467}
468void QPEApplication::setKeepRunning() { 468void QPEApplication::setKeepRunning() {
469 if ( qApp && qApp->inherits( "QPEApplication" ) ) { 469 if ( qApp && qApp->inherits( "QPEApplication" ) ) {
470 QPEApplication * qpeApp = ( QPEApplication* ) qApp; 470 QPEApplication * qpeApp = ( QPEApplication* ) qApp;
471 qpeApp->d->keep_running = TRUE; 471 qpeApp->d->keep_running = TRUE;
472 } 472 }
473} 473}
474bool QPEApplication::keepRunning()const { 474bool QPEApplication::keepRunning()const {
475 return d->keep_running; 475 return d->keep_running;
476} 476}
477bool QPEApplication::keyboardGrabbed()const { 477bool QPEApplication::keyboardGrabbed()const {
478 return d->kbgrabber; 478 return d->kbgrabber;
479} 479}
480int QPEApplication::exec() { 480int QPEApplication::exec() {
481 /* now send the QCOP stuff gotten from the file */ 481 /* now send the QCOP stuff gotten from the file */
482 d->sendQCopQ(); 482 d->sendQCopQ();
483 483
484 if ( d->keep_running ) { 484 if ( d->keep_running ) {
485 qWarning("going to exec"); 485 qWarning("going to exec");
486 int a = QApplication::exec(); 486 int a = QApplication::exec();
487 qWarning("left"); 487 qWarning("left");
488 return a; 488 return a;
489 } 489 }
490 490
491 { 491 {
492 QCopEnvelope e( "QPE/System", "closing(QString)" ); 492 QCopEnvelope e( "QPE/System", "closing(QString)" );
493 e << d->appName; 493 e << d->appName;
494 } 494 }
495 qWarning("processing events!"); 495 qWarning("processing events!");
496 processEvents(); 496 processEvents();
497 return 0; 497 return 0;
498} 498}
499void QPEApplication::internalSetStyle( const QString& ) { 499void QPEApplication::internalSetStyle( const QString& ) {
500 500
501} 501}
502void QPEApplication::systemMessage( const QCString& chan, const QByteArray& ) { 502void QPEApplication::systemMessage( const QCString& chan, const QByteArray& ) {
503 qWarning("QPEApplication::systemMessage( %s )", chan.data() ); 503 qWarning("QPEApplication::systemMessage( %s )", chan.data() );
504} 504}
505void QPEApplication::pidMessage( const QCString& msg, const QByteArray& ) { 505void QPEApplication::pidMessage( const QCString& msg, const QByteArray& ) {
506 if ( msg == "flush()" ) { 506 if ( msg == "flush()" ) {
507 emit flush(); 507 emit flush();
508 QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" ); 508 QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" );
509 e << d->appName; 509 e << d->appName;
510 }else if ( msg == "reload()" ) { 510 }else if ( msg == "reload()" ) {
511 emit reload(); 511 emit reload();
512 } 512 }
513 513
514} 514}
515void QPEApplication::timerEvent( QTimerEvent* e ) { 515void QPEApplication::timerEvent( QTimerEvent* e ) {
516 if ( e->timerId() == d->presstimer && d->presswidget ) { 516 if ( e->timerId() == d->presstimer && d->presswidget ) {
517 // Right pressed 517 // Right pressed
518 postEvent( d->presswidget, 518 postEvent( d->presswidget,
519 new QMouseEvent( QEvent::MouseButtonPress, d->presspos, 519 new QMouseEvent( QEvent::MouseButtonPress, d->presspos,
520 RightButton, LeftButton ) ); 520 RightButton, LeftButton ) );
521 killTimer( d->presstimer ); 521 killTimer( d->presstimer );
522 d->presstimer = 0; 522 d->presstimer = 0;
523 } 523 }
524} 524}
525 525
526// InputMethods Hints 526// InputMethods Hints
527namespace { 527namespace {
528 static QPtrDict<void>* inputMethodDict = 0; 528 static QPtrDict<void>* inputMethodDict = 0;
529 static void createInputMethodDict(){ 529 static void createInputMethodDict(){
530 if ( !inputMethodDict ) 530 if ( !inputMethodDict )
531 inputMethodDict = new QPtrDict<void>; 531 inputMethodDict = new QPtrDict<void>;
532 } 532 }
533 533
534 static QPtrDict<void>* stylusDict = 0; 534 static QPtrDict<void>* stylusDict = 0;
535 static void createDict() { 535 static void createDict() {
536 if ( !stylusDict ) 536 if ( !stylusDict )
537 stylusDict = new QPtrDict<void>; 537 stylusDict = new QPtrDict<void>;
538 } 538 }
539}; 539};
540 540
541void QPEApplication::setInputMethodHint( QWidget* w, InputMethodHint mode ) { 541void QPEApplication::setInputMethodHint( QWidget* w, InputMethodHint mode ) {
542 createInputMethodDict(); 542 createInputMethodDict();
543 if ( mode == Normal ) { 543 if ( mode == Normal ) {
544 inputMethodDict->remove 544 inputMethodDict->remove
545 ( w ); 545 ( w );
546 }else { 546 }else {
547 inputMethodDict->insert( w, ( void* ) mode ); 547 inputMethodDict->insert( w, ( void* ) mode );
548 } 548 }
549} 549}
550QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget* w) { 550QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget* w) {
551 if ( inputMethodDict && w ) 551 if ( inputMethodDict && w )
552 return ( InputMethodHint ) ( int ) inputMethodDict->find( w ); 552 return ( InputMethodHint ) ( int ) inputMethodDict->find( w );
553 return Normal; 553 return Normal;
554} 554}
555 555
556 556
557void QPEApplication::removeSenderFromStylusDict() { 557void QPEApplication::removeSenderFromStylusDict() {
558 stylusDict->remove( ( void* ) sender() ); 558 stylusDict->remove( ( void* ) sender() );
559 if ( d->presswidget == sender() ) 559 if ( d->presswidget == sender() )
560 d->presswidget = 0; 560 d->presswidget = 0;
561} 561}
562void QPEApplication::setStylusOperation( QWidget* w, StylusMode mode) { 562void QPEApplication::setStylusOperation( QWidget* w, StylusMode mode) {
563 createDict(); 563 createDict();
564 if ( mode == LeftOnly ) { 564 if ( mode == LeftOnly ) {
565 stylusDict->remove 565 stylusDict->remove
566 ( w ); 566 ( w );
567 w->removeEventFilter( qApp ); 567 w->removeEventFilter( qApp );
568 }else { 568 }else {
569 stylusDict->insert( w, ( void* ) mode ); 569 stylusDict->insert( w, ( void* ) mode );
570 connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) ); 570 connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) );
571 w->installEventFilter( qApp ); 571 w->installEventFilter( qApp );
572 } 572 }
573} 573}
574QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w) { 574QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w) {
575 if ( stylusDict ) 575 if ( stylusDict )
576 return ( StylusMode ) ( int ) stylusDict->find( w ); 576 return ( StylusMode ) ( int ) stylusDict->find( w );
577 return LeftOnly; 577 return LeftOnly;
578} 578}
579 579
580// eventFilter...... 580// eventFilter......
581bool QPEApplication::eventFilter( QObject* o, QEvent* e ) { 581bool QPEApplication::eventFilter( QObject* o, QEvent* e ) {
582 /* 582 /*
583 * We want our WM to show Ok and a X button 583 * We want our WM to show Ok and a X button
584 * on dialogs 584 * on dialogs
585 * our part is to set the _NET_WM_CONTEXT_ACCEPT 585 * our part is to set the _NET_WM_CONTEXT_ACCEPT
586 * propery 586 * propery
587 * and then wait for a client message -zecke 587 * and then wait for a client message -zecke
588 * on show we will add the prop 588 * on show we will add the prop
589 */ 589 */
590 if (o->inherits("QDialog") && e->type() == QEvent::Show ) { 590 if (o->inherits("QDialog") && e->type() == QEvent::Show ) {
591 QDialog* dialog = (QDialog*)o; 591 QDialog* dialog = (QDialog*)o;
592 Atom wm_prot[45]; 592 Atom wm_prot[45];
593 int n = 0; 593 int n = 0;
594 wm_prot[n++] = d->wm_delete_window; 594 wm_prot[n++] = d->wm_delete_window;
595 wm_prot[n++] = d->wm_take_focus; 595 wm_prot[n++] = d->wm_take_focus;
596 wm_prot[n++] = d->wm_context_accept; 596 wm_prot[n++] = d->wm_context_accept;
597 if ( dialog->testWFlags( WStyle_ContextHelp ) ) 597 if ( dialog->testWFlags( WStyle_ContextHelp ) )
598 wm_prot[n++] = d->wm_context_help; 598 wm_prot[n++] = d->wm_context_help;
599 XSetWMProtocols( qt_xdisplay(), dialog->winId(), wm_prot, n ); 599 XSetWMProtocols( qt_xdisplay(), dialog->winId(), wm_prot, n );
600 return TRUE; // should be save 600 return TRUE; // should be save
601 } 601 }
602 if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) { 602 if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) {
603 QMouseEvent * me = ( QMouseEvent* ) e; 603 QMouseEvent * me = ( QMouseEvent* ) e;
604 StylusMode mode = (StylusMode)(int)stylusDict->find(o); 604 StylusMode mode = (StylusMode)(int)stylusDict->find(o);
605 switch (mode) { 605 switch (mode) {
606 case RightOnHold: 606 case RightOnHold:
607 switch ( me->type() ) { 607 switch ( me->type() ) {
608 case QEvent::MouseButtonPress: 608 case QEvent::MouseButtonPress:
609 if ( me->button() == LeftButton ) { 609 if ( me->button() == LeftButton ) {
610 d->presstimer = startTimer(500); // #### pref. 610 d->presstimer = startTimer(500); // #### pref.
611 d->presswidget = (QWidget*)o; 611 d->presswidget = (QWidget*)o;
612 d->presspos = me->pos(); 612 d->presspos = me->pos();
613 d->rightpressed = FALSE; 613 d->rightpressed = FALSE;
614 } 614 }
615 break; 615 break;
616 case QEvent::MouseMove: 616 case QEvent::MouseMove:
617 if (d->presstimer && (me->pos() - d->presspos).manhattanLength() > 8) { 617 if (d->presstimer && (me->pos() - d->presspos).manhattanLength() > 8) {
618 killTimer(d->presstimer); 618 killTimer(d->presstimer);
619 d->presstimer = 0; 619 d->presstimer = 0;
620 } 620 }
621 break; 621 break;
622 case QEvent::MouseButtonRelease: 622 case QEvent::MouseButtonRelease:
623 if ( me->button() == LeftButton ) { 623 if ( me->button() == LeftButton ) {
624 if ( d->presstimer ) { 624 if ( d->presstimer ) {
625 killTimer(d->presstimer); 625 killTimer(d->presstimer);
626 d->presstimer = 0; 626 d->presstimer = 0;
627 } 627 }
628 if ( d->rightpressed && d->presswidget ) { 628 if ( d->rightpressed && d->presswidget ) {
629 // Right released 629 // Right released
630 postEvent( d->presswidget, 630 postEvent( d->presswidget,
631 new QMouseEvent( QEvent::MouseButtonRelease, me->pos(), 631 new QMouseEvent( QEvent::MouseButtonRelease, me->pos(),
632 RightButton, LeftButton + RightButton ) ); 632 RightButton, LeftButton + RightButton ) );
633 // Left released, off-widget 633 // Left released, off-widget
634 postEvent( d->presswidget, 634 postEvent( d->presswidget,
635 new QMouseEvent( QEvent::MouseMove, QPoint( -1, -1), 635 new QMouseEvent( QEvent::MouseMove, QPoint( -1, -1),
636 LeftButton, LeftButton ) ); 636 LeftButton, LeftButton ) );
637 postEvent( d->presswidget, 637 postEvent( d->presswidget,
638 new QMouseEvent( QEvent::MouseButtonRelease, QPoint( -1, -1), 638 new QMouseEvent( QEvent::MouseButtonRelease, QPoint( -1, -1),
639 LeftButton, LeftButton ) ); 639 LeftButton, LeftButton ) );
640 d->rightpressed = FALSE; 640 d->rightpressed = FALSE;
641 return TRUE; // don't send the real Left release 641 return TRUE; // don't send the real Left release
642 } 642 }
643 } 643 }
644 break; 644 break;
645 default: 645 default:
646 break; 646 break;
647 } 647 }
648 break; 648 break;
649 default: 649 default:
650 ; 650 ;
651 } 651 }
652 } 652 }
653 else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { 653 else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) {
654 QKeyEvent *ke = (QKeyEvent *)e; 654 QKeyEvent *ke = (QKeyEvent *)e;
655 if ( ke->key() == Key_Enter ) { 655 if ( ke->key() == Key_Enter ) {
656 if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) { 656 if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) {
657 postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ', 657 postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ',
658 ke->state(), " ", ke->isAutoRepeat(), ke->count() ) ); 658 ke->state(), " ", ke->isAutoRepeat(), ke->count() ) );
659 return TRUE; 659 return TRUE;
660 } 660 }
661 } 661 }
662 } 662 }
663 return FALSE; 663 return FALSE;
664} 664}
665 665
666// Quit stuff 666// Quit stuff
667void QPEApplication::restart() { 667void QPEApplication::restart() {
668 668
669} 669}
670void QPEApplication::shutdown() { 670void QPEApplication::shutdown() {
671 671
672} 672}
673void QPEApplication::tryQuit() { 673void QPEApplication::tryQuit() {
674 qWarning("TryQuit!!"); 674 qWarning("TryQuit!!");
675 if ( activeModalWidget() || strcmp( argv() [ 0 ], "embeddedkonsole" ) == 0 ) 675 if ( activeModalWidget() || strcmp( argv() [ 0 ], "embeddedkonsole" ) == 0 )
676 return ; // Inside modal loop or konsole. Too hard to save state. 676 return ; // Inside modal loop or konsole. Too hard to save state.
677 { 677 {
678 QCopEnvelope e( "QPE/System", "closing(QString)" ); 678 QCopEnvelope e( "QPE/System", "closing(QString)" );
679 e << d->appName; 679 e << d->appName;
680 } 680 }
681 processEvents(); 681 processEvents();
682 682
683 quit(); 683 quit();
684} 684}
685void QPEApplication::hideOrQuit() { 685void QPEApplication::hideOrQuit() {
686 qWarning("hide or close"); 686 qWarning("hide or close");
687 processEvents(); 687 processEvents();
688 qWarning("past processing"); 688 qWarning("past processing");
689 689
690 // If we are a preloaded application we don't actually quit, so emit 690 // If we are a preloaded application we don't actually quit, so emit
691 // a System message indicating we're quasi-closing. 691 // a System message indicating we're quasi-closing.
692 if ( d->preloaded && d->qpe_main_widget ) 692 if ( d->preloaded && d->qpe_main_widget )
693 693
694 { 694 {
695 qWarning("hiding"); 695 qWarning("hiding");
696 QCopEnvelope e("QPE/System", "fastAppHiding(QString)" ); 696 QCopEnvelope e("QPE/System", "fastAppHiding(QString)" );
697 e << d->appName; 697 e << d->appName;
698 d->qpe_main_widget->hide(); 698 d->qpe_main_widget->hide();
699 } 699 }
700 else 700 else
701 quit(); 701 quit();
702} 702}
703 703
704/*! 704/*!
705 \internal 705 \internal
706*/ 706*/
707void QPEApplication::prepareForTermination( bool willrestart ) 707void QPEApplication::prepareForTermination( bool willrestart )
708{ 708{
709 if ( willrestart ) { 709 if ( willrestart ) {
710 // Draw a big wait icon, the image can be altered in later revisions 710 // Draw a big wait icon, the image can be altered in later revisions
711 // QWidget *d = QApplication::desktop(); 711 // QWidget *d = QApplication::desktop();
712 QImage img = Resource::loadImage( "launcher/new_wait" ); 712 QImage img = Resource::loadImage( "launcher/new_wait" );
713 QPixmap pix; 713 QPixmap pix;
714 pix.convertFromImage( img.smoothScale( 1 * img.width(), 1 * img.height() ) ); 714 pix.convertFromImage( img.smoothScale( 1 * img.width(), 1 * img.height() ) );
715 QLabel *lblWait = new QLabel( 0, "wait hack!", QWidget::WStyle_Customize | 715 QLabel *lblWait = new QLabel( 0, "wait hack!", QWidget::WStyle_Customize |
716 QWidget::WStyle_NoBorder | QWidget::WStyle_Tool ); 716 QWidget::WStyle_NoBorder | QWidget::WStyle_Tool );
717 lblWait->setPixmap( pix ); 717 lblWait->setPixmap( pix );
718 lblWait->setAlignment( QWidget::AlignCenter ); 718 lblWait->setAlignment( QWidget::AlignCenter );
719 lblWait->show(); 719 lblWait->show();
720 lblWait->showMaximized(); 720 lblWait->showMaximized();
721 } 721 }
722#ifndef SINGLE_APP 722#ifndef SINGLE_APP
723 { QCopEnvelope envelope( "QPE/System", "forceQuit()" ); 723 { QCopEnvelope envelope( "QPE/System", "forceQuit()" );
724 } 724 }
725 processEvents(); // ensure the message goes out. 725 processEvents(); // ensure the message goes out.
726 sleep( 1 ); // You have 1 second to comply. 726 sleep( 1 ); // You have 1 second to comply.
727#endif 727#endif
728} 728}
729int QPEApplication::x11ClientMessage(QWidget* w, XEvent* event, bool b ) { 729int QPEApplication::x11ClientMessage(QWidget* w, XEvent* event, bool b ) {
730 qWarning("X11 ClientMessage %d %d", event->type, ClientMessage); 730 qWarning("X11 ClientMessage %d %d", event->type, ClientMessage);
731 if ( event->type == ClientMessage ) { 731 if ( event->type == ClientMessage ) {
732 if ( (event->xclient.message_type == d->wm_protocols) && 732 if ( (event->xclient.message_type == d->wm_protocols) &&
733 (event->xclient.data.l[0] == d->wm_context_accept ) ) { 733 (event->xclient.data.l[0] == d->wm_context_accept ) ) {
734 qWarning("accepted!!!"); 734 qWarning("accepted!!!");
735 /* 735 /*
736 * I'm not sure if we should use activeWidget 736 * I'm not sure if we should use activeWidget
737 * or activeModalWidget 737 * or activeModalWidget
738 * a QDialog could be not modal too 738 * a QDialog could be not modal too
739 */ 739 */
740 if ( w->inherits("QDialog" ) ) { 740 if ( w->inherits("QDialog" ) ) {
741 qWarning("inherits QDialog!!!"); 741 qWarning("inherits QDialog!!!");
742 QDialog* dia = (QDialog*)w; 742 QDialog* dia = (QDialog*)w;
743 /* 743 /*
744 * call it directly or via QTimer::singleShot? 744 * call it directly or via QTimer::singleShot?
745 */ 745 */
746 QTimer::singleShot(0, dia, SLOT(accept() ) ); 746 QTimer::singleShot(0, dia, SLOT(accept() ) );
747 return 0; 747 return 0;
748 } 748 }
749 749
750 } 750 }
751 } 751 }
752 return QApplication::x11ClientMessage(w, event, b ); 752 return QApplication::x11ClientMessage(w, event, b );
753} 753}
754 754
755#define KeyPress XKeyPress 755#define KeyPress XKeyPress
756#define KeyRelease XKeyRelease 756#define KeyRelease XKeyRelease
757 757
758#if defined(QT_QWS_IPAQ) || defined(QT_QWS_SL5XXX) 758#if defined(OPIE_NEW_MALLOC)
759 759
760// The libraries with the skiff package (and possibly others) have 760// The libraries with the skiff package (and possibly others) have
761// completely useless implementations of builtin new and delete that 761// completely useless implementations of builtin new and delete that
762// use about 50% of your CPU. Here we revert to the simple libc 762// use about 50% of your CPU. Here we revert to the simple libc
763// functions. 763// functions.
764 764
765void* operator new[]( size_t size ) 765void* operator new[]( size_t size )
766{ 766{
767 return malloc( size ); 767 return malloc( size );
768} 768}
769 769
770void* operator new( size_t size ) 770void* operator new( size_t size )
771{ 771{
772 return malloc( size ); 772 return malloc( size );
773} 773}
774 774
775void operator delete[]( void* p ) 775void operator delete[]( void* p )
776{ 776{
777 free( p ); 777 free( p );
778} 778}
779 779
780void operator delete[]( void* p, size_t /*size*/ ) 780void operator delete[]( void* p, size_t /*size*/ )
781{ 781{
782 free( p ); 782 free( p );
783} 783}
784 784
785void operator delete( void* p ) 785void operator delete( void* p )
786{ 786{
787 free( p ); 787 free( p );
788} 788}
789 789
790void operator delete( void* p, size_t /*size*/ ) 790void operator delete( void* p, size_t /*size*/ )
791{ 791{
792 free( p ); 792 free( p );
793} 793}
794 794
795#endif 795#endif