-rw-r--r-- | library/qpeapplication.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp index feba8b6..cd1c62e 100644 --- a/library/qpeapplication.cpp +++ b/library/qpeapplication.cpp | |||
@@ -74,193 +74,193 @@ | |||
74 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) | 74 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) |
75 | #include "qutfcodec.h" | 75 | #include "qutfcodec.h" |
76 | #endif | 76 | #endif |
77 | #include "config.h" | 77 | #include "config.h" |
78 | #include "network.h" | 78 | #include "network.h" |
79 | #ifdef QWS | 79 | #ifdef QWS |
80 | #include "fontmanager.h" | 80 | #include "fontmanager.h" |
81 | #endif | 81 | #endif |
82 | 82 | ||
83 | #include "alarmserver.h" | 83 | #include "alarmserver.h" |
84 | #include "applnk.h" | 84 | #include "applnk.h" |
85 | #include "qpemenubar.h" | 85 | #include "qpemenubar.h" |
86 | #include "textcodecinterface.h" | 86 | #include "textcodecinterface.h" |
87 | #include "imagecodecinterface.h" | 87 | #include "imagecodecinterface.h" |
88 | 88 | ||
89 | #include <unistd.h> | 89 | #include <unistd.h> |
90 | #include <sys/file.h> | 90 | #include <sys/file.h> |
91 | #include <sys/ioctl.h> | 91 | #include <sys/ioctl.h> |
92 | #include <sys/soundcard.h> | 92 | #include <sys/soundcard.h> |
93 | 93 | ||
94 | #include "qt_override_p.h" | 94 | #include "qt_override_p.h" |
95 | 95 | ||
96 | 96 | ||
97 | class QPEApplicationData | 97 | class QPEApplicationData |
98 | { | 98 | { |
99 | public: | 99 | public: |
100 | QPEApplicationData ( ) | 100 | QPEApplicationData ( ) |
101 | : presstimer( 0 ), presswidget( 0 ), rightpressed( false ), kbgrabbed( false ), | 101 | : presstimer( 0 ), presswidget( 0 ), rightpressed( false ), kbgrabbed( false ), |
102 | notbusysent( false ), preloaded( false ), forceshow( false ), nomaximize( false ), | 102 | notbusysent( false ), preloaded( false ), forceshow( false ), nomaximize( false ), |
103 | keep_running( true ), qcopQok( false ), qpe_main_widget( 0 ) | 103 | keep_running( true ), qcopQok( false ), qpe_main_widget( 0 ) |
104 | 104 | ||
105 | {} | 105 | {} |
106 | 106 | ||
107 | int presstimer; | 107 | int presstimer; |
108 | QWidget* presswidget; | 108 | QWidget* presswidget; |
109 | QPoint presspos; | 109 | QPoint presspos; |
110 | 110 | ||
111 | bool rightpressed : 1; | 111 | bool rightpressed : 1; |
112 | bool kbgrabbed : 1; | 112 | bool kbgrabbed : 1; |
113 | bool notbusysent : 1; | 113 | bool notbusysent : 1; |
114 | bool preloaded : 1; | 114 | bool preloaded : 1; |
115 | bool forceshow : 1; | 115 | bool forceshow : 1; |
116 | bool nomaximize : 1; | 116 | bool nomaximize : 1; |
117 | bool keep_running : 1; | 117 | bool keep_running : 1; |
118 | bool qcopQok : 1; | 118 | bool qcopQok : 1; |
119 | 119 | ||
120 | 120 | ||
121 | QStringList langs; | 121 | QStringList langs; |
122 | QString appName; | 122 | QString appName; |
123 | struct QCopRec | 123 | struct QCopRec |
124 | { | 124 | { |
125 | QCopRec( const QCString &ch, const QCString &msg, | 125 | QCopRec( const QCString &ch, const QCString &msg, |
126 | const QByteArray &d ) : | 126 | const QByteArray &d ) : |
127 | channel( ch ), message( msg ), data( d ) | 127 | channel( ch ), message( msg ), data( d ) |
128 | { } | 128 | { } |
129 | 129 | ||
130 | QCString channel; | 130 | QCString channel; |
131 | QCString message; | 131 | QCString message; |
132 | QByteArray data; | 132 | QByteArray data; |
133 | }; | 133 | }; |
134 | QWidget* qpe_main_widget; | 134 | QWidget* qpe_main_widget; |
135 | QGuardedPtr<QWidget> lastraised; | 135 | QGuardedPtr<QWidget> lastraised; |
136 | QQueue<QCopRec> qcopq; | 136 | QQueue<QCopRec> qcopq; |
137 | QString styleName; | 137 | QString styleName; |
138 | QString decorationName; | 138 | QString decorationName; |
139 | 139 | ||
140 | void enqueueQCop( const QCString &ch, const QCString &msg, | 140 | void enqueueQCop( const QCString &ch, const QCString &msg, |
141 | const QByteArray &data ) | 141 | const QByteArray &data ) |
142 | { | 142 | { |
143 | qcopq.enqueue( new QCopRec( ch, msg, data ) ); | 143 | qcopq.enqueue( new QCopRec( ch, msg, data ) ); |
144 | } | 144 | } |
145 | void sendQCopQ() | 145 | void sendQCopQ() |
146 | { | 146 | { |
147 | if (!qcopQok ) | 147 | if (!qcopQok ) |
148 | return; | 148 | return; |
149 | 149 | ||
150 | QCopRec * r; | 150 | QCopRec * r; |
151 | 151 | ||
152 | while((r=qcopq.dequeue())) { | 152 | while((r=qcopq.dequeue())) { |
153 | // remove from queue before sending... | 153 | // remove from queue before sending... |
154 | // event loop can come around again before getting | 154 | // event loop can come around again before getting |
155 | // back from sendLocally | 155 | // back from sendLocally |
156 | #ifndef QT_NO_COP | 156 | #ifndef QT_NO_COP |
157 | QCopChannel::sendLocally( r->channel, r->message, r->data ); | 157 | QCopChannel::sendLocally( r->channel, r->message, r->data ); |
158 | #endif | 158 | #endif |
159 | 159 | ||
160 | delete r; | 160 | delete r; |
161 | } | 161 | } |
162 | } | 162 | } |
163 | static void show_mx(QWidget* mw, bool nomaximize, const QString & = QString::null ) | 163 | static void show_mx(QWidget* mw, bool nomaximize, const QString & = QString::null ) |
164 | { | 164 | { |
165 | 165 | ||
166 | // ugly hack, remove that later after finding a sane solution | 166 | // ugly hack, remove that later after finding a sane solution |
167 | // Addendum: Only Sharp currently has models with high resolution but (physically) small displays, | 167 | // Addendum: Only Sharp currently has models with high resolution but (physically) small displays, |
168 | // so this is only useful if QT_QWS_SIMPAD is NOT defined. E.g. SIMpad has 800x600 but has | 168 | // so this is only useful if QT_QWS_SIMPAD is NOT defined. E.g. SIMpad has 800x600 but has |
169 | // a (physically) large enough display to use the small icons | 169 | // a (physically) large enough display to use the small icons |
170 | #ifndef QT_QWS_SIMPAD | 170 | #if defined(OPIE_HIGH_RES_SMALL_PHY) |
171 | if ( QPEApplication::desktop() ->width() >= 600 && ( mw->inherits("QMainWindow") || mw->isA("QMainWindow") ) ) { | 171 | if ( QPEApplication::desktop() ->width() >= 600 && ( mw->inherits("QMainWindow") || mw->isA("QMainWindow") ) ) { |
172 | ( ( QMainWindow* ) mw )->setUsesBigPixmaps( true ); | 172 | ( ( QMainWindow* ) mw )->setUsesBigPixmaps( true ); |
173 | } | 173 | } |
174 | #endif | 174 | #endif |
175 | 175 | ||
176 | if ( mw->layout() && mw->inherits("QDialog") ) { | 176 | if ( mw->layout() && mw->inherits("QDialog") ) { |
177 | QPEApplication::showDialog((QDialog*)mw, nomaximize); | 177 | QPEApplication::showDialog((QDialog*)mw, nomaximize); |
178 | } | 178 | } |
179 | else { | 179 | else { |
180 | #ifdef Q_WS_QWS | 180 | #ifdef Q_WS_QWS |
181 | if ( !nomaximize ) | 181 | if ( !nomaximize ) |
182 | mw->showMaximized(); | 182 | mw->showMaximized(); |
183 | else | 183 | else |
184 | #endif | 184 | #endif |
185 | 185 | ||
186 | mw->show(); | 186 | mw->show(); |
187 | } | 187 | } |
188 | } | 188 | } |
189 | static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) | 189 | static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) |
190 | { | 190 | { |
191 | /* | 191 | /* |
192 | // This works but disable it for now until it is safe to apply | 192 | // This works but disable it for now until it is safe to apply |
193 | // What is does is scan the .desktop files of all the apps for | 193 | // What is does is scan the .desktop files of all the apps for |
194 | // the applnk that has the corresponding argv[0] as this program | 194 | // the applnk that has the corresponding argv[0] as this program |
195 | // then it uses the name stored in the .desktop file as the caption | 195 | // then it uses the name stored in the .desktop file as the caption |
196 | // for the main widget. This saves duplicating translations for | 196 | // for the main widget. This saves duplicating translations for |
197 | // the app name in the program and in the .desktop files. | 197 | // the app name in the program and in the .desktop files. |
198 | 198 | ||
199 | AppLnkSet apps( appsPath ); | 199 | AppLnkSet apps( appsPath ); |
200 | 200 | ||
201 | QList<AppLnk> appsList = apps.children(); | 201 | QList<AppLnk> appsList = apps.children(); |
202 | for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { | 202 | for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { |
203 | if ( (*it)->exec() == appName ) { | 203 | if ( (*it)->exec() == appName ) { |
204 | mw->setCaption( (*it)->name() ); | 204 | mw->setCaption( (*it)->name() ); |
205 | return TRUE; | 205 | return TRUE; |
206 | } | 206 | } |
207 | } | 207 | } |
208 | */ | 208 | */ |
209 | return FALSE; | 209 | return FALSE; |
210 | } | 210 | } |
211 | 211 | ||
212 | 212 | ||
213 | void show(QWidget* mw, bool nomax) | 213 | void show(QWidget* mw, bool nomax) |
214 | { | 214 | { |
215 | setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" ); | 215 | setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" ); |
216 | nomaximize = nomax; | 216 | nomaximize = nomax; |
217 | qpe_main_widget = mw; | 217 | qpe_main_widget = mw; |
218 | qcopQok = TRUE; | 218 | qcopQok = TRUE; |
219 | #ifndef QT_NO_COP | 219 | #ifndef QT_NO_COP |
220 | 220 | ||
221 | sendQCopQ(); | 221 | sendQCopQ(); |
222 | #endif | 222 | #endif |
223 | 223 | ||
224 | if ( preloaded ) { | 224 | if ( preloaded ) { |
225 | if (forceshow) | 225 | if (forceshow) |
226 | show_mx(mw, nomax); | 226 | show_mx(mw, nomax); |
227 | } | 227 | } |
228 | else if ( keep_running ) { | 228 | else if ( keep_running ) { |
229 | show_mx(mw, nomax); | 229 | show_mx(mw, nomax); |
230 | } | 230 | } |
231 | } | 231 | } |
232 | 232 | ||
233 | void loadTextCodecs() | 233 | void loadTextCodecs() |
234 | { | 234 | { |
235 | QString path = QPEApplication::qpeDir() + "/plugins/textcodecs"; | 235 | QString path = QPEApplication::qpeDir() + "/plugins/textcodecs"; |
236 | QDir dir( path, "lib*.so" ); | 236 | QDir dir( path, "lib*.so" ); |
237 | QStringList list; | 237 | QStringList list; |
238 | if ( dir. exists ( )) | 238 | if ( dir. exists ( )) |
239 | list = dir.entryList(); | 239 | list = dir.entryList(); |
240 | QStringList::Iterator it; | 240 | QStringList::Iterator it; |
241 | for ( it = list.begin(); it != list.end(); ++it ) { | 241 | for ( it = list.begin(); it != list.end(); ++it ) { |
242 | TextCodecInterface *iface = 0; | 242 | TextCodecInterface *iface = 0; |
243 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 243 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
244 | if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { | 244 | if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { |
245 | QValueList<int> mibs = iface->mibEnums(); | 245 | QValueList<int> mibs = iface->mibEnums(); |
246 | for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) { | 246 | for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) { |
247 | (void)iface->createForMib(*i); | 247 | (void)iface->createForMib(*i); |
248 | // ### it exists now; need to remember if we can delete it | 248 | // ### it exists now; need to remember if we can delete it |
249 | } | 249 | } |
250 | } | 250 | } |
251 | else { | 251 | else { |
252 | lib->unload(); | 252 | lib->unload(); |
253 | delete lib; | 253 | delete lib; |
254 | } | 254 | } |
255 | } | 255 | } |
256 | } | 256 | } |
257 | 257 | ||
258 | void loadImageCodecs() | 258 | void loadImageCodecs() |
259 | { | 259 | { |
260 | QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs"; | 260 | QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs"; |
261 | QDir dir( path, "lib*.so" ); | 261 | QDir dir( path, "lib*.so" ); |
262 | QStringList list; | 262 | QStringList list; |
263 | if ( dir. exists ( )) | 263 | if ( dir. exists ( )) |
264 | list = dir.entryList(); | 264 | list = dir.entryList(); |
265 | QStringList::Iterator it; | 265 | QStringList::Iterator it; |
266 | for ( it = list.begin(); it != list.end(); ++it ) { | 266 | for ( it = list.begin(); it != list.end(); ++it ) { |
@@ -497,196 +497,196 @@ static void setTreble( int t = 0, int percent = -1 ) | |||
497 | \fn void QPEApplication::dateFormatChanged(DateFormat) | 497 | \fn void QPEApplication::dateFormatChanged(DateFormat) |
498 | 498 | ||
499 | This signal is emitted whenever the date format is changed. | 499 | This signal is emitted whenever the date format is changed. |
500 | */ | 500 | */ |
501 | 501 | ||
502 | /*! | 502 | /*! |
503 | \fn void QPEApplication::flush() | 503 | \fn void QPEApplication::flush() |
504 | 504 | ||
505 | ### | 505 | ### |
506 | */ | 506 | */ |
507 | 507 | ||
508 | /*! | 508 | /*! |
509 | \fn void QPEApplication::reload() | 509 | \fn void QPEApplication::reload() |
510 | 510 | ||
511 | */ | 511 | */ |
512 | 512 | ||
513 | 513 | ||
514 | 514 | ||
515 | void QPEApplication::processQCopFile() | 515 | void QPEApplication::processQCopFile() |
516 | { | 516 | { |
517 | QString qcopfn("/tmp/qcop-msg-"); | 517 | QString qcopfn("/tmp/qcop-msg-"); |
518 | qcopfn += d->appName; // append command name | 518 | qcopfn += d->appName; // append command name |
519 | 519 | ||
520 | QFile f(qcopfn); | 520 | QFile f(qcopfn); |
521 | if ( f.open(IO_ReadWrite) ) { | 521 | if ( f.open(IO_ReadWrite) ) { |
522 | #ifndef Q_OS_WIN32 | 522 | #ifndef Q_OS_WIN32 |
523 | flock(f.handle(), LOCK_EX); | 523 | flock(f.handle(), LOCK_EX); |
524 | #endif | 524 | #endif |
525 | QDataStream ds(&f); | 525 | QDataStream ds(&f); |
526 | QCString channel, message; | 526 | QCString channel, message; |
527 | QByteArray data; | 527 | QByteArray data; |
528 | while(!ds.atEnd()) { | 528 | while(!ds.atEnd()) { |
529 | ds >> channel >> message >> data; | 529 | ds >> channel >> message >> data; |
530 | d->enqueueQCop(channel,message,data); | 530 | d->enqueueQCop(channel,message,data); |
531 | } | 531 | } |
532 | ::ftruncate(f.handle(), 0); | 532 | ::ftruncate(f.handle(), 0); |
533 | #ifndef Q_OS_WIN32 | 533 | #ifndef Q_OS_WIN32 |
534 | f.flush(); | 534 | f.flush(); |
535 | flock(f.handle(), LOCK_UN); | 535 | flock(f.handle(), LOCK_UN); |
536 | #endif | 536 | #endif |
537 | } | 537 | } |
538 | #endif | 538 | #endif |
539 | } | 539 | } |
540 | 540 | ||
541 | 541 | ||
542 | /*! | 542 | /*! |
543 | \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data ) | 543 | \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data ) |
544 | 544 | ||
545 | This signal is emitted when a message is received on this | 545 | This signal is emitted when a message is received on this |
546 | application's QPE/Application/<i>appname</i> \link qcop.html | 546 | application's QPE/Application/<i>appname</i> \link qcop.html |
547 | QCop\endlink channel. | 547 | QCop\endlink channel. |
548 | 548 | ||
549 | The slot to which you connect this signal uses \a msg and \a data | 549 | The slot to which you connect this signal uses \a msg and \a data |
550 | in the following way: | 550 | in the following way: |
551 | 551 | ||
552 | \code | 552 | \code |
553 | void MyWidget::receive( const QCString& msg, const QByteArray& data ) | 553 | void MyWidget::receive( const QCString& msg, const QByteArray& data ) |
554 | { | 554 | { |
555 | QDataStream stream( data, IO_ReadOnly ); | 555 | QDataStream stream( data, IO_ReadOnly ); |
556 | if ( msg == "someMessage(int,int,int)" ) { | 556 | if ( msg == "someMessage(int,int,int)" ) { |
557 | int a,b,c; | 557 | int a,b,c; |
558 | stream >> a >> b >> c; | 558 | stream >> a >> b >> c; |
559 | ... | 559 | ... |
560 | } else if ( msg == "otherMessage(QString)" ) { | 560 | } else if ( msg == "otherMessage(QString)" ) { |
561 | ... | 561 | ... |
562 | } | 562 | } |
563 | } | 563 | } |
564 | \endcode | 564 | \endcode |
565 | 565 | ||
566 | \sa qcop.html | 566 | \sa qcop.html |
567 | Note that messages received here may be processed by qpe application | 567 | Note that messages received here may be processed by qpe application |
568 | and emitted as signals, such as flush() and reload(). | 568 | and emitted as signals, such as flush() and reload(). |
569 | */ | 569 | */ |
570 | 570 | ||
571 | /*! | 571 | /*! |
572 | Constructs a QPEApplication just as you would construct | 572 | Constructs a QPEApplication just as you would construct |
573 | a QApplication, passing \a argc, \a argv, and \a t. | 573 | a QApplication, passing \a argc, \a argv, and \a t. |
574 | 574 | ||
575 | For applications, \a t should be the default, GuiClient. Only | 575 | For applications, \a t should be the default, GuiClient. Only |
576 | the Qtopia server passes GuiServer. | 576 | the Qtopia server passes GuiServer. |
577 | */ | 577 | */ |
578 | QPEApplication::QPEApplication( int & argc, char **argv, Type t ) | 578 | QPEApplication::QPEApplication( int & argc, char **argv, Type t ) |
579 | : QApplication( hack(argc), argv, t ), pidChannel( 0 ) | 579 | : QApplication( hack(argc), argv, t ), pidChannel( 0 ) |
580 | { | 580 | { |
581 | QPixmapCache::setCacheLimit(256); // sensible default for smaller devices. | 581 | QPixmapCache::setCacheLimit(256); // sensible default for smaller devices. |
582 | 582 | ||
583 | d = new QPEApplicationData; | 583 | d = new QPEApplicationData; |
584 | d->loadTextCodecs(); | 584 | d->loadTextCodecs(); |
585 | d->loadImageCodecs(); | 585 | d->loadImageCodecs(); |
586 | int dw = desktop() ->width(); | 586 | int dw = desktop() ->width(); |
587 | 587 | ||
588 | if ( dw < 200 ) { | 588 | if ( dw < 200 ) { |
589 | setFont( QFont( "vera", 8 ) ); | 589 | setFont( QFont( "vera", 8 ) ); |
590 | AppLnk::setSmallIconSize( 10 ); | 590 | AppLnk::setSmallIconSize( 10 ); |
591 | AppLnk::setBigIconSize( 28 ); | 591 | AppLnk::setBigIconSize( 28 ); |
592 | } | 592 | } |
593 | #ifndef QT_QWS_SIMPAD | 593 | #ifndef OPIE_HIGH_RES_SMALL_PHY |
594 | else if ( dw > 600 ) { | 594 | else if ( dw > 600 ) { |
595 | setFont( QFont( "vera", 16 ) ); | 595 | setFont( QFont( "vera", 16 ) ); |
596 | AppLnk::setSmallIconSize( 24 ); | 596 | AppLnk::setSmallIconSize( 24 ); |
597 | AppLnk::setBigIconSize( 48 ); | 597 | AppLnk::setBigIconSize( 48 ); |
598 | } | 598 | } |
599 | #endif | 599 | #endif |
600 | else if ( dw > 200 ) { | 600 | else if ( dw > 200 ) { |
601 | setFont( QFont( "vera", 10 ) ); | 601 | setFont( QFont( "vera", 10 ) ); |
602 | AppLnk::setSmallIconSize( 14 ); | 602 | AppLnk::setSmallIconSize( 14 ); |
603 | AppLnk::setBigIconSize( 32 ); | 603 | AppLnk::setBigIconSize( 32 ); |
604 | } | 604 | } |
605 | 605 | ||
606 | QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory ); | 606 | QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory ); |
607 | 607 | ||
608 | connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) ); | 608 | connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) ); |
609 | 609 | ||
610 | 610 | ||
611 | sysChannel = new QCopChannel( "QPE/System", this ); | 611 | sysChannel = new QCopChannel( "QPE/System", this ); |
612 | connect( sysChannel, SIGNAL( received( const QCString &, const QByteArray & ) ), | 612 | connect( sysChannel, SIGNAL( received( const QCString &, const QByteArray & ) ), |
613 | this, SLOT( systemMessage( const QCString &, const QByteArray & ) ) ); | 613 | this, SLOT( systemMessage( const QCString &, const QByteArray & ) ) ); |
614 | 614 | ||
615 | /* COde now in initapp */ | 615 | /* COde now in initapp */ |
616 | #if 0 | 616 | #if 0 |
617 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 617 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
618 | 618 | ||
619 | QString qcopfn( "/tmp/qcop-msg-" ); | 619 | QString qcopfn( "/tmp/qcop-msg-" ); |
620 | qcopfn += QString( argv[ 0 ] ); // append command name | 620 | qcopfn += QString( argv[ 0 ] ); // append command name |
621 | 621 | ||
622 | QFile f( qcopfn ); | 622 | QFile f( qcopfn ); |
623 | if ( f.open( IO_ReadOnly ) ) { | 623 | if ( f.open( IO_ReadOnly ) ) { |
624 | flock( f.handle(), LOCK_EX ); | 624 | flock( f.handle(), LOCK_EX ); |
625 | } | 625 | } |
626 | 626 | ||
627 | 627 | ||
628 | 628 | ||
629 | QCString channel = QCString( argv[ 0 ] ); | 629 | QCString channel = QCString( argv[ 0 ] ); |
630 | channel.replace( QRegExp( ".*/" ), "" ); | 630 | channel.replace( QRegExp( ".*/" ), "" ); |
631 | d->appName = channel; | 631 | d->appName = channel; |
632 | channel = "QPE/Application/" + channel; | 632 | channel = "QPE/Application/" + channel; |
633 | pidChannel = new QCopChannel( channel, this ); | 633 | pidChannel = new QCopChannel( channel, this ); |
634 | connect( pidChannel, SIGNAL( received( const QCString &, const QByteArray & ) ), | 634 | connect( pidChannel, SIGNAL( received( const QCString &, const QByteArray & ) ), |
635 | this, SLOT( pidMessage( const QCString &, const QByteArray & ) ) ); | 635 | this, SLOT( pidMessage( const QCString &, const QByteArray & ) ) ); |
636 | 636 | ||
637 | if ( f.isOpen() ) { | 637 | if ( f.isOpen() ) { |
638 | d->keep_running = FALSE; | 638 | d->keep_running = FALSE; |
639 | QDataStream ds( &f ); | 639 | QDataStream ds( &f ); |
640 | QCString channel, message; | 640 | QCString channel, message; |
641 | QByteArray data; | 641 | QByteArray data; |
642 | while ( !ds.atEnd() ) { | 642 | while ( !ds.atEnd() ) { |
643 | ds >> channel >> message >> data; | 643 | ds >> channel >> message >> data; |
644 | d->enqueueQCop( channel, message, data ); | 644 | d->enqueueQCop( channel, message, data ); |
645 | } | 645 | } |
646 | 646 | ||
647 | flock( f.handle(), LOCK_UN ); | 647 | flock( f.handle(), LOCK_UN ); |
648 | f.close(); | 648 | f.close(); |
649 | f.remove(); | 649 | f.remove(); |
650 | } | 650 | } |
651 | 651 | ||
652 | for ( int a = 0; a < argc; a++ ) { | 652 | for ( int a = 0; a < argc; a++ ) { |
653 | if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) { | 653 | if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) { |
654 | argv[ a ] = argv[ a + 1 ]; | 654 | argv[ a ] = argv[ a + 1 ]; |
655 | a++; | 655 | a++; |
656 | d->preloaded = TRUE; | 656 | d->preloaded = TRUE; |
657 | argc -= 1; | 657 | argc -= 1; |
658 | } | 658 | } |
659 | else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) { | 659 | else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) { |
660 | argv[ a ] = argv[ a + 1 ]; | 660 | argv[ a ] = argv[ a + 1 ]; |
661 | a++; | 661 | a++; |
662 | d->preloaded = TRUE; | 662 | d->preloaded = TRUE; |
663 | d->forceshow = TRUE; | 663 | d->forceshow = TRUE; |
664 | argc -= 1; | 664 | argc -= 1; |
665 | } | 665 | } |
666 | } | 666 | } |
667 | 667 | ||
668 | /* overide stored arguments */ | 668 | /* overide stored arguments */ |
669 | setArgs( argc, argv ); | 669 | setArgs( argc, argv ); |
670 | 670 | ||
671 | #endif | 671 | #endif |
672 | #else | 672 | #else |
673 | initApp( argc, argv ); | 673 | initApp( argc, argv ); |
674 | #endif | 674 | #endif |
675 | // qwsSetDecoration( new QPEDecoration() ); | 675 | // qwsSetDecoration( new QPEDecoration() ); |
676 | 676 | ||
677 | #ifndef QT_NO_TRANSLATION | 677 | #ifndef QT_NO_TRANSLATION |
678 | 678 | ||
679 | d->langs = Global::languageList(); | 679 | d->langs = Global::languageList(); |
680 | for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it ) { | 680 | for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it ) { |
681 | QString lang = *it; | 681 | QString lang = *it; |
682 | 682 | ||
683 | installTranslation( lang + "/libopie.qm"); | 683 | installTranslation( lang + "/libopie.qm"); |
684 | installTranslation( lang + "/libqpe.qm" ); | 684 | installTranslation( lang + "/libqpe.qm" ); |
685 | installTranslation( lang + "/" + d->appName + ".qm" ); | 685 | installTranslation( lang + "/" + d->appName + ".qm" ); |
686 | 686 | ||
687 | 687 | ||
688 | //###language/font hack; should look it up somewhere | 688 | //###language/font hack; should look it up somewhere |
689 | #ifdef QWS | 689 | #ifdef QWS |
690 | 690 | ||
691 | if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) { | 691 | if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) { |
692 | QFont fn = FontManager::unicodeFont( FontManager::Proportional ); | 692 | QFont fn = FontManager::unicodeFont( FontManager::Proportional ); |
@@ -1915,160 +1915,160 @@ void QPEApplication::grabKeyboard() | |||
1915 | */ | 1915 | */ |
1916 | int QPEApplication::exec() | 1916 | int QPEApplication::exec() |
1917 | { | 1917 | { |
1918 | d->qcopQok = true; | 1918 | d->qcopQok = true; |
1919 | #ifndef QT_NO_COP | 1919 | #ifndef QT_NO_COP |
1920 | d->sendQCopQ(); | 1920 | d->sendQCopQ(); |
1921 | if ( !d->keep_running ) | 1921 | if ( !d->keep_running ) |
1922 | processEvents(); // we may have received QCop messages in the meantime. | 1922 | processEvents(); // we may have received QCop messages in the meantime. |
1923 | #endif | 1923 | #endif |
1924 | 1924 | ||
1925 | if ( d->keep_running ) | 1925 | if ( d->keep_running ) |
1926 | //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() ) | 1926 | //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() ) |
1927 | return QApplication::exec(); | 1927 | return QApplication::exec(); |
1928 | 1928 | ||
1929 | #ifndef QT_NO_COP | 1929 | #ifndef QT_NO_COP |
1930 | 1930 | ||
1931 | { | 1931 | { |
1932 | QCopEnvelope e( "QPE/System", "closing(QString)" ); | 1932 | QCopEnvelope e( "QPE/System", "closing(QString)" ); |
1933 | e << d->appName; | 1933 | e << d->appName; |
1934 | } | 1934 | } |
1935 | #endif | 1935 | #endif |
1936 | processEvents(); | 1936 | processEvents(); |
1937 | return 0; | 1937 | return 0; |
1938 | } | 1938 | } |
1939 | 1939 | ||
1940 | /*! | 1940 | /*! |
1941 | \internal | 1941 | \internal |
1942 | External request for application to quit. Quits if possible without | 1942 | External request for application to quit. Quits if possible without |
1943 | loosing state. | 1943 | loosing state. |
1944 | */ | 1944 | */ |
1945 | void QPEApplication::tryQuit() | 1945 | void QPEApplication::tryQuit() |
1946 | { | 1946 | { |
1947 | if ( activeModalWidget() || strcmp( argv() [ 0 ], "embeddedkonsole" ) == 0 ) | 1947 | if ( activeModalWidget() || strcmp( argv() [ 0 ], "embeddedkonsole" ) == 0 ) |
1948 | return ; // Inside modal loop or konsole. Too hard to save state. | 1948 | return ; // Inside modal loop or konsole. Too hard to save state. |
1949 | #ifndef QT_NO_COP | 1949 | #ifndef QT_NO_COP |
1950 | 1950 | ||
1951 | { | 1951 | { |
1952 | QCopEnvelope e( "QPE/System", "closing(QString)" ); | 1952 | QCopEnvelope e( "QPE/System", "closing(QString)" ); |
1953 | e << d->appName; | 1953 | e << d->appName; |
1954 | } | 1954 | } |
1955 | #endif | 1955 | #endif |
1956 | processEvents(); | 1956 | processEvents(); |
1957 | 1957 | ||
1958 | quit(); | 1958 | quit(); |
1959 | } | 1959 | } |
1960 | 1960 | ||
1961 | /*! | 1961 | /*! |
1962 | \internal | 1962 | \internal |
1963 | */ | 1963 | */ |
1964 | void QPEApplication::installTranslation( const QString& baseName ) { | 1964 | void QPEApplication::installTranslation( const QString& baseName ) { |
1965 | QTranslator* trans = new QTranslator(this); | 1965 | QTranslator* trans = new QTranslator(this); |
1966 | QString tfn = qpeDir() + "/i18n/"+baseName; | 1966 | QString tfn = qpeDir() + "/i18n/"+baseName; |
1967 | if ( trans->load( tfn ) ) | 1967 | if ( trans->load( tfn ) ) |
1968 | installTranslator( trans ); | 1968 | installTranslator( trans ); |
1969 | else | 1969 | else |
1970 | delete trans; | 1970 | delete trans; |
1971 | } | 1971 | } |
1972 | 1972 | ||
1973 | /*! | 1973 | /*! |
1974 | \internal | 1974 | \internal |
1975 | User initiated quit. Makes the window 'Go Away'. If preloaded this means | 1975 | User initiated quit. Makes the window 'Go Away'. If preloaded this means |
1976 | hiding the window. If not it means quitting the application. | 1976 | hiding the window. If not it means quitting the application. |
1977 | As this is user initiated we don't need to check state. | 1977 | As this is user initiated we don't need to check state. |
1978 | */ | 1978 | */ |
1979 | void QPEApplication::hideOrQuit() | 1979 | void QPEApplication::hideOrQuit() |
1980 | { | 1980 | { |
1981 | processEvents(); | 1981 | processEvents(); |
1982 | 1982 | ||
1983 | // If we are a preloaded application we don't actually quit, so emit | 1983 | // If we are a preloaded application we don't actually quit, so emit |
1984 | // a System message indicating we're quasi-closing. | 1984 | // a System message indicating we're quasi-closing. |
1985 | if ( d->preloaded && d->qpe_main_widget ) | 1985 | if ( d->preloaded && d->qpe_main_widget ) |
1986 | #ifndef QT_NO_COP | 1986 | #ifndef QT_NO_COP |
1987 | 1987 | ||
1988 | { | 1988 | { |
1989 | QCopEnvelope e("QPE/System", "fastAppHiding(QString)" ); | 1989 | QCopEnvelope e("QPE/System", "fastAppHiding(QString)" ); |
1990 | e << d->appName; | 1990 | e << d->appName; |
1991 | d->qpe_main_widget->hide(); | 1991 | d->qpe_main_widget->hide(); |
1992 | } | 1992 | } |
1993 | #endif | 1993 | #endif |
1994 | else | 1994 | else |
1995 | quit(); | 1995 | quit(); |
1996 | } | 1996 | } |
1997 | 1997 | ||
1998 | #if (__GNUC__ > 2 ) | 1998 | #if (__GNUC__ > 2 ) |
1999 | extern "C" void __cxa_pure_virtual(); | 1999 | extern "C" void __cxa_pure_virtual(); |
2000 | 2000 | ||
2001 | void __cxa_pure_virtual() | 2001 | void __cxa_pure_virtual() |
2002 | { | 2002 | { |
2003 | fprintf( stderr, "Pure virtual called\n"); | 2003 | fprintf( stderr, "Pure virtual called\n"); |
2004 | abort(); | 2004 | abort(); |
2005 | 2005 | ||
2006 | } | 2006 | } |
2007 | 2007 | ||
2008 | #endif | 2008 | #endif |
2009 | 2009 | ||
2010 | 2010 | ||
2011 | #if defined(QT_QWS_IPAQ) || defined(QT_QWS_SL5XXX) || defined(QT_QWS_RAMSES) | 2011 | #if defined(OPIE_NEW_MALLOC) |
2012 | 2012 | ||
2013 | // The libraries with the skiff package (and possibly others) have | 2013 | // The libraries with the skiff package (and possibly others) have |
2014 | // completely useless implementations of builtin new and delete that | 2014 | // completely useless implementations of builtin new and delete that |
2015 | // use about 50% of your CPU. Here we revert to the simple libc | 2015 | // use about 50% of your CPU. Here we revert to the simple libc |
2016 | // functions. | 2016 | // functions. |
2017 | 2017 | ||
2018 | void* operator new[]( size_t size ) | 2018 | void* operator new[]( size_t size ) |
2019 | { | 2019 | { |
2020 | return malloc( size ); | 2020 | return malloc( size ); |
2021 | } | 2021 | } |
2022 | 2022 | ||
2023 | void* operator new( size_t size ) | 2023 | void* operator new( size_t size ) |
2024 | { | 2024 | { |
2025 | return malloc( size ); | 2025 | return malloc( size ); |
2026 | } | 2026 | } |
2027 | 2027 | ||
2028 | void operator delete[]( void* p ) | 2028 | void operator delete[]( void* p ) |
2029 | { | 2029 | { |
2030 | free( p ); | 2030 | free( p ); |
2031 | } | 2031 | } |
2032 | 2032 | ||
2033 | void operator delete[]( void* p, size_t /*size*/ ) | 2033 | void operator delete[]( void* p, size_t /*size*/ ) |
2034 | { | 2034 | { |
2035 | free( p ); | 2035 | free( p ); |
2036 | } | 2036 | } |
2037 | 2037 | ||
2038 | 2038 | ||
2039 | void operator delete( void* p ) | 2039 | void operator delete( void* p ) |
2040 | { | 2040 | { |
2041 | free( p ); | 2041 | free( p ); |
2042 | } | 2042 | } |
2043 | 2043 | ||
2044 | void operator delete( void* p, size_t /*size*/ ) | 2044 | void operator delete( void* p, size_t /*size*/ ) |
2045 | { | 2045 | { |
2046 | free( p ); | 2046 | free( p ); |
2047 | } | 2047 | } |
2048 | 2048 | ||
2049 | #endif | 2049 | #endif |
2050 | 2050 | ||
2051 | #if ( QT_VERSION <= 230 ) && !defined(SINGLE_APP) | 2051 | #if ( QT_VERSION <= 230 ) && !defined(SINGLE_APP) |
2052 | #include <qwidgetlist.h> | 2052 | #include <qwidgetlist.h> |
2053 | #ifdef QWS | 2053 | #ifdef QWS |
2054 | #include <qgfx_qws.h> | 2054 | #include <qgfx_qws.h> |
2055 | extern QRect qt_maxWindowRect; | 2055 | extern QRect qt_maxWindowRect; |
2056 | void qt_setMaxWindowRect(const QRect& r ) | 2056 | void qt_setMaxWindowRect(const QRect& r ) |
2057 | { | 2057 | { |
2058 | qt_maxWindowRect = qt_screen->mapFromDevice( r, | 2058 | qt_maxWindowRect = qt_screen->mapFromDevice( r, |
2059 | qt_screen->mapToDevice( QSize( qt_screen->width(), qt_screen->height() ) ) ); | 2059 | qt_screen->mapToDevice( QSize( qt_screen->width(), qt_screen->height() ) ) ); |
2060 | // Re-resize any maximized windows | 2060 | // Re-resize any maximized windows |
2061 | QWidgetList* l = QApplication::topLevelWidgets(); | 2061 | QWidgetList* l = QApplication::topLevelWidgets(); |
2062 | if ( l ) { | 2062 | if ( l ) { |
2063 | QWidget * w = l->first(); | 2063 | QWidget * w = l->first(); |
2064 | while ( w ) { | 2064 | while ( w ) { |
2065 | if ( w->isVisible() && w->isMaximized() ) { | 2065 | if ( w->isVisible() && w->isMaximized() ) { |
2066 | w->showMaximized(); | 2066 | w->showMaximized(); |
2067 | } | 2067 | } |
2068 | w = l->next(); | 2068 | w = l->next(); |
2069 | } | 2069 | } |
2070 | delete l; | 2070 | delete l; |
2071 | } | 2071 | } |
2072 | } | 2072 | } |
2073 | #endif | 2073 | #endif |
2074 | #endif | 2074 | #endif |