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