-rw-r--r-- | library/qpeapplication.cpp | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp index 2ef60d5..7f8299a 100644 --- a/library/qpeapplication.cpp +++ b/library/qpeapplication.cpp | |||
@@ -1,212 +1,219 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | ** $Id$ | 19 | ** $Id$ |
20 | ** | 20 | ** |
21 | **********************************************************************/ | 21 | **********************************************************************/ |
22 | #define QTOPIA_INTERNAL_LANGLIST | 22 | #define QTOPIA_INTERNAL_LANGLIST |
23 | #include <stdlib.h> | 23 | #include <stdlib.h> |
24 | #include <unistd.h> | 24 | #include <unistd.h> |
25 | #include <linux/limits.h> // needed for some toolchains (PATH_MAX) | 25 | #include <linux/limits.h> // needed for some toolchains (PATH_MAX) |
26 | #include <qfile.h> | 26 | #include <qfile.h> |
27 | #ifdef Q_WS_QWS | 27 | #ifdef Q_WS_QWS |
28 | #ifndef QT_NO_COP | 28 | #ifndef QT_NO_COP |
29 | #if QT_VERSION <= 231 | 29 | #if QT_VERSION <= 231 |
30 | #define private public | 30 | #define private public |
31 | #define sendLocally processEvent | 31 | #define sendLocally processEvent |
32 | #include "qcopenvelope_qws.h" | 32 | #include "qcopenvelope_qws.h" |
33 | #undef private | 33 | #undef private |
34 | #else | 34 | #else |
35 | #include "qcopenvelope_qws.h" | 35 | #include "qcopenvelope_qws.h" |
36 | #endif | 36 | #endif |
37 | #endif | 37 | #endif |
38 | #include <qwindowsystem_qws.h> | 38 | #include <qwindowsystem_qws.h> |
39 | #endif | 39 | #endif |
40 | #include <qtextstream.h> | 40 | #include <qtextstream.h> |
41 | #include <qpalette.h> | 41 | #include <qpalette.h> |
42 | #include <qbuffer.h> | 42 | #include <qbuffer.h> |
43 | #include <qptrdict.h> | 43 | #include <qptrdict.h> |
44 | #include <qregexp.h> | 44 | #include <qregexp.h> |
45 | #include <qdir.h> | 45 | #include <qdir.h> |
46 | #include <qlabel.h> | 46 | #include <qlabel.h> |
47 | #include <qdialog.h> | 47 | #include <qdialog.h> |
48 | #include <qdragobject.h> | 48 | #include <qdragobject.h> |
49 | #include <qtextcodec.h> | 49 | #include <qtextcodec.h> |
50 | #include <qevent.h> | 50 | #include <qevent.h> |
51 | #include <qtooltip.h> | 51 | #include <qtooltip.h> |
52 | #include <qsignal.h> | 52 | #include <qsignal.h> |
53 | #include <qmainwindow.h> | ||
53 | #include "qpeapplication.h" | 54 | #include "qpeapplication.h" |
54 | #include "qpestyle.h" | 55 | #include "qpestyle.h" |
55 | #include "styleinterface.h" | 56 | #include "styleinterface.h" |
56 | #if QT_VERSION >= 300 | 57 | #if QT_VERSION >= 300 |
57 | #include <qstylefactory.h> | 58 | #include <qstylefactory.h> |
58 | #else | 59 | #else |
59 | #include <qplatinumstyle.h> | 60 | #include <qplatinumstyle.h> |
60 | #include <qwindowsstyle.h> | 61 | #include <qwindowsstyle.h> |
61 | #include <qmotifstyle.h> | 62 | #include <qmotifstyle.h> |
62 | #include <qmotifplusstyle.h> | 63 | #include <qmotifplusstyle.h> |
63 | #include "lightstyle.h" | 64 | #include "lightstyle.h" |
64 | 65 | ||
65 | #include <qpe/qlibrary.h> | 66 | #include <qpe/qlibrary.h> |
66 | #endif | 67 | #endif |
67 | #include "global.h" | 68 | #include "global.h" |
68 | #include "resource.h" | 69 | #include "resource.h" |
69 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) | 70 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) |
70 | #include "qutfcodec.h" | 71 | #include "qutfcodec.h" |
71 | #endif | 72 | #endif |
72 | #include "config.h" | 73 | #include "config.h" |
73 | #include "network.h" | 74 | #include "network.h" |
74 | #ifdef QWS | 75 | #ifdef QWS |
75 | #include "fontmanager.h" | 76 | #include "fontmanager.h" |
76 | #endif | 77 | #endif |
77 | 78 | ||
78 | #include "alarmserver.h" | 79 | #include "alarmserver.h" |
79 | #include "applnk.h" | 80 | #include "applnk.h" |
80 | #include "qpemenubar.h" | 81 | #include "qpemenubar.h" |
81 | #include "textcodecinterface.h" | 82 | #include "textcodecinterface.h" |
82 | #include "imagecodecinterface.h" | 83 | #include "imagecodecinterface.h" |
83 | 84 | ||
84 | #include <unistd.h> | 85 | #include <unistd.h> |
85 | #include <sys/file.h> | 86 | #include <sys/file.h> |
86 | #include <sys/ioctl.h> | 87 | #include <sys/ioctl.h> |
87 | #include <sys/soundcard.h> | 88 | #include <sys/soundcard.h> |
88 | 89 | ||
89 | #include "qt_override_p.h" | 90 | #include "qt_override_p.h" |
90 | 91 | ||
91 | 92 | ||
92 | class QPEApplicationData | 93 | class QPEApplicationData |
93 | { | 94 | { |
94 | public: | 95 | public: |
95 | QPEApplicationData ( ) | 96 | QPEApplicationData ( ) |
96 | : presstimer( 0 ), presswidget( 0 ), rightpressed( false ), kbgrabbed( false ), | 97 | : presstimer( 0 ), presswidget( 0 ), rightpressed( false ), kbgrabbed( false ), |
97 | notbusysent( false ), preloaded( false ), forceshow( false ), nomaximize( false ), | 98 | notbusysent( false ), preloaded( false ), forceshow( false ), nomaximize( false ), |
98 | keep_running( true ), qpe_main_widget( 0 ) | 99 | keep_running( true ), qpe_main_widget( 0 ) |
99 | 100 | ||
100 | { | 101 | { |
101 | qcopq.setAutoDelete( TRUE ); | 102 | qcopq.setAutoDelete( TRUE ); |
102 | } | 103 | } |
103 | 104 | ||
104 | int presstimer; | 105 | int presstimer; |
105 | QWidget* presswidget; | 106 | QWidget* presswidget; |
106 | QPoint presspos; | 107 | QPoint presspos; |
107 | 108 | ||
108 | bool rightpressed : 1; | 109 | bool rightpressed : 1; |
109 | bool kbgrabbed : 1; | 110 | bool kbgrabbed : 1; |
110 | bool notbusysent : 1; | 111 | bool notbusysent : 1; |
111 | bool preloaded : 1; | 112 | bool preloaded : 1; |
112 | bool forceshow : 1; | 113 | bool forceshow : 1; |
113 | bool nomaximize : 1; | 114 | bool nomaximize : 1; |
114 | bool keep_running : 1; | 115 | bool keep_running : 1; |
115 | 116 | ||
116 | QString appName; | 117 | QString appName; |
117 | struct QCopRec | 118 | struct QCopRec |
118 | { | 119 | { |
119 | QCopRec( const QCString &ch, const QCString &msg, | 120 | QCopRec( const QCString &ch, const QCString &msg, |
120 | const QByteArray &d ) : | 121 | const QByteArray &d ) : |
121 | channel( ch ), message( msg ), data( d ) | 122 | channel( ch ), message( msg ), data( d ) |
122 | { } | 123 | { } |
123 | 124 | ||
124 | QCString channel; | 125 | QCString channel; |
125 | QCString message; | 126 | QCString message; |
126 | QByteArray data; | 127 | QByteArray data; |
127 | }; | 128 | }; |
128 | QWidget* qpe_main_widget; | 129 | QWidget* qpe_main_widget; |
129 | QList<QCopRec> qcopq; | 130 | QList<QCopRec> qcopq; |
130 | 131 | ||
131 | void enqueueQCop( const QCString &ch, const QCString &msg, | 132 | void enqueueQCop( const QCString &ch, const QCString &msg, |
132 | const QByteArray &data ) | 133 | const QByteArray &data ) |
133 | { | 134 | { |
134 | qcopq.append( new QCopRec( ch, msg, data ) ); | 135 | qcopq.append( new QCopRec( ch, msg, data ) ); |
135 | } | 136 | } |
136 | void sendQCopQ() | 137 | void sendQCopQ() |
137 | { | 138 | { |
138 | QCopRec * r; | 139 | QCopRec * r; |
139 | #ifndef QT_NO_COP | 140 | #ifndef QT_NO_COP |
140 | 141 | ||
141 | for ( QListIterator<QCopRec> it( qcopq ); ( r = it.current() ); ++it ) | 142 | for ( QListIterator<QCopRec> it( qcopq ); ( r = it.current() ); ++it ) |
142 | QCopChannel::sendLocally( r->channel, r->message, r->data ); | 143 | QCopChannel::sendLocally( r->channel, r->message, r->data ); |
143 | #endif | 144 | #endif |
144 | 145 | ||
145 | qcopq.clear(); | 146 | qcopq.clear(); |
146 | } | 147 | } |
147 | static void show_mx(QWidget* mw, bool nomaximize) | 148 | static void show_mx(QWidget* mw, bool nomaximize) |
148 | { | 149 | { |
150 | |||
151 | // ugly hack, remove that later after finding a sane solution | ||
152 | if ( QPEApplication::desktop() ->width() >= 600 && ( mw->inherits("QMainWindow") || mw->isA("QMainWindow") ) ) { | ||
153 | ( ( QMainWindow* ) mw )->setUsesBigPixmaps( true ); | ||
154 | } | ||
155 | |||
149 | if ( mw->layout() && mw->inherits("QDialog") ) { | 156 | if ( mw->layout() && mw->inherits("QDialog") ) { |
150 | QPEApplication::showDialog((QDialog*)mw, nomaximize); | 157 | QPEApplication::showDialog((QDialog*)mw, nomaximize); |
151 | } | 158 | } |
152 | else { | 159 | else { |
153 | #ifdef Q_WS_QWS | 160 | #ifdef Q_WS_QWS |
154 | if ( !nomaximize ) | 161 | if ( !nomaximize ) |
155 | mw->showMaximized(); | 162 | mw->showMaximized(); |
156 | else | 163 | else |
157 | #endif | 164 | #endif |
158 | 165 | ||
159 | mw->show(); | 166 | mw->show(); |
160 | } | 167 | } |
161 | } | 168 | } |
162 | static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) | 169 | static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) |
163 | { | 170 | { |
164 | /* | 171 | /* |
165 | // This works but disable it for now until it is safe to apply | 172 | // This works but disable it for now until it is safe to apply |
166 | // What is does is scan the .desktop files of all the apps for | 173 | // What is does is scan the .desktop files of all the apps for |
167 | // the applnk that has the corresponding argv[0] as this program | 174 | // the applnk that has the corresponding argv[0] as this program |
168 | // then it uses the name stored in the .desktop file as the caption | 175 | // then it uses the name stored in the .desktop file as the caption |
169 | // for the main widget. This saves duplicating translations for | 176 | // for the main widget. This saves duplicating translations for |
170 | // the app name in the program and in the .desktop files. | 177 | // the app name in the program and in the .desktop files. |
171 | 178 | ||
172 | AppLnkSet apps( appsPath ); | 179 | AppLnkSet apps( appsPath ); |
173 | 180 | ||
174 | QList<AppLnk> appsList = apps.children(); | 181 | QList<AppLnk> appsList = apps.children(); |
175 | for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { | 182 | for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { |
176 | if ( (*it)->exec() == appName ) { | 183 | if ( (*it)->exec() == appName ) { |
177 | mw->setCaption( (*it)->name() ); | 184 | mw->setCaption( (*it)->name() ); |
178 | return TRUE; | 185 | return TRUE; |
179 | } | 186 | } |
180 | } | 187 | } |
181 | */ | 188 | */ |
182 | return FALSE; | 189 | return FALSE; |
183 | } | 190 | } |
184 | 191 | ||
185 | 192 | ||
186 | void show(QWidget* mw, bool nomax) | 193 | void show(QWidget* mw, bool nomax) |
187 | { | 194 | { |
188 | setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" ); | 195 | setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" ); |
189 | nomaximize = nomax; | 196 | nomaximize = nomax; |
190 | qpe_main_widget = mw; | 197 | qpe_main_widget = mw; |
191 | #ifndef QT_NO_COP | 198 | #ifndef QT_NO_COP |
192 | 199 | ||
193 | sendQCopQ(); | 200 | sendQCopQ(); |
194 | #endif | 201 | #endif |
195 | 202 | ||
196 | if ( preloaded ) { | 203 | if ( preloaded ) { |
197 | if (forceshow) | 204 | if (forceshow) |
198 | show_mx(mw, nomax); | 205 | show_mx(mw, nomax); |
199 | } | 206 | } |
200 | else if ( keep_running ) { | 207 | else if ( keep_running ) { |
201 | show_mx(mw, nomax); | 208 | show_mx(mw, nomax); |
202 | } | 209 | } |
203 | } | 210 | } |
204 | 211 | ||
205 | void loadTextCodecs() | 212 | void loadTextCodecs() |
206 | { | 213 | { |
207 | QString path = QPEApplication::qpeDir() + "/plugins/textcodecs"; | 214 | QString path = QPEApplication::qpeDir() + "/plugins/textcodecs"; |
208 | QDir dir( path, "lib*.so" ); | 215 | QDir dir( path, "lib*.so" ); |
209 | QStringList list; | 216 | QStringList list; |
210 | if ( dir. exists ( )) | 217 | if ( dir. exists ( )) |
211 | list = dir.entryList(); | 218 | list = dir.entryList(); |
212 | QStringList::Iterator it; | 219 | QStringList::Iterator it; |
@@ -447,138 +454,138 @@ static void setTreble( int t = 0, int percent = -1 ) | |||
447 | startOnMonday is TRUE then the first day of the week is Monday; if | 454 | startOnMonday is TRUE then the first day of the week is Monday; if |
448 | \a startOnMonday is FALSE then the first day of the week is | 455 | \a startOnMonday is FALSE then the first day of the week is |
449 | Sunday. | 456 | Sunday. |
450 | */ | 457 | */ |
451 | 458 | ||
452 | /*! | 459 | /*! |
453 | \fn void QPEApplication::dateFormatChanged(DateFormat) | 460 | \fn void QPEApplication::dateFormatChanged(DateFormat) |
454 | 461 | ||
455 | This signal is emitted whenever the date format is changed. | 462 | This signal is emitted whenever the date format is changed. |
456 | */ | 463 | */ |
457 | 464 | ||
458 | /*! | 465 | /*! |
459 | \fn void QPEApplication::flush() | 466 | \fn void QPEApplication::flush() |
460 | 467 | ||
461 | ### | 468 | ### |
462 | */ | 469 | */ |
463 | 470 | ||
464 | /*! | 471 | /*! |
465 | \fn void QPEApplication::reload() | 472 | \fn void QPEApplication::reload() |
466 | 473 | ||
467 | */ | 474 | */ |
468 | 475 | ||
469 | /*! | 476 | /*! |
470 | \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data ) | 477 | \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data ) |
471 | 478 | ||
472 | This signal is emitted when a message is received on this | 479 | This signal is emitted when a message is received on this |
473 | application's QPE/Application/<i>appname</i> \link qcop.html | 480 | application's QPE/Application/<i>appname</i> \link qcop.html |
474 | QCop\endlink channel. | 481 | QCop\endlink channel. |
475 | 482 | ||
476 | The slot to which you connect this signal uses \a msg and \a data | 483 | The slot to which you connect this signal uses \a msg and \a data |
477 | in the following way: | 484 | in the following way: |
478 | 485 | ||
479 | \code | 486 | \code |
480 | void MyWidget::receive( const QCString& msg, const QByteArray& data ) | 487 | void MyWidget::receive( const QCString& msg, const QByteArray& data ) |
481 | { | 488 | { |
482 | QDataStream stream( data, IO_ReadOnly ); | 489 | QDataStream stream( data, IO_ReadOnly ); |
483 | if ( msg == "someMessage(int,int,int)" ) { | 490 | if ( msg == "someMessage(int,int,int)" ) { |
484 | int a,b,c; | 491 | int a,b,c; |
485 | stream >> a >> b >> c; | 492 | stream >> a >> b >> c; |
486 | ... | 493 | ... |
487 | } else if ( msg == "otherMessage(QString)" ) { | 494 | } else if ( msg == "otherMessage(QString)" ) { |
488 | ... | 495 | ... |
489 | } | 496 | } |
490 | } | 497 | } |
491 | \endcode | 498 | \endcode |
492 | 499 | ||
493 | \sa qcop.html | 500 | \sa qcop.html |
494 | Note that messages received here may be processed by qpe application | 501 | Note that messages received here may be processed by qpe application |
495 | and emitted as signals, such as flush() and reload(). | 502 | and emitted as signals, such as flush() and reload(). |
496 | */ | 503 | */ |
497 | 504 | ||
498 | /*! | 505 | /*! |
499 | Constructs a QPEApplication just as you would construct | 506 | Constructs a QPEApplication just as you would construct |
500 | a QApplication, passing \a argc, \a argv, and \a t. | 507 | a QApplication, passing \a argc, \a argv, and \a t. |
501 | 508 | ||
502 | For applications, \a t should be the default, GuiClient. Only | 509 | For applications, \a t should be the default, GuiClient. Only |
503 | the Qtopia server passes GuiServer. | 510 | the Qtopia server passes GuiServer. |
504 | */ | 511 | */ |
505 | QPEApplication::QPEApplication( int & argc, char **argv, Type t ) | 512 | QPEApplication::QPEApplication( int & argc, char **argv, Type t ) |
506 | : QApplication( argc, argv, t ) | 513 | : QApplication( argc, argv, t ) |
507 | { | 514 | { |
508 | d = new QPEApplicationData; | 515 | d = new QPEApplicationData; |
509 | d->loadTextCodecs(); | 516 | d->loadTextCodecs(); |
510 | d->loadImageCodecs(); | 517 | d->loadImageCodecs(); |
511 | int dw = desktop() ->width(); | 518 | int dw = desktop() ->width(); |
512 | 519 | ||
513 | if ( dw < 200 ) { | 520 | if ( dw < 200 ) { |
514 | setFont( QFont( "helvetica", 8 ) ); | 521 | setFont( QFont( "helvetica", 8 ) ); |
515 | AppLnk::setSmallIconSize( 10 ); | 522 | AppLnk::setSmallIconSize( 10 ); |
516 | AppLnk::setBigIconSize( 28 ); | 523 | AppLnk::setBigIconSize( 28 ); |
517 | } | 524 | } |
518 | else if ( dw > 600 ) { | 525 | else if ( dw > 600 ) { |
519 | setFont( QFont( "helvetica", 18 ) ); | 526 | setFont( QFont( "helvetica", 18 ) ); |
520 | AppLnk::setSmallIconSize( 24 ); | 527 | AppLnk::setSmallIconSize( 24 ); |
521 | AppLnk::setBigIconSize( 48 ); | 528 | AppLnk::setBigIconSize( 48 ); |
522 | } | 529 | } |
523 | else if ( dw > 200 ) { | 530 | else if ( dw > 200 ) { |
524 | setFont( QFont( "helvetica", 10 ) ); | 531 | setFont( QFont( "helvetica", 10 ) ); |
525 | AppLnk::setSmallIconSize( 14 ); | 532 | AppLnk::setSmallIconSize( 14 ); |
526 | AppLnk::setBigIconSize( 32 ); | 533 | AppLnk::setBigIconSize( 32 ); |
527 | } | 534 | } |
528 | 535 | ||
529 | 536 | ||
530 | QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory ); | 537 | QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory ); |
531 | 538 | ||
532 | connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) ); | 539 | connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) ); |
533 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 540 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
534 | 541 | ||
535 | QString qcopfn( "/tmp/qcop-msg-" ); | 542 | QString qcopfn( "/tmp/qcop-msg-" ); |
536 | qcopfn += QString( argv[ 0 ] ); // append command name | 543 | qcopfn += QString( argv[ 0 ] ); // append command name |
537 | 544 | ||
538 | QFile f( qcopfn ); | 545 | QFile f( qcopfn ); |
539 | if ( f.open( IO_ReadOnly ) ) { | 546 | if ( f.open( IO_ReadOnly ) ) { |
540 | flock( f.handle(), LOCK_EX ); | 547 | flock( f.handle(), LOCK_EX ); |
541 | } | 548 | } |
542 | 549 | ||
543 | sysChannel = new QCopChannel( "QPE/System", this ); | 550 | sysChannel = new QCopChannel( "QPE/System", this ); |
544 | connect( sysChannel, SIGNAL( received( const QCString &, const QByteArray & ) ), | 551 | connect( sysChannel, SIGNAL( received( const QCString &, const QByteArray & ) ), |
545 | this, SLOT( systemMessage( const QCString &, const QByteArray & ) ) ); | 552 | this, SLOT( systemMessage( const QCString &, const QByteArray & ) ) ); |
546 | 553 | ||
547 | QCString channel = QCString( argv[ 0 ] ); | 554 | QCString channel = QCString( argv[ 0 ] ); |
548 | channel.replace( QRegExp( ".*/" ), "" ); | 555 | channel.replace( QRegExp( ".*/" ), "" ); |
549 | d->appName = channel; | 556 | d->appName = channel; |
550 | channel = "QPE/Application/" + channel; | 557 | channel = "QPE/Application/" + channel; |
551 | pidChannel = new QCopChannel( channel, this ); | 558 | pidChannel = new QCopChannel( channel, this ); |
552 | connect( pidChannel, SIGNAL( received( const QCString &, const QByteArray & ) ), | 559 | connect( pidChannel, SIGNAL( received( const QCString &, const QByteArray & ) ), |
553 | this, SLOT( pidMessage( const QCString &, const QByteArray & ) ) ); | 560 | this, SLOT( pidMessage( const QCString &, const QByteArray & ) ) ); |
554 | 561 | ||
555 | if ( f.isOpen() ) { | 562 | if ( f.isOpen() ) { |
556 | d->keep_running = FALSE; | 563 | d->keep_running = FALSE; |
557 | QDataStream ds( &f ); | 564 | QDataStream ds( &f ); |
558 | QCString channel, message; | 565 | QCString channel, message; |
559 | QByteArray data; | 566 | QByteArray data; |
560 | while ( !ds.atEnd() ) { | 567 | while ( !ds.atEnd() ) { |
561 | ds >> channel >> message >> data; | 568 | ds >> channel >> message >> data; |
562 | d->enqueueQCop( channel, message, data ); | 569 | d->enqueueQCop( channel, message, data ); |
563 | } | 570 | } |
564 | 571 | ||
565 | flock( f.handle(), LOCK_UN ); | 572 | flock( f.handle(), LOCK_UN ); |
566 | f.close(); | 573 | f.close(); |
567 | f.remove(); | 574 | f.remove(); |
568 | } | 575 | } |
569 | 576 | ||
570 | for ( int a = 0; a < argc; a++ ) { | 577 | for ( int a = 0; a < argc; a++ ) { |
571 | if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) { | 578 | if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) { |
572 | argv[ a ] = argv[ a + 1 ]; | 579 | argv[ a ] = argv[ a + 1 ]; |
573 | a++; | 580 | a++; |
574 | d->preloaded = TRUE; | 581 | d->preloaded = TRUE; |
575 | argc -= 1; | 582 | argc -= 1; |
576 | } | 583 | } |
577 | else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) { | 584 | else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) { |
578 | argv[ a ] = argv[ a + 1 ]; | 585 | argv[ a ] = argv[ a + 1 ]; |
579 | a++; | 586 | a++; |
580 | d->preloaded = TRUE; | 587 | d->preloaded = TRUE; |
581 | d->forceshow = TRUE; | 588 | d->forceshow = TRUE; |
582 | argc -= 1; | 589 | argc -= 1; |
583 | } | 590 | } |
584 | } | 591 | } |
@@ -802,128 +809,130 @@ bool QPEApplication::qwsEventFilter( QWSEvent * e ) | |||
802 | return TRUE; | 809 | return TRUE; |
803 | } | 810 | } |
804 | else if ( strcmp( argv() [ 0 ], "embeddedkonsole" ) != 0 ) { | 811 | else if ( strcmp( argv() [ 0 ], "embeddedkonsole" ) != 0 ) { |
805 | active->close(); | 812 | active->close(); |
806 | } | 813 | } |
807 | } | 814 | } |
808 | } | 815 | } |
809 | else if ( ke->simpleData.keycode >= Qt::Key_F1 && ke->simpleData.keycode <= Qt::Key_F29 ) { | 816 | else if ( ke->simpleData.keycode >= Qt::Key_F1 && ke->simpleData.keycode <= Qt::Key_F29 ) { |
810 | // this should be if ( ODevice::inst ( )-> buttonForKeycode ( ... )) | 817 | // this should be if ( ODevice::inst ( )-> buttonForKeycode ( ... )) |
811 | // but we cannot access libopie function within libqpe :( | 818 | // but we cannot access libopie function within libqpe :( |
812 | 819 | ||
813 | QWidget * active = activeWindow ( ); | 820 | QWidget * active = activeWindow ( ); |
814 | if ( active && ((int) active-> winId ( ) == ke-> simpleData.window )) { | 821 | if ( active && ((int) active-> winId ( ) == ke-> simpleData.window )) { |
815 | if ( d-> kbgrabbed ) { // we grabbed the keyboard | 822 | if ( d-> kbgrabbed ) { // we grabbed the keyboard |
816 | QChar ch ( ke-> simpleData.unicode ); | 823 | QChar ch ( ke-> simpleData.unicode ); |
817 | QKeyEvent qke ( ke-> simpleData. is_press ? QEvent::KeyPress : QEvent::KeyRelease, | 824 | QKeyEvent qke ( ke-> simpleData. is_press ? QEvent::KeyPress : QEvent::KeyRelease, |
818 | ke-> simpleData.keycode, | 825 | ke-> simpleData.keycode, |
819 | ch. latin1 ( ), | 826 | ch. latin1 ( ), |
820 | ke-> simpleData.modifiers, | 827 | ke-> simpleData.modifiers, |
821 | QString ( ch ), | 828 | QString ( ch ), |
822 | ke-> simpleData.is_auto_repeat, 1 ); | 829 | ke-> simpleData.is_auto_repeat, 1 ); |
823 | 830 | ||
824 | QObject *which = QWidget::keyboardGrabber ( ); | 831 | QObject *which = QWidget::keyboardGrabber ( ); |
825 | if ( !which ) | 832 | if ( !which ) |
826 | which = QApplication::focusWidget ( ); | 833 | which = QApplication::focusWidget ( ); |
827 | if ( !which ) | 834 | if ( !which ) |
828 | which = QApplication::activeWindow ( ); | 835 | which = QApplication::activeWindow ( ); |
829 | if ( !which ) | 836 | if ( !which ) |
830 | which = qApp; | 837 | which = qApp; |
831 | 838 | ||
832 | QApplication::sendEvent ( which, &qke ); | 839 | QApplication::sendEvent ( which, &qke ); |
833 | } | 840 | } |
834 | else { // we didn't grab the keyboard, so send the event to the launcher | 841 | else { // we didn't grab the keyboard, so send the event to the launcher |
835 | QCopEnvelope e ( "QPE/Launcher", "deviceButton(int,int,int)" ); | 842 | QCopEnvelope e ( "QPE/Launcher", "deviceButton(int,int,int)" ); |
836 | e << int( ke-> simpleData.keycode ) << int( ke-> simpleData. is_press ) << int( ke-> simpleData.is_auto_repeat ); | 843 | e << int( ke-> simpleData.keycode ) << int( ke-> simpleData. is_press ) << int( ke-> simpleData.is_auto_repeat ); |
837 | } | 844 | } |
838 | } | 845 | } |
839 | return true; | 846 | return true; |
840 | } | 847 | } |
841 | } | 848 | } |
842 | if ( e->type == QWSEvent::Focus ) { | 849 | if ( e->type == QWSEvent::Focus ) { |
843 | QWSFocusEvent * fe = ( QWSFocusEvent* ) e; | 850 | QWSFocusEvent * fe = ( QWSFocusEvent* ) e; |
844 | if ( !fe->simpleData.get_focus ) { | 851 | if ( !fe->simpleData.get_focus ) { |
845 | QWidget * active = activeWindow(); | 852 | QWidget * active = activeWindow(); |
846 | while ( active && active->isPopup() ) { | 853 | while ( active && active->isPopup() ) { |
847 | active->close(); | 854 | active->close(); |
848 | active = activeWindow(); | 855 | active = activeWindow(); |
849 | } | 856 | } |
850 | } | 857 | } |
851 | else { | 858 | else { |
852 | // make sure our modal widget is ALWAYS on top | 859 | // make sure our modal widget is ALWAYS on top |
853 | QWidget *topm = activeModalWidget(); | 860 | QWidget *topm = activeModalWidget(); |
854 | if ( topm ) { | 861 | if ( topm ) { |
855 | topm->raise(); | 862 | topm->raise(); |
856 | } | 863 | } |
857 | } | 864 | } |
858 | if ( fe->simpleData.get_focus && inputMethodDict ) { | 865 | if ( fe->simpleData.get_focus && inputMethodDict ) { |
859 | InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) ); | 866 | InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) ); |
860 | if ( m == AlwaysOff ) | 867 | if ( m == AlwaysOff ) |
861 | Global::hideInputMethod(); | 868 | Global::hideInputMethod(); |
862 | if ( m == AlwaysOn ) | 869 | if ( m == AlwaysOn ) |
863 | Global::showInputMethod(); | 870 | Global::showInputMethod(); |
864 | } | 871 | } |
865 | } | 872 | } |
873 | |||
874 | |||
866 | return QApplication::qwsEventFilter( e ); | 875 | return QApplication::qwsEventFilter( e ); |
867 | } | 876 | } |
868 | #endif | 877 | #endif |
869 | 878 | ||
870 | /*! | 879 | /*! |
871 | Destroys the QPEApplication. | 880 | Destroys the QPEApplication. |
872 | */ | 881 | */ |
873 | QPEApplication::~QPEApplication() | 882 | QPEApplication::~QPEApplication() |
874 | { | 883 | { |
875 | ungrabKeyboard(); | 884 | ungrabKeyboard(); |
876 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 885 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
877 | // Need to delete QCopChannels early, since the display will | 886 | // Need to delete QCopChannels early, since the display will |
878 | // be gone by the time we get to ~QObject(). | 887 | // be gone by the time we get to ~QObject(). |
879 | delete sysChannel; | 888 | delete sysChannel; |
880 | delete pidChannel; | 889 | delete pidChannel; |
881 | #endif | 890 | #endif |
882 | 891 | ||
883 | delete d; | 892 | delete d; |
884 | } | 893 | } |
885 | 894 | ||
886 | /*! | 895 | /*! |
887 | Returns <tt>$OPIEDIR/</tt>. | 896 | Returns <tt>$OPIEDIR/</tt>. |
888 | */ | 897 | */ |
889 | QString QPEApplication::qpeDir() | 898 | QString QPEApplication::qpeDir() |
890 | { | 899 | { |
891 | const char * base = getenv( "OPIEDIR" ); | 900 | const char * base = getenv( "OPIEDIR" ); |
892 | if ( base ) | 901 | if ( base ) |
893 | return QString( base ) + "/"; | 902 | return QString( base ) + "/"; |
894 | 903 | ||
895 | return QString( "../" ); | 904 | return QString( "../" ); |
896 | } | 905 | } |
897 | 906 | ||
898 | /*! | 907 | /*! |
899 | Returns the user's current Document directory. There is a trailing "/". | 908 | Returns the user's current Document directory. There is a trailing "/". |
900 | .. well, it does now,, and there's no trailing '/' | 909 | .. well, it does now,, and there's no trailing '/' |
901 | */ | 910 | */ |
902 | QString QPEApplication::documentDir() | 911 | QString QPEApplication::documentDir() |
903 | { | 912 | { |
904 | const char* base = getenv( "HOME"); | 913 | const char* base = getenv( "HOME"); |
905 | if ( base ) | 914 | if ( base ) |
906 | return QString( base ) + "/Documents"; | 915 | return QString( base ) + "/Documents"; |
907 | 916 | ||
908 | return QString( "../Documents" ); | 917 | return QString( "../Documents" ); |
909 | } | 918 | } |
910 | 919 | ||
911 | static int deforient = -1; | 920 | static int deforient = -1; |
912 | 921 | ||
913 | /*! | 922 | /*! |
914 | \internal | 923 | \internal |
915 | */ | 924 | */ |
916 | int QPEApplication::defaultRotation() | 925 | int QPEApplication::defaultRotation() |
917 | { | 926 | { |
918 | if ( deforient < 0 ) { | 927 | if ( deforient < 0 ) { |
919 | QString d = getenv( "QWS_DISPLAY" ); | 928 | QString d = getenv( "QWS_DISPLAY" ); |
920 | if ( d.contains( "Rot90" ) ) { | 929 | if ( d.contains( "Rot90" ) ) { |
921 | deforient = 90; | 930 | deforient = 90; |
922 | } | 931 | } |
923 | else if ( d.contains( "Rot180" ) ) { | 932 | else if ( d.contains( "Rot180" ) ) { |
924 | deforient = 180; | 933 | deforient = 180; |
925 | } | 934 | } |
926 | else if ( d.contains( "Rot270" ) ) { | 935 | else if ( d.contains( "Rot270" ) ) { |
927 | deforient = 270; | 936 | deforient = 270; |
928 | } | 937 | } |
929 | else { | 938 | else { |
@@ -1256,147 +1265,148 @@ void QPEApplication::pidMessage( const QCString& msg, const QByteArray& data) | |||
1256 | hideOrQuit(); | 1265 | hideOrQuit(); |
1257 | } | 1266 | } |
1258 | else if ( msg == "disablePreload()" ) { | 1267 | else if ( msg == "disablePreload()" ) { |
1259 | d->preloaded = FALSE; | 1268 | d->preloaded = FALSE; |
1260 | d->keep_running = TRUE; | 1269 | d->keep_running = TRUE; |
1261 | /* so that quit will quit */ | 1270 | /* so that quit will quit */ |
1262 | } | 1271 | } |
1263 | else if ( msg == "enablePreload()" ) { | 1272 | else if ( msg == "enablePreload()" ) { |
1264 | if (d->qpe_main_widget) | 1273 | if (d->qpe_main_widget) |
1265 | d->preloaded = TRUE; | 1274 | d->preloaded = TRUE; |
1266 | d->keep_running = TRUE; | 1275 | d->keep_running = TRUE; |
1267 | /* so next quit won't quit */ | 1276 | /* so next quit won't quit */ |
1268 | } | 1277 | } |
1269 | else if ( msg == "raise()" ) { | 1278 | else if ( msg == "raise()" ) { |
1270 | d->keep_running = TRUE; | 1279 | d->keep_running = TRUE; |
1271 | d->notbusysent = FALSE; | 1280 | d->notbusysent = FALSE; |
1272 | raiseAppropriateWindow(); | 1281 | raiseAppropriateWindow(); |
1273 | // Tell the system we're still chugging along... | 1282 | // Tell the system we're still chugging along... |
1274 | QCopEnvelope e("QPE/System", "appRaised(QString)"); | 1283 | QCopEnvelope e("QPE/System", "appRaised(QString)"); |
1275 | e << d->appName; | 1284 | e << d->appName; |
1276 | } | 1285 | } |
1277 | else if ( msg == "flush()" ) { | 1286 | else if ( msg == "flush()" ) { |
1278 | emit flush(); | 1287 | emit flush(); |
1279 | // we need to tell the desktop | 1288 | // we need to tell the desktop |
1280 | QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" ); | 1289 | QCopEnvelope e( "QPE/Desktop", "flushDone(QString)" ); |
1281 | e << d->appName; | 1290 | e << d->appName; |
1282 | } | 1291 | } |
1283 | else if ( msg == "reload()" ) { | 1292 | else if ( msg == "reload()" ) { |
1284 | emit reload(); | 1293 | emit reload(); |
1285 | } | 1294 | } |
1286 | else if ( msg == "setDocument(QString)" ) { | 1295 | else if ( msg == "setDocument(QString)" ) { |
1287 | d->keep_running = TRUE; | 1296 | d->keep_running = TRUE; |
1288 | QDataStream stream( data, IO_ReadOnly ); | 1297 | QDataStream stream( data, IO_ReadOnly ); |
1289 | QString doc; | 1298 | QString doc; |
1290 | stream >> doc; | 1299 | stream >> doc; |
1291 | QWidget *mw = mainWidget(); | 1300 | QWidget *mw = mainWidget(); |
1292 | if ( !mw ) | 1301 | if ( !mw ) |
1293 | mw = d->qpe_main_widget; | 1302 | mw = d->qpe_main_widget; |
1294 | if ( mw ) | 1303 | if ( mw ) |
1295 | Global::setDocument( mw, doc ); | 1304 | Global::setDocument( mw, doc ); |
1296 | } | 1305 | } |
1297 | else if ( msg == "nextView()" ) { | 1306 | else if ( msg == "nextView()" ) { |
1298 | qDebug("got nextView()"); | 1307 | qDebug("got nextView()"); |
1299 | /* | 1308 | /* |
1300 | if ( raiseAppropriateWindow() ) | 1309 | if ( raiseAppropriateWindow() ) |
1301 | */ | 1310 | */ |
1302 | emit appMessage( msg, data); | 1311 | emit appMessage( msg, data); |
1303 | } | 1312 | } |
1304 | else { | 1313 | else { |
1305 | emit appMessage( msg, data); | 1314 | emit appMessage( msg, data); |
1306 | } | 1315 | } |
1307 | 1316 | ||
1308 | #endif | 1317 | #endif |
1309 | } | 1318 | } |
1310 | 1319 | ||
1311 | 1320 | ||
1312 | /*! | 1321 | /*! |
1313 | Sets widget \a mw as the mainWidget() and shows it. For small windows, | 1322 | Sets widget \a mw as the mainWidget() and shows it. For small windows, |
1314 | consider passing TRUE for \a nomaximize rather than the default FALSE. | 1323 | consider passing TRUE for \a nomaximize rather than the default FALSE. |
1315 | 1324 | ||
1316 | \sa showMainDocumentWidget() | 1325 | \sa showMainDocumentWidget() |
1317 | */ | 1326 | */ |
1318 | void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize ) | 1327 | void QPEApplication::showMainWidget( QWidget* mw, bool nomaximize ) |
1319 | { | 1328 | { |
1320 | d->show(mw, nomaximize ); | 1329 | d->show(mw, nomaximize ); |
1321 | } | 1330 | } |
1322 | 1331 | ||
1323 | /*! | 1332 | /*! |
1324 | Sets widget \a mw as the mainWidget() and shows it. For small windows, | 1333 | Sets widget \a mw as the mainWidget() and shows it. For small windows, |
1325 | consider passing TRUE for \a nomaximize rather than the default FALSE. | 1334 | consider passing TRUE for \a nomaximize rather than the default FALSE. |
1326 | 1335 | ||
1327 | This calls designates the application as | 1336 | This calls designates the application as |
1328 | a \link docwidget.html document-oriented\endlink application. | 1337 | a \link docwidget.html document-oriented\endlink application. |
1329 | 1338 | ||
1330 | The \a mw widget \e must have this slot: setDocument(const QString&). | 1339 | The \a mw widget \e must have this slot: setDocument(const QString&). |
1331 | 1340 | ||
1332 | \sa showMainWidget() | 1341 | \sa showMainWidget() |
1333 | */ | 1342 | */ |
1334 | void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize ) | 1343 | void QPEApplication::showMainDocumentWidget( QWidget* mw, bool nomaximize ) |
1335 | { | 1344 | { |
1336 | if ( mw && argc() == 2 ) | 1345 | if ( mw && argc() == 2 ) |
1337 | Global::setDocument( mw, QString::fromUtf8(argv()[1]) ); | 1346 | Global::setDocument( mw, QString::fromUtf8(argv()[1]) ); |
1338 | 1347 | ||
1348 | |||
1339 | d->show(mw, nomaximize ); | 1349 | d->show(mw, nomaximize ); |
1340 | } | 1350 | } |
1341 | 1351 | ||
1342 | 1352 | ||
1343 | /*! | 1353 | /*! |
1344 | If an application is started via a \link qcop.html QCop\endlink | 1354 | If an application is started via a \link qcop.html QCop\endlink |
1345 | message, the application will process the \link qcop.html | 1355 | message, the application will process the \link qcop.html |
1346 | QCop\endlink message and then quit. If the application calls this | 1356 | QCop\endlink message and then quit. If the application calls this |
1347 | function while processing a \link qcop.html QCop\endlink message, | 1357 | function while processing a \link qcop.html QCop\endlink message, |
1348 | after processing its outstanding \link qcop.html QCop\endlink | 1358 | after processing its outstanding \link qcop.html QCop\endlink |
1349 | messages the application will start 'properly' and show itself. | 1359 | messages the application will start 'properly' and show itself. |
1350 | 1360 | ||
1351 | \sa keepRunning() | 1361 | \sa keepRunning() |
1352 | */ | 1362 | */ |
1353 | void QPEApplication::setKeepRunning() | 1363 | void QPEApplication::setKeepRunning() |
1354 | { | 1364 | { |
1355 | if ( qApp && qApp->inherits( "QPEApplication" ) ) { | 1365 | if ( qApp && qApp->inherits( "QPEApplication" ) ) { |
1356 | QPEApplication * qpeApp = ( QPEApplication* ) qApp; | 1366 | QPEApplication * qpeApp = ( QPEApplication* ) qApp; |
1357 | qpeApp->d->keep_running = TRUE; | 1367 | qpeApp->d->keep_running = TRUE; |
1358 | } | 1368 | } |
1359 | } | 1369 | } |
1360 | 1370 | ||
1361 | /*! | 1371 | /*! |
1362 | Returns TRUE if the application will quit after processing the | 1372 | Returns TRUE if the application will quit after processing the |
1363 | current list of qcop messages; otherwise returns FALSE. | 1373 | current list of qcop messages; otherwise returns FALSE. |
1364 | 1374 | ||
1365 | \sa setKeepRunning() | 1375 | \sa setKeepRunning() |
1366 | */ | 1376 | */ |
1367 | bool QPEApplication::keepRunning() const | 1377 | bool QPEApplication::keepRunning() const |
1368 | { | 1378 | { |
1369 | return d->keep_running; | 1379 | return d->keep_running; |
1370 | } | 1380 | } |
1371 | 1381 | ||
1372 | /*! | 1382 | /*! |
1373 | \internal | 1383 | \internal |
1374 | */ | 1384 | */ |
1375 | void QPEApplication::internalSetStyle( const QString &style ) | 1385 | void QPEApplication::internalSetStyle( const QString &style ) |
1376 | { | 1386 | { |
1377 | #if QT_VERSION >= 300 | 1387 | #if QT_VERSION >= 300 |
1378 | if ( style == "QPE" ) { | 1388 | if ( style == "QPE" ) { |
1379 | setStyle( new QPEStyle ); | 1389 | setStyle( new QPEStyle ); |
1380 | } | 1390 | } |
1381 | else { | 1391 | else { |
1382 | QStyle *s = QStyleFactory::create( style ); | 1392 | QStyle *s = QStyleFactory::create( style ); |
1383 | if ( s ) | 1393 | if ( s ) |
1384 | setStyle( s ); | 1394 | setStyle( s ); |
1385 | } | 1395 | } |
1386 | #else | 1396 | #else |
1387 | if ( style == "Windows" ) { | 1397 | if ( style == "Windows" ) { |
1388 | setStyle( new QWindowsStyle ); | 1398 | setStyle( new QWindowsStyle ); |
1389 | } | 1399 | } |
1390 | else if ( style == "QPE" ) { | 1400 | else if ( style == "QPE" ) { |
1391 | setStyle( new QPEStyle ); | 1401 | setStyle( new QPEStyle ); |
1392 | } | 1402 | } |
1393 | else if ( style == "Light" ) { | 1403 | else if ( style == "Light" ) { |
1394 | setStyle( new LightStyle ); | 1404 | setStyle( new LightStyle ); |
1395 | } | 1405 | } |
1396 | #ifndef QT_NO_STYLE_PLATINUM | 1406 | #ifndef QT_NO_STYLE_PLATINUM |
1397 | else if ( style == "Platinum" ) { | 1407 | else if ( style == "Platinum" ) { |
1398 | setStyle( new QPlatinumStyle ); | 1408 | setStyle( new QPlatinumStyle ); |
1399 | } | 1409 | } |
1400 | #endif | 1410 | #endif |
1401 | #ifndef QT_NO_STYLE_MOTIF | 1411 | #ifndef QT_NO_STYLE_MOTIF |
1402 | else if ( style == "Motif" ) { | 1412 | else if ( style == "Motif" ) { |