author | zecke <zecke> | 2004-08-24 17:37:59 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-08-24 17:37:59 (UTC) |
commit | e90847c784c48bd21bf8768cb38edb853b832697 (patch) (unidiff) | |
tree | 7c95b22cc4e9b69aa384c041ae67babb8fafe319 /library/qpeapplication.cpp | |
parent | 0a141c4a9719aa273867ad45c4293208545489b1 (diff) | |
download | opie-e90847c784c48bd21bf8768cb38edb853b832697.zip opie-e90847c784c48bd21bf8768cb38edb853b832697.tar.gz opie-e90847c784c48bd21bf8768cb38edb853b832697.tar.bz2 |
Allow to completely turn off/on Right on Hold Visual Feedback
mickey thanks for spotting the linking failures :}
-rw-r--r-- | library/qpeapplication.cpp | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp index acad81d..35f433c 100644 --- a/library/qpeapplication.cpp +++ b/library/qpeapplication.cpp | |||
@@ -5,262 +5,267 @@ | |||
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 | */ | 19 | */ |
20 | #define QTOPIA_INTERNAL_LANGLIST | 20 | #define QTOPIA_INTERNAL_LANGLIST |
21 | #include <stdlib.h> | 21 | #include <stdlib.h> |
22 | #include <unistd.h> | 22 | #include <unistd.h> |
23 | #ifndef Q_OS_MACX | 23 | #ifndef Q_OS_MACX |
24 | #include <linux/limits.h> // needed for some toolchains (PATH_MAX) | 24 | #include <linux/limits.h> // needed for some toolchains (PATH_MAX) |
25 | #endif | 25 | #endif |
26 | #include <qfile.h> | 26 | #include <qfile.h> |
27 | #include <qqueue.h> | 27 | #include <qqueue.h> |
28 | #ifdef Q_WS_QWS | 28 | #ifdef Q_WS_QWS |
29 | #ifndef QT_NO_COP | 29 | #ifndef QT_NO_COP |
30 | #if QT_VERSION <= 231 | 30 | #if QT_VERSION <= 231 |
31 | #define private public | 31 | #define private public |
32 | #define sendLocally processEvent | 32 | #define sendLocally processEvent |
33 | #include "qcopenvelope_qws.h" | 33 | #include "qcopenvelope_qws.h" |
34 | #undef private | 34 | #undef private |
35 | #else | 35 | #else |
36 | #include "qcopenvelope_qws.h" | 36 | #include "qcopenvelope_qws.h" |
37 | #endif | 37 | #endif |
38 | #endif | 38 | #endif |
39 | #include <qwindowsystem_qws.h> | 39 | #include <qwindowsystem_qws.h> |
40 | #endif | 40 | #endif |
41 | #include <qtextstream.h> | 41 | #include <qtextstream.h> |
42 | #include <qpalette.h> | 42 | #include <qpalette.h> |
43 | #include <qbuffer.h> | 43 | #include <qbuffer.h> |
44 | #include <qptrdict.h> | 44 | #include <qptrdict.h> |
45 | #include <qregexp.h> | 45 | #include <qregexp.h> |
46 | #include <qdir.h> | 46 | #include <qdir.h> |
47 | #include <qlabel.h> | 47 | #include <qlabel.h> |
48 | #include <qdialog.h> | 48 | #include <qdialog.h> |
49 | #include <qdragobject.h> | 49 | #include <qdragobject.h> |
50 | #include <qtextcodec.h> | 50 | #include <qtextcodec.h> |
51 | #include <qevent.h> | 51 | #include <qevent.h> |
52 | #include <qtooltip.h> | 52 | #include <qtooltip.h> |
53 | #include <qsignal.h> | 53 | #include <qsignal.h> |
54 | #include <qmainwindow.h> | 54 | #include <qmainwindow.h> |
55 | #include <qwidgetlist.h> | 55 | #include <qwidgetlist.h> |
56 | #include <qpixmapcache.h> | 56 | #include <qpixmapcache.h> |
57 | 57 | ||
58 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 58 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
59 | #define QTOPIA_INTERNAL_INITAPP | 59 | #define QTOPIA_INTERNAL_INITAPP |
60 | #include "qpeapplication.h" | 60 | #include "qpeapplication.h" |
61 | #include "qpestyle.h" | 61 | #include "qpestyle.h" |
62 | #include "styleinterface.h" | 62 | #include "styleinterface.h" |
63 | #if QT_VERSION >= 300 | 63 | #if QT_VERSION >= 300 |
64 | #include <qstylefactory.h> | 64 | #include <qstylefactory.h> |
65 | #else | 65 | #else |
66 | #include <qplatinumstyle.h> | 66 | #include <qplatinumstyle.h> |
67 | #include <qwindowsstyle.h> | 67 | #include <qwindowsstyle.h> |
68 | #include <qmotifstyle.h> | 68 | #include <qmotifstyle.h> |
69 | #include <qmotifplusstyle.h> | 69 | #include <qmotifplusstyle.h> |
70 | #include "lightstyle.h" | 70 | #include "lightstyle.h" |
71 | 71 | ||
72 | #include <qpe/qlibrary.h> | 72 | #include <qpe/qlibrary.h> |
73 | #endif | 73 | #endif |
74 | #include "global.h" | 74 | #include "global.h" |
75 | #include "resource.h" | 75 | #include "resource.h" |
76 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) | 76 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) |
77 | #include "qutfcodec.h" | 77 | #include "qutfcodec.h" |
78 | #endif | 78 | #endif |
79 | #include "config.h" | 79 | #include "config.h" |
80 | #include "network.h" | 80 | #include "network.h" |
81 | #ifdef QWS | 81 | #ifdef QWS |
82 | #include "fontmanager.h" | 82 | #include "fontmanager.h" |
83 | #include "fontdatabase.h" | 83 | #include "fontdatabase.h" |
84 | #endif | 84 | #endif |
85 | 85 | ||
86 | #include "alarmserver.h" | 86 | #include "alarmserver.h" |
87 | #include "applnk.h" | 87 | #include "applnk.h" |
88 | #include "qpemenubar.h" | 88 | #include "qpemenubar.h" |
89 | #include "textcodecinterface.h" | 89 | #include "textcodecinterface.h" |
90 | #include "imagecodecinterface.h" | 90 | #include "imagecodecinterface.h" |
91 | 91 | ||
92 | #include <unistd.h> | 92 | #include <unistd.h> |
93 | #include <sys/file.h> | 93 | #include <sys/file.h> |
94 | #include <sys/ioctl.h> | 94 | #include <sys/ioctl.h> |
95 | #ifndef QT_NO_SOUND | 95 | #ifndef QT_NO_SOUND |
96 | #include <sys/soundcard.h> | 96 | #include <sys/soundcard.h> |
97 | #endif | 97 | #endif |
98 | #include "qt_override_p.h" | 98 | #include "qt_override_p.h" |
99 | 99 | ||
100 | #include <qpe/rohfeedback.h> | 100 | #include <qpe/rohfeedback.h> |
101 | 101 | ||
102 | 102 | ||
103 | static bool useBigPixmaps = 0; | 103 | static bool useBigPixmaps = 0; |
104 | 104 | ||
105 | 105 | ||
106 | class HackWidget : public QWidget | 106 | class HackWidget : public QWidget |
107 | { | 107 | { |
108 | public: | 108 | public: |
109 | bool needsOk() | 109 | bool needsOk() |
110 | { return (getWState() & WState_Reserved1 ); } | 110 | { return (getWState() & WState_Reserved1 ); } |
111 | 111 | ||
112 | QRect normalGeometry() | 112 | QRect normalGeometry() |
113 | { return topData()->normalGeometry; }; | 113 | { return topData()->normalGeometry; }; |
114 | }; | 114 | }; |
115 | 115 | ||
116 | class QPEApplicationData | 116 | class QPEApplicationData |
117 | { | 117 | { |
118 | public: | 118 | public: |
119 | QPEApplicationData ( ) | 119 | QPEApplicationData ( ) |
120 | : presstimer( 0 ), presswidget( 0 ), rightpressed( false ), kbgrabbed( false ), | 120 | : presstimer( 0 ), presswidget( 0 ), rightpressed( false ), kbgrabbed( false ), |
121 | notbusysent( false ), preloaded( false ), forceshow( false ), nomaximize( false ), | 121 | notbusysent( false ), preloaded( false ), forceshow( false ), nomaximize( false ), |
122 | keep_running( true ), qcopQok( false ), | 122 | keep_running( true ), qcopQok( false ), |
123 | fontFamily( "Vera" ), fontSize( 10 ), smallIconSize( 14 ), | 123 | fontFamily( "Vera" ), fontSize( 10 ), smallIconSize( 14 ), |
124 | bigIconSize( 32 ), qpe_main_widget( 0 ) | 124 | bigIconSize( 32 ), qpe_main_widget( 0 ) |
125 | { | 125 | { |
126 | Config cfg( "qpe" ); | 126 | Config cfg( "qpe" ); |
127 | cfg.setGroup( "Appearance" ); | 127 | cfg.setGroup( "Appearance" ); |
128 | useBigPixmaps = cfg.readBoolEntry( "useBigPixmaps", false ); | 128 | useBigPixmaps = cfg.readBoolEntry( "useBigPixmaps", false ); |
129 | fontFamily = cfg.readEntry( "FontFamily", "Vera" ); | 129 | fontFamily = cfg.readEntry( "FontFamily", "Vera" ); |
130 | fontSize = cfg.readNumEntry( "FontSize", 10 ); | 130 | fontSize = cfg.readNumEntry( "FontSize", 10 ); |
131 | smallIconSize = cfg.readNumEntry( "SmallIconSize", 14 ); | 131 | smallIconSize = cfg.readNumEntry( "SmallIconSize", 14 ); |
132 | bigIconSize = cfg.readNumEntry( "BigIconSize", 32 ); | 132 | bigIconSize = cfg.readNumEntry( "BigIconSize", 32 ); |
133 | #ifdef OPIE_ROHFEEDBACK | ||
133 | RoH = 0; | 134 | RoH = 0; |
135 | #endif | ||
134 | } | 136 | } |
135 | 137 | ||
136 | int presstimer; | 138 | int presstimer; |
137 | QWidget* presswidget; | 139 | QWidget* presswidget; |
138 | QPoint presspos; | 140 | QPoint presspos; |
141 | #ifdef OPIE_ROHFEEDBACK | ||
142 | Opie::Internal::RoHFeedback *RoH; | ||
143 | #endif | ||
139 | 144 | ||
140 | bool rightpressed : 1; | 145 | bool rightpressed : 1; |
141 | bool kbgrabbed : 1; | 146 | bool kbgrabbed : 1; |
142 | bool notbusysent : 1; | 147 | bool notbusysent : 1; |
143 | bool preloaded : 1; | 148 | bool preloaded : 1; |
144 | bool forceshow : 1; | 149 | bool forceshow : 1; |
145 | bool nomaximize : 1; | 150 | bool nomaximize : 1; |
146 | bool keep_running : 1; | 151 | bool keep_running : 1; |
147 | bool qcopQok : 1; | 152 | bool qcopQok : 1; |
148 | 153 | ||
149 | QCString fontFamily; | 154 | QCString fontFamily; |
150 | int fontSize; | 155 | int fontSize; |
151 | int smallIconSize; | 156 | int smallIconSize; |
152 | int bigIconSize; | 157 | int bigIconSize; |
153 | 158 | ||
154 | QStringList langs; | 159 | QStringList langs; |
155 | QString appName; | 160 | QString appName; |
156 | struct QCopRec | 161 | struct QCopRec |
157 | { | 162 | { |
158 | QCopRec( const QCString &ch, const QCString &msg, | 163 | QCopRec( const QCString &ch, const QCString &msg, |
159 | const QByteArray &d ) : | 164 | const QByteArray &d ) : |
160 | channel( ch ), message( msg ), data( d ) | 165 | channel( ch ), message( msg ), data( d ) |
161 | { } | 166 | { } |
162 | 167 | ||
163 | QCString channel; | 168 | QCString channel; |
164 | QCString message; | 169 | QCString message; |
165 | QByteArray data; | 170 | QByteArray data; |
166 | }; | 171 | }; |
167 | QWidget* qpe_main_widget; | 172 | QWidget* qpe_main_widget; |
168 | QGuardedPtr<QWidget> lastraised; | 173 | QGuardedPtr<QWidget> lastraised; |
169 | QQueue<QCopRec> qcopq; | 174 | QQueue<QCopRec> qcopq; |
170 | QString styleName; | 175 | QString styleName; |
171 | QString decorationName; | 176 | QString decorationName; |
172 | 177 | ||
173 | void enqueueQCop( const QCString &ch, const QCString &msg, | 178 | void enqueueQCop( const QCString &ch, const QCString &msg, |
174 | const QByteArray &data ) | 179 | const QByteArray &data ) |
175 | { | 180 | { |
176 | qcopq.enqueue( new QCopRec( ch, msg, data ) ); | 181 | qcopq.enqueue( new QCopRec( ch, msg, data ) ); |
177 | } | 182 | } |
178 | void sendQCopQ() | 183 | void sendQCopQ() |
179 | { | 184 | { |
180 | if (!qcopQok ) | 185 | if (!qcopQok ) |
181 | return; | 186 | return; |
182 | 187 | ||
183 | QCopRec * r; | 188 | QCopRec * r; |
184 | 189 | ||
185 | while((r=qcopq.dequeue())) { | 190 | while((r=qcopq.dequeue())) { |
186 | // remove from queue before sending... | 191 | // remove from queue before sending... |
187 | // event loop can come around again before getting | 192 | // event loop can come around again before getting |
188 | // back from sendLocally | 193 | // back from sendLocally |
189 | #ifndef QT_NO_COP | 194 | #ifndef QT_NO_COP |
190 | QCopChannel::sendLocally( r->channel, r->message, r->data ); | 195 | QCopChannel::sendLocally( r->channel, r->message, r->data ); |
191 | #endif | 196 | #endif |
192 | 197 | ||
193 | delete r; | 198 | delete r; |
194 | } | 199 | } |
195 | } | 200 | } |
196 | 201 | ||
197 | static void show_mx(QWidget* mw, bool nomaximize, QString &strName) | 202 | static void show_mx(QWidget* mw, bool nomaximize, QString &strName) |
198 | { | 203 | { |
199 | if ( mw->inherits("QMainWindow") || mw->isA("QMainWindow") ) | 204 | if ( mw->inherits("QMainWindow") || mw->isA("QMainWindow") ) |
200 | { | 205 | { |
201 | ( ( QMainWindow* ) mw )->setUsesBigPixmaps( useBigPixmaps ); | 206 | ( ( QMainWindow* ) mw )->setUsesBigPixmaps( useBigPixmaps ); |
202 | } | 207 | } |
203 | QPoint p; | 208 | QPoint p; |
204 | QSize s; | 209 | QSize s; |
205 | bool max; | 210 | bool max; |
206 | if ( mw->isVisible() ) { | 211 | if ( mw->isVisible() ) { |
207 | if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { | 212 | if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { |
208 | mw->resize(s); | 213 | mw->resize(s); |
209 | mw->move(p); | 214 | mw->move(p); |
210 | } | 215 | } |
211 | mw->raise(); | 216 | mw->raise(); |
212 | } else { | 217 | } else { |
213 | 218 | ||
214 | if ( mw->layout() && mw->inherits("QDialog") ) { | 219 | if ( mw->layout() && mw->inherits("QDialog") ) { |
215 | if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { | 220 | if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { |
216 | mw->resize(s); | 221 | mw->resize(s); |
217 | mw->move(p); | 222 | mw->move(p); |
218 | 223 | ||
219 | if ( max && !nomaximize ) { | 224 | if ( max && !nomaximize ) { |
220 | mw->showMaximized(); | 225 | mw->showMaximized(); |
221 | } else { | 226 | } else { |
222 | mw->show(); | 227 | mw->show(); |
223 | } | 228 | } |
224 | } else { | 229 | } else { |
225 | qpe_show_dialog((QDialog*)mw,nomaximize); | 230 | qpe_show_dialog((QDialog*)mw,nomaximize); |
226 | } | 231 | } |
227 | } else { | 232 | } else { |
228 | if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { | 233 | if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { |
229 | mw->resize(s); | 234 | mw->resize(s); |
230 | mw->move(p); | 235 | mw->move(p); |
231 | } else { //no stored rectangle, make an estimation | 236 | } else { //no stored rectangle, make an estimation |
232 | int x = (qApp->desktop()->width()-mw->frameGeometry().width())/2; | 237 | int x = (qApp->desktop()->width()-mw->frameGeometry().width())/2; |
233 | int y = (qApp->desktop()->height()-mw->frameGeometry().height())/2; | 238 | int y = (qApp->desktop()->height()-mw->frameGeometry().height())/2; |
234 | mw->move( QMAX(x,0), QMAX(y,0) ); | 239 | mw->move( QMAX(x,0), QMAX(y,0) ); |
235 | #ifdef Q_WS_QWS | 240 | #ifdef Q_WS_QWS |
236 | if ( !nomaximize ) | 241 | if ( !nomaximize ) |
237 | mw->showMaximized(); | 242 | mw->showMaximized(); |
238 | #endif | 243 | #endif |
239 | } | 244 | } |
240 | if ( max && !nomaximize ) | 245 | if ( max && !nomaximize ) |
241 | mw->showMaximized(); | 246 | mw->showMaximized(); |
242 | else | 247 | else |
243 | mw->show(); | 248 | mw->show(); |
244 | } | 249 | } |
245 | } | 250 | } |
246 | } | 251 | } |
247 | 252 | ||
248 | static void qpe_show_dialog( QDialog* d, bool nomax ) | 253 | static void qpe_show_dialog( QDialog* d, bool nomax ) |
249 | { | 254 | { |
250 | QSize sh = d->sizeHint(); | 255 | QSize sh = d->sizeHint(); |
251 | int w = QMAX(sh.width(),d->width()); | 256 | int w = QMAX(sh.width(),d->width()); |
252 | int h = QMAX(sh.height(),d->height()); | 257 | int h = QMAX(sh.height(),d->height()); |
253 | 258 | ||
254 | if ( d->parentWidget() && !d->parentWidget()->topLevelWidget()->isMaximized() ) | 259 | if ( d->parentWidget() && !d->parentWidget()->topLevelWidget()->isMaximized() ) |
255 | nomax = TRUE; | 260 | nomax = TRUE; |
256 | 261 | ||
257 | #ifndef Q_WS_QWS | 262 | #ifndef Q_WS_QWS |
258 | QSize s(qApp->desktop()->width(), qApp->desktop()->height() ); | 263 | QSize s(qApp->desktop()->width(), qApp->desktop()->height() ); |
259 | #else | 264 | #else |
260 | QSize s(qt_maxWindowRect.width(), qt_maxWindowRect.height() ); | 265 | QSize s(qt_maxWindowRect.width(), qt_maxWindowRect.height() ); |
261 | #endif | 266 | #endif |
262 | 267 | ||
263 | int maxX = s.width() - (d->frameGeometry().width() - d->geometry().width()); | 268 | int maxX = s.width() - (d->frameGeometry().width() - d->geometry().width()); |
264 | int maxY = s.height() - (d->frameGeometry().height() - d->geometry().height()); | 269 | int maxY = s.height() - (d->frameGeometry().height() - d->geometry().height()); |
265 | 270 | ||
266 | if ( (w >= maxX && h >= maxY) || ( (!nomax) && ( w > s.width()*3/4 || h > s.height()*3/4 ) ) ) { | 271 | if ( (w >= maxX && h >= maxY) || ( (!nomax) && ( w > s.width()*3/4 || h > s.height()*3/4 ) ) ) { |
@@ -372,258 +377,256 @@ static void qpe_show_dialog( QDialog* d, bool nomax ) | |||
372 | return TRUE; | 377 | return TRUE; |
373 | } | 378 | } |
374 | 379 | ||
375 | static void store_widget_rect(QWidget *w, QString &app) | 380 | static void store_widget_rect(QWidget *w, QString &app) |
376 | { | 381 | { |
377 | // 350 is the trigger in qwsdefaultdecoration for providing a resize button | 382 | // 350 is the trigger in qwsdefaultdecoration for providing a resize button |
378 | if ( qApp->desktop()->width() <= 350 ) | 383 | if ( qApp->desktop()->width() <= 350 ) |
379 | return; | 384 | return; |
380 | // we use these to map the offset of geometry and pos. ( we can only use normalGeometry to | 385 | // we use these to map the offset of geometry and pos. ( we can only use normalGeometry to |
381 | // get the non-maximized version, so we have to do it the hard way ) | 386 | // get the non-maximized version, so we have to do it the hard way ) |
382 | int offsetX = w->x() - w->geometry().left(); | 387 | int offsetX = w->x() - w->geometry().left(); |
383 | int offsetY = w->y() - w->geometry().top(); | 388 | int offsetY = w->y() - w->geometry().top(); |
384 | 389 | ||
385 | QRect r; | 390 | QRect r; |
386 | if ( w->isMaximized() ) | 391 | if ( w->isMaximized() ) |
387 | r = ( (HackWidget *) w)->normalGeometry(); | 392 | r = ( (HackWidget *) w)->normalGeometry(); |
388 | else | 393 | else |
389 | r = w->geometry(); | 394 | r = w->geometry(); |
390 | 395 | ||
391 | // Stores the window placement as pos(), size() (due to the offset mapping) | 396 | // Stores the window placement as pos(), size() (due to the offset mapping) |
392 | Config cfg( "qpe" ); | 397 | Config cfg( "qpe" ); |
393 | cfg.setGroup("ApplicationPositions"); | 398 | cfg.setGroup("ApplicationPositions"); |
394 | QString s; | 399 | QString s; |
395 | s.sprintf("%d,%d,%d,%d,%d", r.left() + offsetX, r.top() + offsetY, r.width(), r.height(), w->isMaximized() ); | 400 | s.sprintf("%d,%d,%d,%d,%d", r.left() + offsetX, r.top() + offsetY, r.width(), r.height(), w->isMaximized() ); |
396 | cfg.writeEntry( app, s ); | 401 | cfg.writeEntry( app, s ); |
397 | } | 402 | } |
398 | 403 | ||
399 | static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) | 404 | static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) |
400 | { | 405 | { |
401 | /* | 406 | /* |
402 | // This works but disable it for now until it is safe to apply | 407 | // This works but disable it for now until it is safe to apply |
403 | // What is does is scan the .desktop files of all the apps for | 408 | // What is does is scan the .desktop files of all the apps for |
404 | // the applnk that has the corresponding argv[0] as this program | 409 | // the applnk that has the corresponding argv[0] as this program |
405 | // then it uses the name stored in the .desktop file as the caption | 410 | // then it uses the name stored in the .desktop file as the caption |
406 | // for the main widget. This saves duplicating translations for | 411 | // for the main widget. This saves duplicating translations for |
407 | // the app name in the program and in the .desktop files. | 412 | // the app name in the program and in the .desktop files. |
408 | 413 | ||
409 | AppLnkSet apps( appsPath ); | 414 | AppLnkSet apps( appsPath ); |
410 | 415 | ||
411 | QList<AppLnk> appsList = apps.children(); | 416 | QList<AppLnk> appsList = apps.children(); |
412 | for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { | 417 | for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { |
413 | if ( (*it)->exec() == appName ) { | 418 | if ( (*it)->exec() == appName ) { |
414 | mw->setCaption( (*it)->name() ); | 419 | mw->setCaption( (*it)->name() ); |
415 | return TRUE; | 420 | return TRUE; |
416 | } | 421 | } |
417 | } | 422 | } |
418 | */ | 423 | */ |
419 | return FALSE; | 424 | return FALSE; |
420 | } | 425 | } |
421 | 426 | ||
422 | 427 | ||
423 | void show(QWidget* mw, bool nomax) | 428 | void show(QWidget* mw, bool nomax) |
424 | { | 429 | { |
425 | setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" ); | 430 | setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" ); |
426 | nomaximize = nomax; | 431 | nomaximize = nomax; |
427 | qpe_main_widget = mw; | 432 | qpe_main_widget = mw; |
428 | qcopQok = TRUE; | 433 | qcopQok = TRUE; |
429 | #ifndef QT_NO_COP | 434 | #ifndef QT_NO_COP |
430 | 435 | ||
431 | sendQCopQ(); | 436 | sendQCopQ(); |
432 | #endif | 437 | #endif |
433 | 438 | ||
434 | if ( preloaded ) { | 439 | if ( preloaded ) { |
435 | if (forceshow) | 440 | if (forceshow) |
436 | show_mx(mw, nomax, appName); | 441 | show_mx(mw, nomax, appName); |
437 | } | 442 | } |
438 | else if ( keep_running ) { | 443 | else if ( keep_running ) { |
439 | show_mx(mw, nomax, appName); | 444 | show_mx(mw, nomax, appName); |
440 | } | 445 | } |
441 | } | 446 | } |
442 | 447 | ||
443 | void loadTextCodecs() | 448 | void loadTextCodecs() |
444 | { | 449 | { |
445 | QString path = QPEApplication::qpeDir() + "/plugins/textcodecs"; | 450 | QString path = QPEApplication::qpeDir() + "/plugins/textcodecs"; |
446 | #ifdef Q_OS_MACX | 451 | #ifdef Q_OS_MACX |
447 | QDir dir( path, "lib*.dylib" ); | 452 | QDir dir( path, "lib*.dylib" ); |
448 | #else | 453 | #else |
449 | QDir dir( path, "lib*.so" ); | 454 | QDir dir( path, "lib*.so" ); |
450 | #endif | 455 | #endif |
451 | QStringList list; | 456 | QStringList list; |
452 | if ( dir. exists ( )) | 457 | if ( dir. exists ( )) |
453 | list = dir.entryList(); | 458 | list = dir.entryList(); |
454 | QStringList::Iterator it; | 459 | QStringList::Iterator it; |
455 | for ( it = list.begin(); it != list.end(); ++it ) { | 460 | for ( it = list.begin(); it != list.end(); ++it ) { |
456 | TextCodecInterface *iface = 0; | 461 | TextCodecInterface *iface = 0; |
457 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 462 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
458 | if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { | 463 | if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { |
459 | QValueList<int> mibs = iface->mibEnums(); | 464 | QValueList<int> mibs = iface->mibEnums(); |
460 | for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) { | 465 | for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) { |
461 | (void)iface->createForMib(*i); | 466 | (void)iface->createForMib(*i); |
462 | // ### it exists now; need to remember if we can delete it | 467 | // ### it exists now; need to remember if we can delete it |
463 | } | 468 | } |
464 | } | 469 | } |
465 | else { | 470 | else { |
466 | lib->unload(); | 471 | lib->unload(); |
467 | delete lib; | 472 | delete lib; |
468 | } | 473 | } |
469 | } | 474 | } |
470 | } | 475 | } |
471 | 476 | ||
472 | void loadImageCodecs() | 477 | void loadImageCodecs() |
473 | { | 478 | { |
474 | QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs"; | 479 | QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs"; |
475 | #ifdef Q_OS_MACX | 480 | #ifdef Q_OS_MACX |
476 | QDir dir( path, "lib*.dylib" ); | 481 | QDir dir( path, "lib*.dylib" ); |
477 | #else | 482 | #else |
478 | QDir dir( path, "lib*.so" ); | 483 | QDir dir( path, "lib*.so" ); |
479 | #endif | 484 | #endif |
480 | QStringList list; | 485 | QStringList list; |
481 | if ( dir. exists ( )) | 486 | if ( dir. exists ( )) |
482 | list = dir.entryList(); | 487 | list = dir.entryList(); |
483 | QStringList::Iterator it; | 488 | QStringList::Iterator it; |
484 | for ( it = list.begin(); it != list.end(); ++it ) { | 489 | for ( it = list.begin(); it != list.end(); ++it ) { |
485 | ImageCodecInterface *iface = 0; | 490 | ImageCodecInterface *iface = 0; |
486 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 491 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
487 | if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { | 492 | if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { |
488 | QStringList formats = iface->keys(); | 493 | QStringList formats = iface->keys(); |
489 | for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) { | 494 | for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) { |
490 | (void)iface->installIOHandler(*i); | 495 | (void)iface->installIOHandler(*i); |
491 | // ### it exists now; need to remember if we can delete it | 496 | // ### it exists now; need to remember if we can delete it |
492 | } | 497 | } |
493 | } | 498 | } |
494 | else { | 499 | else { |
495 | lib->unload(); | 500 | lib->unload(); |
496 | delete lib; | 501 | delete lib; |
497 | } | 502 | } |
498 | } | 503 | } |
499 | } | 504 | } |
500 | |||
501 | Opie::Internal::RoHFeedback * RoH; | ||
502 | }; | 505 | }; |
503 | 506 | ||
504 | class ResourceMimeFactory : public QMimeSourceFactory | 507 | class ResourceMimeFactory : public QMimeSourceFactory |
505 | { | 508 | { |
506 | public: | 509 | public: |
507 | ResourceMimeFactory() : resImage( 0 ) | 510 | ResourceMimeFactory() : resImage( 0 ) |
508 | { | 511 | { |
509 | setFilePath( Global::helpPath() ); | 512 | setFilePath( Global::helpPath() ); |
510 | setExtensionType( "html", "text/html;charset=UTF-8" ); | 513 | setExtensionType( "html", "text/html;charset=UTF-8" ); |
511 | } | 514 | } |
512 | ~ResourceMimeFactory() { | 515 | ~ResourceMimeFactory() { |
513 | delete resImage; | 516 | delete resImage; |
514 | } | 517 | } |
515 | 518 | ||
516 | const QMimeSource* data( const QString& abs_name ) const | 519 | const QMimeSource* data( const QString& abs_name ) const |
517 | { | 520 | { |
518 | const QMimeSource * r = QMimeSourceFactory::data( abs_name ); | 521 | const QMimeSource * r = QMimeSourceFactory::data( abs_name ); |
519 | if ( !r ) { | 522 | if ( !r ) { |
520 | int sl = abs_name.length(); | 523 | int sl = abs_name.length(); |
521 | do { | 524 | do { |
522 | sl = abs_name.findRev( '/', sl - 1 ); | 525 | sl = abs_name.findRev( '/', sl - 1 ); |
523 | QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; | 526 | QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; |
524 | int dot = name.findRev( '.' ); | 527 | int dot = name.findRev( '.' ); |
525 | if ( dot >= 0 ) | 528 | if ( dot >= 0 ) |
526 | name = name.left( dot ); | 529 | name = name.left( dot ); |
527 | QImage img = Resource::loadImage( name ); | 530 | QImage img = Resource::loadImage( name ); |
528 | if ( !img.isNull() ) { | 531 | if ( !img.isNull() ) { |
529 | delete resImage; | 532 | delete resImage; |
530 | resImage = new QImageDrag( img ); | 533 | resImage = new QImageDrag( img ); |
531 | r = resImage; | 534 | r = resImage; |
532 | } | 535 | } |
533 | } | 536 | } |
534 | while ( !r && sl > 0 ); | 537 | while ( !r && sl > 0 ); |
535 | } | 538 | } |
536 | return r; | 539 | return r; |
537 | } | 540 | } |
538 | private: | 541 | private: |
539 | mutable QImageDrag *resImage; | 542 | mutable QImageDrag *resImage; |
540 | }; | 543 | }; |
541 | 544 | ||
542 | static int& hack(int& i) | 545 | static int& hack(int& i) |
543 | { | 546 | { |
544 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) | 547 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) |
545 | // These should be created, but aren't in Qt 2.3.0 | 548 | // These should be created, but aren't in Qt 2.3.0 |
546 | (void)new QUtf8Codec; | 549 | (void)new QUtf8Codec; |
547 | (void)new QUtf16Codec; | 550 | (void)new QUtf16Codec; |
548 | #endif | 551 | #endif |
549 | return i; | 552 | return i; |
550 | } | 553 | } |
551 | 554 | ||
552 | static int muted = 0; | 555 | static int muted = 0; |
553 | static int micMuted = 0; | 556 | static int micMuted = 0; |
554 | 557 | ||
555 | static void setVolume( int t = 0, int percent = -1 ) | 558 | static void setVolume( int t = 0, int percent = -1 ) |
556 | { | 559 | { |
557 | switch ( t ) { | 560 | switch ( t ) { |
558 | case 0: { | 561 | case 0: { |
559 | Config cfg( "qpe" ); | 562 | Config cfg( "qpe" ); |
560 | cfg.setGroup( "Volume" ); | 563 | cfg.setGroup( "Volume" ); |
561 | if ( percent < 0 ) | 564 | if ( percent < 0 ) |
562 | percent = cfg.readNumEntry( "VolumePercent", 50 ); | 565 | percent = cfg.readNumEntry( "VolumePercent", 50 ); |
563 | #ifndef QT_NO_SOUND | 566 | #ifndef QT_NO_SOUND |
564 | int fd = 0; | 567 | int fd = 0; |
565 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 568 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
566 | int vol = muted ? 0 : percent; | 569 | int vol = muted ? 0 : percent; |
567 | // set both channels to same volume | 570 | // set both channels to same volume |
568 | vol |= vol << 8; | 571 | vol |= vol << 8; |
569 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_VOLUME ), &vol ); | 572 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_VOLUME ), &vol ); |
570 | ::close( fd ); | 573 | ::close( fd ); |
571 | } | 574 | } |
572 | #endif | 575 | #endif |
573 | } | 576 | } |
574 | break; | 577 | break; |
575 | } | 578 | } |
576 | } | 579 | } |
577 | 580 | ||
578 | static void setMic( int t = 0, int percent = -1 ) | 581 | static void setMic( int t = 0, int percent = -1 ) |
579 | { | 582 | { |
580 | switch ( t ) { | 583 | switch ( t ) { |
581 | case 0: { | 584 | case 0: { |
582 | Config cfg( "qpe" ); | 585 | Config cfg( "qpe" ); |
583 | cfg.setGroup( "Volume" ); | 586 | cfg.setGroup( "Volume" ); |
584 | if ( percent < 0 ) | 587 | if ( percent < 0 ) |
585 | percent = cfg.readNumEntry( "Mic", 50 ); | 588 | percent = cfg.readNumEntry( "Mic", 50 ); |
586 | 589 | ||
587 | #ifndef QT_NO_SOUND | 590 | #ifndef QT_NO_SOUND |
588 | int fd = 0; | 591 | int fd = 0; |
589 | int mic = micMuted ? 0 : percent; | 592 | int mic = micMuted ? 0 : percent; |
590 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 593 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
591 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic ); | 594 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic ); |
592 | ::close( fd ); | 595 | ::close( fd ); |
593 | } | 596 | } |
594 | #endif | 597 | #endif |
595 | } | 598 | } |
596 | break; | 599 | break; |
597 | } | 600 | } |
598 | } | 601 | } |
599 | 602 | ||
600 | 603 | ||
601 | static void setBass( int t = 0, int percent = -1 ) | 604 | static void setBass( int t = 0, int percent = -1 ) |
602 | { | 605 | { |
603 | switch ( t ) { | 606 | switch ( t ) { |
604 | case 0: { | 607 | case 0: { |
605 | Config cfg( "qpe" ); | 608 | Config cfg( "qpe" ); |
606 | cfg.setGroup( "Volume" ); | 609 | cfg.setGroup( "Volume" ); |
607 | if ( percent < 0 ) | 610 | if ( percent < 0 ) |
608 | percent = cfg.readNumEntry( "BassPercent", 50 ); | 611 | percent = cfg.readNumEntry( "BassPercent", 50 ); |
609 | 612 | ||
610 | #ifndef QT_NO_SOUND | 613 | #ifndef QT_NO_SOUND |
611 | int fd = 0; | 614 | int fd = 0; |
612 | int bass = percent; | 615 | int bass = percent; |
613 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 616 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
614 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_BASS ), &bass ); | 617 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_BASS ), &bass ); |
615 | ::close( fd ); | 618 | ::close( fd ); |
616 | } | 619 | } |
617 | #endif | 620 | #endif |
618 | } | 621 | } |
619 | break; | 622 | break; |
620 | } | 623 | } |
621 | } | 624 | } |
622 | 625 | ||
623 | 626 | ||
624 | static void setTreble( int t = 0, int percent = -1 ) | 627 | static void setTreble( int t = 0, int percent = -1 ) |
625 | { | 628 | { |
626 | switch ( t ) { | 629 | switch ( t ) { |
627 | case 0: { | 630 | case 0: { |
628 | Config cfg( "qpe" ); | 631 | Config cfg( "qpe" ); |
629 | cfg.setGroup( "Volume" ); | 632 | cfg.setGroup( "Volume" ); |
@@ -1087,257 +1090,259 @@ bool QPEApplication::qwsEventFilter( QWSEvent * e ) | |||
1087 | if ( e->type == QWSEvent::Key ) { | 1090 | if ( e->type == QWSEvent::Key ) { |
1088 | QWSKeyEvent *ke = ( QWSKeyEvent * ) e; | 1091 | QWSKeyEvent *ke = ( QWSKeyEvent * ) e; |
1089 | if ( ke->simpleData.keycode == Qt::Key_F33 ) { | 1092 | if ( ke->simpleData.keycode == Qt::Key_F33 ) { |
1090 | // Use special "OK" key to press "OK" on top level widgets | 1093 | // Use special "OK" key to press "OK" on top level widgets |
1091 | QWidget * active = activeWindow(); | 1094 | QWidget * active = activeWindow(); |
1092 | QWidget *popup = 0; | 1095 | QWidget *popup = 0; |
1093 | if ( active && active->isPopup() ) { | 1096 | if ( active && active->isPopup() ) { |
1094 | popup = active; | 1097 | popup = active; |
1095 | active = active->parentWidget(); | 1098 | active = active->parentWidget(); |
1096 | } | 1099 | } |
1097 | if ( active && ( int ) active->winId() == ke->simpleData.window && | 1100 | if ( active && ( int ) active->winId() == ke->simpleData.window && |
1098 | !active->testWFlags( WStyle_Customize | WType_Popup | WType_Desktop ) ) { | 1101 | !active->testWFlags( WStyle_Customize | WType_Popup | WType_Desktop ) ) { |
1099 | if ( ke->simpleData.is_press ) { | 1102 | if ( ke->simpleData.is_press ) { |
1100 | if ( popup ) | 1103 | if ( popup ) |
1101 | popup->close(); | 1104 | popup->close(); |
1102 | if ( active->inherits( "QDialog" ) ) { | 1105 | if ( active->inherits( "QDialog" ) ) { |
1103 | HackDialog * d = ( HackDialog * ) active; | 1106 | HackDialog * d = ( HackDialog * ) active; |
1104 | d->acceptIt(); | 1107 | d->acceptIt(); |
1105 | return TRUE; | 1108 | return TRUE; |
1106 | } | 1109 | } |
1107 | else if ( ( ( HackWidget * ) active ) ->needsOk() ) { | 1110 | else if ( ( ( HackWidget * ) active ) ->needsOk() ) { |
1108 | QSignal s; | 1111 | QSignal s; |
1109 | s.connect( active, SLOT( accept() ) ); | 1112 | s.connect( active, SLOT( accept() ) ); |
1110 | s.activate(); | 1113 | s.activate(); |
1111 | } | 1114 | } |
1112 | else { | 1115 | else { |
1113 | // do the same as with the select key: Map to the default action of the widget: | 1116 | // do the same as with the select key: Map to the default action of the widget: |
1114 | mapToDefaultAction( ke, Qt::Key_Return ); | 1117 | mapToDefaultAction( ke, Qt::Key_Return ); |
1115 | } | 1118 | } |
1116 | } | 1119 | } |
1117 | } | 1120 | } |
1118 | } | 1121 | } |
1119 | else if ( ke->simpleData.keycode == Qt::Key_F30 ) { | 1122 | else if ( ke->simpleData.keycode == Qt::Key_F30 ) { |
1120 | // Use special "select" key to do whatever default action a widget has | 1123 | // Use special "select" key to do whatever default action a widget has |
1121 | mapToDefaultAction( ke, Qt::Key_Space ); | 1124 | mapToDefaultAction( ke, Qt::Key_Space ); |
1122 | } | 1125 | } |
1123 | else if ( ke->simpleData.keycode == Qt::Key_Escape && | 1126 | else if ( ke->simpleData.keycode == Qt::Key_Escape && |
1124 | ke->simpleData.is_press ) { | 1127 | ke->simpleData.is_press ) { |
1125 | // Escape key closes app if focus on toplevel | 1128 | // Escape key closes app if focus on toplevel |
1126 | QWidget * active = activeWindow(); | 1129 | QWidget * active = activeWindow(); |
1127 | if ( active && active->testWFlags( WType_TopLevel ) && | 1130 | if ( active && active->testWFlags( WType_TopLevel ) && |
1128 | ( int ) active->winId() == ke->simpleData.window && | 1131 | ( int ) active->winId() == ke->simpleData.window && |
1129 | !active->testWFlags( WStyle_Dialog | WStyle_Customize | WType_Popup | WType_Desktop ) ) { | 1132 | !active->testWFlags( WStyle_Dialog | WStyle_Customize | WType_Popup | WType_Desktop ) ) { |
1130 | if ( active->inherits( "QDialog" ) ) { | 1133 | if ( active->inherits( "QDialog" ) ) { |
1131 | HackDialog * d = ( HackDialog * ) active; | 1134 | HackDialog * d = ( HackDialog * ) active; |
1132 | d->rejectIt(); | 1135 | d->rejectIt(); |
1133 | return TRUE; | 1136 | return TRUE; |
1134 | } else /*if ( strcmp( argv() [ 0 ], "embeddedkonsole" ) != 0 )*/ { | 1137 | } else /*if ( strcmp( argv() [ 0 ], "embeddedkonsole" ) != 0 )*/ { |
1135 | active->close(); | 1138 | active->close(); |
1136 | } | 1139 | } |
1137 | } | 1140 | } |
1138 | 1141 | ||
1139 | } | 1142 | } |
1140 | else if ( ke->simpleData.keycode >= Qt::Key_F1 && ke->simpleData.keycode <= Qt::Key_F29 ) { | 1143 | else if ( ke->simpleData.keycode >= Qt::Key_F1 && ke->simpleData.keycode <= Qt::Key_F29 ) { |
1141 | // this should be if ( ODevice::inst ( )-> buttonForKeycode ( ... )) | 1144 | // this should be if ( ODevice::inst ( )-> buttonForKeycode ( ... )) |
1142 | // but we cannot access libopie function within libqpe :( | 1145 | // but we cannot access libopie function within libqpe :( |
1143 | 1146 | ||
1144 | QWidget * active = activeWindow ( ); | 1147 | QWidget * active = activeWindow ( ); |
1145 | if ( active && ((int) active-> winId ( ) == ke-> simpleData.window )) { | 1148 | if ( active && ((int) active-> winId ( ) == ke-> simpleData.window )) { |
1146 | if ( d-> kbgrabbed ) { // we grabbed the keyboard | 1149 | if ( d-> kbgrabbed ) { // we grabbed the keyboard |
1147 | QChar ch ( ke-> simpleData.unicode ); | 1150 | QChar ch ( ke-> simpleData.unicode ); |
1148 | QKeyEvent qke ( ke-> simpleData. is_press ? QEvent::KeyPress : QEvent::KeyRelease, | 1151 | QKeyEvent qke ( ke-> simpleData. is_press ? QEvent::KeyPress : QEvent::KeyRelease, |
1149 | ke-> simpleData.keycode, | 1152 | ke-> simpleData.keycode, |
1150 | ch. latin1 ( ), | 1153 | ch. latin1 ( ), |
1151 | ke-> simpleData.modifiers, | 1154 | ke-> simpleData.modifiers, |
1152 | QString ( ch ), | 1155 | QString ( ch ), |
1153 | ke-> simpleData.is_auto_repeat, 1 ); | 1156 | ke-> simpleData.is_auto_repeat, 1 ); |
1154 | 1157 | ||
1155 | QObject *which = QWidget::keyboardGrabber ( ); | 1158 | QObject *which = QWidget::keyboardGrabber ( ); |
1156 | if ( !which ) | 1159 | if ( !which ) |
1157 | which = QApplication::focusWidget ( ); | 1160 | which = QApplication::focusWidget ( ); |
1158 | if ( !which ) | 1161 | if ( !which ) |
1159 | which = QApplication::activeWindow ( ); | 1162 | which = QApplication::activeWindow ( ); |
1160 | if ( !which ) | 1163 | if ( !which ) |
1161 | which = qApp; | 1164 | which = qApp; |
1162 | 1165 | ||
1163 | QApplication::sendEvent ( which, &qke ); | 1166 | QApplication::sendEvent ( which, &qke ); |
1164 | } | 1167 | } |
1165 | else { // we didn't grab the keyboard, so send the event to the launcher | 1168 | else { // we didn't grab the keyboard, so send the event to the launcher |
1166 | QCopEnvelope e ( "QPE/Launcher", "deviceButton(int,int,int)" ); | 1169 | QCopEnvelope e ( "QPE/Launcher", "deviceButton(int,int,int)" ); |
1167 | e << int( ke-> simpleData.keycode ) << int( ke-> simpleData. is_press ) << int( ke-> simpleData.is_auto_repeat ); | 1170 | e << int( ke-> simpleData.keycode ) << int( ke-> simpleData. is_press ) << int( ke-> simpleData.is_auto_repeat ); |
1168 | } | 1171 | } |
1169 | } | 1172 | } |
1170 | return true; | 1173 | return true; |
1171 | } | 1174 | } |
1172 | } | 1175 | } |
1173 | if ( e->type == QWSEvent::Focus ) { | 1176 | if ( e->type == QWSEvent::Focus ) { |
1174 | QWSFocusEvent * fe = ( QWSFocusEvent* ) e; | 1177 | QWSFocusEvent * fe = ( QWSFocusEvent* ) e; |
1175 | if ( !fe->simpleData.get_focus ) { | 1178 | if ( !fe->simpleData.get_focus ) { |
1176 | QWidget * active = activeWindow(); | 1179 | QWidget * active = activeWindow(); |
1177 | while ( active && active->isPopup() ) { | 1180 | while ( active && active->isPopup() ) { |
1178 | active->close(); | 1181 | active->close(); |
1179 | active = activeWindow(); | 1182 | active = activeWindow(); |
1180 | } | 1183 | } |
1181 | } | 1184 | } |
1182 | else { | 1185 | else { |
1183 | // make sure our modal widget is ALWAYS on top | 1186 | // make sure our modal widget is ALWAYS on top |
1184 | QWidget *topm = activeModalWidget(); | 1187 | QWidget *topm = activeModalWidget(); |
1185 | if ( topm && static_cast<int>( topm->winId() ) != fe->simpleData.window) { | 1188 | if ( topm && static_cast<int>( topm->winId() ) != fe->simpleData.window) { |
1186 | topm->raise(); | 1189 | topm->raise(); |
1187 | } | 1190 | } |
1188 | } | 1191 | } |
1189 | if ( fe->simpleData.get_focus && inputMethodDict ) { | 1192 | if ( fe->simpleData.get_focus && inputMethodDict ) { |
1190 | InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) ); | 1193 | InputMethodHint m = inputMethodHint( QWidget::find( e->window() ) ); |
1191 | if ( m == AlwaysOff ) | 1194 | if ( m == AlwaysOff ) |
1192 | Global::hideInputMethod(); | 1195 | Global::hideInputMethod(); |
1193 | if ( m == AlwaysOn ) | 1196 | if ( m == AlwaysOn ) |
1194 | Global::showInputMethod(); | 1197 | Global::showInputMethod(); |
1195 | } | 1198 | } |
1196 | } | 1199 | } |
1197 | 1200 | ||
1198 | 1201 | ||
1199 | return QApplication::qwsEventFilter( e ); | 1202 | return QApplication::qwsEventFilter( e ); |
1200 | } | 1203 | } |
1201 | #endif | 1204 | #endif |
1202 | 1205 | ||
1203 | /*! | 1206 | /*! |
1204 | Destroys the QPEApplication. | 1207 | Destroys the QPEApplication. |
1205 | */ | 1208 | */ |
1206 | QPEApplication::~QPEApplication() | 1209 | QPEApplication::~QPEApplication() |
1207 | { | 1210 | { |
1208 | ungrabKeyboard(); | 1211 | ungrabKeyboard(); |
1209 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 1212 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
1210 | // Need to delete QCopChannels early, since the display will | 1213 | // Need to delete QCopChannels early, since the display will |
1211 | // be gone by the time we get to ~QObject(). | 1214 | // be gone by the time we get to ~QObject(). |
1212 | delete sysChannel; | 1215 | delete sysChannel; |
1213 | delete pidChannel; | 1216 | delete pidChannel; |
1214 | #endif | 1217 | #endif |
1218 | #ifdef OPIE_ROHFEEDBACK | ||
1215 | delete d->RoH; | 1219 | delete d->RoH; |
1220 | #endif | ||
1216 | delete d; | 1221 | delete d; |
1217 | } | 1222 | } |
1218 | 1223 | ||
1219 | /*! | 1224 | /*! |
1220 | Returns <tt>$OPIEDIR/</tt>. | 1225 | Returns <tt>$OPIEDIR/</tt>. |
1221 | */ | 1226 | */ |
1222 | QString QPEApplication::qpeDir() | 1227 | QString QPEApplication::qpeDir() |
1223 | { | 1228 | { |
1224 | const char * base = getenv( "OPIEDIR" ); | 1229 | const char * base = getenv( "OPIEDIR" ); |
1225 | if ( base ) | 1230 | if ( base ) |
1226 | return QString( base ) + "/"; | 1231 | return QString( base ) + "/"; |
1227 | 1232 | ||
1228 | return QString( "../" ); | 1233 | return QString( "../" ); |
1229 | } | 1234 | } |
1230 | 1235 | ||
1231 | /*! | 1236 | /*! |
1232 | Returns the user's current Document directory. There is a trailing "/". | 1237 | Returns the user's current Document directory. There is a trailing "/". |
1233 | .. well, it does now,, and there's no trailing '/' | 1238 | .. well, it does now,, and there's no trailing '/' |
1234 | */ | 1239 | */ |
1235 | QString QPEApplication::documentDir() | 1240 | QString QPEApplication::documentDir() |
1236 | { | 1241 | { |
1237 | const char* base = getenv( "HOME"); | 1242 | const char* base = getenv( "HOME"); |
1238 | if ( base ) | 1243 | if ( base ) |
1239 | return QString( base ) + "/Documents"; | 1244 | return QString( base ) + "/Documents"; |
1240 | 1245 | ||
1241 | return QString( "../Documents" ); | 1246 | return QString( "../Documents" ); |
1242 | } | 1247 | } |
1243 | 1248 | ||
1244 | static int deforient = -1; | 1249 | static int deforient = -1; |
1245 | 1250 | ||
1246 | /*! | 1251 | /*! |
1247 | \internal | 1252 | \internal |
1248 | */ | 1253 | */ |
1249 | int QPEApplication::defaultRotation() | 1254 | int QPEApplication::defaultRotation() |
1250 | { | 1255 | { |
1251 | if ( deforient < 0 ) { | 1256 | if ( deforient < 0 ) { |
1252 | QString d = getenv( "QWS_DISPLAY" ); | 1257 | QString d = getenv( "QWS_DISPLAY" ); |
1253 | if ( d.contains( "Rot90" ) ) { | 1258 | if ( d.contains( "Rot90" ) ) { |
1254 | deforient = 90; | 1259 | deforient = 90; |
1255 | } | 1260 | } |
1256 | else if ( d.contains( "Rot180" ) ) { | 1261 | else if ( d.contains( "Rot180" ) ) { |
1257 | deforient = 180; | 1262 | deforient = 180; |
1258 | } | 1263 | } |
1259 | else if ( d.contains( "Rot270" ) ) { | 1264 | else if ( d.contains( "Rot270" ) ) { |
1260 | deforient = 270; | 1265 | deforient = 270; |
1261 | } | 1266 | } |
1262 | else { | 1267 | else { |
1263 | deforient = 0; | 1268 | deforient = 0; |
1264 | } | 1269 | } |
1265 | } | 1270 | } |
1266 | return deforient; | 1271 | return deforient; |
1267 | } | 1272 | } |
1268 | 1273 | ||
1269 | /*! | 1274 | /*! |
1270 | \internal | 1275 | \internal |
1271 | */ | 1276 | */ |
1272 | void QPEApplication::setDefaultRotation( int r ) | 1277 | void QPEApplication::setDefaultRotation( int r ) |
1273 | { | 1278 | { |
1274 | if ( qApp->type() == GuiServer ) { | 1279 | if ( qApp->type() == GuiServer ) { |
1275 | deforient = r; | 1280 | deforient = r; |
1276 | setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 ); | 1281 | setenv( "QWS_DISPLAY", QString( "Transformed:Rot%1:0" ).arg( r ).latin1(), 1 ); |
1277 | Config config("qpe"); | 1282 | Config config("qpe"); |
1278 | config.setGroup( "Rotation" ); | 1283 | config.setGroup( "Rotation" ); |
1279 | config.writeEntry( "Rot", r ); | 1284 | config.writeEntry( "Rot", r ); |
1280 | } | 1285 | } |
1281 | else { | 1286 | else { |
1282 | #ifndef QT_NO_COP | 1287 | #ifndef QT_NO_COP |
1283 | { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" ); | 1288 | { QCopEnvelope e( "QPE/System", "setDefaultRotation(int)" ); |
1284 | e << r; | 1289 | e << r; |
1285 | } | 1290 | } |
1286 | #endif | 1291 | #endif |
1287 | 1292 | ||
1288 | } | 1293 | } |
1289 | } | 1294 | } |
1290 | 1295 | ||
1291 | #include <qgfx_qws.h> | 1296 | #include <qgfx_qws.h> |
1292 | #include <qwindowsystem_qws.h> | 1297 | #include <qwindowsystem_qws.h> |
1293 | 1298 | ||
1294 | #if QT_VERSION > 236 | 1299 | #if QT_VERSION > 236 |
1295 | extern void qws_clearLoadedFonts(); | 1300 | extern void qws_clearLoadedFonts(); |
1296 | #endif | 1301 | #endif |
1297 | 1302 | ||
1298 | void QPEApplication::setCurrentMode( int x, int y, int depth ) | 1303 | void QPEApplication::setCurrentMode( int x, int y, int depth ) |
1299 | { | 1304 | { |
1300 | // Reset the caches | 1305 | // Reset the caches |
1301 | #if QT_VERSION > 236 | 1306 | #if QT_VERSION > 236 |
1302 | qws_clearLoadedFonts(); | 1307 | qws_clearLoadedFonts(); |
1303 | #endif | 1308 | #endif |
1304 | QPixmapCache::clear(); | 1309 | QPixmapCache::clear(); |
1305 | 1310 | ||
1306 | // Change the screen mode | 1311 | // Change the screen mode |
1307 | qt_screen->setMode(x, y, depth); | 1312 | qt_screen->setMode(x, y, depth); |
1308 | 1313 | ||
1309 | if ( qApp->type() == GuiServer ) { | 1314 | if ( qApp->type() == GuiServer ) { |
1310 | #if QT_VERSION > 236 | 1315 | #if QT_VERSION > 236 |
1311 | // Reconfigure the GuiServer | 1316 | // Reconfigure the GuiServer |
1312 | qwsServer->beginDisplayReconfigure(); | 1317 | qwsServer->beginDisplayReconfigure(); |
1313 | qwsServer->endDisplayReconfigure(); | 1318 | qwsServer->endDisplayReconfigure(); |
1314 | #endif | 1319 | #endif |
1315 | // Get all the running apps to reset | 1320 | // Get all the running apps to reset |
1316 | QCopEnvelope env( "QPE/System", "reset()" ); | 1321 | QCopEnvelope env( "QPE/System", "reset()" ); |
1317 | } | 1322 | } |
1318 | } | 1323 | } |
1319 | 1324 | ||
1320 | void QPEApplication::reset() { | 1325 | void QPEApplication::reset() { |
1321 | // Reconnect to the screen | 1326 | // Reconnect to the screen |
1322 | qt_screen->disconnect(); | 1327 | qt_screen->disconnect(); |
1323 | qt_screen->connect( QString::null ); | 1328 | qt_screen->connect( QString::null ); |
1324 | 1329 | ||
1325 | // Redraw everything | 1330 | // Redraw everything |
1326 | applyStyle(); | 1331 | applyStyle(); |
1327 | } | 1332 | } |
1328 | 1333 | ||
1329 | #if (QT_VERSION < 238) && defined Q_OS_MACX | 1334 | #if (QT_VERSION < 238) && defined Q_OS_MACX |
1330 | bool qt_left_hand_scrollbars = false; | 1335 | bool qt_left_hand_scrollbars = false; |
1331 | #else | 1336 | #else |
1332 | #ifdef Q_OS_MACX | 1337 | #ifdef Q_OS_MACX |
1333 | #define WEAK_SYMBOL __attribute__((weak_import)) | 1338 | #define WEAK_SYMBOL __attribute__((weak_import)) |
1334 | #else | 1339 | #else |
1335 | #define WEAK_SYMBOL __attribute__((weak)) | 1340 | #define WEAK_SYMBOL __attribute__((weak)) |
1336 | #endif | 1341 | #endif |
1337 | extern bool qt_left_hand_scrollbars WEAK_SYMBOL; | 1342 | extern bool qt_left_hand_scrollbars WEAK_SYMBOL; |
1338 | #endif | 1343 | #endif |
1339 | 1344 | ||
1340 | /*! | 1345 | /*! |
1341 | \internal | 1346 | \internal |
1342 | */ | 1347 | */ |
1343 | void QPEApplication::applyStyle() | 1348 | void QPEApplication::applyStyle() |
@@ -1910,340 +1915,342 @@ void QPEApplication::internalSetStyle( const QString &style ) | |||
1910 | lastlib = lib; | 1915 | lastlib = lib; |
1911 | } | 1916 | } |
1912 | else { | 1917 | else { |
1913 | if ( iface ) | 1918 | if ( iface ) |
1914 | iface-> release ( ); | 1919 | iface-> release ( ); |
1915 | delete lib; | 1920 | delete lib; |
1916 | 1921 | ||
1917 | setStyle ( new LightStyle ( )); | 1922 | setStyle ( new LightStyle ( )); |
1918 | } | 1923 | } |
1919 | } | 1924 | } |
1920 | #endif | 1925 | #endif |
1921 | } | 1926 | } |
1922 | 1927 | ||
1923 | /*! | 1928 | /*! |
1924 | \internal | 1929 | \internal |
1925 | */ | 1930 | */ |
1926 | void QPEApplication::prepareForTermination( bool willrestart ) | 1931 | void QPEApplication::prepareForTermination( bool willrestart ) |
1927 | { | 1932 | { |
1928 | if ( willrestart ) { | 1933 | if ( willrestart ) { |
1929 | // Draw a big wait icon, the image can be altered in later revisions | 1934 | // Draw a big wait icon, the image can be altered in later revisions |
1930 | // QWidget *d = QApplication::desktop(); | 1935 | // QWidget *d = QApplication::desktop(); |
1931 | QImage img = Resource::loadImage( "launcher/new_wait" ); | 1936 | QImage img = Resource::loadImage( "launcher/new_wait" ); |
1932 | QPixmap pix; | 1937 | QPixmap pix; |
1933 | pix.convertFromImage( img.smoothScale( 1 * img.width(), 1 * img.height() ) ); | 1938 | pix.convertFromImage( img.smoothScale( 1 * img.width(), 1 * img.height() ) ); |
1934 | QLabel *lblWait = new QLabel( 0, "wait hack!", QWidget::WStyle_Customize | | 1939 | QLabel *lblWait = new QLabel( 0, "wait hack!", QWidget::WStyle_Customize | |
1935 | QWidget::WStyle_NoBorder | QWidget::WStyle_Tool ); | 1940 | QWidget::WStyle_NoBorder | QWidget::WStyle_Tool ); |
1936 | lblWait->setPixmap( pix ); | 1941 | lblWait->setPixmap( pix ); |
1937 | lblWait->setAlignment( QWidget::AlignCenter ); | 1942 | lblWait->setAlignment( QWidget::AlignCenter ); |
1938 | lblWait->show(); | 1943 | lblWait->show(); |
1939 | lblWait->showMaximized(); | 1944 | lblWait->showMaximized(); |
1940 | } | 1945 | } |
1941 | #ifndef SINGLE_APP | 1946 | #ifndef SINGLE_APP |
1942 | { QCopEnvelope envelope( "QPE/System", "forceQuit()" ); | 1947 | { QCopEnvelope envelope( "QPE/System", "forceQuit()" ); |
1943 | } | 1948 | } |
1944 | processEvents(); // ensure the message goes out. | 1949 | processEvents(); // ensure the message goes out. |
1945 | sleep( 1 ); // You have 1 second to comply. | 1950 | sleep( 1 ); // You have 1 second to comply. |
1946 | #endif | 1951 | #endif |
1947 | } | 1952 | } |
1948 | 1953 | ||
1949 | /*! | 1954 | /*! |
1950 | \internal | 1955 | \internal |
1951 | */ | 1956 | */ |
1952 | void QPEApplication::shutdown() | 1957 | void QPEApplication::shutdown() |
1953 | { | 1958 | { |
1954 | // Implement in server's QPEApplication subclass | 1959 | // Implement in server's QPEApplication subclass |
1955 | } | 1960 | } |
1956 | 1961 | ||
1957 | /*! | 1962 | /*! |
1958 | \internal | 1963 | \internal |
1959 | */ | 1964 | */ |
1960 | void QPEApplication::restart() | 1965 | void QPEApplication::restart() |
1961 | { | 1966 | { |
1962 | // Implement in server's QPEApplication subclass | 1967 | // Implement in server's QPEApplication subclass |
1963 | } | 1968 | } |
1964 | 1969 | ||
1965 | static QPtrDict<void>* stylusDict = 0; | 1970 | static QPtrDict<void>* stylusDict = 0; |
1966 | static void createDict() | 1971 | static void createDict() |
1967 | { | 1972 | { |
1968 | if ( !stylusDict ) | 1973 | if ( !stylusDict ) |
1969 | stylusDict = new QPtrDict<void>; | 1974 | stylusDict = new QPtrDict<void>; |
1970 | } | 1975 | } |
1971 | 1976 | ||
1972 | /*! | 1977 | /*! |
1973 | Returns the current StylusMode for widget \a w. | 1978 | Returns the current StylusMode for widget \a w. |
1974 | 1979 | ||
1975 | \sa setStylusOperation() StylusMode | 1980 | \sa setStylusOperation() StylusMode |
1976 | */ | 1981 | */ |
1977 | QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w ) | 1982 | QPEApplication::StylusMode QPEApplication::stylusOperation( QWidget* w ) |
1978 | { | 1983 | { |
1979 | if ( stylusDict ) | 1984 | if ( stylusDict ) |
1980 | return ( StylusMode ) ( int ) stylusDict->find( w ); | 1985 | return ( StylusMode ) ( int ) stylusDict->find( w ); |
1981 | return LeftOnly; | 1986 | return LeftOnly; |
1982 | } | 1987 | } |
1983 | 1988 | ||
1984 | /*! | 1989 | /*! |
1985 | \enum QPEApplication::StylusMode | 1990 | \enum QPEApplication::StylusMode |
1986 | 1991 | ||
1987 | \value LeftOnly the stylus only generates LeftButton | 1992 | \value LeftOnly the stylus only generates LeftButton |
1988 | events (the default). | 1993 | events (the default). |
1989 | \value RightOnHold the stylus generates RightButton events | 1994 | \value RightOnHold the stylus generates RightButton events |
1990 | if the user uses the press-and-hold gesture. | 1995 | if the user uses the press-and-hold gesture. |
1991 | 1996 | ||
1992 | \sa setStylusOperation() stylusOperation() | 1997 | \sa setStylusOperation() stylusOperation() |
1993 | */ | 1998 | */ |
1994 | 1999 | ||
1995 | /*! | 2000 | /*! |
1996 | Causes widget \a w to receive mouse events according to the stylus | 2001 | Causes widget \a w to receive mouse events according to the stylus |
1997 | \a mode. | 2002 | \a mode. |
1998 | 2003 | ||
1999 | \sa stylusOperation() StylusMode | 2004 | \sa stylusOperation() StylusMode |
2000 | */ | 2005 | */ |
2001 | void QPEApplication::setStylusOperation( QWidget * w, StylusMode mode ) | 2006 | void QPEApplication::setStylusOperation( QWidget * w, StylusMode mode ) |
2002 | { | 2007 | { |
2003 | createDict(); | 2008 | createDict(); |
2004 | if ( mode == LeftOnly ) { | 2009 | if ( mode == LeftOnly ) { |
2005 | stylusDict->remove | 2010 | stylusDict->remove |
2006 | ( w ); | 2011 | ( w ); |
2007 | w->removeEventFilter( qApp ); | 2012 | w->removeEventFilter( qApp ); |
2008 | } | 2013 | } |
2009 | else { | 2014 | else { |
2010 | stylusDict->insert( w, ( void* ) mode ); | 2015 | stylusDict->insert( w, ( void* ) mode ); |
2011 | connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) ); | 2016 | connect( w, SIGNAL( destroyed() ), qApp, SLOT( removeSenderFromStylusDict() ) ); |
2012 | w->installEventFilter( qApp ); | 2017 | w->installEventFilter( qApp ); |
2013 | } | 2018 | } |
2014 | } | 2019 | } |
2015 | 2020 | ||
2016 | 2021 | ||
2017 | /*! | 2022 | /*! |
2018 | \reimp | 2023 | \reimp |
2019 | */ | 2024 | */ |
2020 | bool QPEApplication::eventFilter( QObject *o, QEvent *e ) | 2025 | bool QPEApplication::eventFilter( QObject *o, QEvent *e ) |
2021 | { | 2026 | { |
2022 | if ( !o->isWidgetType() ) | 2027 | if ( !o->isWidgetType() ) |
2023 | return FALSE; | 2028 | return FALSE; |
2024 | 2029 | ||
2025 | if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) { | 2030 | if ( stylusDict && e->type() >= QEvent::MouseButtonPress && e->type() <= QEvent::MouseMove ) { |
2026 | QMouseEvent * me = ( QMouseEvent* ) e; | 2031 | QMouseEvent * me = ( QMouseEvent* ) e; |
2027 | StylusMode mode = (StylusMode)(int)stylusDict->find(o); | 2032 | StylusMode mode = (StylusMode)(int)stylusDict->find(o); |
2028 | switch (mode) { | 2033 | switch (mode) { |
2029 | case RightOnHold: | 2034 | case RightOnHold: |
2030 | switch ( me->type() ) { | 2035 | switch ( me->type() ) { |
2031 | case QEvent::MouseButtonPress: | 2036 | case QEvent::MouseButtonPress: |
2032 | if ( me->button() == LeftButton ) { | 2037 | if ( me->button() == LeftButton ) { |
2033 | d->presswidget = (QWidget*)o; | 2038 | d->presswidget = (QWidget*)o; |
2034 | d->presspos = me->pos(); | 2039 | d->presspos = me->pos(); |
2035 | d->rightpressed = FALSE; | 2040 | d->rightpressed = FALSE; |
2036 | // just for the time being | 2041 | // just for the time being |
2037 | static int pref = 500; | 2042 | static int pref = 500; |
2038 | #ifdef WITHROHFEEDBACK | 2043 | #ifdef OPIE_ROHFEEDBACK |
2039 | if( ! d->RoH ) | 2044 | if( ! d->RoH ) |
2040 | d->RoH = new Opie::Internal::RoHFeedback; | 2045 | d->RoH = new Opie::Internal::RoHFeedback; |
2041 | 2046 | ||
2042 | d->RoH->init( me->globalPos(), d->presswidget ); | 2047 | d->RoH->init( me->globalPos(), d->presswidget ); |
2043 | pref = d->RoH->delay(); | 2048 | pref = d->RoH->delay(); |
2044 | #endif | 2049 | #endif |
2045 | if (!d->presstimer ) | 2050 | if (!d->presstimer ) |
2046 | d->presstimer = startTimer( pref ); // #### pref. | 2051 | d->presstimer = startTimer( pref ); // #### pref. |
2047 | 2052 | ||
2048 | } | 2053 | } |
2049 | break; | 2054 | break; |
2050 | case QEvent::MouseMove: | 2055 | case QEvent::MouseMove: |
2051 | if (d->presstimer && (me->pos() - d->presspos).manhattanLength() > 8) { | 2056 | if (d->presstimer && (me->pos() - d->presspos).manhattanLength() > 8) { |
2052 | killTimer(d->presstimer); | 2057 | killTimer(d->presstimer); |
2053 | #ifdef WITHROHFEEDBACK | 2058 | #ifdef OPIE_ROHFEEDBACK |
2054 | if( d->RoH ) | 2059 | if( d->RoH ) |
2055 | d->RoH->stop( ); | 2060 | d->RoH->stop( ); |
2056 | #endif | 2061 | #endif |
2057 | d->presstimer = 0; | 2062 | d->presstimer = 0; |
2058 | } | 2063 | } |
2059 | break; | 2064 | break; |
2060 | case QEvent::MouseButtonRelease: | 2065 | case QEvent::MouseButtonRelease: |
2061 | if ( me->button() == LeftButton ) { | 2066 | if ( me->button() == LeftButton ) { |
2062 | if ( d->presstimer ) { | 2067 | if ( d->presstimer ) { |
2063 | killTimer(d->presstimer); | 2068 | killTimer(d->presstimer); |
2064 | #ifdef WITHROHFEEDBACK | 2069 | #ifdef OPIE_ROHFEEDBACK |
2065 | if( d->RoH ) | 2070 | if( d->RoH ) |
2066 | d->RoH->stop( ); | 2071 | d->RoH->stop( ); |
2067 | #endif | 2072 | #endif |
2068 | d->presstimer = 0; | 2073 | d->presstimer = 0; |
2069 | } | 2074 | } |
2070 | if ( d->rightpressed && d->presswidget ) { | 2075 | if ( d->rightpressed && d->presswidget ) { |
2071 | // Right released | 2076 | // Right released |
2072 | postEvent( d->presswidget, | 2077 | postEvent( d->presswidget, |
2073 | new QMouseEvent( QEvent::MouseButtonRelease, me->pos(), | 2078 | new QMouseEvent( QEvent::MouseButtonRelease, me->pos(), |
2074 | RightButton, LeftButton + RightButton ) ); | 2079 | RightButton, LeftButton + RightButton ) ); |
2075 | // Left released, off-widget | 2080 | // Left released, off-widget |
2076 | postEvent( d->presswidget, | 2081 | postEvent( d->presswidget, |
2077 | new QMouseEvent( QEvent::MouseMove, QPoint( -1, -1), | 2082 | new QMouseEvent( QEvent::MouseMove, QPoint( -1, -1), |
2078 | LeftButton, LeftButton ) ); | 2083 | LeftButton, LeftButton ) ); |
2079 | postEvent( d->presswidget, | 2084 | postEvent( d->presswidget, |
2080 | new QMouseEvent( QEvent::MouseButtonRelease, QPoint( -1, -1), | 2085 | new QMouseEvent( QEvent::MouseButtonRelease, QPoint( -1, -1), |
2081 | LeftButton, LeftButton ) ); | 2086 | LeftButton, LeftButton ) ); |
2082 | d->rightpressed = FALSE; | 2087 | d->rightpressed = FALSE; |
2083 | return TRUE; // don't send the real Left release | 2088 | return TRUE; // don't send the real Left release |
2084 | } | 2089 | } |
2085 | } | 2090 | } |
2086 | break; | 2091 | break; |
2087 | default: | 2092 | default: |
2088 | break; | 2093 | break; |
2089 | } | 2094 | } |
2090 | break; | 2095 | break; |
2091 | default: | 2096 | default: |
2092 | ; | 2097 | ; |
2093 | } | 2098 | } |
2094 | } | 2099 | } |
2095 | else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { | 2100 | else if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { |
2096 | QKeyEvent *ke = (QKeyEvent *)e; | 2101 | QKeyEvent *ke = (QKeyEvent *)e; |
2097 | if ( ke->key() == Key_Enter ) { | 2102 | if ( ke->key() == Key_Enter ) { |
2098 | if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) { | 2103 | if ( o->isA( "QRadioButton" ) || o->isA( "QCheckBox" ) ) { |
2099 | postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ', | 2104 | postEvent( o, new QKeyEvent( e->type(), Key_Space, ' ', |
2100 | ke->state(), " ", ke->isAutoRepeat(), ke->count() ) ); | 2105 | ke->state(), " ", ke->isAutoRepeat(), ke->count() ) ); |
2101 | return TRUE; | 2106 | return TRUE; |
2102 | } | 2107 | } |
2103 | } | 2108 | } |
2104 | } | 2109 | } |
2105 | return FALSE; | 2110 | return FALSE; |
2106 | } | 2111 | } |
2107 | 2112 | ||
2108 | /*! | 2113 | /*! |
2109 | \reimp | 2114 | \reimp |
2110 | */ | 2115 | */ |
2111 | void QPEApplication::timerEvent( QTimerEvent *e ) | 2116 | void QPEApplication::timerEvent( QTimerEvent *e ) |
2112 | { | 2117 | { |
2113 | if ( e->timerId() == d->presstimer && d->presswidget ) { | 2118 | if ( e->timerId() == d->presstimer && d->presswidget ) { |
2114 | // Right pressed | 2119 | // Right pressed |
2115 | postEvent( d->presswidget, | 2120 | postEvent( d->presswidget, |
2116 | new QMouseEvent( QEvent::MouseButtonPress, d->presspos, | 2121 | new QMouseEvent( QEvent::MouseButtonPress, d->presspos, |
2117 | RightButton, LeftButton ) ); | 2122 | RightButton, LeftButton ) ); |
2118 | killTimer( d->presstimer ); | 2123 | killTimer( d->presstimer ); |
2119 | d->presstimer = 0; | 2124 | d->presstimer = 0; |
2120 | d->rightpressed = TRUE; | 2125 | d->rightpressed = TRUE; |
2126 | #ifdef OPIE_ROHFEEDBACK | ||
2121 | d->RoH->stop(); | 2127 | d->RoH->stop(); |
2128 | #endif | ||
2122 | } | 2129 | } |
2123 | } | 2130 | } |
2124 | 2131 | ||
2125 | void QPEApplication::removeSenderFromStylusDict() | 2132 | void QPEApplication::removeSenderFromStylusDict() |
2126 | { | 2133 | { |
2127 | stylusDict->remove | 2134 | stylusDict->remove |
2128 | ( ( void* ) sender() ); | 2135 | ( ( void* ) sender() ); |
2129 | if ( d->presswidget == sender() ) | 2136 | if ( d->presswidget == sender() ) |
2130 | d->presswidget = 0; | 2137 | d->presswidget = 0; |
2131 | } | 2138 | } |
2132 | 2139 | ||
2133 | /*! | 2140 | /*! |
2134 | \internal | 2141 | \internal |
2135 | */ | 2142 | */ |
2136 | bool QPEApplication::keyboardGrabbed() const | 2143 | bool QPEApplication::keyboardGrabbed() const |
2137 | { | 2144 | { |
2138 | return d->kbgrabbed; | 2145 | return d->kbgrabbed; |
2139 | } | 2146 | } |
2140 | 2147 | ||
2141 | 2148 | ||
2142 | /*! | 2149 | /*! |
2143 | Reverses the effect of grabKeyboard(). This is called automatically | 2150 | Reverses the effect of grabKeyboard(). This is called automatically |
2144 | on program exit. | 2151 | on program exit. |
2145 | */ | 2152 | */ |
2146 | void QPEApplication::ungrabKeyboard() | 2153 | void QPEApplication::ungrabKeyboard() |
2147 | { | 2154 | { |
2148 | ((QPEApplication *) qApp )-> d-> kbgrabbed = false; | 2155 | ((QPEApplication *) qApp )-> d-> kbgrabbed = false; |
2149 | } | 2156 | } |
2150 | 2157 | ||
2151 | /*! | 2158 | /*! |
2152 | Grabs the physical keyboard keys, e.g. the application's launching | 2159 | Grabs the physical keyboard keys, e.g. the application's launching |
2153 | keys. Instead of launching applications when these keys are pressed | 2160 | keys. Instead of launching applications when these keys are pressed |
2154 | the signals emitted are sent to this application instead. Some games | 2161 | the signals emitted are sent to this application instead. Some games |
2155 | programs take over the launch keys in this way to make interaction | 2162 | programs take over the launch keys in this way to make interaction |
2156 | easier. | 2163 | easier. |
2157 | 2164 | ||
2158 | \sa ungrabKeyboard() | 2165 | \sa ungrabKeyboard() |
2159 | */ | 2166 | */ |
2160 | void QPEApplication::grabKeyboard() | 2167 | void QPEApplication::grabKeyboard() |
2161 | { | 2168 | { |
2162 | ((QPEApplication *) qApp )-> d-> kbgrabbed = true; | 2169 | ((QPEApplication *) qApp )-> d-> kbgrabbed = true; |
2163 | } | 2170 | } |
2164 | 2171 | ||
2165 | /*! | 2172 | /*! |
2166 | \reimp | 2173 | \reimp |
2167 | */ | 2174 | */ |
2168 | int QPEApplication::exec() | 2175 | int QPEApplication::exec() |
2169 | { | 2176 | { |
2170 | d->qcopQok = true; | 2177 | d->qcopQok = true; |
2171 | #ifndef QT_NO_COP | 2178 | #ifndef QT_NO_COP |
2172 | d->sendQCopQ(); | 2179 | d->sendQCopQ(); |
2173 | if ( !d->keep_running ) | 2180 | if ( !d->keep_running ) |
2174 | processEvents(); // we may have received QCop messages in the meantime. | 2181 | processEvents(); // we may have received QCop messages in the meantime. |
2175 | #endif | 2182 | #endif |
2176 | 2183 | ||
2177 | if ( d->keep_running ) | 2184 | if ( d->keep_running ) |
2178 | //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() ) | 2185 | //|| d->qpe_main_widget && d->qpe_main_widget->isVisible() ) |
2179 | return QApplication::exec(); | 2186 | return QApplication::exec(); |
2180 | 2187 | ||
2181 | #ifndef QT_NO_COP | 2188 | #ifndef QT_NO_COP |
2182 | 2189 | ||
2183 | { | 2190 | { |
2184 | QCopEnvelope e( "QPE/System", "closing(QString)" ); | 2191 | QCopEnvelope e( "QPE/System", "closing(QString)" ); |
2185 | e << d->appName; | 2192 | e << d->appName; |
2186 | } | 2193 | } |
2187 | #endif | 2194 | #endif |
2188 | processEvents(); | 2195 | processEvents(); |
2189 | return 0; | 2196 | return 0; |
2190 | } | 2197 | } |
2191 | 2198 | ||
2192 | /*! | 2199 | /*! |
2193 | \internal | 2200 | \internal |
2194 | External request for application to quit. Quits if possible without | 2201 | External request for application to quit. Quits if possible without |
2195 | loosing state. | 2202 | loosing state. |
2196 | */ | 2203 | */ |
2197 | void QPEApplication::tryQuit() | 2204 | void QPEApplication::tryQuit() |
2198 | { | 2205 | { |
2199 | if ( activeModalWidget() ) | 2206 | if ( activeModalWidget() ) |
2200 | return ; // Inside modal loop or konsole. Too hard to save state. | 2207 | return ; // Inside modal loop or konsole. Too hard to save state. |
2201 | #ifndef QT_NO_COP | 2208 | #ifndef QT_NO_COP |
2202 | 2209 | ||
2203 | { | 2210 | { |
2204 | QCopEnvelope e( "QPE/System", "closing(QString)" ); | 2211 | QCopEnvelope e( "QPE/System", "closing(QString)" ); |
2205 | e << d->appName; | 2212 | e << d->appName; |
2206 | } | 2213 | } |
2207 | #endif | 2214 | #endif |
2208 | if ( d->keep_running ) | 2215 | if ( d->keep_running ) |
2209 | d->store_widget_rect(d->qpe_main_widget, d->appName); | 2216 | d->store_widget_rect(d->qpe_main_widget, d->appName); |
2210 | processEvents(); | 2217 | processEvents(); |
2211 | 2218 | ||
2212 | quit(); | 2219 | quit(); |
2213 | } | 2220 | } |
2214 | 2221 | ||
2215 | /*! | 2222 | /*! |
2216 | \internal | 2223 | \internal |
2217 | */ | 2224 | */ |
2218 | void QPEApplication::installTranslation( const QString& baseName ) { | 2225 | void QPEApplication::installTranslation( const QString& baseName ) { |
2219 | QTranslator* trans = new QTranslator(this); | 2226 | QTranslator* trans = new QTranslator(this); |
2220 | QString tfn = qpeDir() + "/i18n/"+baseName; | 2227 | QString tfn = qpeDir() + "/i18n/"+baseName; |
2221 | if ( trans->load( tfn ) ) | 2228 | if ( trans->load( tfn ) ) |
2222 | installTranslator( trans ); | 2229 | installTranslator( trans ); |
2223 | else | 2230 | else |
2224 | delete trans; | 2231 | delete trans; |
2225 | } | 2232 | } |
2226 | 2233 | ||
2227 | /*! | 2234 | /*! |
2228 | \internal | 2235 | \internal |
2229 | User initiated quit. Makes the window 'Go Away'. If preloaded this means | 2236 | User initiated quit. Makes the window 'Go Away'. If preloaded this means |
2230 | hiding the window. If not it means quitting the application. | 2237 | hiding the window. If not it means quitting the application. |
2231 | As this is user initiated we don't need to check state. | 2238 | As this is user initiated we don't need to check state. |
2232 | */ | 2239 | */ |
2233 | void QPEApplication::hideOrQuit() | 2240 | void QPEApplication::hideOrQuit() |
2234 | { | 2241 | { |
2235 | if ( d->keep_running ) | 2242 | if ( d->keep_running ) |
2236 | d->store_widget_rect(d->qpe_main_widget, d->appName); | 2243 | d->store_widget_rect(d->qpe_main_widget, d->appName); |
2237 | processEvents(); | 2244 | processEvents(); |
2238 | 2245 | ||
2239 | // If we are a preloaded application we don't actually quit, so emit | 2246 | // If we are a preloaded application we don't actually quit, so emit |
2240 | // a System message indicating we're quasi-closing. | 2247 | // a System message indicating we're quasi-closing. |
2241 | if ( d->preloaded && d->qpe_main_widget ) | 2248 | if ( d->preloaded && d->qpe_main_widget ) |
2242 | #ifndef QT_NO_COP | 2249 | #ifndef QT_NO_COP |
2243 | 2250 | ||
2244 | { | 2251 | { |
2245 | QCopEnvelope e("QPE/System", "fastAppHiding(QString)" ); | 2252 | QCopEnvelope e("QPE/System", "fastAppHiding(QString)" ); |
2246 | e << d->appName; | 2253 | e << d->appName; |
2247 | d->qpe_main_widget->hide(); | 2254 | d->qpe_main_widget->hide(); |
2248 | } | 2255 | } |
2249 | #endif | 2256 | #endif |