author | llornkcor <llornkcor> | 2002-09-25 16:26:19 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2002-09-25 16:26:19 (UTC) |
commit | d44c455b86d6cccbc497e3e8d8aa399096eff7db (patch) (unidiff) | |
tree | 8dd582c828f21ff11a99800159df2b982dbfcc48 | |
parent | a546a6ea143da9244a06f1e40829254e8bf4dc8f (diff) | |
download | opie-d44c455b86d6cccbc497e3e8d8aa399096eff7db.zip opie-d44c455b86d6cccbc497e3e8d8aa399096eff7db.tar.gz opie-d44c455b86d6cccbc497e3e8d8aa399096eff7db.tar.bz2 |
fix qpeDir() to return users dir, not qpeDir.. duh
-rw-r--r-- | library/qpeapplication.cpp | 543 |
1 files changed, 272 insertions, 271 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp index c107a08..bdf67b9 100644 --- a/library/qpeapplication.cpp +++ b/library/qpeapplication.cpp | |||
@@ -43,267 +43,267 @@ | |||
43 | #include <qregexp.h> | 43 | #include <qregexp.h> |
44 | #include <qdir.h> | 44 | #include <qdir.h> |
45 | #include <qlabel.h> | 45 | #include <qlabel.h> |
46 | #include <qdialog.h> | 46 | #include <qdialog.h> |
47 | #include <qdragobject.h> | 47 | #include <qdragobject.h> |
48 | #include <qtextcodec.h> | 48 | #include <qtextcodec.h> |
49 | #include <qevent.h> | 49 | #include <qevent.h> |
50 | #include <qtooltip.h> | 50 | #include <qtooltip.h> |
51 | #include <qsignal.h> | 51 | #include <qsignal.h> |
52 | #include "qpeapplication.h" | 52 | #include "qpeapplication.h" |
53 | #include "qpestyle.h" | 53 | #include "qpestyle.h" |
54 | #include "styleinterface.h" | 54 | #include "styleinterface.h" |
55 | #if QT_VERSION >= 300 | 55 | #if QT_VERSION >= 300 |
56 | #include <qstylefactory.h> | 56 | #include <qstylefactory.h> |
57 | #else | 57 | #else |
58 | #include <qplatinumstyle.h> | 58 | #include <qplatinumstyle.h> |
59 | #include <qwindowsstyle.h> | 59 | #include <qwindowsstyle.h> |
60 | #include <qmotifstyle.h> | 60 | #include <qmotifstyle.h> |
61 | #include <qmotifplusstyle.h> | 61 | #include <qmotifplusstyle.h> |
62 | #include "lightstyle.h" | 62 | #include "lightstyle.h" |
63 | 63 | ||
64 | #include <qpe/qlibrary.h> | 64 | #include <qpe/qlibrary.h> |
65 | #endif | 65 | #endif |
66 | #include "global.h" | 66 | #include "global.h" |
67 | #include "resource.h" | 67 | #include "resource.h" |
68 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) | 68 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) |
69 | #include "qutfcodec.h" | 69 | #include "qutfcodec.h" |
70 | #endif | 70 | #endif |
71 | #include "config.h" | 71 | #include "config.h" |
72 | #include "network.h" | 72 | #include "network.h" |
73 | #ifdef QWS | 73 | #ifdef QWS |
74 | #include "fontmanager.h" | 74 | #include "fontmanager.h" |
75 | #endif | 75 | #endif |
76 | 76 | ||
77 | #include "alarmserver.h" | 77 | #include "alarmserver.h" |
78 | #include "applnk.h" | 78 | #include "applnk.h" |
79 | #include "qpemenubar.h" | 79 | #include "qpemenubar.h" |
80 | #include "textcodecinterface.h" | 80 | #include "textcodecinterface.h" |
81 | #include "imagecodecinterface.h" | 81 | #include "imagecodecinterface.h" |
82 | 82 | ||
83 | #include <unistd.h> | 83 | #include <unistd.h> |
84 | #include <sys/file.h> | 84 | #include <sys/file.h> |
85 | #include <sys/ioctl.h> | 85 | #include <sys/ioctl.h> |
86 | #include <sys/soundcard.h> | 86 | #include <sys/soundcard.h> |
87 | 87 | ||
88 | 88 | ||
89 | class QPEApplicationData { | 89 | class QPEApplicationData { |
90 | public: | 90 | public: |
91 | QPEApplicationData() : presstimer( 0 ), presswidget( 0 ), rightpressed( FALSE ), | 91 | QPEApplicationData() : presstimer( 0 ), presswidget( 0 ), rightpressed( FALSE ), |
92 | kbgrabber( 0 ), kbregrab( FALSE ), notbusysent( FALSE ), preloaded( FALSE ), | 92 | kbgrabber( 0 ), kbregrab( FALSE ), notbusysent( FALSE ), preloaded( FALSE ), |
93 | forceshow( FALSE ), nomaximize( FALSE ), qpe_main_widget( 0 ), | 93 | forceshow( FALSE ), nomaximize( FALSE ), qpe_main_widget( 0 ), |
94 | keep_running( TRUE ) | 94 | keep_running( TRUE ) |
95 | { | 95 | { |
96 | qcopq.setAutoDelete( TRUE ); | 96 | qcopq.setAutoDelete( TRUE ); |
97 | } | 97 | } |
98 | 98 | ||
99 | int presstimer; | 99 | int presstimer; |
100 | QWidget* presswidget; | 100 | QWidget* presswidget; |
101 | QPoint presspos; | 101 | QPoint presspos; |
102 | bool rightpressed : 1; // AEH why not use uint foobar :1; if it's tt style -zecke | 102 | bool rightpressed : 1; // AEH why not use uint foobar :1; if it's tt style -zecke |
103 | int kbgrabber; | 103 | int kbgrabber; |
104 | bool kbregrab : 1; | 104 | bool kbregrab : 1; |
105 | bool notbusysent : 1; | 105 | bool notbusysent : 1; |
106 | QString appName; | 106 | QString appName; |
107 | struct QCopRec { | 107 | struct QCopRec { |
108 | QCopRec( const QCString &ch, const QCString &msg, | 108 | QCopRec( const QCString &ch, const QCString &msg, |
109 | const QByteArray &d ) : | 109 | const QByteArray &d ) : |
110 | channel( ch ), message( msg ), data( d ) { } | 110 | channel( ch ), message( msg ), data( d ) { } |
111 | 111 | ||
112 | QCString channel; | 112 | QCString channel; |
113 | QCString message; | 113 | QCString message; |
114 | QByteArray data; | 114 | QByteArray data; |
115 | }; | 115 | }; |
116 | bool preloaded : 1; | 116 | bool preloaded : 1; |
117 | bool forceshow : 1; | 117 | bool forceshow : 1; |
118 | bool nomaximize : 1; | 118 | bool nomaximize : 1; |
119 | QWidget* qpe_main_widget; | 119 | QWidget* qpe_main_widget; |
120 | bool keep_running : 1; | 120 | bool keep_running : 1; |
121 | QList<QCopRec> qcopq; | 121 | QList<QCopRec> qcopq; |
122 | 122 | ||
123 | void enqueueQCop( const QCString &ch, const QCString &msg, | 123 | void enqueueQCop( const QCString &ch, const QCString &msg, |
124 | const QByteArray &data ) | 124 | const QByteArray &data ) |
125 | { | 125 | { |
126 | qcopq.append( new QCopRec( ch, msg, data ) ); | 126 | qcopq.append( new QCopRec( ch, msg, data ) ); |
127 | } | 127 | } |
128 | void sendQCopQ() { | 128 | void sendQCopQ() { |
129 | QCopRec * r; | 129 | QCopRec * r; |
130 | #ifndef QT_NO_COP | 130 | #ifndef QT_NO_COP |
131 | for ( QListIterator<QCopRec> it( qcopq ); ( r = it.current() ); ++it ) | 131 | for ( QListIterator<QCopRec> it( qcopq ); ( r = it.current() ); ++it ) |
132 | QCopChannel::sendLocally( r->channel, r->message, r->data ); | 132 | QCopChannel::sendLocally( r->channel, r->message, r->data ); |
133 | #endif | 133 | #endif |
134 | qcopq.clear(); | 134 | qcopq.clear(); |
135 | } | 135 | } |
136 | static void show_mx(QWidget* mw, bool nomaximize) { | 136 | static void show_mx(QWidget* mw, bool nomaximize) { |
137 | if ( mw->layout() && mw->inherits("QDialog") ) { | 137 | if ( mw->layout() && mw->inherits("QDialog") ) { |
138 | QPEApplication::showDialog((QDialog*)mw,nomaximize); | 138 | QPEApplication::showDialog((QDialog*)mw,nomaximize); |
139 | } else { | 139 | } else { |
140 | #ifdef Q_WS_QWS | 140 | #ifdef Q_WS_QWS |
141 | if ( !nomaximize ) | 141 | if ( !nomaximize ) |
142 | mw->showMaximized(); | 142 | mw->showMaximized(); |
143 | else | 143 | else |
144 | #endif | 144 | #endif |
145 | mw->show(); | 145 | mw->show(); |
146 | } | 146 | } |
147 | } | 147 | } |
148 | static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) | 148 | static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) |
149 | { | 149 | { |
150 | /* | 150 | /* |
151 | // This works but disable it for now until it is safe to apply | 151 | // This works but disable it for now until it is safe to apply |
152 | // What is does is scan the .desktop files of all the apps for | 152 | // What is does is scan the .desktop files of all the apps for |
153 | // the applnk that has the corresponding argv[0] as this program | 153 | // the applnk that has the corresponding argv[0] as this program |
154 | // then it uses the name stored in the .desktop file as the caption | 154 | // then it uses the name stored in the .desktop file as the caption |
155 | // for the main widget. This saves duplicating translations for | 155 | // for the main widget. This saves duplicating translations for |
156 | // the app name in the program and in the .desktop files. | 156 | // the app name in the program and in the .desktop files. |
157 | 157 | ||
158 | AppLnkSet apps( appsPath ); | 158 | AppLnkSet apps( appsPath ); |
159 | 159 | ||
160 | QList<AppLnk> appsList = apps.children(); | 160 | QList<AppLnk> appsList = apps.children(); |
161 | for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { | 161 | for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { |
162 | if ( (*it)->exec() == appName ) { | 162 | if ( (*it)->exec() == appName ) { |
163 | mw->setCaption( (*it)->name() ); | 163 | mw->setCaption( (*it)->name() ); |
164 | return TRUE; | 164 | return TRUE; |
165 | } | 165 | } |
166 | } | 166 | } |
167 | */ | 167 | */ |
168 | return FALSE; | 168 | return FALSE; |
169 | } | 169 | } |
170 | 170 | ||
171 | 171 | ||
172 | void show(QWidget* mw, bool nomax) | 172 | void show(QWidget* mw, bool nomax) |
173 | { | 173 | { |
174 | setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" ); | 174 | setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" ); |
175 | nomaximize = nomax; | 175 | nomaximize = nomax; |
176 | qpe_main_widget = mw; | 176 | qpe_main_widget = mw; |
177 | #ifndef QT_NO_COP | 177 | #ifndef QT_NO_COP |
178 | sendQCopQ(); | 178 | sendQCopQ(); |
179 | #endif | 179 | #endif |
180 | if ( preloaded ) { | 180 | if ( preloaded ) { |
181 | if(forceshow) | 181 | if(forceshow) |
182 | show_mx(mw,nomax); | 182 | show_mx(mw,nomax); |
183 | } else if ( keep_running ) { | 183 | } else if ( keep_running ) { |
184 | show_mx(mw,nomax); | 184 | show_mx(mw,nomax); |
185 | } | 185 | } |
186 | } | 186 | } |
187 | 187 | ||
188 | void loadTextCodecs() | 188 | void loadTextCodecs() |
189 | { | 189 | { |
190 | QString path = QPEApplication::qpeDir() + "/plugins/textcodecs"; | 190 | QString path = QPEApplication::qpeDir() + "/plugins/textcodecs"; |
191 | QDir dir( path, "lib*.so" ); | 191 | QDir dir( path, "lib*.so" ); |
192 | QStringList list = dir.entryList(); | 192 | QStringList list = dir.entryList(); |
193 | QStringList::Iterator it; | 193 | QStringList::Iterator it; |
194 | for ( it = list.begin(); it != list.end(); ++it ) { | 194 | for ( it = list.begin(); it != list.end(); ++it ) { |
195 | TextCodecInterface *iface = 0; | 195 | TextCodecInterface *iface = 0; |
196 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 196 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
197 | if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { | 197 | if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { |
198 | QValueList<int> mibs = iface->mibEnums(); | 198 | QValueList<int> mibs = iface->mibEnums(); |
199 | for (QValueList<int>::ConstIterator i=mibs.begin(); i!=mibs.end(); ++i) { | 199 | for (QValueList<int>::ConstIterator i=mibs.begin(); i!=mibs.end(); ++i) { |
200 | (void)iface->createForMib(*i); | 200 | (void)iface->createForMib(*i); |
201 | // ### it exists now; need to remember if we can delete it | 201 | // ### it exists now; need to remember if we can delete it |
202 | } | 202 | } |
203 | } else { | 203 | } else { |
204 | lib->unload(); | 204 | lib->unload(); |
205 | delete lib; | 205 | delete lib; |
206 | } | 206 | } |
207 | } | 207 | } |
208 | } | 208 | } |
209 | 209 | ||
210 | void loadImageCodecs() | 210 | void loadImageCodecs() |
211 | { | 211 | { |
212 | QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs"; | 212 | QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs"; |
213 | QDir dir( path, "lib*.so" ); | 213 | QDir dir( path, "lib*.so" ); |
214 | QStringList list = dir.entryList(); | 214 | QStringList list = dir.entryList(); |
215 | QStringList::Iterator it; | 215 | QStringList::Iterator it; |
216 | for ( it = list.begin(); it != list.end(); ++it ) { | 216 | for ( it = list.begin(); it != list.end(); ++it ) { |
217 | ImageCodecInterface *iface = 0; | 217 | ImageCodecInterface *iface = 0; |
218 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 218 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
219 | if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { | 219 | if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { |
220 | QStringList formats = iface->keys(); | 220 | QStringList formats = iface->keys(); |
221 | for (QStringList::ConstIterator i=formats.begin(); i!=formats.end(); ++i) { | 221 | for (QStringList::ConstIterator i=formats.begin(); i!=formats.end(); ++i) { |
222 | (void)iface->installIOHandler(*i); | 222 | (void)iface->installIOHandler(*i); |
223 | // ### it exists now; need to remember if we can delete it | 223 | // ### it exists now; need to remember if we can delete it |
224 | } | 224 | } |
225 | } else { | 225 | } else { |
226 | lib->unload(); | 226 | lib->unload(); |
227 | delete lib; | 227 | delete lib; |
228 | } | 228 | } |
229 | } | 229 | } |
230 | } | 230 | } |
231 | QString styleName; | 231 | QString styleName; |
232 | QString decorationName; | 232 | QString decorationName; |
233 | }; | 233 | }; |
234 | 234 | ||
235 | class ResourceMimeFactory : public QMimeSourceFactory { | 235 | class ResourceMimeFactory : public QMimeSourceFactory { |
236 | public: | 236 | public: |
237 | ResourceMimeFactory() | 237 | ResourceMimeFactory() |
238 | { | 238 | { |
239 | setFilePath( Global::helpPath() ); | 239 | setFilePath( Global::helpPath() ); |
240 | setExtensionType( "html", "text/html;charset=UTF-8" ); | 240 | setExtensionType( "html", "text/html;charset=UTF-8" ); |
241 | } | 241 | } |
242 | 242 | ||
243 | const QMimeSource* data( const QString& abs_name ) const | 243 | const QMimeSource* data( const QString& abs_name ) const |
244 | { | 244 | { |
245 | const QMimeSource * r = QMimeSourceFactory::data( abs_name ); | 245 | const QMimeSource * r = QMimeSourceFactory::data( abs_name ); |
246 | if ( !r ) { | 246 | if ( !r ) { |
247 | int sl = abs_name.length(); | 247 | int sl = abs_name.length(); |
248 | do { | 248 | do { |
249 | sl = abs_name.findRev( '/', sl - 1 ); | 249 | sl = abs_name.findRev( '/', sl - 1 ); |
250 | QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; | 250 | QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; |
251 | int dot = name.findRev( '.' ); | 251 | int dot = name.findRev( '.' ); |
252 | if ( dot >= 0 ) | 252 | if ( dot >= 0 ) |
253 | name = name.left( dot ); | 253 | name = name.left( dot ); |
254 | QImage img = Resource::loadImage( name ); | 254 | QImage img = Resource::loadImage( name ); |
255 | if ( !img.isNull() ) | 255 | if ( !img.isNull() ) |
256 | r = new QImageDrag( img ); | 256 | r = new QImageDrag( img ); |
257 | } | 257 | } |
258 | while ( !r && sl > 0 ); | 258 | while ( !r && sl > 0 ); |
259 | } | 259 | } |
260 | return r; | 260 | return r; |
261 | } | 261 | } |
262 | }; | 262 | }; |
263 | 263 | ||
264 | static int muted = 0; | 264 | static int muted = 0; |
265 | static int micMuted = 0; | 265 | static int micMuted = 0; |
266 | 266 | ||
267 | static void setVolume( int t = 0, int percent = -1 ) | 267 | static void setVolume( int t = 0, int percent = -1 ) |
268 | { | 268 | { |
269 | switch ( t ) { | 269 | switch ( t ) { |
270 | case 0: { | 270 | case 0: { |
271 | Config cfg( "qpe" ); | 271 | Config cfg( "qpe" ); |
272 | cfg.setGroup( "Volume" ); | 272 | cfg.setGroup( "Volume" ); |
273 | if ( percent < 0 ) | 273 | if ( percent < 0 ) |
274 | percent = cfg.readNumEntry( "VolumePercent", 50 ); | 274 | percent = cfg.readNumEntry( "VolumePercent", 50 ); |
275 | int fd = 0; | 275 | int fd = 0; |
276 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 276 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
277 | int vol = muted ? 0 : percent; | 277 | int vol = muted ? 0 : percent; |
278 | // set both channels to same volume | 278 | // set both channels to same volume |
279 | vol |= vol << 8; | 279 | vol |= vol << 8; |
280 | ioctl( fd, MIXER_WRITE( 0 ), &vol ); | 280 | ioctl( fd, MIXER_WRITE( 0 ), &vol ); |
281 | ::close( fd ); | 281 | ::close( fd ); |
282 | } | 282 | } |
283 | } | 283 | } |
284 | break; | 284 | break; |
285 | } | 285 | } |
286 | } | 286 | } |
287 | 287 | ||
288 | static void setMic( int t = 0, int percent = -1 ) | 288 | static void setMic( int t = 0, int percent = -1 ) |
289 | { | 289 | { |
290 | switch ( t ) { | 290 | switch ( t ) { |
291 | case 0: { | 291 | case 0: { |
292 | Config cfg( "qpe" ); | 292 | Config cfg( "qpe" ); |
293 | cfg.setGroup( "Volume" ); | 293 | cfg.setGroup( "Volume" ); |
294 | if ( percent < 0 ) | 294 | if ( percent < 0 ) |
295 | percent = cfg.readNumEntry( "Mic", 50 ); | 295 | percent = cfg.readNumEntry( "Mic", 50 ); |
296 | 296 | ||
297 | int fd = 0; | 297 | int fd = 0; |
298 | int mic = micMuted ? 0 : percent; | 298 | int mic = micMuted ? 0 : percent; |
299 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 299 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
300 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic ); | 300 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic ); |
301 | ::close( fd ); | 301 | ::close( fd ); |
302 | } | 302 | } |
303 | } | 303 | } |
304 | break; | 304 | break; |
305 | } | 305 | } |
306 | } | 306 | } |
307 | 307 | ||
308 | 308 | ||
309 | /*! | 309 | /*! |
@@ -475,127 +475,127 @@ QPEApplication::QPEApplication( int & argc, char **argv, Type t ) | |||
475 | sysChannel = new QCopChannel( "QPE/System", this ); | 475 | sysChannel = new QCopChannel( "QPE/System", this ); |
476 | connect( sysChannel, SIGNAL( received( const QCString &, const QByteArray & ) ), | 476 | connect( sysChannel, SIGNAL( received( const QCString &, const QByteArray & ) ), |
477 | this, SLOT( systemMessage( const QCString &, const QByteArray & ) ) ); | 477 | this, SLOT( systemMessage( const QCString &, const QByteArray & ) ) ); |
478 | 478 | ||
479 | QCString channel = QCString( argv[ 0 ] ); | 479 | QCString channel = QCString( argv[ 0 ] ); |
480 | channel.replace( QRegExp( ".*/" ), "" ); | 480 | channel.replace( QRegExp( ".*/" ), "" ); |
481 | d->appName = channel; | 481 | d->appName = channel; |
482 | channel = "QPE/Application/" + channel; | 482 | channel = "QPE/Application/" + channel; |
483 | pidChannel = new QCopChannel( channel, this ); | 483 | pidChannel = new QCopChannel( channel, this ); |
484 | connect( pidChannel, SIGNAL( received( const QCString &, const QByteArray & ) ), | 484 | connect( pidChannel, SIGNAL( received( const QCString &, const QByteArray & ) ), |
485 | this, SLOT( pidMessage( const QCString &, const QByteArray & ) ) ); | 485 | this, SLOT( pidMessage( const QCString &, const QByteArray & ) ) ); |
486 | 486 | ||
487 | if ( f.isOpen() ) { | 487 | if ( f.isOpen() ) { |
488 | d->keep_running = FALSE; | 488 | d->keep_running = FALSE; |
489 | QDataStream ds( &f ); | 489 | QDataStream ds( &f ); |
490 | QCString channel, message; | 490 | QCString channel, message; |
491 | QByteArray data; | 491 | QByteArray data; |
492 | while ( !ds.atEnd() ) { | 492 | while ( !ds.atEnd() ) { |
493 | ds >> channel >> message >> data; | 493 | ds >> channel >> message >> data; |
494 | d->enqueueQCop( channel, message, data ); | 494 | d->enqueueQCop( channel, message, data ); |
495 | } | 495 | } |
496 | 496 | ||
497 | flock( f.handle(), LOCK_UN ); | 497 | flock( f.handle(), LOCK_UN ); |
498 | f.close(); | 498 | f.close(); |
499 | f.remove(); | 499 | f.remove(); |
500 | } | 500 | } |
501 | 501 | ||
502 | for ( int a = 0; a < argc; a++ ) { | 502 | for ( int a = 0; a < argc; a++ ) { |
503 | if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) { | 503 | if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) { |
504 | argv[ a ] = argv[ a + 1 ]; | 504 | argv[ a ] = argv[ a + 1 ]; |
505 | a++; | 505 | a++; |
506 | d->preloaded = TRUE; | 506 | d->preloaded = TRUE; |
507 | argc -= 1; | 507 | argc -= 1; |
508 | } | 508 | } |
509 | else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) { | 509 | else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) { |
510 | argv[ a ] = argv[ a + 1 ]; | 510 | argv[ a ] = argv[ a + 1 ]; |
511 | a++; | 511 | a++; |
512 | d->preloaded = TRUE; | 512 | d->preloaded = TRUE; |
513 | d->forceshow = TRUE; | 513 | d->forceshow = TRUE; |
514 | argc -= 1; | 514 | argc -= 1; |
515 | } | 515 | } |
516 | } | 516 | } |
517 | 517 | ||
518 | /* overide stored arguments */ | 518 | /* overide stored arguments */ |
519 | setArgs( argc, argv ); | 519 | setArgs( argc, argv ); |
520 | 520 | ||
521 | #endif | 521 | #endif |
522 | 522 | ||
523 | //qwsSetDecoration( new QPEDecoration() ); | 523 | // qwsSetDecoration( new QPEDecoration() ); |
524 | 524 | ||
525 | #ifndef QT_NO_TRANSLATION | 525 | #ifndef QT_NO_TRANSLATION |
526 | 526 | ||
527 | QStringList langs = Global::languageList(); | 527 | QStringList langs = Global::languageList(); |
528 | for ( QStringList::ConstIterator it = langs.begin(); it != langs.end(); ++it ) { | 528 | for ( QStringList::ConstIterator it = langs.begin(); it != langs.end(); ++it ) { |
529 | QString lang = *it; | 529 | QString lang = *it; |
530 | 530 | ||
531 | QTranslator * trans; | 531 | QTranslator * trans; |
532 | QString tfn; | 532 | QString tfn; |
533 | 533 | ||
534 | trans = new QTranslator( this ); | 534 | trans = new QTranslator( this ); |
535 | tfn = qpeDir() + "/i18n/" + lang + "/libqpe.qm"; | 535 | tfn = qpeDir() + "/i18n/" + lang + "/libqpe.qm"; |
536 | if ( trans->load( tfn ) ) | 536 | if ( trans->load( tfn ) ) |
537 | installTranslator( trans ); | 537 | installTranslator( trans ); |
538 | else | 538 | else |
539 | delete trans; | 539 | delete trans; |
540 | 540 | ||
541 | trans = new QTranslator( this ); | 541 | trans = new QTranslator( this ); |
542 | tfn = qpeDir() + "/i18n/" + lang + "/" + d->appName + ".qm"; | 542 | tfn = qpeDir() + "/i18n/" + lang + "/" + d->appName + ".qm"; |
543 | if ( trans->load( tfn ) ) | 543 | if ( trans->load( tfn ) ) |
544 | installTranslator( trans ); | 544 | installTranslator( trans ); |
545 | else | 545 | else |
546 | delete trans; | 546 | delete trans; |
547 | 547 | ||
548 | //###language/font hack; should look it up somewhere | 548 | //###language/font hack; should look it up somewhere |
549 | #ifdef QWS | 549 | #ifdef QWS |
550 | if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) { | 550 | if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) { |
551 | QFont fn = FontManager::unicodeFont( FontManager::Proportional ); | 551 | QFont fn = FontManager::unicodeFont( FontManager::Proportional ); |
552 | setFont( fn ); | 552 | setFont( fn ); |
553 | } | 553 | } |
554 | #endif | 554 | #endif |
555 | } | 555 | } |
556 | #endif | 556 | #endif |
557 | 557 | ||
558 | applyStyle(); | 558 | applyStyle(); |
559 | 559 | ||
560 | if ( type() == GuiServer ) { | 560 | if ( type() == GuiServer ) { |
561 | setVolume(); | 561 | setVolume(); |
562 | } | 562 | } |
563 | 563 | ||
564 | installEventFilter( this ); | 564 | installEventFilter( this ); |
565 | 565 | ||
566 | QPEMenuToolFocusManager::initialize(); | 566 | QPEMenuToolFocusManager::initialize(); |
567 | 567 | ||
568 | #ifdef QT_NO_QWS_CURSOR | 568 | #ifdef QT_NO_QWS_CURSOR |
569 | // if we have no cursor, probably don't want tooltips | 569 | // if we have no cursor, probably don't want tooltips |
570 | QToolTip::setEnabled( FALSE ); | 570 | QToolTip::setEnabled( FALSE ); |
571 | #endif | 571 | #endif |
572 | } | 572 | } |
573 | 573 | ||
574 | static QPtrDict<void>* inputMethodDict = 0; | 574 | static QPtrDict<void>* inputMethodDict = 0; |
575 | static void createInputMethodDict() | 575 | static void createInputMethodDict() |
576 | { | 576 | { |
577 | if ( !inputMethodDict ) | 577 | if ( !inputMethodDict ) |
578 | inputMethodDict = new QPtrDict<void>; | 578 | inputMethodDict = new QPtrDict<void>; |
579 | } | 579 | } |
580 | 580 | ||
581 | /*! | 581 | /*! |
582 | Returns the currently set hint to the system as to whether | 582 | Returns the currently set hint to the system as to whether |
583 | widget \a w has any use for text input methods. | 583 | widget \a w has any use for text input methods. |
584 | 584 | ||
585 | 585 | ||
586 | \sa setInputMethodHint() InputMethodHint | 586 | \sa setInputMethodHint() InputMethodHint |
587 | */ | 587 | */ |
588 | QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w ) | 588 | QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w ) |
589 | { | 589 | { |
590 | if ( inputMethodDict && w ) | 590 | if ( inputMethodDict && w ) |
591 | return ( InputMethodHint ) ( int ) inputMethodDict->find( w ); | 591 | return ( InputMethodHint ) ( int ) inputMethodDict->find( w ); |
592 | return Normal; | 592 | return Normal; |
593 | } | 593 | } |
594 | 594 | ||
595 | /*! | 595 | /*! |
596 | \enum QPEApplication::InputMethodHint | 596 | \enum QPEApplication::InputMethodHint |
597 | 597 | ||
598 | \value Normal the application sometimes needs text input (the default). | 598 | \value Normal the application sometimes needs text input (the default). |
599 | \value AlwaysOff the application never needs text input. | 599 | \value AlwaysOff the application never needs text input. |
600 | \value AlwaysOn the application always needs text input. | 600 | \value AlwaysOn the application always needs text input. |
601 | */ | 601 | */ |
@@ -759,177 +759,178 @@ bool QPEApplication::qwsEventFilter( QWSEvent * e ) | |||
759 | } | 759 | } |
760 | if ( d->kbregrab ) { | 760 | if ( d->kbregrab ) { |
761 | grabKeyboard(); | 761 | grabKeyboard(); |
762 | d->kbregrab = FALSE; | 762 | d->kbregrab = FALSE; |
763 | } | 763 | } |
764 | } | 764 | } |
765 | if ( fe->simpleData.get_focus && inputMethodDict ) { | 765 | if ( fe->simpleData.get_focus && inputMethodDict ) { |
766 | InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) ); | 766 | InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) ); |
767 | if ( m == AlwaysOff ) | 767 | if ( m == AlwaysOff ) |
768 | Global::hideInputMethod(); | 768 | Global::hideInputMethod(); |
769 | if ( m == AlwaysOn ) | 769 | if ( m == AlwaysOn ) |
770 | Global::showInputMethod(); | 770 | Global::showInputMethod(); |
771 | } | 771 | } |
772 | } | 772 | } |
773 | return QApplication::qwsEventFilter( e ); | 773 | return QApplication::qwsEventFilter( e ); |
774 | } | 774 | } |
775 | #endif | 775 | #endif |
776 | 776 | ||
777 | /*! | 777 | /*! |
778 | Destroys the QPEApplication. | 778 | Destroys the QPEApplication. |
779 | */ | 779 | */ |
780 | QPEApplication::~QPEApplication() | 780 | QPEApplication::~QPEApplication() |
781 | { | 781 | { |
782 | ungrabKeyboard(); | 782 | ungrabKeyboard(); |
783 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 783 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
784 | // Need to delete QCopChannels early, since the display will | 784 | // Need to delete QCopChannels early, since the display will |
785 | // be gone by the time we get to ~QObject(). | 785 | // be gone by the time we get to ~QObject(). |
786 | delete sysChannel; | 786 | delete sysChannel; |
787 | delete pidChannel; | 787 | delete pidChannel; |
788 | #endif | 788 | #endif |
789 | 789 | ||
790 | delete d; | 790 | delete d; |
791 | } | 791 | } |
792 | 792 | ||
793 | /*! | 793 | /*! |
794 | Returns <tt>$OPIEDIR/</tt>. | 794 | Returns <tt>$OPIEDIR/</tt>. |
795 | */ | 795 | */ |
796 | QString QPEApplication::qpeDir() | 796 | QString QPEApplication::qpeDir() |
797 | { | 797 | { |
798 | const char * base = getenv( "OPIEDIR" ); | 798 | const char * base = getenv( "OPIEDIR" ); |
799 | if ( base ) | 799 | if ( base ) |
800 | return QString( base ) + "/"; | 800 | return QString( base ) + "/"; |
801 | 801 | ||
802 | return QString( "../" ); | 802 | return QString( "../" ); |
803 | } | 803 | } |
804 | 804 | ||
805 | /*! | 805 | /*! |
806 | Returns the user's current Document directory. There is a trailing "/". | 806 | Returns the user's current Document directory. There is a trailing "/". |
807 | .. well, it does now,, and there's no trailing '/' | ||
807 | */ | 808 | */ |
808 | QString QPEApplication::documentDir() | 809 | QString QPEApplication::documentDir() |
809 | { | 810 | { |
810 | return QString( qpeDir() + "Documents"); | 811 | return QString( QDir::homeDirPath() + "/Documents"); |
811 | } | 812 | } |
812 | 813 | ||
813 | static int deforient = -1; | 814 | static int deforient = -1; |
814 | 815 | ||
815 | /*! | 816 | /*! |
816 | \internal | 817 | \internal |
817 | */ | 818 | */ |
818 | int QPEApplication::defaultRotation() | 819 | int QPEApplication::defaultRotation() |
819 | { | 820 | { |
820 | if ( deforient < 0 ) { | 821 | if ( deforient < 0 ) { |
821 | QString d = getenv( "QWS_DISPLAY" ); | 822 | QString d = getenv( "QWS_DISPLAY" ); |
822 | if ( d.contains( "Rot90" ) ) { | 823 | if ( d.contains( "Rot90" ) ) { |
823 | deforient = 90; | 824 | deforient = 90; |
824 | } | 825 | } |
825 | else if ( d.contains( "Rot180" ) ) { | 826 | else if ( d.contains( "Rot180" ) ) { |
826 | deforient = 180; | 827 | deforient = 180; |
827 | } | 828 | } |
828 | else if ( d.contains( "Rot270" ) ) { | 829 | else if ( d.contains( "Rot270" ) ) { |
829 | deforient = 270; | 830 | deforient = 270; |
830 | } | 831 | } |
831 | else { | 832 | else { |
832 | deforient = 0; | 833 | deforient = 0; |
833 | } | 834 | } |
834 | } | 835 | } |
835 | return deforient; | 836 | return deforient; |
836 | } | 837 | } |
837 | 838 | ||
838 | /*! | 839 | /*! |
839 | \internal | 840 | \internal |
840 | */ | 841 | */ |
841 | void QPEApplication::setDefaultRotation( int r ) | 842 | void QPEApplication::setDefaultRotation( int r ) |
842 | { | 843 | { |
843 | if ( qApp->type() == GuiServer ) { | 844 | if ( qApp->type() == GuiServer ) { |
844 | deforient = r; | 845 | deforient = r; |
845 | setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 ); | 846 | setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 ); |
846 | Config config("qpe"); | 847 | Config config("qpe"); |
847 | config.setGroup( "Rotation" ); | 848 | config.setGroup( "Rotation" ); |
848 | config.writeEntry( "Screen", getenv("QWS_DISPLAY") ); | 849 | config.writeEntry( "Screen", getenv("QWS_DISPLAY") ); |
849 | } else { | 850 | } else { |
850 | #ifndef QT_NO_COP | 851 | #ifndef QT_NO_COP |
851 | { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" ); e << r; } | 852 | { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" ); e << r; } |
852 | #endif | 853 | #endif |
853 | } | 854 | } |
854 | } | 855 | } |
855 | 856 | ||
856 | /*! | 857 | /*! |
857 | \internal | 858 | \internal |
858 | */ | 859 | */ |
859 | void QPEApplication::applyStyle() | 860 | void QPEApplication::applyStyle() |
860 | { | 861 | { |
861 | Config config( "qpe" ); | 862 | Config config( "qpe" ); |
862 | 863 | ||
863 | config.setGroup( "Appearance" ); | 864 | config.setGroup( "Appearance" ); |
864 | 865 | ||
865 | // Widget style | 866 | // Widget style |
866 | QString style = config.readEntry( "Style", "Light" ); | 867 | QString style = config.readEntry( "Style", "Light" ); |
867 | internalSetStyle( style ); | 868 | internalSetStyle( style ); |
868 | 869 | ||
869 | // Colors | 870 | // Colors |
870 | QColor bgcolor( config.readEntry( "Background", "#E5E1D5" ) ); | 871 | QColor bgcolor( config.readEntry( "Background", "#E5E1D5" ) ); |
871 | QColor btncolor( config.readEntry( "Button", "#D6CDBB" ) ); | 872 | QColor btncolor( config.readEntry( "Button", "#D6CDBB" ) ); |
872 | QPalette pal( btncolor, bgcolor ); | 873 | QPalette pal( btncolor, bgcolor ); |
873 | QString color = config.readEntry( "Highlight", "#800000" ); | 874 | QString color = config.readEntry( "Highlight", "#800000" ); |
874 | pal.setColor( QColorGroup::Highlight, QColor( color ) ); | 875 | pal.setColor( QColorGroup::Highlight, QColor( color ) ); |
875 | color = config.readEntry( "HighlightedText", "#FFFFFF" ); | 876 | color = config.readEntry( "HighlightedText", "#FFFFFF" ); |
876 | pal.setColor( QColorGroup::HighlightedText, QColor( color ) ); | 877 | pal.setColor( QColorGroup::HighlightedText, QColor( color ) ); |
877 | color = config.readEntry( "Text", "#000000" ); | 878 | color = config.readEntry( "Text", "#000000" ); |
878 | pal.setColor( QColorGroup::Text, QColor( color ) ); | 879 | pal.setColor( QColorGroup::Text, QColor( color ) ); |
879 | color = config.readEntry( "ButtonText", "#000000" ); | 880 | color = config.readEntry( "ButtonText", "#000000" ); |
880 | pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) ); | 881 | pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) ); |
881 | color = config.readEntry( "Base", "#FFFFFF" ); | 882 | color = config.readEntry( "Base", "#FFFFFF" ); |
882 | pal.setColor( QColorGroup::Base, QColor( color ) ); | 883 | pal.setColor( QColorGroup::Base, QColor( color ) ); |
883 | 884 | ||
884 | pal.setColor( QPalette::Disabled, QColorGroup::Text, | 885 | pal.setColor( QPalette::Disabled, QColorGroup::Text, |
885 | pal.color( QPalette::Active, QColorGroup::Background ).dark() ); | 886 | pal.color( QPalette::Active, QColorGroup::Background ).dark() ); |
886 | 887 | ||
887 | setPalette( pal, TRUE ); | 888 | setPalette( pal, TRUE ); |
888 | 889 | ||
889 | // Window Decoration | 890 | // Window Decoration |
890 | QString dec = config.readEntry( "Decoration", "Qtopia" ); | 891 | QString dec = config.readEntry( "Decoration", "Qtopia" ); |
891 | if ( dec != d->decorationName ) { | 892 | if ( dec != d->decorationName ) { |
892 | qwsSetDecoration( new QPEDecoration( dec ) ); | 893 | qwsSetDecoration( new QPEDecoration( dec ) ); |
893 | d->decorationName = dec; | 894 | d->decorationName = dec; |
894 | } | 895 | } |
895 | 896 | ||
896 | // Font | 897 | // Font |
897 | QString ff = config.readEntry( "FontFamily", font().family() ); | 898 | QString ff = config.readEntry( "FontFamily", font().family() ); |
898 | int fs = config.readNumEntry( "FontSize", font().pointSize() ); | 899 | int fs = config.readNumEntry( "FontSize", font().pointSize() ); |
899 | setFont( QFont(ff,fs) ); | 900 | setFont( QFont(ff,fs) ); |
900 | } | 901 | } |
901 | 902 | ||
902 | void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data ) | 903 | void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data ) |
903 | { | 904 | { |
904 | #ifdef Q_WS_QWS | 905 | #ifdef Q_WS_QWS |
905 | QDataStream stream( data, IO_ReadOnly ); | 906 | QDataStream stream( data, IO_ReadOnly ); |
906 | if ( msg == "applyStyle()" ) { | 907 | if ( msg == "applyStyle()" ) { |
907 | applyStyle(); | 908 | applyStyle(); |
908 | } else if ( msg == "setDefaultRotation(int)" ) { | 909 | } else if ( msg == "setDefaultRotation(int)" ) { |
909 | if ( type() == GuiServer ) { | 910 | if ( type() == GuiServer ) { |
910 | int r; | 911 | int r; |
911 | stream >> r; | 912 | stream >> r; |
912 | setDefaultRotation( r ); | 913 | setDefaultRotation( r ); |
913 | } | 914 | } |
914 | } else if ( msg == "shutdown()" ) { | 915 | } else if ( msg == "shutdown()" ) { |
915 | if ( type() == GuiServer ) | 916 | if ( type() == GuiServer ) |
916 | shutdown(); | 917 | shutdown(); |
917 | } else if ( msg == "quit()" ) { | 918 | } else if ( msg == "quit()" ) { |
918 | if ( type() != GuiServer ) | 919 | if ( type() != GuiServer ) |
919 | tryQuit(); | 920 | tryQuit(); |
920 | } else if ( msg == "forceQuit()" ) { | 921 | } else if ( msg == "forceQuit()" ) { |
921 | if ( type() != GuiServer ) | 922 | if ( type() != GuiServer ) |
922 | quit(); | 923 | quit(); |
923 | } else if ( msg == "restart()" ) { | 924 | } else if ( msg == "restart()" ) { |
924 | if ( type() == GuiServer ) | 925 | if ( type() == GuiServer ) |
925 | restart(); | 926 | restart(); |
926 | } else if ( msg == "grabKeyboard(QString)" ) { | 927 | } else if ( msg == "grabKeyboard(QString)" ) { |
927 | QString who; | 928 | QString who; |
928 | stream >> who; | 929 | stream >> who; |
929 | if ( who.isEmpty() ) | 930 | if ( who.isEmpty() ) |
930 | d->kbgrabber = 0; | 931 | d->kbgrabber = 0; |
931 | else if ( who != d->appName ) | 932 | else if ( who != d->appName ) |
932 | d->kbgrabber = 1; | 933 | d->kbgrabber = 1; |
933 | else | 934 | else |
934 | d->kbgrabber = 2; | 935 | d->kbgrabber = 2; |
935 | } else if ( msg == "language(QString)" ) { | 936 | } else if ( msg == "language(QString)" ) { |
@@ -982,239 +983,239 @@ void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data | |||
982 | stream >> when >> channel >> message >> data; | 983 | stream >> when >> channel >> message >> data; |
983 | AlarmServer::deleteAlarm( when, channel, message, data ); | 984 | AlarmServer::deleteAlarm( when, channel, message, data ); |
984 | } | 985 | } |
985 | } else if ( msg == "clockChange(bool)" ) { | 986 | } else if ( msg == "clockChange(bool)" ) { |
986 | int tmp; | 987 | int tmp; |
987 | stream >> tmp; | 988 | stream >> tmp; |
988 | emit clockChanged( tmp ); | 989 | emit clockChanged( tmp ); |
989 | } else if ( msg == "weekChange(bool)" ) { | 990 | } else if ( msg == "weekChange(bool)" ) { |
990 | int tmp; | 991 | int tmp; |
991 | stream >> tmp; | 992 | stream >> tmp; |
992 | emit weekChanged( tmp ); | 993 | emit weekChanged( tmp ); |
993 | } else if ( msg == "setDateFormat(DateFormat)" ) { | 994 | } else if ( msg == "setDateFormat(DateFormat)" ) { |
994 | DateFormat tmp; | 995 | DateFormat tmp; |
995 | stream >> tmp; | 996 | stream >> tmp; |
996 | emit dateFormatChanged( tmp ); | 997 | emit dateFormatChanged( tmp ); |
997 | } else if ( msg == "setVolume(int,int)" ) { | 998 | } else if ( msg == "setVolume(int,int)" ) { |
998 | int t, v; | 999 | int t, v; |
999 | stream >> t >> v; | 1000 | stream >> t >> v; |
1000 | setVolume( t, v ); | 1001 | setVolume( t, v ); |
1001 | emit volumeChanged( muted ); | 1002 | emit volumeChanged( muted ); |
1002 | } else if ( msg == "volumeChange(bool)" ) { | 1003 | } else if ( msg == "volumeChange(bool)" ) { |
1003 | stream >> muted; | 1004 | stream >> muted; |
1004 | setVolume(); | 1005 | setVolume(); |
1005 | emit volumeChanged( muted ); | 1006 | emit volumeChanged( muted ); |
1006 | } else if ( msg == "setMic(int,int)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> | 1007 | } else if ( msg == "setMic(int,int)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> |
1007 | int t, v; | 1008 | int t, v; |
1008 | stream >> t >> v; | 1009 | stream >> t >> v; |
1009 | setMic( t, v ); | 1010 | setMic( t, v ); |
1010 | emit micChanged( micMuted ); | 1011 | emit micChanged( micMuted ); |
1011 | } else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> | 1012 | } else if ( msg == "micChange(bool)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> |
1012 | stream >> micMuted; | 1013 | stream >> micMuted; |
1013 | setMic(); | 1014 | setMic(); |
1014 | emit micChanged( micMuted ); | 1015 | emit micChanged( micMuted ); |
1015 | } | 1016 | } |
1016 | #endif | 1017 | #endif |
1017 | } | 1018 | } |
1018 | 1019 | ||
1019 | /*! | 1020 | /*! |
1020 | \internal | 1021 | \internal |
1021 | */ | 1022 | */ |
1022 | bool QPEApplication::raiseAppropriateWindow() | 1023 | bool QPEApplication::raiseAppropriateWindow() |
1023 | { | 1024 | { |
1024 | bool r=FALSE; | 1025 | bool r=FALSE; |
1025 | // ########## raise()ing main window should raise and set active | 1026 | // ########## raise()ing main window should raise and set active |
1026 | // ########## it and then all childen. This belongs in Qt/Embedded | 1027 | // ########## it and then all childen. This belongs in Qt/Embedded |
1027 | QWidget *top = d->qpe_main_widget; | 1028 | QWidget *top = d->qpe_main_widget; |
1028 | if ( !top ) top =mainWidget(); | 1029 | if ( !top ) top =mainWidget(); |
1029 | if ( top && d->keep_running ) { | 1030 | if ( top && d->keep_running ) { |
1030 | if ( top->isVisible() ) | 1031 | if ( top->isVisible() ) |
1031 | r = TRUE; | 1032 | r = TRUE; |
1032 | else if (d->preloaded) { | 1033 | else if (d->preloaded) { |
1033 | // We are preloaded and not visible.. pretend we just started.. | 1034 | // We are preloaded and not visible.. pretend we just started.. |
1034 | QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); | 1035 | QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); |
1035 | e << d->appName; | 1036 | e << d->appName; |
1036 | } | 1037 | } |
1037 | 1038 | ||
1038 | d->show_mx(top,d->nomaximize); | 1039 | d->show_mx(top,d->nomaximize); |
1039 | top->raise(); | 1040 | top->raise(); |
1040 | top->setActiveWindow(); | 1041 | top->setActiveWindow(); |
1041 | } | 1042 | } |
1042 | QWidget *topm = activeModalWidget(); | 1043 | QWidget *topm = activeModalWidget(); |
1043 | if ( topm && topm != top ) { | 1044 | if ( topm && topm != top ) { |
1044 | topm->show(); | 1045 | topm->show(); |
1045 | topm->raise(); | 1046 | topm->raise(); |
1046 | topm->setActiveWindow(); | 1047 | topm->setActiveWindow(); |
1047 | // If we haven't already handled the fastAppShowing message | 1048 | // If we haven't already handled the fastAppShowing message |
1048 | if (!top && d->preloaded) { | 1049 | if (!top && d->preloaded) { |
1049 | QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); | 1050 | QCopEnvelope e("QPE/System", "fastAppShowing(QString)"); |
1050 | e << d->appName; | 1051 | e << d->appName; |
1051 | } | 1052 | } |
1052 | r = FALSE; | 1053 | r = FALSE; |
1053 | } | 1054 | } |
1054 | return r; | 1055 | return r; |
1055 | } | 1056 | } |
1056 | 1057 | ||
1057 | void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data) | 1058 | void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data) |
1058 | { | 1059 | { |
1059 | #ifdef Q_WS_QWS | 1060 | #ifdef Q_WS_QWS |
1060 | 1061 | ||
1061 | if ( msg == "quit()" ) { | 1062 | if ( msg == "quit()" ) { |
1062 | tryQuit(); | 1063 | tryQuit(); |
1063 | } else if ( msg == "quitIfInvisible()" ) { | 1064 | } else if ( msg == "quitIfInvisible()" ) { |
1064 | if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() ) | 1065 | if ( d->qpe_main_widget && !d->qpe_main_widget->isVisible() ) |
1065 | quit(); | 1066 | quit(); |
1066 | } else if ( msg == "close()" ) { | 1067 | } else if ( msg == "close()" ) { |
1067 | hideOrQuit(); | 1068 | hideOrQuit(); |
1068 | } else if ( msg == "disablePreload()" ) { | 1069 | } else if ( msg == "disablePreload()" ) { |
1069 | d->preloaded = FALSE; | 1070 | d->preloaded = FALSE; |
1070 | d->keep_running = TRUE; | 1071 | d->keep_running = TRUE; |
1071 | /* so that quit will quit */ | 1072 | /* so that quit will quit */ |
1072 | } else if ( msg == "enablePreload()" ) { | 1073 | } else if ( msg == "enablePreload()" ) { |
1073 | if (d->qpe_main_widget) | 1074 | if (d->qpe_main_widget) |
1074 | d->preloaded = TRUE; | 1075 | d->preloaded = TRUE; |
1075 | d->keep_running = TRUE; | 1076 | d->keep_running = TRUE; |
1076 | /* so next quit won't quit */ | 1077 | /* so next quit won't quit */ |
1077 | } else if ( msg == "raise()" ) { | 1078 | } else if ( msg == "raise()" ) { |
1078 | d->keep_running = TRUE; | 1079 | d->keep_running = TRUE; |
1079 | d->notbusysent = FALSE; | 1080 | d->notbusysent = FALSE; |
1080 | raiseAppropriateWindow(); | 1081 | raiseAppropriateWindow(); |
1081 | // Tell the system we're still chugging along... | 1082 | // Tell the system we're still chugging along... |
1082 | QCopEnvelope e("QPE/System", "appRaised(QString)"); | 1083 | QCopEnvelope e("QPE/System", "appRaised(QString)"); |
1083 | e << d->appName; | 1084 | e << d->appName; |
1084 | } else if ( msg == "flush()" ) { | 1085 | } else if ( msg == "flush()" ) { |
1085 | emit flush(); | 1086 | emit flush(); |
1086 | // we need to tell the desktop | 1087 | // we need to tell the desktop |
1087 | QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" ); | 1088 | QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" ); |
1088 | e << d->appName; | 1089 | e << d->appName; |
1089 | } else if ( msg == "reload()" ) { | 1090 | } else if ( msg == "reload()" ) { |
1090 | emit reload(); | 1091 | emit reload(); |
1091 | } else if ( msg == "setDocument(QString)" ) { | 1092 | } else if ( msg == "setDocument(QString)" ) { |
1092 | d->keep_running = TRUE; | 1093 | d->keep_running = TRUE; |
1093 | QDataStream stream( data, IO_ReadOnly ); | 1094 | QDataStream stream( data, IO_ReadOnly ); |
1094 | QString doc; | 1095 | QString doc; |
1095 | stream >> doc; | 1096 | stream >> doc; |
1096 | QWidget *mw = mainWidget(); | 1097 | QWidget *mw = mainWidget(); |
1097 | if ( !mw ) | 1098 | if ( !mw ) |
1098 | mw = d->qpe_main_widget; | 1099 | mw = d->qpe_main_widget; |
1099 | if ( mw ) | 1100 | if ( mw ) |
1100 | Global::setDocument( mw, doc ); | 1101 | Global::setDocument( mw, doc ); |
1101 | } else if ( msg == "nextView()" ) { | 1102 | } else if ( msg == "nextView()" ) { |
1102 | qDebug("got nextView()"); | 1103 | qDebug("got nextView()"); |
1103 | /* | 1104 | /* |
1104 | if ( raiseAppropriateWindow() ) | 1105 | if ( raiseAppropriateWindow() ) |
1105 | */ | 1106 | */ |
1106 | emit appMessage( msg, data); | 1107 | emit appMessage( msg, data); |
1107 | } else { | 1108 | } else { |
1108 | emit appMessage( msg, data); | 1109 | emit appMessage( msg, data); |
1109 | } | 1110 | } |
1110 | 1111 | ||
1111 | #endif | 1112 | #endif |
1112 | } | 1113 | } |
1113 | 1114 | ||
1114 | 1115 | ||
1115 | /*! | 1116 | /*! |
1116 | Sets widget \a mw as the mainWidget() and shows it. For small windows, | 1117 | Sets widget \a mw as the mainWidget() and shows it. For small windows, |
1117 | consider passing TRUE for \a nomaximize rather than the default FALSE. | 1118 | consider passing TRUE for \a nomaximize rather than the default FALSE. |
1118 | 1119 | ||
1119 | \sa showMainDocumentWidget() | 1120 | \sa showMainDocumentWidget() |
1120 | */ | 1121 | */ |
1121 | void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize ) | 1122 | void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize ) |
1122 | { | 1123 | { |
1123 | d->show(mw,nomaximize ); | 1124 | d->show(mw,nomaximize ); |
1124 | } | 1125 | } |
1125 | 1126 | ||
1126 | /*! | 1127 | /*! |
1127 | Sets widget \a mw as the mainWidget() and shows it. For small windows, | 1128 | Sets widget \a mw as the mainWidget() and shows it. For small windows, |
1128 | consider passing TRUE for \a nomaximize rather than the default FALSE. | 1129 | consider passing TRUE for \a nomaximize rather than the default FALSE. |
1129 | 1130 | ||
1130 | This calls designates the application as | 1131 | This calls designates the application as |
1131 | a \link docwidget.html document-oriented\endlink application. | 1132 | a \link docwidget.html document-oriented\endlink application. |
1132 | 1133 | ||
1133 | The \a mw widget \e must have this slot: setDocument(const QString&). | 1134 | The \a mw widget \e must have this slot: setDocument(const QString&). |
1134 | 1135 | ||
1135 | \sa showMainWidget() | 1136 | \sa showMainWidget() |
1136 | */ | 1137 | */ |
1137 | void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize ) | 1138 | void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize ) |
1138 | { | 1139 | { |
1139 | if ( mw && argc() == 2 ) | 1140 | if ( mw && argc() == 2 ) |
1140 | Global::setDocument( mw, QString::fromUtf8(argv()[1]) ); | 1141 | Global::setDocument( mw, QString::fromUtf8(argv()[1]) ); |
1141 | 1142 | ||
1142 | d->show(mw, nomaximize ); | 1143 | d->show(mw, nomaximize ); |
1143 | } | 1144 | } |
1144 | 1145 | ||
1145 | 1146 | ||
1146 | /*! | 1147 | /*! |
1147 | If an application is started via a \link qcop.html QCop\endlink | 1148 | If an application is started via a \link qcop.html QCop\endlink |
1148 | message, the application will process the \link qcop.html | 1149 | message, the application will process the \link qcop.html |
1149 | QCop\endlink message and then quit. If the application calls this | 1150 | QCop\endlink message and then quit. If the application calls this |
1150 | function while processing a \link qcop.html QCop\endlink message, | 1151 | function while processing a \link qcop.html QCop\endlink message, |
1151 | after processing its outstanding \link qcop.html QCop\endlink | 1152 | after processing its outstanding \link qcop.html QCop\endlink |
1152 | messages the application will start 'properly' and show itself. | 1153 | messages the application will start 'properly' and show itself. |
1153 | 1154 | ||
1154 | \sa keepRunning() | 1155 | \sa keepRunning() |
1155 | */ | 1156 | */ |
1156 | void QPEApplication::setKeepRunning() | 1157 | void QPEApplication::setKeepRunning() |
1157 | { | 1158 | { |
1158 | if ( qApp && qApp->inherits( "QPEApplication" ) ) { | 1159 | if ( qApp && qApp->inherits( "QPEApplication" ) ) { |
1159 | QPEApplication * qpeApp = ( QPEApplication* ) qApp; | 1160 | QPEApplication * qpeApp = ( QPEApplication* ) qApp; |
1160 | qpeApp->d->keep_running = TRUE; | 1161 | qpeApp->d->keep_running = TRUE; |
1161 | } | 1162 | } |
1162 | } | 1163 | } |
1163 | 1164 | ||
1164 | /*! | 1165 | /*! |
1165 | Returns TRUE if the application will quit after processing the | 1166 | Returns TRUE if the application will quit after processing the |
1166 | current list of qcop messages; otherwise returns FALSE. | 1167 | current list of qcop messages; otherwise returns FALSE. |
1167 | 1168 | ||
1168 | \sa setKeepRunning() | 1169 | \sa setKeepRunning() |
1169 | */ | 1170 | */ |
1170 | bool QPEApplication::keepRunning() const | 1171 | bool QPEApplication::keepRunning() const |
1171 | { | 1172 | { |
1172 | return d->keep_running; | 1173 | return d->keep_running; |
1173 | } | 1174 | } |
1174 | 1175 | ||
1175 | /*! | 1176 | /*! |
1176 | \internal | 1177 | \internal |
1177 | */ | 1178 | */ |
1178 | void QPEApplication::internalSetStyle( const QString &style ) | 1179 | void QPEApplication::internalSetStyle( const QString &style ) |
1179 | { | 1180 | { |
1180 | #if QT_VERSION >= 300 | 1181 | #if QT_VERSION >= 300 |
1181 | if ( style == "QPE" ) { | 1182 | if ( style == "QPE" ) { |
1182 | setStyle( new QPEStyle ); | 1183 | setStyle( new QPEStyle ); |
1183 | } | 1184 | } |
1184 | else { | 1185 | else { |
1185 | QStyle *s = QStyleFactory::create( style ); | 1186 | QStyle *s = QStyleFactory::create( style ); |
1186 | if ( s ) | 1187 | if ( s ) |
1187 | setStyle( s ); | 1188 | setStyle( s ); |
1188 | } | 1189 | } |
1189 | #else | 1190 | #else |
1190 | if ( style == "Windows" ) { | 1191 | if ( style == "Windows" ) { |
1191 | setStyle( new QWindowsStyle ); | 1192 | setStyle( new QWindowsStyle ); |
1192 | } | 1193 | } |
1193 | else if ( style == "QPE" ) { | 1194 | else if ( style == "QPE" ) { |
1194 | setStyle( new QPEStyle ); | 1195 | setStyle( new QPEStyle ); |
1195 | } | 1196 | } |
1196 | else if ( style == "Light" ) { | 1197 | else if ( style == "Light" ) { |
1197 | setStyle( new LightStyle ); | 1198 | setStyle( new LightStyle ); |
1198 | } | 1199 | } |
1199 | #ifndef QT_NO_STYLE_PLATINUM | 1200 | #ifndef QT_NO_STYLE_PLATINUM |
1200 | else if ( style == "Platinum" ) { | 1201 | else if ( style == "Platinum" ) { |
1201 | setStyle( new QPlatinumStyle ); | 1202 | setStyle( new QPlatinumStyle ); |
1202 | } | 1203 | } |
1203 | #endif | 1204 | #endif |
1204 | #ifndef QT_NO_STYLE_MOTIF | 1205 | #ifndef QT_NO_STYLE_MOTIF |
1205 | else if ( style == "Motif" ) { | 1206 | else if ( style == "Motif" ) { |
1206 | setStyle( new QMotifStyle ); | 1207 | setStyle( new QMotifStyle ); |
1207 | } | 1208 | } |
1208 | #endif | 1209 | #endif |
1209 | #ifndef QT_NO_STYLE_MOTIFPLUS | 1210 | #ifndef QT_NO_STYLE_MOTIFPLUS |
1210 | else if ( style == "MotifPlus" ) { | 1211 | else if ( style == "MotifPlus" ) { |
1211 | setStyle( new QMotifPlusStyle ); | 1212 | setStyle( new QMotifPlusStyle ); |
1212 | } | 1213 | } |
1213 | #endif | 1214 | #endif |
1214 | 1215 | ||
1215 | else { | 1216 | else { |
1216 | QStyle *sty = 0; | 1217 | QStyle *sty = 0; |
1217 | QString path = QPEApplication::qpeDir ( ) + "/plugins/styles/lib" + style. lower ( ) + ".so"; | 1218 | QString path = QPEApplication::qpeDir ( ) + "/plugins/styles/lib" + style. lower ( ) + ".so"; |
1218 | 1219 | ||
1219 | static QLibrary *lastlib = 0; | 1220 | static QLibrary *lastlib = 0; |
1220 | static StyleInterface *lastiface = 0; | 1221 | static StyleInterface *lastiface = 0; |
@@ -1306,176 +1307,176 @@ static void createDict() | |||
1306 | QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w ) | 1307 | QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w ) |
1307 | { | 1308 | { |
1308 | if ( stylusDict ) | 1309 | if ( stylusDict ) |
1309 | return ( StylusMode ) ( int ) stylusDict->find( w ); | 1310 | return ( StylusMode ) ( int ) stylusDict->find( w ); |
1310 | return LeftOnly; | 1311 | return LeftOnly; |
1311 | } | 1312 | } |
1312 | 1313 | ||
1313 | /*! | 1314 | /*! |
1314 | \enum QPEApplication::StylusMode | 1315 | \enum QPEApplication::StylusMode |
1315 | 1316 | ||
1316 | \value LeftOnly the stylus only generates LeftButton | 1317 | \value LeftOnly the stylus only generates LeftButton |
1317 | events (the default). | 1318 | events (the default). |
1318 | \value RightOnHold the stylus generates RightButton events | 1319 | \value RightOnHold the stylus generates RightButton events |
1319 | if the user uses the press-and-hold gesture. | 1320 | if the user uses the press-and-hold gesture. |
1320 | 1321 | ||
1321 | \sa setStylusOperation() stylusOperation() | 1322 | \sa setStylusOperation() stylusOperation() |
1322 | */ | 1323 | */ |
1323 | 1324 | ||
1324 | /*! | 1325 | /*! |
1325 | Causes widget \a w to receive mouse events according to the stylus | 1326 | Causes widget \a w to receive mouse events according to the stylus |
1326 | \a mode. | 1327 | \a mode. |
1327 | 1328 | ||
1328 | \sa stylusOperation() StylusMode | 1329 | \sa stylusOperation() StylusMode |
1329 | */ | 1330 | */ |
1330 | void QPEApplication::setStylusOperation( QWidget * w, StylusMode mode ) | 1331 | void QPEApplication::setStylusOperation( QWidget * w, StylusMode mode ) |
1331 | { | 1332 | { |
1332 | createDict(); | 1333 | createDict(); |
1333 | if ( mode == LeftOnly ) { | 1334 | if ( mode == LeftOnly ) { |
1334 | stylusDict->remove | 1335 | stylusDict->remove |
1335 | ( w ); | 1336 | ( w ); |
1336 | w->removeEventFilter( qApp ); | 1337 | w->removeEventFilter( qApp ); |
1337 | } | 1338 | } |
1338 | else { | 1339 | else { |
1339 | stylusDict->insert( w, ( void* ) mode ); | 1340 | stylusDict->insert( w, ( void* ) mode ); |
1340 | connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) ); | 1341 | connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) ); |
1341 | w->installEventFilter( qApp ); | 1342 | w->installEventFilter( qApp ); |
1342 | } | 1343 | } |
1343 | } | 1344 | } |
1344 | 1345 | ||
1345 | 1346 | ||
1346 | /*! | 1347 | /*! |
1347 | \reimp | 1348 | \reimp |
1348 | */ | 1349 | */ |
1349 | bool QPEApplication::eventFilter( QObject *o, QEvent *e ) | 1350 | bool QPEApplication::eventFilter( QObject *o, QEvent *e ) |
1350 | { | 1351 | { |
1351 | if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) { | 1352 | if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) { |
1352 | QMouseEvent * me = ( QMouseEvent* ) e; | 1353 | QMouseEvent * me = ( QMouseEvent* ) e; |
1353 | StylusMode mode = (StylusMode)(int)stylusDict->find(o); | 1354 | StylusMode mode = (StylusMode)(int)stylusDict->find(o); |
1354 | switch (mode) { | 1355 | switch (mode) { |
1355 | case RightOnHold: | 1356 | case RightOnHold: |
1356 | switch ( me->type() ) { | 1357 | switch ( me->type() ) { |
1357 | case QEvent::MouseButtonPress: | 1358 | case QEvent::MouseButtonPress: |
1358 | if ( me->button() == LeftButton ) { | 1359 | if ( me->button() == LeftButton ) { |
1359 | d->presstimer = startTimer(500); // #### pref. | 1360 | d->presstimer = startTimer(500); // #### pref. |
1360 | d->presswidget = (QWidget*)o; | 1361 | d->presswidget = (QWidget*)o; |
1361 | d->presspos = me->pos(); | 1362 | d->presspos = me->pos(); |
1362 | d->rightpressed = FALSE; | 1363 | d->rightpressed = FALSE; |
1363 | } | 1364 | } |
1364 | break; | 1365 | break; |
1365 | case QEvent::MouseMove: | 1366 | case QEvent::MouseMove: |
1366 | if (d->presstimer && (me->pos()-d->presspos).manhattanLength() > 8) { | 1367 | if (d->presstimer && (me->pos()-d->presspos).manhattanLength() > 8) { |
1367 | killTimer(d->presstimer); | 1368 | killTimer(d->presstimer); |
1368 | d->presstimer = 0; | 1369 | d->presstimer = 0; |
1369 | } | 1370 | } |
1370 | break; | 1371 | break; |
1371 | case QEvent::MouseButtonRelease: | 1372 | case QEvent::MouseButtonRelease: |
1372 | if ( me->button() == LeftButton ) { | 1373 | if ( me->button() == LeftButton ) { |
1373 | if ( d->presstimer ) { | 1374 | if ( d->presstimer ) { |
1374 | killTimer(d->presstimer); | 1375 | killTimer(d->presstimer); |
1375 | d->presstimer = 0; | 1376 | d->presstimer = 0; |
1376 | } | 1377 | } |
1377 | if ( d->rightpressed && d->presswidget ) { | 1378 | if ( d->rightpressed && d->presswidget ) { |
1378 | // Right released | 1379 | // Right released |
1379 | postEvent( d->presswidget, | 1380 | postEvent( d->presswidget, |
1380 | new QMouseEvent( QEvent::MouseButtonRelease, me->pos(), | 1381 | new QMouseEvent( QEvent::MouseButtonRelease, me->pos(), |
1381 | RightButton, LeftButton+RightButton ) ); | 1382 | RightButton, LeftButton+RightButton ) ); |
1382 | // Left released, off-widget | 1383 | // Left released, off-widget |
1383 | postEvent( d->presswidget, | 1384 | postEvent( d->presswidget, |
1384 | new QMouseEvent( QEvent::MouseMove, QPoint(-1,-1), | 1385 | new QMouseEvent( QEvent::MouseMove, QPoint(-1,-1), |
1385 | LeftButton, LeftButton ) ); | 1386 | LeftButton, LeftButton ) ); |
1386 | postEvent( d->presswidget, | 1387 | postEvent( d->presswidget, |
1387 | new QMouseEvent( QEvent::MouseButtonRelease, QPoint(-1,-1), | 1388 | new QMouseEvent( QEvent::MouseButtonRelease, QPoint(-1,-1), |
1388 | LeftButton, LeftButton ) ); | 1389 | LeftButton, LeftButton ) ); |
1389 | d->rightpressed = FALSE; | 1390 | d->rightpressed = FALSE; |
1390 | return TRUE; // don't send the real Left release | 1391 | return TRUE; // don't send the real Left release |
1391 | } | 1392 | } |
1392 | } | 1393 | } |
1393 | break; | 1394 | break; |
1394 | default: | 1395 | default: |
1395 | break; | 1396 | break; |
1396 | } | 1397 | } |
1397 | break; | 1398 | break; |
1398 | default: | 1399 | default: |
1399 | ; | 1400 | ; |
1400 | } | 1401 | } |
1401 | }else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { | 1402 | }else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { |
1402 | QKeyEvent *ke = (QKeyEvent *)e; | 1403 | QKeyEvent *ke = (QKeyEvent *)e; |
1403 | if ( ke->key() == Key_Enter ) { | 1404 | if ( ke->key() == Key_Enter ) { |
1404 | if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) { | 1405 | if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) { |
1405 | postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ', | 1406 | postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ', |
1406 | ke->state(), " ", ke->isAutoRepeat(), ke->count() ) ); | 1407 | ke->state(), " ", ke->isAutoRepeat(), ke->count() ) ); |
1407 | return TRUE; | 1408 | return TRUE; |
1408 | } | 1409 | } |
1409 | } | 1410 | } |
1410 | } | 1411 | } |
1411 | return FALSE; | 1412 | return FALSE; |
1412 | } | 1413 | } |
1413 | 1414 | ||
1414 | /*! | 1415 | /*! |
1415 | \reimp | 1416 | \reimp |
1416 | */ | 1417 | */ |
1417 | void QPEApplication::timerEvent( QTimerEvent *e ) | 1418 | void QPEApplication::timerEvent( QTimerEvent *e ) |
1418 | { | 1419 | { |
1419 | if ( e->timerId() == d->presstimer && d->presswidget ) { | 1420 | if ( e->timerId() == d->presstimer && d->presswidget ) { |
1420 | // Right pressed | 1421 | // Right pressed |
1421 | postEvent( d->presswidget, | 1422 | postEvent( d->presswidget, |
1422 | new QMouseEvent( QEvent::MouseButtonPress, d->presspos, | 1423 | new QMouseEvent( QEvent::MouseButtonPress, d->presspos, |
1423 | RightButton, LeftButton ) ); | 1424 | RightButton, LeftButton ) ); |
1424 | killTimer( d->presstimer ); | 1425 | killTimer( d->presstimer ); |
1425 | d->presstimer = 0; | 1426 | d->presstimer = 0; |
1426 | d->rightpressed = TRUE; | 1427 | d->rightpressed = TRUE; |
1427 | } | 1428 | } |
1428 | } | 1429 | } |
1429 | 1430 | ||
1430 | void QPEApplication::removeSenderFromStylusDict() | 1431 | void QPEApplication::removeSenderFromStylusDict() |
1431 | { | 1432 | { |
1432 | stylusDict->remove | 1433 | stylusDict->remove |
1433 | ( ( void* ) sender() ); | 1434 | ( ( void* ) sender() ); |
1434 | if ( d->presswidget == sender() ) | 1435 | if ( d->presswidget == sender() ) |
1435 | d->presswidget = 0; | 1436 | d->presswidget = 0; |
1436 | } | 1437 | } |
1437 | 1438 | ||
1438 | /*! | 1439 | /*! |
1439 | \internal | 1440 | \internal |
1440 | */ | 1441 | */ |
1441 | bool QPEApplication::keyboardGrabbed() const | 1442 | bool QPEApplication::keyboardGrabbed() const |
1442 | { | 1443 | { |
1443 | return d->kbgrabber; | 1444 | return d->kbgrabber; |
1444 | } | 1445 | } |
1445 | 1446 | ||
1446 | 1447 | ||
1447 | /*! | 1448 | /*! |
1448 | Reverses the effect of grabKeyboard(). This is called automatically | 1449 | Reverses the effect of grabKeyboard(). This is called automatically |
1449 | on program exit. | 1450 | on program exit. |
1450 | */ | 1451 | */ |
1451 | void QPEApplication::ungrabKeyboard() | 1452 | void QPEApplication::ungrabKeyboard() |
1452 | { | 1453 | { |
1453 | QPEApplicationData * d = ( ( QPEApplication* ) qApp ) ->d; | 1454 | QPEApplicationData * d = ( ( QPEApplication* ) qApp ) ->d; |
1454 | if ( d->kbgrabber == 2 ) { | 1455 | if ( d->kbgrabber == 2 ) { |
1455 | #ifndef QT_NO_COP | 1456 | #ifndef QT_NO_COP |
1456 | QCopEnvelope e( "QPE/System", "grabKeyboard(QString)" ); | 1457 | QCopEnvelope e( "QPE/System", "grabKeyboard(QString)" ); |
1457 | e << QString::null; | 1458 | e << QString::null; |
1458 | #endif | 1459 | #endif |
1459 | d->kbregrab = FALSE; | 1460 | d->kbregrab = FALSE; |
1460 | d->kbgrabber = 0; | 1461 | d->kbgrabber = 0; |
1461 | } | 1462 | } |
1462 | } | 1463 | } |
1463 | 1464 | ||
1464 | /*! | 1465 | /*! |
1465 | Grabs the physical keyboard keys, e.g. the application's launching | 1466 | Grabs the physical keyboard keys, e.g. the application's launching |
1466 | keys. Instead of launching applications when these keys are pressed | 1467 | keys. Instead of launching applications when these keys are pressed |
1467 | the signals emitted are sent to this application instead. Some games | 1468 | the signals emitted are sent to this application instead. Some games |
1468 | programs take over the launch keys in this way to make interaction | 1469 | programs take over the launch keys in this way to make interaction |
1469 | easier. | 1470 | easier. |
1470 | 1471 | ||
1471 | \sa ungrabKeyboard() | 1472 | \sa ungrabKeyboard() |
1472 | */ | 1473 | */ |
1473 | void QPEApplication::grabKeyboard() | 1474 | void QPEApplication::grabKeyboard() |
1474 | { | 1475 | { |
1475 | QPEApplicationData * d = ( ( QPEApplication* ) qApp ) ->d; | 1476 | QPEApplicationData * d = ( ( QPEApplication* ) qApp ) ->d; |
1476 | if ( qApp->type() == QApplication::GuiServer ) | 1477 | if ( qApp->type() == QApplication::GuiServer ) |
1477 | d->kbgrabber = 0; | 1478 | d->kbgrabber = 0; |
1478 | else { | 1479 | else { |
1479 | #ifndef QT_NO_COP | 1480 | #ifndef QT_NO_COP |
1480 | QCopEnvelope e( "QPE/System", "grabKeyboard(QString)" ); | 1481 | QCopEnvelope e( "QPE/System", "grabKeyboard(QString)" ); |
1481 | e << d->appName; | 1482 | e << d->appName; |
@@ -1496,99 +1497,99 @@ int QPEApplication::exec() | |||
1496 | //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() ) | 1497 | //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() ) |
1497 | return QApplication::exec(); | 1498 | return QApplication::exec(); |
1498 | 1499 | ||
1499 | #ifndef QT_NO_COP | 1500 | #ifndef QT_NO_COP |
1500 | { | 1501 | { |
1501 | QCopEnvelope e( "QPE/System", "closing(QString)" ); | 1502 | QCopEnvelope e( "QPE/System", "closing(QString)" ); |
1502 | e << d->appName; | 1503 | e << d->appName; |
1503 | } | 1504 | } |
1504 | #endif | 1505 | #endif |
1505 | processEvents(); | 1506 | processEvents(); |
1506 | return 0; | 1507 | return 0; |
1507 | } | 1508 | } |
1508 | 1509 | ||
1509 | /*! | 1510 | /*! |
1510 | \internal | 1511 | \internal |
1511 | External request for application to quit. Quits if possible without | 1512 | External request for application to quit. Quits if possible without |
1512 | loosing state. | 1513 | loosing state. |
1513 | */ | 1514 | */ |
1514 | void QPEApplication::tryQuit() | 1515 | void QPEApplication::tryQuit() |
1515 | { | 1516 | { |
1516 | if ( activeModalWidget() || strcmp( argv() [ 0 ], "embeddedkonsole" ) == 0 ) | 1517 | if ( activeModalWidget() || strcmp( argv() [ 0 ], "embeddedkonsole" ) == 0 ) |
1517 | return ; // Inside modal loop or konsole. Too hard to save state. | 1518 | return ; // Inside modal loop or konsole. Too hard to save state. |
1518 | #ifndef QT_NO_COP | 1519 | #ifndef QT_NO_COP |
1519 | { | 1520 | { |
1520 | QCopEnvelope e( "QPE/System", "closing(QString)" ); | 1521 | QCopEnvelope e( "QPE/System", "closing(QString)" ); |
1521 | e << d->appName; | 1522 | e << d->appName; |
1522 | } | 1523 | } |
1523 | #endif | 1524 | #endif |
1524 | processEvents(); | 1525 | processEvents(); |
1525 | 1526 | ||
1526 | quit(); | 1527 | quit(); |
1527 | } | 1528 | } |
1528 | 1529 | ||
1529 | /*! | 1530 | /*! |
1530 | \internal | 1531 | \internal |
1531 | User initiated quit. Makes the window 'Go Away'. If preloaded this means | 1532 | User initiated quit. Makes the window 'Go Away'. If preloaded this means |
1532 | hiding the window. If not it means quitting the application. | 1533 | hiding the window. If not it means quitting the application. |
1533 | As this is user initiated we don't need to check state. | 1534 | As this is user initiated we don't need to check state. |
1534 | */ | 1535 | */ |
1535 | void QPEApplication::hideOrQuit() | 1536 | void QPEApplication::hideOrQuit() |
1536 | { | 1537 | { |
1537 | processEvents(); | 1538 | processEvents(); |
1538 | 1539 | ||
1539 | // If we are a preloaded application we don't actually quit, so emit | 1540 | // If we are a preloaded application we don't actually quit, so emit |
1540 | // a System message indicating we're quasi-closing. | 1541 | // a System message indicating we're quasi-closing. |
1541 | if ( d->preloaded && d->qpe_main_widget ) | 1542 | if ( d->preloaded && d->qpe_main_widget ) |
1542 | #ifndef QT_NO_COP | 1543 | #ifndef QT_NO_COP |
1543 | { | 1544 | { |
1544 | QCopEnvelope e("QPE/System", "fastAppHiding(QString)" ); | 1545 | QCopEnvelope e("QPE/System", "fastAppHiding(QString)" ); |
1545 | e << d->appName; | 1546 | e << d->appName; |
1546 | d->qpe_main_widget->hide(); | 1547 | d->qpe_main_widget->hide(); |
1547 | } | 1548 | } |
1548 | #endif | 1549 | #endif |
1549 | else | 1550 | else |
1550 | quit(); | 1551 | quit(); |
1551 | } | 1552 | } |
1552 | 1553 | ||
1553 | #if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) | 1554 | #if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) |
1554 | 1555 | ||
1555 | // The libraries with the skiff package (and possibly others) have | 1556 | // The libraries with the skiff package (and possibly others) have |
1556 | // completely useless implementations of builtin new and delete that | 1557 | // completely useless implementations of builtin new and delete that |
1557 | // use about 50% of your CPU. Here we revert to the simple libc | 1558 | // use about 50% of your CPU. Here we revert to the simple libc |
1558 | // functions. | 1559 | // functions. |
1559 | 1560 | ||
1560 | void* operator new[]( size_t size ) | 1561 | void* operator new[]( size_t size ) |
1561 | { | 1562 | { |
1562 | return malloc( size ); | 1563 | return malloc( size ); |
1563 | } | 1564 | } |
1564 | 1565 | ||
1565 | void* operator new( size_t size ) | 1566 | void* operator new( size_t size ) |
1566 | { | 1567 | { |
1567 | return malloc( size ); | 1568 | return malloc( size ); |
1568 | } | 1569 | } |
1569 | 1570 | ||
1570 | void operator delete[]( void* p ) | 1571 | void operator delete[]( void* p ) |
1571 | { | 1572 | { |
1572 | free( p ); | 1573 | free( p ); |
1573 | } | 1574 | } |
1574 | 1575 | ||
1575 | void operator delete[]( void* p, size_t /*size*/ ) | 1576 | void operator delete[]( void* p, size_t /*size*/ ) |
1576 | { | 1577 | { |
1577 | free( p ); | 1578 | free( p ); |
1578 | } | 1579 | } |
1579 | 1580 | ||
1580 | void operator delete( void* p ) | 1581 | void operator delete( void* p ) |
1581 | { | 1582 | { |
1582 | free( p ); | 1583 | free( p ); |
1583 | } | 1584 | } |
1584 | 1585 | ||
1585 | void operator delete( void* p, size_t /*size*/ ) | 1586 | void operator delete( void* p, size_t /*size*/ ) |
1586 | { | 1587 | { |
1587 | free( p ); | 1588 | free( p ); |
1588 | } | 1589 | } |
1589 | 1590 | ||
1590 | #endif | 1591 | #endif |
1591 | 1592 | ||
1592 | #if ( QT_VERSION <= 230 ) && !defined(SINGLE_APP) | 1593 | #if ( QT_VERSION <= 230 ) && !defined(SINGLE_APP) |
1593 | #include <qwidgetlist.h> | 1594 | #include <qwidgetlist.h> |
1594 | #ifdef QWS | 1595 | #ifdef QWS |