author | sandman <sandman> | 2002-12-07 19:58:03 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-12-07 19:58:03 (UTC) |
commit | d856a53635479f5ace72159aa513480ecd90bf1e (patch) (unidiff) | |
tree | aba6aaa2cc9168ebd364308f37cdc9c4286c6703 /library/qpeapplication.cpp | |
parent | 09aa2b9a766e02e52ad64c0294e8b72e6fda8c85 (diff) | |
download | opie-d856a53635479f5ace72159aa513480ecd90bf1e.zip opie-d856a53635479f5ace72159aa513480ecd90bf1e.tar.gz opie-d856a53635479f5ace72159aa513480ecd90bf1e.tar.bz2 |
- removed the libpreload stuff from global.cpp
- added qt_override.* which provides the same functionality as libpreload
(the new -override patch for Qt/E is needed for this to work/compile)
- changed qpeapplication a bit to accomodate the new interface
-rw-r--r-- | library/qpeapplication.cpp | 40 |
1 files changed, 14 insertions, 26 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp index 7cbda92..4c93111 100644 --- a/library/qpeapplication.cpp +++ b/library/qpeapplication.cpp | |||
@@ -1,216 +1,218 @@ | |||
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 "qpeapplication.h" | 53 | #include "qpeapplication.h" |
54 | #include "qpestyle.h" | 54 | #include "qpestyle.h" |
55 | #include "styleinterface.h" | 55 | #include "styleinterface.h" |
56 | #if QT_VERSION >= 300 | 56 | #if QT_VERSION >= 300 |
57 | #include <qstylefactory.h> | 57 | #include <qstylefactory.h> |
58 | #else | 58 | #else |
59 | #include <qplatinumstyle.h> | 59 | #include <qplatinumstyle.h> |
60 | #include <qwindowsstyle.h> | 60 | #include <qwindowsstyle.h> |
61 | #include <qmotifstyle.h> | 61 | #include <qmotifstyle.h> |
62 | #include <qmotifplusstyle.h> | 62 | #include <qmotifplusstyle.h> |
63 | #include "lightstyle.h" | 63 | #include "lightstyle.h" |
64 | 64 | ||
65 | #include <qpe/qlibrary.h> | 65 | #include <qpe/qlibrary.h> |
66 | #endif | 66 | #endif |
67 | #include "global.h" | 67 | #include "global.h" |
68 | #include "resource.h" | 68 | #include "resource.h" |
69 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) | 69 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) |
70 | #include "qutfcodec.h" | 70 | #include "qutfcodec.h" |
71 | #endif | 71 | #endif |
72 | #include "config.h" | 72 | #include "config.h" |
73 | #include "network.h" | 73 | #include "network.h" |
74 | #ifdef QWS | 74 | #ifdef QWS |
75 | #include "fontmanager.h" | 75 | #include "fontmanager.h" |
76 | #endif | 76 | #endif |
77 | 77 | ||
78 | #include "alarmserver.h" | 78 | #include "alarmserver.h" |
79 | #include "applnk.h" | 79 | #include "applnk.h" |
80 | #include "qpemenubar.h" | 80 | #include "qpemenubar.h" |
81 | #include "textcodecinterface.h" | 81 | #include "textcodecinterface.h" |
82 | #include "imagecodecinterface.h" | 82 | #include "imagecodecinterface.h" |
83 | 83 | ||
84 | #include <unistd.h> | 84 | #include <unistd.h> |
85 | #include <sys/file.h> | 85 | #include <sys/file.h> |
86 | #include <sys/ioctl.h> | 86 | #include <sys/ioctl.h> |
87 | #include <sys/soundcard.h> | 87 | #include <sys/soundcard.h> |
88 | 88 | ||
89 | #include "qt_override_p.h" | ||
90 | |||
89 | 91 | ||
90 | class QPEApplicationData | 92 | class QPEApplicationData |
91 | { | 93 | { |
92 | public: | 94 | public: |
93 | QPEApplicationData() : presstimer( 0 ), presswidget( 0 ), rightpressed( FALSE ), | 95 | QPEApplicationData() : presstimer( 0 ), presswidget( 0 ), rightpressed( FALSE ), |
94 | kbgrabber( 0 ), kbregrab( FALSE ), notbusysent( FALSE ), preloaded( FALSE ), | 96 | kbgrabber( 0 ), kbregrab( FALSE ), notbusysent( FALSE ), preloaded( FALSE ), |
95 | forceshow( FALSE ), nomaximize( FALSE ), qpe_main_widget( 0 ), | 97 | forceshow( FALSE ), nomaximize( FALSE ), qpe_main_widget( 0 ), |
96 | keep_running( TRUE ) | 98 | keep_running( TRUE ) |
97 | { | 99 | { |
98 | qcopq.setAutoDelete( TRUE ); | 100 | qcopq.setAutoDelete( TRUE ); |
99 | } | 101 | } |
100 | 102 | ||
101 | int presstimer; | 103 | int presstimer; |
102 | QWidget* presswidget; | 104 | QWidget* presswidget; |
103 | QPoint presspos; | 105 | QPoint presspos; |
104 | bool rightpressed : | 106 | bool rightpressed : |
105 | 1; // AEH why not use uint foobar :1; if it's tt style -zecke | 107 | 1; // AEH why not use uint foobar :1; if it's tt style -zecke |
106 | int kbgrabber; | 108 | int kbgrabber; |
107 | bool kbregrab : | 109 | bool kbregrab : |
108 | 1; | 110 | 1; |
109 | bool notbusysent : | 111 | bool notbusysent : |
110 | 1; | 112 | 1; |
111 | QString appName; | 113 | QString appName; |
112 | struct QCopRec | 114 | struct QCopRec |
113 | { | 115 | { |
114 | QCopRec( const QCString &ch, const QCString &msg, | 116 | QCopRec( const QCString &ch, const QCString &msg, |
115 | const QByteArray &d ) : | 117 | const QByteArray &d ) : |
116 | channel( ch ), message( msg ), data( d ) | 118 | channel( ch ), message( msg ), data( d ) |
117 | { } | 119 | { } |
118 | 120 | ||
119 | QCString channel; | 121 | QCString channel; |
120 | QCString message; | 122 | QCString message; |
121 | QByteArray data; | 123 | QByteArray data; |
122 | }; | 124 | }; |
123 | bool preloaded : | 125 | bool preloaded : |
124 | 1; | 126 | 1; |
125 | bool forceshow : | 127 | bool forceshow : |
126 | 1; | 128 | 1; |
127 | bool nomaximize : | 129 | bool nomaximize : |
128 | 1; | 130 | 1; |
129 | QWidget* qpe_main_widget; | 131 | QWidget* qpe_main_widget; |
130 | bool keep_running : | 132 | bool keep_running : |
131 | 1; | 133 | 1; |
132 | QList<QCopRec> qcopq; | 134 | QList<QCopRec> qcopq; |
133 | 135 | ||
134 | void enqueueQCop( const QCString &ch, const QCString &msg, | 136 | void enqueueQCop( const QCString &ch, const QCString &msg, |
135 | const QByteArray &data ) | 137 | const QByteArray &data ) |
136 | { | 138 | { |
137 | qcopq.append( new QCopRec( ch, msg, data ) ); | 139 | qcopq.append( new QCopRec( ch, msg, data ) ); |
138 | } | 140 | } |
139 | void sendQCopQ() | 141 | void sendQCopQ() |
140 | { | 142 | { |
141 | QCopRec * r; | 143 | QCopRec * r; |
142 | #ifndef QT_NO_COP | 144 | #ifndef QT_NO_COP |
143 | 145 | ||
144 | for ( QListIterator<QCopRec> it( qcopq ); ( r = it.current() ); ++it ) | 146 | for ( QListIterator<QCopRec> it( qcopq ); ( r = it.current() ); ++it ) |
145 | QCopChannel::sendLocally( r->channel, r->message, r->data ); | 147 | QCopChannel::sendLocally( r->channel, r->message, r->data ); |
146 | #endif | 148 | #endif |
147 | 149 | ||
148 | qcopq.clear(); | 150 | qcopq.clear(); |
149 | } | 151 | } |
150 | static void show_mx(QWidget* mw, bool nomaximize) | 152 | static void show_mx(QWidget* mw, bool nomaximize) |
151 | { | 153 | { |
152 | if ( mw->layout() && mw->inherits("QDialog") ) { | 154 | if ( mw->layout() && mw->inherits("QDialog") ) { |
153 | QPEApplication::showDialog((QDialog*)mw, nomaximize); | 155 | QPEApplication::showDialog((QDialog*)mw, nomaximize); |
154 | } | 156 | } |
155 | else { | 157 | else { |
156 | #ifdef Q_WS_QWS | 158 | #ifdef Q_WS_QWS |
157 | if ( !nomaximize ) | 159 | if ( !nomaximize ) |
158 | mw->showMaximized(); | 160 | mw->showMaximized(); |
159 | else | 161 | else |
160 | #endif | 162 | #endif |
161 | 163 | ||
162 | mw->show(); | 164 | mw->show(); |
163 | } | 165 | } |
164 | } | 166 | } |
165 | static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) | 167 | static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) |
166 | { | 168 | { |
167 | /* | 169 | /* |
168 | // This works but disable it for now until it is safe to apply | 170 | // This works but disable it for now until it is safe to apply |
169 | // What is does is scan the .desktop files of all the apps for | 171 | // What is does is scan the .desktop files of all the apps for |
170 | // the applnk that has the corresponding argv[0] as this program | 172 | // the applnk that has the corresponding argv[0] as this program |
171 | // then it uses the name stored in the .desktop file as the caption | 173 | // then it uses the name stored in the .desktop file as the caption |
172 | // for the main widget. This saves duplicating translations for | 174 | // for the main widget. This saves duplicating translations for |
173 | // the app name in the program and in the .desktop files. | 175 | // the app name in the program and in the .desktop files. |
174 | 176 | ||
175 | AppLnkSet apps( appsPath ); | 177 | AppLnkSet apps( appsPath ); |
176 | 178 | ||
177 | QList<AppLnk> appsList = apps.children(); | 179 | QList<AppLnk> appsList = apps.children(); |
178 | for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { | 180 | for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { |
179 | if ( (*it)->exec() == appName ) { | 181 | if ( (*it)->exec() == appName ) { |
180 | mw->setCaption( (*it)->name() ); | 182 | mw->setCaption( (*it)->name() ); |
181 | return TRUE; | 183 | return TRUE; |
182 | } | 184 | } |
183 | } | 185 | } |
184 | */ | 186 | */ |
185 | return FALSE; | 187 | return FALSE; |
186 | } | 188 | } |
187 | 189 | ||
188 | 190 | ||
189 | void show(QWidget* mw, bool nomax) | 191 | void show(QWidget* mw, bool nomax) |
190 | { | 192 | { |
191 | setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" ); | 193 | setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" ); |
192 | nomaximize = nomax; | 194 | nomaximize = nomax; |
193 | qpe_main_widget = mw; | 195 | qpe_main_widget = mw; |
194 | #ifndef QT_NO_COP | 196 | #ifndef QT_NO_COP |
195 | 197 | ||
196 | sendQCopQ(); | 198 | sendQCopQ(); |
197 | #endif | 199 | #endif |
198 | 200 | ||
199 | if ( preloaded ) { | 201 | if ( preloaded ) { |
200 | if (forceshow) | 202 | if (forceshow) |
201 | show_mx(mw, nomax); | 203 | show_mx(mw, nomax); |
202 | } | 204 | } |
203 | else if ( keep_running ) { | 205 | else if ( keep_running ) { |
204 | show_mx(mw, nomax); | 206 | show_mx(mw, nomax); |
205 | } | 207 | } |
206 | } | 208 | } |
207 | 209 | ||
208 | void loadTextCodecs() | 210 | void loadTextCodecs() |
209 | { | 211 | { |
210 | QString path = QPEApplication::qpeDir() + "/plugins/textcodecs"; | 212 | QString path = QPEApplication::qpeDir() + "/plugins/textcodecs"; |
211 | QDir dir( path, "lib*.so" ); | 213 | QDir dir( path, "lib*.so" ); |
212 | QStringList list = dir.entryList(); | 214 | QStringList list = dir.entryList(); |
213 | QStringList::Iterator it; | 215 | QStringList::Iterator it; |
214 | for ( it = list.begin(); it != list.end(); ++it ) { | 216 | for ( it = list.begin(); it != list.end(); ++it ) { |
215 | TextCodecInterface *iface = 0; | 217 | TextCodecInterface *iface = 0; |
216 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 218 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
@@ -774,355 +776,337 @@ bool QPEApplication::qwsEventFilter( QWSEvent * e ) | |||
774 | #endif | 776 | #endif |
775 | 777 | ||
776 | } | 778 | } |
777 | if ( e->type == QWSEvent::Focus ) { | 779 | if ( e->type == QWSEvent::Focus ) { |
778 | QWSFocusEvent * fe = ( QWSFocusEvent* ) e; | 780 | QWSFocusEvent * fe = ( QWSFocusEvent* ) e; |
779 | QWidget* nfw = QWidget::find( e->window() ); | 781 | QWidget* nfw = QWidget::find( e->window() ); |
780 | if ( !fe->simpleData.get_focus ) { | 782 | if ( !fe->simpleData.get_focus ) { |
781 | QWidget * active = activeWindow(); | 783 | QWidget * active = activeWindow(); |
782 | while ( active && active->isPopup() ) { | 784 | while ( active && active->isPopup() ) { |
783 | active->close(); | 785 | active->close(); |
784 | active = activeWindow(); | 786 | active = activeWindow(); |
785 | } | 787 | } |
786 | if ( !nfw && d->kbgrabber == 2 ) { | 788 | if ( !nfw && d->kbgrabber == 2 ) { |
787 | ungrabKeyboard(); | 789 | ungrabKeyboard(); |
788 | d->kbregrab = TRUE; // want kb back when we're active | 790 | d->kbregrab = TRUE; // want kb back when we're active |
789 | } | 791 | } |
790 | } | 792 | } |
791 | else { | 793 | else { |
792 | // make sure our modal widget is ALWAYS on top | 794 | // make sure our modal widget is ALWAYS on top |
793 | QWidget *topm = activeModalWidget(); | 795 | QWidget *topm = activeModalWidget(); |
794 | if ( topm ) { | 796 | if ( topm ) { |
795 | topm->raise(); | 797 | topm->raise(); |
796 | } | 798 | } |
797 | if ( d->kbregrab ) { | 799 | if ( d->kbregrab ) { |
798 | grabKeyboard(); | 800 | grabKeyboard(); |
799 | d->kbregrab = FALSE; | 801 | d->kbregrab = FALSE; |
800 | } | 802 | } |
801 | } | 803 | } |
802 | if ( fe->simpleData.get_focus && inputMethodDict ) { | 804 | if ( fe->simpleData.get_focus && inputMethodDict ) { |
803 | InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) ); | 805 | InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) ); |
804 | if ( m == AlwaysOff ) | 806 | if ( m == AlwaysOff ) |
805 | Global::hideInputMethod(); | 807 | Global::hideInputMethod(); |
806 | if ( m == AlwaysOn ) | 808 | if ( m == AlwaysOn ) |
807 | Global::showInputMethod(); | 809 | Global::showInputMethod(); |
808 | } | 810 | } |
809 | } | 811 | } |
810 | return QApplication::qwsEventFilter( e ); | 812 | return QApplication::qwsEventFilter( e ); |
811 | } | 813 | } |
812 | #endif | 814 | #endif |
813 | 815 | ||
814 | /*! | 816 | /*! |
815 | Destroys the QPEApplication. | 817 | Destroys the QPEApplication. |
816 | */ | 818 | */ |
817 | QPEApplication::~QPEApplication() | 819 | QPEApplication::~QPEApplication() |
818 | { | 820 | { |
819 | ungrabKeyboard(); | 821 | ungrabKeyboard(); |
820 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 822 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
821 | // Need to delete QCopChannels early, since the display will | 823 | // Need to delete QCopChannels early, since the display will |
822 | // be gone by the time we get to ~QObject(). | 824 | // be gone by the time we get to ~QObject(). |
823 | delete sysChannel; | 825 | delete sysChannel; |
824 | delete pidChannel; | 826 | delete pidChannel; |
825 | #endif | 827 | #endif |
826 | 828 | ||
827 | delete d; | 829 | delete d; |
828 | } | 830 | } |
829 | 831 | ||
830 | /*! | 832 | /*! |
831 | Returns <tt>$OPIEDIR/</tt>. | 833 | Returns <tt>$OPIEDIR/</tt>. |
832 | */ | 834 | */ |
833 | QString QPEApplication::qpeDir() | 835 | QString QPEApplication::qpeDir() |
834 | { | 836 | { |
835 | const char * base = getenv( "OPIEDIR" ); | 837 | const char * base = getenv( "OPIEDIR" ); |
836 | if ( base ) | 838 | if ( base ) |
837 | return QString( base ) + "/"; | 839 | return QString( base ) + "/"; |
838 | 840 | ||
839 | return QString( "../" ); | 841 | return QString( "../" ); |
840 | } | 842 | } |
841 | 843 | ||
842 | /*! | 844 | /*! |
843 | Returns the user's current Document directory. There is a trailing "/". | 845 | Returns the user's current Document directory. There is a trailing "/". |
844 | .. well, it does now,, and there's no trailing '/' | 846 | .. well, it does now,, and there's no trailing '/' |
845 | */ | 847 | */ |
846 | QString QPEApplication::documentDir() | 848 | QString QPEApplication::documentDir() |
847 | { | 849 | { |
848 | const char* base = getenv( "HOME"); | 850 | const char* base = getenv( "HOME"); |
849 | if ( base ) | 851 | if ( base ) |
850 | return QString( base ) + "/Documents"; | 852 | return QString( base ) + "/Documents"; |
851 | 853 | ||
852 | return QString( "../Documents" ); | 854 | return QString( "../Documents" ); |
853 | } | 855 | } |
854 | 856 | ||
855 | static int deforient = -1; | 857 | static int deforient = -1; |
856 | 858 | ||
857 | /*! | 859 | /*! |
858 | \internal | 860 | \internal |
859 | */ | 861 | */ |
860 | int QPEApplication::defaultRotation() | 862 | int QPEApplication::defaultRotation() |
861 | { | 863 | { |
862 | if ( deforient < 0 ) { | 864 | if ( deforient < 0 ) { |
863 | QString d = getenv( "QWS_DISPLAY" ); | 865 | QString d = getenv( "QWS_DISPLAY" ); |
864 | if ( d.contains( "Rot90" ) ) { | 866 | if ( d.contains( "Rot90" ) ) { |
865 | deforient = 90; | 867 | deforient = 90; |
866 | } | 868 | } |
867 | else if ( d.contains( "Rot180" ) ) { | 869 | else if ( d.contains( "Rot180" ) ) { |
868 | deforient = 180; | 870 | deforient = 180; |
869 | } | 871 | } |
870 | else if ( d.contains( "Rot270" ) ) { | 872 | else if ( d.contains( "Rot270" ) ) { |
871 | deforient = 270; | 873 | deforient = 270; |
872 | } | 874 | } |
873 | else { | 875 | else { |
874 | deforient = 0; | 876 | deforient = 0; |
875 | } | 877 | } |
876 | } | 878 | } |
877 | return deforient; | 879 | return deforient; |
878 | } | 880 | } |
879 | 881 | ||
880 | /*! | 882 | /*! |
881 | \internal | 883 | \internal |
882 | */ | 884 | */ |
883 | void QPEApplication::setDefaultRotation( int r ) | 885 | void QPEApplication::setDefaultRotation( int r ) |
884 | { | 886 | { |
885 | if ( qApp->type() == GuiServer ) { | 887 | if ( qApp->type() == GuiServer ) { |
886 | deforient = r; | 888 | deforient = r; |
887 | setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 ); | 889 | setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 ); |
888 | Config config("qpe"); | 890 | Config config("qpe"); |
889 | config.setGroup( "Rotation" ); | 891 | config.setGroup( "Rotation" ); |
890 | config.writeEntry( "Screen", getenv("QWS_DISPLAY") ); | 892 | config.writeEntry( "Screen", getenv("QWS_DISPLAY") ); |
891 | } | 893 | } |
892 | else { | 894 | else { |
893 | #ifndef QT_NO_COP | 895 | #ifndef QT_NO_COP |
894 | { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" ); | 896 | { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" ); |
895 | e << r; | 897 | e << r; |
896 | } | 898 | } |
897 | #endif | 899 | #endif |
898 | 900 | ||
899 | } | 901 | } |
900 | } | 902 | } |
901 | 903 | ||
902 | // exported to libpreload.so | ||
903 | int opie_block_style = 0; | ||
904 | 904 | ||
905 | /*! | 905 | /*! |
906 | \internal | 906 | \internal |
907 | */ | 907 | */ |
908 | void QPEApplication::applyStyle() | 908 | void QPEApplication::applyStyle() |
909 | { | 909 | { |
910 | Config config( "qpe" ); | 910 | Config config( "qpe" ); |
911 | config.setGroup( "Appearance" ); | 911 | config.setGroup( "Appearance" ); |
912 | 912 | ||
913 | // don't block ourselves ... | 913 | // don't block ourselves ... |
914 | opie_block_style = 0; | 914 | Opie::force_appearance = 0; |
915 | 915 | ||
916 | 916 | static QString appname = Opie::binaryName ( ); | |
917 | static QString appname; | ||
918 | |||
919 | if ( appname. isNull ( )) { | ||
920 | char src [32]; | ||
921 | char dst [PATH_MAX + 1]; | ||
922 | ::sprintf ( src, "/proc/%d/exe", ::getpid ( )); | ||
923 | int l = ::readlink ( src, dst, PATH_MAX ); | ||
924 | if ( l > 0 ) { | ||
925 | dst [l] = 0; | ||
926 | const char *b = ::strrchr ( dst, '/' ); | ||
927 | appname = ( b ? b + 1 : dst ); | ||
928 | } | ||
929 | else | ||
930 | appname = ""; | ||
931 | } | ||
932 | |||
933 | 917 | ||
934 | QStringList ex = config. readListEntry ( "NoStyle", ';' ); | 918 | QStringList ex = config. readListEntry ( "NoStyle", ';' ); |
935 | int nostyle = 0; | 919 | int nostyle = 0; |
936 | for ( QStringList::Iterator it = ex. begin ( ); it != ex. end ( ); ++it ) { | 920 | for ( QStringList::Iterator it = ex. begin ( ); it != ex. end ( ); ++it ) { |
937 | if ( QRegExp (( *it ). mid ( 1 ), false, true ). find ( appname, 0 ) >= 0 ) { | 921 | if ( QRegExp (( *it ). mid ( 1 ), false, true ). find ( appname, 0 ) >= 0 ) { |
938 | nostyle = ( *it ). left ( 1 ). toInt ( 0, 32 ); | 922 | nostyle = ( *it ). left ( 1 ). toInt ( 0, 32 ); |
939 | break; | 923 | break; |
940 | } | 924 | } |
941 | } | 925 | } |
942 | 926 | ||
943 | // Widget style | 927 | // Widget style |
944 | QString style = config.readEntry( "Style", "Light" ); | 928 | QString style = config.readEntry( "Style", "Light" ); |
945 | 929 | ||
946 | // don't set a custom style | 930 | // don't set a custom style |
947 | if ( nostyle & 0x01 ) | 931 | if ( nostyle & Opie::Force_Style ) |
948 | style = "Light"; | 932 | style = "Light"; |
949 | 933 | ||
950 | internalSetStyle ( style ); | 934 | internalSetStyle ( style ); |
951 | 935 | ||
952 | // Colors | 936 | // Colors |
953 | QColor bgcolor( config.readEntry( "Background", "#E5E1D5" ) ); | 937 | QColor bgcolor( config.readEntry( "Background", "#E5E1D5" ) ); |
954 | QColor btncolor( config.readEntry( "Button", "#D6CDBB" ) ); | 938 | QColor btncolor( config.readEntry( "Button", "#D6CDBB" ) ); |
955 | QPalette pal( btncolor, bgcolor ); | 939 | QPalette pal( btncolor, bgcolor ); |
956 | QString color = config.readEntry( "Highlight", "#800000" ); | 940 | QString color = config.readEntry( "Highlight", "#800000" ); |
957 | pal.setColor( QColorGroup::Highlight, QColor( color ) ); | 941 | pal.setColor( QColorGroup::Highlight, QColor( color ) ); |
958 | color = config.readEntry( "HighlightedText", "#FFFFFF" ); | 942 | color = config.readEntry( "HighlightedText", "#FFFFFF" ); |
959 | pal.setColor( QColorGroup::HighlightedText, QColor( color ) ); | 943 | pal.setColor( QColorGroup::HighlightedText, QColor( color ) ); |
960 | color = config.readEntry( "Text", "#000000" ); | 944 | color = config.readEntry( "Text", "#000000" ); |
961 | pal.setColor( QColorGroup::Text, QColor( color ) ); | 945 | pal.setColor( QColorGroup::Text, QColor( color ) ); |
962 | color = config.readEntry( "ButtonText", "#000000" ); | 946 | color = config.readEntry( "ButtonText", "#000000" ); |
963 | pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) ); | 947 | pal.setColor( QPalette::Active, QColorGroup::ButtonText, QColor( color ) ); |
964 | color = config.readEntry( "Base", "#FFFFFF" ); | 948 | color = config.readEntry( "Base", "#FFFFFF" ); |
965 | pal.setColor( QColorGroup::Base, QColor( color ) ); | 949 | pal.setColor( QColorGroup::Base, QColor( color ) ); |
966 | 950 | ||
967 | pal.setColor( QPalette::Disabled, QColorGroup::Text, | 951 | pal.setColor( QPalette::Disabled, QColorGroup::Text, |
968 | pal.color( QPalette::Active, QColorGroup::Background ).dark() ); | 952 | pal.color( QPalette::Active, QColorGroup::Background ).dark() ); |
969 | 953 | ||
970 | setPalette( pal, TRUE ); | 954 | setPalette( pal, TRUE ); |
971 | 955 | ||
972 | // Window Decoration | 956 | // Window Decoration |
973 | QString dec = config.readEntry( "Decoration", "Qtopia" ); | 957 | QString dec = config.readEntry( "Decoration", "Qtopia" ); |
974 | 958 | ||
975 | // don't set a custom deco | 959 | // don't set a custom deco |
976 | if ( nostyle & 0x04 ) | 960 | if ( nostyle & Opie::Force_Decoration ) |
977 | dec = ""; | 961 | dec = ""; |
978 | 962 | ||
979 | //qDebug ( "Setting Deco: %s -- old %s (%d)", dec.latin1(), d-> decorationName.latin1(), nostyle); | 963 | //qDebug ( "Setting Deco: %s -- old %s (%d)", dec.latin1(), d-> decorationName.latin1(), nostyle); |
980 | 964 | ||
981 | if ( dec != d->decorationName ) { | 965 | if ( dec != d->decorationName ) { |
982 | qwsSetDecoration( new QPEDecoration( dec ) ); | 966 | qwsSetDecoration( new QPEDecoration( dec ) ); |
983 | d->decorationName = dec; | 967 | d->decorationName = dec; |
984 | } | 968 | } |
985 | 969 | ||
986 | // Font | 970 | // Font |
987 | QString ff = config.readEntry( "FontFamily", font().family() ); | 971 | QString ff = config.readEntry( "FontFamily", font().family() ); |
988 | int fs = config.readNumEntry( "FontSize", font().pointSize() ); | 972 | int fs = config.readNumEntry( "FontSize", font().pointSize() ); |
989 | 973 | ||
990 | // don't set a custom font | 974 | // don't set a custom font |
991 | if ( nostyle & 0x02 ) { | 975 | if ( nostyle & Opie::Force_Font ) { |
992 | ff = "Helvetica"; | 976 | ff = "Helvetica"; |
993 | fs = 10; | 977 | fs = 10; |
994 | } | 978 | } |
995 | 979 | ||
996 | setFont ( QFont ( ff, fs ), true ); | 980 | setFont ( QFont ( ff, fs ), true ); |
997 | 981 | ||
998 | // revert to global blocking policy ... | 982 | // revert to global blocking policy ... |
999 | opie_block_style = config. readBoolEntry ( "ForceStyle", false ) ? 0xff : 0x00; | 983 | Opie::force_appearance = config. readBoolEntry ( "ForceStyle", false ) ? Opie::Force_All : Opie::Force_None; |
1000 | opie_block_style -= nostyle; | 984 | Opie::force_appearance &= ~nostyle; |
1001 | } | 985 | } |
1002 | 986 | ||
1003 | void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data ) | 987 | void QPEApplication::systemMessage( const QCString& msg, const QByteArray& data ) |
1004 | { | 988 | { |
1005 | #ifdef Q_WS_QWS | 989 | #ifdef Q_WS_QWS |
1006 | QDataStream stream( data, IO_ReadOnly ); | 990 | QDataStream stream( data, IO_ReadOnly ); |
1007 | if ( msg == "applyStyle()" ) { | 991 | if ( msg == "applyStyle()" ) { |
1008 | applyStyle(); | 992 | applyStyle(); |
1009 | } | 993 | } |
1010 | else if ( msg == "setDefaultRotation(int)" ) { | 994 | else if ( msg == "setDefaultRotation(int)" ) { |
1011 | if ( type() == GuiServer ) { | 995 | if ( type() == GuiServer ) { |
1012 | int r; | 996 | int r; |
1013 | stream >> r; | 997 | stream >> r; |
1014 | setDefaultRotation( r ); | 998 | setDefaultRotation( r ); |
1015 | } | 999 | } |
1016 | } | 1000 | } |
1017 | else if ( msg == "shutdown()" ) { | 1001 | else if ( msg == "shutdown()" ) { |
1018 | if ( type() == GuiServer ) | 1002 | if ( type() == GuiServer ) |
1019 | shutdown(); | 1003 | shutdown(); |
1020 | } | 1004 | } |
1021 | else if ( msg == "quit()" ) { | 1005 | else if ( msg == "quit()" ) { |
1022 | if ( type() != GuiServer ) | 1006 | if ( type() != GuiServer ) |
1023 | tryQuit(); | 1007 | tryQuit(); |
1024 | } | 1008 | } |
1025 | else if ( msg == "forceQuit()" ) { | 1009 | else if ( msg == "forceQuit()" ) { |
1026 | if ( type() != GuiServer ) | 1010 | if ( type() != GuiServer ) |
1027 | quit(); | 1011 | quit(); |
1028 | } | 1012 | } |
1029 | else if ( msg == "restart()" ) { | 1013 | else if ( msg == "restart()" ) { |
1030 | if ( type() == GuiServer ) | 1014 | if ( type() == GuiServer ) |
1031 | restart(); | 1015 | restart(); |
1032 | } | 1016 | } |
1033 | else if ( msg == "grabKeyboard(QString)" ) { | 1017 | else if ( msg == "grabKeyboard(QString)" ) { |
1034 | QString who; | 1018 | QString who; |
1035 | stream >> who; | 1019 | stream >> who; |
1036 | if ( who.isEmpty() ) | 1020 | if ( who.isEmpty() ) |
1037 | d->kbgrabber = 0; | 1021 | d->kbgrabber = 0; |
1038 | else if ( who != d->appName ) | 1022 | else if ( who != d->appName ) |
1039 | d->kbgrabber = 1; | 1023 | d->kbgrabber = 1; |
1040 | else | 1024 | else |
1041 | d->kbgrabber = 2; | 1025 | d->kbgrabber = 2; |
1042 | } | 1026 | } |
1043 | else if ( msg == "language(QString)" ) { | 1027 | else if ( msg == "language(QString)" ) { |
1044 | if ( type() == GuiServer ) { | 1028 | if ( type() == GuiServer ) { |
1045 | QString l; | 1029 | QString l; |
1046 | stream >> l; | 1030 | stream >> l; |
1047 | QString cl = getenv( "LANG" ); | 1031 | QString cl = getenv( "LANG" ); |
1048 | if ( cl != l ) { | 1032 | if ( cl != l ) { |
1049 | if ( l.isNull() ) | 1033 | if ( l.isNull() ) |
1050 | unsetenv( "LANG" ); | 1034 | unsetenv( "LANG" ); |
1051 | else | 1035 | else |
1052 | setenv( "LANG", l.latin1(), 1 ); | 1036 | setenv( "LANG", l.latin1(), 1 ); |
1053 | restart(); | 1037 | restart(); |
1054 | } | 1038 | } |
1055 | } | 1039 | } |
1056 | } | 1040 | } |
1057 | else if ( msg == "timeChange(QString)" ) { | 1041 | else if ( msg == "timeChange(QString)" ) { |
1058 | QString t; | 1042 | QString t; |
1059 | stream >> t; | 1043 | stream >> t; |
1060 | if ( t.isNull() ) | 1044 | if ( t.isNull() ) |
1061 | unsetenv( "TZ" ); | 1045 | unsetenv( "TZ" ); |
1062 | else | 1046 | else |
1063 | setenv( "TZ", t.latin1(), 1 ); | 1047 | setenv( "TZ", t.latin1(), 1 ); |
1064 | // emit the signal so everyone else knows... | 1048 | // emit the signal so everyone else knows... |
1065 | emit timeChanged(); | 1049 | emit timeChanged(); |
1066 | } | 1050 | } |
1067 | else if ( msg == "execute(QString)" ) { | 1051 | else if ( msg == "execute(QString)" ) { |
1068 | if ( type() == GuiServer ) { | 1052 | if ( type() == GuiServer ) { |
1069 | QString t; | 1053 | QString t; |
1070 | stream >> t; | 1054 | stream >> t; |
1071 | Global::execute( t ); | 1055 | Global::execute( t ); |
1072 | } | 1056 | } |
1073 | } | 1057 | } |
1074 | else if ( msg == "execute(QString,QString)" ) { | 1058 | else if ( msg == "execute(QString,QString)" ) { |
1075 | if ( type() == GuiServer ) { | 1059 | if ( type() == GuiServer ) { |
1076 | QString t, d; | 1060 | QString t, d; |
1077 | stream >> t >> d; | 1061 | stream >> t >> d; |
1078 | Global::execute( t, d ); | 1062 | Global::execute( t, d ); |
1079 | } | 1063 | } |
1080 | } | 1064 | } |
1081 | else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) { | 1065 | else if ( msg == "addAlarm(QDateTime,QCString,QCString,int)" ) { |
1082 | if ( type() == GuiServer ) { | 1066 | if ( type() == GuiServer ) { |
1083 | QDateTime when; | 1067 | QDateTime when; |
1084 | QCString channel, message; | 1068 | QCString channel, message; |
1085 | int data; | 1069 | int data; |
1086 | stream >> when >> channel >> message >> data; | 1070 | stream >> when >> channel >> message >> data; |
1087 | AlarmServer::addAlarm( when, channel, message, data ); | 1071 | AlarmServer::addAlarm( when, channel, message, data ); |
1088 | } | 1072 | } |
1089 | } | 1073 | } |
1090 | else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) { | 1074 | else if ( msg == "deleteAlarm(QDateTime,QCString,QCString,int)" ) { |
1091 | if ( type() == GuiServer ) { | 1075 | if ( type() == GuiServer ) { |
1092 | QDateTime when; | 1076 | QDateTime when; |
1093 | QCString channel, message; | 1077 | QCString channel, message; |
1094 | int data; | 1078 | int data; |
1095 | stream >> when >> channel >> message >> data; | 1079 | stream >> when >> channel >> message >> data; |
1096 | AlarmServer::deleteAlarm( when, channel, message, data ); | 1080 | AlarmServer::deleteAlarm( when, channel, message, data ); |
1097 | } | 1081 | } |
1098 | } | 1082 | } |
1099 | else if ( msg == "clockChange(bool)" ) { | 1083 | else if ( msg == "clockChange(bool)" ) { |
1100 | int tmp; | 1084 | int tmp; |
1101 | stream >> tmp; | 1085 | stream >> tmp; |
1102 | emit clockChanged( tmp ); | 1086 | emit clockChanged( tmp ); |
1103 | } | 1087 | } |
1104 | else if ( msg == "weekChange(bool)" ) { | 1088 | else if ( msg == "weekChange(bool)" ) { |
1105 | int tmp; | 1089 | int tmp; |
1106 | stream >> tmp; | 1090 | stream >> tmp; |
1107 | emit weekChanged( tmp ); | 1091 | emit weekChanged( tmp ); |
1108 | } | 1092 | } |
1109 | else if ( msg == "setDateFormat(DateFormat)" ) { | 1093 | else if ( msg == "setDateFormat(DateFormat)" ) { |
1110 | DateFormat tmp; | 1094 | DateFormat tmp; |
1111 | stream >> tmp; | 1095 | stream >> tmp; |
1112 | emit dateFormatChanged( tmp ); | 1096 | emit dateFormatChanged( tmp ); |
1113 | } | 1097 | } |
1114 | else if ( msg == "setVolume(int,int)" ) { | 1098 | else if ( msg == "setVolume(int,int)" ) { |
1115 | int t, v; | 1099 | int t, v; |
1116 | stream >> t >> v; | 1100 | stream >> t >> v; |
1117 | setVolume( t, v ); | 1101 | setVolume( t, v ); |
1118 | emit volumeChanged( muted ); | 1102 | emit volumeChanged( muted ); |
1119 | } | 1103 | } |
1120 | else if ( msg == "volumeChange(bool)" ) { | 1104 | else if ( msg == "volumeChange(bool)" ) { |
1121 | stream >> muted; | 1105 | stream >> muted; |
1122 | setVolume(); | 1106 | setVolume(); |
1123 | emit volumeChanged( muted ); | 1107 | emit volumeChanged( muted ); |
1124 | } | 1108 | } |
1125 | else if ( msg == "setMic(int,int)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> | 1109 | else if ( msg == "setMic(int,int)" ) { // Added: 2002-02-08 by Jeremy Cowgar <jc@cowgar.com> |
1126 | int t, v; | 1110 | int t, v; |
1127 | stream >> t >> v; | 1111 | stream >> t >> v; |
1128 | setMic( t, v ); | 1112 | setMic( t, v ); |
@@ -1568,191 +1552,195 @@ void QPEApplication::removeSenderFromStylusDict() | |||
1568 | { | 1552 | { |
1569 | stylusDict->remove | 1553 | stylusDict->remove |
1570 | ( ( void* ) sender() ); | 1554 | ( ( void* ) sender() ); |
1571 | if ( d->presswidget == sender() ) | 1555 | if ( d->presswidget == sender() ) |
1572 | d->presswidget = 0; | 1556 | d->presswidget = 0; |
1573 | } | 1557 | } |
1574 | 1558 | ||
1575 | /*! | 1559 | /*! |
1576 | \internal | 1560 | \internal |
1577 | */ | 1561 | */ |
1578 | bool QPEApplication::keyboardGrabbed() const | 1562 | bool QPEApplication::keyboardGrabbed() const |
1579 | { | 1563 | { |
1580 | return d->kbgrabber; | 1564 | return d->kbgrabber; |
1581 | } | 1565 | } |
1582 | 1566 | ||
1583 | 1567 | ||
1584 | /*! | 1568 | /*! |
1585 | Reverses the effect of grabKeyboard(). This is called automatically | 1569 | Reverses the effect of grabKeyboard(). This is called automatically |
1586 | on program exit. | 1570 | on program exit. |
1587 | */ | 1571 | */ |
1588 | void QPEApplication::ungrabKeyboard() | 1572 | void QPEApplication::ungrabKeyboard() |
1589 | { | 1573 | { |
1590 | QPEApplicationData * d = ( ( QPEApplication* ) qApp ) ->d; | 1574 | QPEApplicationData * d = ( ( QPEApplication* ) qApp ) ->d; |
1591 | if ( d->kbgrabber == 2 ) { | 1575 | if ( d->kbgrabber == 2 ) { |
1592 | #ifndef QT_NO_COP | 1576 | #ifndef QT_NO_COP |
1593 | QCopEnvelope e( "QPE/System", "grabKeyboard(QString)" ); | 1577 | QCopEnvelope e( "QPE/System", "grabKeyboard(QString)" ); |
1594 | e << QString::null; | 1578 | e << QString::null; |
1595 | #endif | 1579 | #endif |
1596 | 1580 | ||
1597 | d->kbregrab = FALSE; | 1581 | d->kbregrab = FALSE; |
1598 | d->kbgrabber = 0; | 1582 | d->kbgrabber = 0; |
1599 | } | 1583 | } |
1600 | } | 1584 | } |
1601 | 1585 | ||
1602 | /*! | 1586 | /*! |
1603 | Grabs the physical keyboard keys, e.g. the application's launching | 1587 | Grabs the physical keyboard keys, e.g. the application's launching |
1604 | keys. Instead of launching applications when these keys are pressed | 1588 | keys. Instead of launching applications when these keys are pressed |
1605 | the signals emitted are sent to this application instead. Some games | 1589 | the signals emitted are sent to this application instead. Some games |
1606 | programs take over the launch keys in this way to make interaction | 1590 | programs take over the launch keys in this way to make interaction |
1607 | easier. | 1591 | easier. |
1608 | 1592 | ||
1609 | \sa ungrabKeyboard() | 1593 | \sa ungrabKeyboard() |
1610 | */ | 1594 | */ |
1611 | void QPEApplication::grabKeyboard() | 1595 | void QPEApplication::grabKeyboard() |
1612 | { | 1596 | { |
1613 | QPEApplicationData * d = ( ( QPEApplication* ) qApp ) ->d; | 1597 | QPEApplicationData * d = ( ( QPEApplication* ) qApp ) ->d; |
1614 | if ( qApp->type() == QApplication::GuiServer ) | 1598 | if ( qApp->type() == QApplication::GuiServer ) |
1615 | d->kbgrabber = 0; | 1599 | d->kbgrabber = 0; |
1616 | else { | 1600 | else { |
1617 | #ifndef QT_NO_COP | 1601 | #ifndef QT_NO_COP |
1618 | QCopEnvelope e( "QPE/System", "grabKeyboard(QString)" ); | 1602 | QCopEnvelope e( "QPE/System", "grabKeyboard(QString)" ); |
1619 | e << d->appName; | 1603 | e << d->appName; |
1620 | #endif | 1604 | #endif |
1621 | 1605 | ||
1622 | d->kbgrabber = 2; // me | 1606 | d->kbgrabber = 2; // me |
1623 | } | 1607 | } |
1624 | } | 1608 | } |
1625 | 1609 | ||
1626 | /*! | 1610 | /*! |
1627 | \reimp | 1611 | \reimp |
1628 | */ | 1612 | */ |
1629 | int QPEApplication::exec() | 1613 | int QPEApplication::exec() |
1630 | { | 1614 | { |
1631 | #ifndef QT_NO_COP | 1615 | #ifndef QT_NO_COP |
1632 | d->sendQCopQ(); | 1616 | d->sendQCopQ(); |
1633 | #endif | 1617 | #endif |
1634 | 1618 | ||
1635 | if ( d->keep_running ) | 1619 | if ( d->keep_running ) |
1636 | //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() ) | 1620 | //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() ) |
1637 | return QApplication::exec(); | 1621 | return QApplication::exec(); |
1638 | 1622 | ||
1639 | #ifndef QT_NO_COP | 1623 | #ifndef QT_NO_COP |
1640 | 1624 | ||
1641 | { | 1625 | { |
1642 | QCopEnvelope e( "QPE/System", "closing(QString)" ); | 1626 | QCopEnvelope e( "QPE/System", "closing(QString)" ); |
1643 | e << d->appName; | 1627 | e << d->appName; |
1644 | } | 1628 | } |
1645 | #endif | 1629 | #endif |
1646 | processEvents(); | 1630 | processEvents(); |
1647 | return 0; | 1631 | return 0; |
1648 | } | 1632 | } |
1649 | 1633 | ||
1650 | /*! | 1634 | /*! |
1651 | \internal | 1635 | \internal |
1652 | External request for application to quit. Quits if possible without | 1636 | External request for application to quit. Quits if possible without |
1653 | loosing state. | 1637 | loosing state. |
1654 | */ | 1638 | */ |
1655 | void QPEApplication::tryQuit() | 1639 | void QPEApplication::tryQuit() |
1656 | { | 1640 | { |
1657 | if ( activeModalWidget() || strcmp( argv() [ 0 ], "embeddedkonsole" ) == 0 ) | 1641 | if ( activeModalWidget() || strcmp( argv() [ 0 ], "embeddedkonsole" ) == 0 ) |
1658 | return ; // Inside modal loop or konsole. Too hard to save state. | 1642 | return ; // Inside modal loop or konsole. Too hard to save state. |
1659 | #ifndef QT_NO_COP | 1643 | #ifndef QT_NO_COP |
1660 | 1644 | ||
1661 | { | 1645 | { |
1662 | QCopEnvelope e( "QPE/System", "closing(QString)" ); | 1646 | QCopEnvelope e( "QPE/System", "closing(QString)" ); |
1663 | e << d->appName; | 1647 | e << d->appName; |
1664 | } | 1648 | } |
1665 | #endif | 1649 | #endif |
1666 | processEvents(); | 1650 | processEvents(); |
1667 | 1651 | ||
1668 | quit(); | 1652 | quit(); |
1669 | } | 1653 | } |
1670 | 1654 | ||
1671 | /*! | 1655 | /*! |
1672 | \internal | 1656 | \internal |
1673 | User initiated quit. Makes the window 'Go Away'. If preloaded this means | 1657 | User initiated quit. Makes the window 'Go Away'. If preloaded this means |
1674 | hiding the window. If not it means quitting the application. | 1658 | hiding the window. If not it means quitting the application. |
1675 | As this is user initiated we don't need to check state. | 1659 | As this is user initiated we don't need to check state. |
1676 | */ | 1660 | */ |
1677 | void QPEApplication::hideOrQuit() | 1661 | void QPEApplication::hideOrQuit() |
1678 | { | 1662 | { |
1679 | processEvents(); | 1663 | processEvents(); |
1680 | 1664 | ||
1681 | // If we are a preloaded application we don't actually quit, so emit | 1665 | // If we are a preloaded application we don't actually quit, so emit |
1682 | // a System message indicating we're quasi-closing. | 1666 | // a System message indicating we're quasi-closing. |
1683 | if ( d->preloaded && d->qpe_main_widget ) | 1667 | if ( d->preloaded && d->qpe_main_widget ) |
1684 | #ifndef QT_NO_COP | 1668 | #ifndef QT_NO_COP |
1685 | 1669 | ||
1686 | { | 1670 | { |
1687 | QCopEnvelope e("QPE/System", "fastAppHiding(QString)" ); | 1671 | QCopEnvelope e("QPE/System", "fastAppHiding(QString)" ); |
1688 | e << d->appName; | 1672 | e << d->appName; |
1689 | d->qpe_main_widget->hide(); | 1673 | d->qpe_main_widget->hide(); |
1690 | } | 1674 | } |
1691 | #endif | 1675 | #endif |
1692 | else | 1676 | else |
1693 | quit(); | 1677 | quit(); |
1694 | } | 1678 | } |
1695 | 1679 | ||
1680 | |||
1681 | // These 6 stubs below need 1.5K in the binary and besides that - | ||
1682 | // we are not using ancient toolchains anymore - sandman | ||
1683 | |||
1696 | #if defined(QT_QWS_IPAQ) || defined(QT_QWS_SHARP) | 1684 | #if defined(QT_QWS_IPAQ) || defined(QT_QWS_SHARP) |
1697 | 1685 | ||
1698 | // The libraries with the skiff package (and possibly others) have | 1686 | // The libraries with the skiff package (and possibly others) have |
1699 | // completely useless implementations of builtin new and delete that | 1687 | // completely useless implementations of builtin new and delete that |
1700 | // use about 50% of your CPU. Here we revert to the simple libc | 1688 | // use about 50% of your CPU. Here we revert to the simple libc |
1701 | // functions. | 1689 | // functions. |
1702 | 1690 | ||
1703 | void* operator new[]( size_t size ) | 1691 | void* operator new[]( size_t size ) |
1704 | { | 1692 | { |
1705 | return malloc( size ); | 1693 | return malloc( size ); |
1706 | } | 1694 | } |
1707 | 1695 | ||
1708 | void* operator new( size_t size ) | 1696 | void* operator new( size_t size ) |
1709 | { | 1697 | { |
1710 | return malloc( size ); | 1698 | return malloc( size ); |
1711 | } | 1699 | } |
1712 | 1700 | ||
1713 | void operator delete[]( void* p ) | 1701 | void operator delete[]( void* p ) |
1714 | { | 1702 | { |
1715 | free( p ); | 1703 | free( p ); |
1716 | } | 1704 | } |
1717 | 1705 | ||
1718 | void operator delete[]( void* p, size_t /*size*/ ) | 1706 | void operator delete[]( void* p, size_t /*size*/ ) |
1719 | { | 1707 | { |
1720 | free( p ); | 1708 | free( p ); |
1721 | } | 1709 | } |
1722 | 1710 | ||
1723 | void operator delete( void* p ) | 1711 | void operator delete( void* p ) |
1724 | { | 1712 | { |
1725 | free( p ); | 1713 | free( p ); |
1726 | } | 1714 | } |
1727 | 1715 | ||
1728 | void operator delete( void* p, size_t /*size*/ ) | 1716 | void operator delete( void* p, size_t /*size*/ ) |
1729 | { | 1717 | { |
1730 | free( p ); | 1718 | free( p ); |
1731 | } | 1719 | } |
1732 | 1720 | ||
1733 | #endif | 1721 | #endif |
1734 | 1722 | ||
1735 | #if ( QT_VERSION <= 230 ) && !defined(SINGLE_APP) | 1723 | #if ( QT_VERSION <= 230 ) && !defined(SINGLE_APP) |
1736 | #include <qwidgetlist.h> | 1724 | #include <qwidgetlist.h> |
1737 | #ifdef QWS | 1725 | #ifdef QWS |
1738 | #include <qgfx_qws.h> | 1726 | #include <qgfx_qws.h> |
1739 | extern QRect qt_maxWindowRect; | 1727 | extern QRect qt_maxWindowRect; |
1740 | void qt_setMaxWindowRect(const QRect& r ) | 1728 | void qt_setMaxWindowRect(const QRect& r ) |
1741 | { | 1729 | { |
1742 | qt_maxWindowRect = qt_screen->mapFromDevice( r, | 1730 | qt_maxWindowRect = qt_screen->mapFromDevice( r, |
1743 | qt_screen->mapToDevice( QSize( qt_screen->width(), qt_screen->height() ) ) ); | 1731 | qt_screen->mapToDevice( QSize( qt_screen->width(), qt_screen->height() ) ) ); |
1744 | // Re-resize any maximized windows | 1732 | // Re-resize any maximized windows |
1745 | QWidgetList* l = QApplication::topLevelWidgets(); | 1733 | QWidgetList* l = QApplication::topLevelWidgets(); |
1746 | if ( l ) { | 1734 | if ( l ) { |
1747 | QWidget * w = l->first(); | 1735 | QWidget * w = l->first(); |
1748 | while ( w ) { | 1736 | while ( w ) { |
1749 | if ( w->isVisible() && w->isMaximized() ) { | 1737 | if ( w->isVisible() && w->isMaximized() ) { |
1750 | w->showMaximized(); | 1738 | w->showMaximized(); |
1751 | } | 1739 | } |
1752 | w = l->next(); | 1740 | w = l->next(); |
1753 | } | 1741 | } |
1754 | delete l; | 1742 | delete l; |
1755 | } | 1743 | } |
1756 | } | 1744 | } |
1757 | #endif | 1745 | #endif |
1758 | #endif | 1746 | #endif |