author | llornkcor <llornkcor> | 2004-04-25 08:49:01 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2004-04-25 08:49:01 (UTC) |
commit | ea4380df897798cf4bbadaf786868a18b3dee975 (patch) (unidiff) | |
tree | 14838fcf9c381d4e27bd2ad4bb2c0b759cad12b7 /library | |
parent | fc1f0001f53f57b625f337a68532984959e6d8dd (diff) | |
download | opie-ea4380df897798cf4bbadaf786868a18b3dee975.zip opie-ea4380df897798cf4bbadaf786868a18b3dee975.tar.gz opie-ea4380df897798cf4bbadaf786868a18b3dee975.tar.bz2 |
remove non needed qdebugs
-rw-r--r-- | library/qpeapplication.cpp | 2 |
1 files changed, 0 insertions, 2 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp index ae1632e..5ce3011 100644 --- a/library/qpeapplication.cpp +++ b/library/qpeapplication.cpp | |||
@@ -1,1149 +1,1147 @@ | |||
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 | */ | 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 | #endif | 83 | #endif |
84 | 84 | ||
85 | #include "alarmserver.h" | 85 | #include "alarmserver.h" |
86 | #include "applnk.h" | 86 | #include "applnk.h" |
87 | #include "qpemenubar.h" | 87 | #include "qpemenubar.h" |
88 | #include "textcodecinterface.h" | 88 | #include "textcodecinterface.h" |
89 | #include "imagecodecinterface.h" | 89 | #include "imagecodecinterface.h" |
90 | 90 | ||
91 | #include <unistd.h> | 91 | #include <unistd.h> |
92 | #include <sys/file.h> | 92 | #include <sys/file.h> |
93 | #include <sys/ioctl.h> | 93 | #include <sys/ioctl.h> |
94 | #ifndef QT_NO_SOUND | 94 | #ifndef QT_NO_SOUND |
95 | #include <sys/soundcard.h> | 95 | #include <sys/soundcard.h> |
96 | #endif | 96 | #endif |
97 | #include "qt_override_p.h" | 97 | #include "qt_override_p.h" |
98 | 98 | ||
99 | class HackWidget : public QWidget | 99 | class HackWidget : public QWidget |
100 | { | 100 | { |
101 | public: | 101 | public: |
102 | bool needsOk() | 102 | bool needsOk() |
103 | { return (getWState() & WState_Reserved1 ); } | 103 | { return (getWState() & WState_Reserved1 ); } |
104 | 104 | ||
105 | QRect normalGeometry() | 105 | QRect normalGeometry() |
106 | { return topData()->normalGeometry; }; | 106 | { return topData()->normalGeometry; }; |
107 | }; | 107 | }; |
108 | 108 | ||
109 | class QPEApplicationData | 109 | class QPEApplicationData |
110 | { | 110 | { |
111 | public: | 111 | public: |
112 | QPEApplicationData ( ) | 112 | QPEApplicationData ( ) |
113 | : presstimer( 0 ), presswidget( 0 ), rightpressed( false ), kbgrabbed( false ), | 113 | : presstimer( 0 ), presswidget( 0 ), rightpressed( false ), kbgrabbed( false ), |
114 | notbusysent( false ), preloaded( false ), forceshow( false ), nomaximize( false ), | 114 | notbusysent( false ), preloaded( false ), forceshow( false ), nomaximize( false ), |
115 | keep_running( true ), qcopQok( false ), qpe_main_widget( 0 ) | 115 | keep_running( true ), qcopQok( false ), qpe_main_widget( 0 ) |
116 | 116 | ||
117 | {} | 117 | {} |
118 | 118 | ||
119 | int presstimer; | 119 | int presstimer; |
120 | QWidget* presswidget; | 120 | QWidget* presswidget; |
121 | QPoint presspos; | 121 | QPoint presspos; |
122 | 122 | ||
123 | bool rightpressed : 1; | 123 | bool rightpressed : 1; |
124 | bool kbgrabbed : 1; | 124 | bool kbgrabbed : 1; |
125 | bool notbusysent : 1; | 125 | bool notbusysent : 1; |
126 | bool preloaded : 1; | 126 | bool preloaded : 1; |
127 | bool forceshow : 1; | 127 | bool forceshow : 1; |
128 | bool nomaximize : 1; | 128 | bool nomaximize : 1; |
129 | bool keep_running : 1; | 129 | bool keep_running : 1; |
130 | bool qcopQok : 1; | 130 | bool qcopQok : 1; |
131 | 131 | ||
132 | 132 | ||
133 | QStringList langs; | 133 | QStringList langs; |
134 | QString appName; | 134 | QString appName; |
135 | struct QCopRec | 135 | struct QCopRec |
136 | { | 136 | { |
137 | QCopRec( const QCString &ch, const QCString &msg, | 137 | QCopRec( const QCString &ch, const QCString &msg, |
138 | const QByteArray &d ) : | 138 | const QByteArray &d ) : |
139 | channel( ch ), message( msg ), data( d ) | 139 | channel( ch ), message( msg ), data( d ) |
140 | { } | 140 | { } |
141 | 141 | ||
142 | QCString channel; | 142 | QCString channel; |
143 | QCString message; | 143 | QCString message; |
144 | QByteArray data; | 144 | QByteArray data; |
145 | }; | 145 | }; |
146 | QWidget* qpe_main_widget; | 146 | QWidget* qpe_main_widget; |
147 | QGuardedPtr<QWidget> lastraised; | 147 | QGuardedPtr<QWidget> lastraised; |
148 | QQueue<QCopRec> qcopq; | 148 | QQueue<QCopRec> qcopq; |
149 | QString styleName; | 149 | QString styleName; |
150 | QString decorationName; | 150 | QString decorationName; |
151 | 151 | ||
152 | void enqueueQCop( const QCString &ch, const QCString &msg, | 152 | void enqueueQCop( const QCString &ch, const QCString &msg, |
153 | const QByteArray &data ) | 153 | const QByteArray &data ) |
154 | { | 154 | { |
155 | qcopq.enqueue( new QCopRec( ch, msg, data ) ); | 155 | qcopq.enqueue( new QCopRec( ch, msg, data ) ); |
156 | } | 156 | } |
157 | void sendQCopQ() | 157 | void sendQCopQ() |
158 | { | 158 | { |
159 | if (!qcopQok ) | 159 | if (!qcopQok ) |
160 | return; | 160 | return; |
161 | 161 | ||
162 | QCopRec * r; | 162 | QCopRec * r; |
163 | 163 | ||
164 | while((r=qcopq.dequeue())) { | 164 | while((r=qcopq.dequeue())) { |
165 | // remove from queue before sending... | 165 | // remove from queue before sending... |
166 | // event loop can come around again before getting | 166 | // event loop can come around again before getting |
167 | // back from sendLocally | 167 | // back from sendLocally |
168 | #ifndef QT_NO_COP | 168 | #ifndef QT_NO_COP |
169 | QCopChannel::sendLocally( r->channel, r->message, r->data ); | 169 | QCopChannel::sendLocally( r->channel, r->message, r->data ); |
170 | #endif | 170 | #endif |
171 | 171 | ||
172 | delete r; | 172 | delete r; |
173 | } | 173 | } |
174 | } | 174 | } |
175 | 175 | ||
176 | static void show_mx(QWidget* mw, bool nomaximize, QString &strName/* = QString::null */) | 176 | static void show_mx(QWidget* mw, bool nomaximize, QString &strName/* = QString::null */) |
177 | { | 177 | { |
178 | QPoint p; | 178 | QPoint p; |
179 | QSize s; | 179 | QSize s; |
180 | bool max; | 180 | bool max; |
181 | if ( mw->isVisible() ) { | 181 | if ( mw->isVisible() ) { |
182 | if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { | 182 | if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { |
183 | mw->resize(s); | 183 | mw->resize(s); |
184 | mw->move(p); | 184 | mw->move(p); |
185 | } | 185 | } |
186 | mw->raise(); | 186 | mw->raise(); |
187 | } else { | 187 | } else { |
188 | 188 | ||
189 | if ( mw->layout() && mw->inherits("QDialog") ) { | 189 | if ( mw->layout() && mw->inherits("QDialog") ) { |
190 | if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { | 190 | if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { |
191 | mw->resize(s); | 191 | mw->resize(s); |
192 | mw->move(p); | 192 | mw->move(p); |
193 | 193 | ||
194 | if ( max && !nomaximize ) { | 194 | if ( max && !nomaximize ) { |
195 | mw->showMaximized(); | 195 | mw->showMaximized(); |
196 | } else { | 196 | } else { |
197 | mw->show(); | 197 | mw->show(); |
198 | } | 198 | } |
199 | } else { | 199 | } else { |
200 | qpe_show_dialog((QDialog*)mw,nomaximize); | 200 | qpe_show_dialog((QDialog*)mw,nomaximize); |
201 | } | 201 | } |
202 | } else { | 202 | } else { |
203 | if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { | 203 | if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { |
204 | mw->resize(s); | 204 | mw->resize(s); |
205 | mw->move(p); | 205 | mw->move(p); |
206 | } else { //no stored rectangle, make an estimation | 206 | } else { //no stored rectangle, make an estimation |
207 | int x = (qApp->desktop()->width()-mw->frameGeometry().width())/2; | 207 | int x = (qApp->desktop()->width()-mw->frameGeometry().width())/2; |
208 | int y = (qApp->desktop()->height()-mw->frameGeometry().height())/2; | 208 | int y = (qApp->desktop()->height()-mw->frameGeometry().height())/2; |
209 | mw->move( QMAX(x,0), QMAX(y,0) ); | 209 | mw->move( QMAX(x,0), QMAX(y,0) ); |
210 | #ifdef Q_WS_QWS | 210 | #ifdef Q_WS_QWS |
211 | if ( !nomaximize ) | 211 | if ( !nomaximize ) |
212 | mw->showMaximized(); | 212 | mw->showMaximized(); |
213 | #endif | 213 | #endif |
214 | } | 214 | } |
215 | if ( max && !nomaximize ) | 215 | if ( max && !nomaximize ) |
216 | mw->showMaximized(); | 216 | mw->showMaximized(); |
217 | else | 217 | else |
218 | mw->show(); | 218 | mw->show(); |
219 | } | 219 | } |
220 | } | 220 | } |
221 | } | 221 | } |
222 | // // ugly hack, remove that later after finding a sane solution | 222 | // // ugly hack, remove that later after finding a sane solution |
223 | // // Addendum: Only Sharp currently has models with high resolution but (physically) small displays, | 223 | // // Addendum: Only Sharp currently has models with high resolution but (physically) small displays, |
224 | // // so this is only useful if QT_QWS_SIMPAD is NOT defined. E.g. SIMpad has 800x600 but has | 224 | // // so this is only useful if QT_QWS_SIMPAD is NOT defined. E.g. SIMpad has 800x600 but has |
225 | // // a (physically) large enough display to use the small icons | 225 | // // a (physically) large enough display to use the small icons |
226 | // #if defined(OPIE_HIGH_RES_SMALL_PHY) | 226 | // #if defined(OPIE_HIGH_RES_SMALL_PHY) |
227 | // if ( QPEApplication::desktop() ->width() >= 600 && ( mw->inherits("QMainWindow") || mw->isA("QMainWindow") ) ) { | 227 | // if ( QPEApplication::desktop() ->width() >= 600 && ( mw->inherits("QMainWindow") || mw->isA("QMainWindow") ) ) { |
228 | // ( ( QMainWindow* ) mw )->setUsesBigPixmaps( true ); | 228 | // ( ( QMainWindow* ) mw )->setUsesBigPixmaps( true ); |
229 | // } | 229 | // } |
230 | // #endif | 230 | // #endif |
231 | 231 | ||
232 | // if ( mw->layout() && mw->inherits("QDialog") ) { | 232 | // if ( mw->layout() && mw->inherits("QDialog") ) { |
233 | // QPEApplication::showDialog((QDialog*)mw, nomaximize); | 233 | // QPEApplication::showDialog((QDialog*)mw, nomaximize); |
234 | // } | 234 | // } |
235 | // else { | 235 | // else { |
236 | // #ifdef Q_WS_QWS | 236 | // #ifdef Q_WS_QWS |
237 | // if ( !nomaximize ) { | 237 | // if ( !nomaximize ) { |
238 | // qDebug("QDialog special case XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); | 238 | // qDebug("QDialog special case XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); |
239 | // mw->showMaximized(); | 239 | // mw->showMaximized(); |
240 | // //QPEApplication::showWidget( mw, !nomaximize ); | 240 | // //QPEApplication::showWidget( mw, !nomaximize ); |
241 | // }else | 241 | // }else |
242 | // #endif | 242 | // #endif |
243 | // mw->show(); | 243 | // mw->show(); |
244 | // } | 244 | // } |
245 | //} | 245 | //} |
246 | 246 | ||
247 | 247 | ||
248 | static void qpe_show_dialog( QDialog* d, bool nomax ) | 248 | static void qpe_show_dialog( QDialog* d, bool nomax ) |
249 | { | 249 | { |
250 | QSize sh = d->sizeHint(); | 250 | QSize sh = d->sizeHint(); |
251 | int w = QMAX(sh.width(),d->width()); | 251 | int w = QMAX(sh.width(),d->width()); |
252 | int h = QMAX(sh.height(),d->height()); | 252 | int h = QMAX(sh.height(),d->height()); |
253 | 253 | ||
254 | if ( d->parentWidget() && !d->parentWidget()->topLevelWidget()->isMaximized() ) | 254 | if ( d->parentWidget() && !d->parentWidget()->topLevelWidget()->isMaximized() ) |
255 | nomax = TRUE; | 255 | nomax = TRUE; |
256 | 256 | ||
257 | #ifndef Q_WS_QWS | 257 | #ifndef Q_WS_QWS |
258 | QSize s(qApp->desktop()->width(), qApp->desktop()->height() ); | 258 | QSize s(qApp->desktop()->width(), qApp->desktop()->height() ); |
259 | #else | 259 | #else |
260 | QSize s(qt_maxWindowRect.width(), qt_maxWindowRect.height() ); | 260 | QSize s(qt_maxWindowRect.width(), qt_maxWindowRect.height() ); |
261 | #endif | 261 | #endif |
262 | 262 | ||
263 | int maxX = s.width() - (d->frameGeometry().width() - d->geometry().width()); | 263 | int maxX = s.width() - (d->frameGeometry().width() - d->geometry().width()); |
264 | int maxY = s.height() - (d->frameGeometry().height() - d->geometry().height()); | 264 | int maxY = s.height() - (d->frameGeometry().height() - d->geometry().height()); |
265 | 265 | ||
266 | if ( (w >= maxX && h >= maxY) || ( (!nomax) && ( w > s.width()*3/4 || h > s.height()*3/4 ) ) ) { | 266 | if ( (w >= maxX && h >= maxY) || ( (!nomax) && ( w > s.width()*3/4 || h > s.height()*3/4 ) ) ) { |
267 | d->showMaximized(); | 267 | d->showMaximized(); |
268 | } else { | 268 | } else { |
269 | // try centering the dialog around its parent | 269 | // try centering the dialog around its parent |
270 | QPoint p(0,0); | 270 | QPoint p(0,0); |
271 | if ( d->parentWidget() ) { | 271 | if ( d->parentWidget() ) { |
272 | QPoint pp = d->parentWidget()->mapToGlobal( QPoint(0,0) ); | 272 | QPoint pp = d->parentWidget()->mapToGlobal( QPoint(0,0) ); |
273 | p = QPoint( pp.x() + d->parentWidget()->width()/2, | 273 | p = QPoint( pp.x() + d->parentWidget()->width()/2, |
274 | pp.y() + d->parentWidget()->height()/ 2 ); | 274 | pp.y() + d->parentWidget()->height()/ 2 ); |
275 | } else { | 275 | } else { |
276 | p = QPoint( maxX/2, maxY/2 ); | 276 | p = QPoint( maxX/2, maxY/2 ); |
277 | } | 277 | } |
278 | 278 | ||
279 | p = QPoint( p.x() - w/2, p.y() - h/2 ); | 279 | p = QPoint( p.x() - w/2, p.y() - h/2 ); |
280 | //qDebug("p(x,y) is %d %d", p.x(), p.y() ); | 280 | //qDebug("p(x,y) is %d %d", p.x(), p.y() ); |
281 | 281 | ||
282 | if ( w >= maxX ) { | 282 | if ( w >= maxX ) { |
283 | if ( p.y() < 0 ) | 283 | if ( p.y() < 0 ) |
284 | p.setY(0); | 284 | p.setY(0); |
285 | if ( p.y() + h > maxY ) | 285 | if ( p.y() + h > maxY ) |
286 | p.setY( maxY - h); | 286 | p.setY( maxY - h); |
287 | 287 | ||
288 | d->resize(maxX, h); | 288 | d->resize(maxX, h); |
289 | d->move(0, p.y() ); | 289 | d->move(0, p.y() ); |
290 | } else if ( h >= maxY ) { | 290 | } else if ( h >= maxY ) { |
291 | if ( p.x() < 0 ) | 291 | if ( p.x() < 0 ) |
292 | p.setX(0); | 292 | p.setX(0); |
293 | if ( p.x() + w > maxX ) | 293 | if ( p.x() + w > maxX ) |
294 | p.setX( maxX - w); | 294 | p.setX( maxX - w); |
295 | 295 | ||
296 | d->resize(w, maxY); | 296 | d->resize(w, maxY); |
297 | d->move(p.x(),0); | 297 | d->move(p.x(),0); |
298 | } else { | 298 | } else { |
299 | d->resize(w, h); | 299 | d->resize(w, h); |
300 | } | 300 | } |
301 | 301 | ||
302 | d->show(); | 302 | d->show(); |
303 | } | 303 | } |
304 | } | 304 | } |
305 | 305 | ||
306 | static bool read_widget_rect(const QString &app, bool &maximized, QPoint &p, QSize &s) | 306 | static bool read_widget_rect(const QString &app, bool &maximized, QPoint &p, QSize &s) |
307 | { | 307 | { |
308 | maximized = TRUE; | 308 | maximized = TRUE; |
309 | qDebug("read_widget_rect"); | ||
310 | // 350 is the trigger in qwsdefaultdecoration for providing a resize button | 309 | // 350 is the trigger in qwsdefaultdecoration for providing a resize button |
311 | if ( qApp->desktop()->width() <= 350 ) | 310 | if ( qApp->desktop()->width() <= 350 ) |
312 | return FALSE; | 311 | return FALSE; |
313 | 312 | ||
314 | Config cfg( "qpe" ); | 313 | Config cfg( "qpe" ); |
315 | cfg.setGroup("ApplicationPositions"); | 314 | cfg.setGroup("ApplicationPositions"); |
316 | QString str = cfg.readEntry( app, QString::null ); | 315 | QString str = cfg.readEntry( app, QString::null ); |
317 | QStringList l = QStringList::split(",", str); | 316 | QStringList l = QStringList::split(",", str); |
318 | 317 | ||
319 | if ( l.count() == 5) { | 318 | if ( l.count() == 5) { |
320 | p.setX( l[0].toInt() ); | 319 | p.setX( l[0].toInt() ); |
321 | p.setY( l[1].toInt() ); | 320 | p.setY( l[1].toInt() ); |
322 | 321 | ||
323 | s.setWidth( l[2].toInt() ); | 322 | s.setWidth( l[2].toInt() ); |
324 | s.setHeight( l[3].toInt() ); | 323 | s.setHeight( l[3].toInt() ); |
325 | 324 | ||
326 | maximized = l[4].toInt(); | 325 | maximized = l[4].toInt(); |
327 | 326 | ||
328 | return TRUE; | 327 | return TRUE; |
329 | } | 328 | } |
330 | 329 | ||
331 | return FALSE; | 330 | return FALSE; |
332 | } | 331 | } |
333 | 332 | ||
334 | 333 | ||
335 | static bool validate_widget_size(const QWidget *w, QPoint &p, QSize &s) | 334 | static bool validate_widget_size(const QWidget *w, QPoint &p, QSize &s) |
336 | { | 335 | { |
337 | #ifndef Q_WS_QWS | 336 | #ifndef Q_WS_QWS |
338 | QRect qt_maxWindowRect = qApp->desktop()->geometry(); | 337 | QRect qt_maxWindowRect = qApp->desktop()->geometry(); |
339 | #endif | 338 | #endif |
340 | int maxX = qt_maxWindowRect.width(); | 339 | int maxX = qt_maxWindowRect.width(); |
341 | int maxY = qt_maxWindowRect.height(); | 340 | int maxY = qt_maxWindowRect.height(); |
342 | int wWidth = s.width() + ( w->frameGeometry().width() - w->geometry().width() ); | 341 | int wWidth = s.width() + ( w->frameGeometry().width() - w->geometry().width() ); |
343 | int wHeight = s.height() + ( w->frameGeometry().height() - w->geometry().height() ); | 342 | int wHeight = s.height() + ( w->frameGeometry().height() - w->geometry().height() ); |
344 | 343 | ||
345 | // total window size is not allowed to be larger than desktop window size | 344 | // total window size is not allowed to be larger than desktop window size |
346 | if ( ( wWidth >= maxX ) && ( wHeight >= maxY ) ) | 345 | if ( ( wWidth >= maxX ) && ( wHeight >= maxY ) ) |
347 | return FALSE; | 346 | return FALSE; |
348 | 347 | ||
349 | if ( wWidth > maxX ) { | 348 | if ( wWidth > maxX ) { |
350 | s.setWidth( maxX - (w->frameGeometry().width() - w->geometry().width() ) ); | 349 | s.setWidth( maxX - (w->frameGeometry().width() - w->geometry().width() ) ); |
351 | wWidth = maxX; | 350 | wWidth = maxX; |
352 | } | 351 | } |
353 | 352 | ||
354 | if ( wHeight > maxY ) { | 353 | if ( wHeight > maxY ) { |
355 | s.setHeight( maxY - (w->frameGeometry().height() - w->geometry().height() ) ); | 354 | s.setHeight( maxY - (w->frameGeometry().height() - w->geometry().height() ) ); |
356 | wHeight = maxY; | 355 | wHeight = maxY; |
357 | } | 356 | } |
358 | 357 | ||
359 | // any smaller than this and the maximize/close/help buttons will be overlapping | 358 | // any smaller than this and the maximize/close/help buttons will be overlapping |
360 | if ( wWidth < 80 || wHeight < 60 ) | 359 | if ( wWidth < 80 || wHeight < 60 ) |
361 | return FALSE; | 360 | return FALSE; |
362 | 361 | ||
363 | if ( p.x() < 0 ) | 362 | if ( p.x() < 0 ) |
364 | p.setX(0); | 363 | p.setX(0); |
365 | if ( p.y() < 0 ) | 364 | if ( p.y() < 0 ) |
366 | p.setY(0); | 365 | p.setY(0); |
367 | 366 | ||
368 | if ( p.x() + wWidth > maxX ) | 367 | if ( p.x() + wWidth > maxX ) |
369 | p.setX( maxX - wWidth ); | 368 | p.setX( maxX - wWidth ); |
370 | if ( p.y() + wHeight > maxY ) | 369 | if ( p.y() + wHeight > maxY ) |
371 | p.setY( maxY - wHeight ); | 370 | p.setY( maxY - wHeight ); |
372 | 371 | ||
373 | return TRUE; | 372 | return TRUE; |
374 | } | 373 | } |
375 | 374 | ||
376 | static void store_widget_rect(QWidget *w, QString &app) | 375 | static void store_widget_rect(QWidget *w, QString &app) |
377 | { | 376 | { |
378 | // 350 is the trigger in qwsdefaultdecoration for providing a resize button | 377 | // 350 is the trigger in qwsdefaultdecoration for providing a resize button |
379 | if ( qApp->desktop()->width() <= 350 ) | 378 | if ( qApp->desktop()->width() <= 350 ) |
380 | return; | 379 | return; |
381 | qDebug("store_widget_rect"); | ||
382 | // we use these to map the offset of geometry and pos. ( we can only use normalGeometry to | 380 | // we use these to map the offset of geometry and pos. ( we can only use normalGeometry to |
383 | // get the non-maximized version, so we have to do it the hard way ) | 381 | // get the non-maximized version, so we have to do it the hard way ) |
384 | int offsetX = w->x() - w->geometry().left(); | 382 | int offsetX = w->x() - w->geometry().left(); |
385 | int offsetY = w->y() - w->geometry().top(); | 383 | int offsetY = w->y() - w->geometry().top(); |
386 | 384 | ||
387 | QRect r; | 385 | QRect r; |
388 | if ( w->isMaximized() ) | 386 | if ( w->isMaximized() ) |
389 | r = ( (HackWidget *) w)->normalGeometry(); | 387 | r = ( (HackWidget *) w)->normalGeometry(); |
390 | else | 388 | else |
391 | r = w->geometry(); | 389 | r = w->geometry(); |
392 | 390 | ||
393 | // Stores the window placement as pos(), size() (due to the offset mapping) | 391 | // Stores the window placement as pos(), size() (due to the offset mapping) |
394 | Config cfg( "qpe" ); | 392 | Config cfg( "qpe" ); |
395 | cfg.setGroup("ApplicationPositions"); | 393 | cfg.setGroup("ApplicationPositions"); |
396 | QString s; | 394 | QString s; |
397 | s.sprintf("%d,%d,%d,%d,%d", r.left() + offsetX, r.top() + offsetY, r.width(), r.height(), w->isMaximized() ); | 395 | s.sprintf("%d,%d,%d,%d,%d", r.left() + offsetX, r.top() + offsetY, r.width(), r.height(), w->isMaximized() ); |
398 | cfg.writeEntry( app, s ); | 396 | cfg.writeEntry( app, s ); |
399 | } | 397 | } |
400 | 398 | ||
401 | static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) | 399 | static bool setWidgetCaptionFromAppName( QWidget* /*mw*/, const QString& /*appName*/, const QString& /*appsPath*/ ) |
402 | { | 400 | { |
403 | /* | 401 | /* |
404 | // This works but disable it for now until it is safe to apply | 402 | // This works but disable it for now until it is safe to apply |
405 | // What is does is scan the .desktop files of all the apps for | 403 | // What is does is scan the .desktop files of all the apps for |
406 | // the applnk that has the corresponding argv[0] as this program | 404 | // the applnk that has the corresponding argv[0] as this program |
407 | // then it uses the name stored in the .desktop file as the caption | 405 | // then it uses the name stored in the .desktop file as the caption |
408 | // for the main widget. This saves duplicating translations for | 406 | // for the main widget. This saves duplicating translations for |
409 | // the app name in the program and in the .desktop files. | 407 | // the app name in the program and in the .desktop files. |
410 | 408 | ||
411 | AppLnkSet apps( appsPath ); | 409 | AppLnkSet apps( appsPath ); |
412 | 410 | ||
413 | QList<AppLnk> appsList = apps.children(); | 411 | QList<AppLnk> appsList = apps.children(); |
414 | for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { | 412 | for ( QListIterator<AppLnk> it(appsList); it.current(); ++it ) { |
415 | if ( (*it)->exec() == appName ) { | 413 | if ( (*it)->exec() == appName ) { |
416 | mw->setCaption( (*it)->name() ); | 414 | mw->setCaption( (*it)->name() ); |
417 | return TRUE; | 415 | return TRUE; |
418 | } | 416 | } |
419 | } | 417 | } |
420 | */ | 418 | */ |
421 | return FALSE; | 419 | return FALSE; |
422 | } | 420 | } |
423 | 421 | ||
424 | 422 | ||
425 | void show(QWidget* mw, bool nomax) | 423 | void show(QWidget* mw, bool nomax) |
426 | { | 424 | { |
427 | setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" ); | 425 | setWidgetCaptionFromAppName( mw, appName, QPEApplication::qpeDir() + "apps" ); |
428 | nomaximize = nomax; | 426 | nomaximize = nomax; |
429 | qpe_main_widget = mw; | 427 | qpe_main_widget = mw; |
430 | qcopQok = TRUE; | 428 | qcopQok = TRUE; |
431 | #ifndef QT_NO_COP | 429 | #ifndef QT_NO_COP |
432 | 430 | ||
433 | sendQCopQ(); | 431 | sendQCopQ(); |
434 | #endif | 432 | #endif |
435 | 433 | ||
436 | if ( preloaded ) { | 434 | if ( preloaded ) { |
437 | if (forceshow) | 435 | if (forceshow) |
438 | show_mx(mw, nomax, appName); | 436 | show_mx(mw, nomax, appName); |
439 | } | 437 | } |
440 | else if ( keep_running ) { | 438 | else if ( keep_running ) { |
441 | show_mx(mw, nomax, appName); | 439 | show_mx(mw, nomax, appName); |
442 | } | 440 | } |
443 | } | 441 | } |
444 | 442 | ||
445 | void loadTextCodecs() | 443 | void loadTextCodecs() |
446 | { | 444 | { |
447 | QString path = QPEApplication::qpeDir() + "/plugins/textcodecs"; | 445 | QString path = QPEApplication::qpeDir() + "/plugins/textcodecs"; |
448 | #ifdef Q_OS_MACX | 446 | #ifdef Q_OS_MACX |
449 | QDir dir( path, "lib*.dylib" ); | 447 | QDir dir( path, "lib*.dylib" ); |
450 | #else | 448 | #else |
451 | QDir dir( path, "lib*.so" ); | 449 | QDir dir( path, "lib*.so" ); |
452 | #endif | 450 | #endif |
453 | QStringList list; | 451 | QStringList list; |
454 | if ( dir. exists ( )) | 452 | if ( dir. exists ( )) |
455 | list = dir.entryList(); | 453 | list = dir.entryList(); |
456 | QStringList::Iterator it; | 454 | QStringList::Iterator it; |
457 | for ( it = list.begin(); it != list.end(); ++it ) { | 455 | for ( it = list.begin(); it != list.end(); ++it ) { |
458 | TextCodecInterface *iface = 0; | 456 | TextCodecInterface *iface = 0; |
459 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 457 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
460 | if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { | 458 | if ( lib->queryInterface( IID_QtopiaTextCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { |
461 | QValueList<int> mibs = iface->mibEnums(); | 459 | QValueList<int> mibs = iface->mibEnums(); |
462 | for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) { | 460 | for (QValueList<int>::ConstIterator i = mibs.begin(); i != mibs.end(); ++i) { |
463 | (void)iface->createForMib(*i); | 461 | (void)iface->createForMib(*i); |
464 | // ### it exists now; need to remember if we can delete it | 462 | // ### it exists now; need to remember if we can delete it |
465 | } | 463 | } |
466 | } | 464 | } |
467 | else { | 465 | else { |
468 | lib->unload(); | 466 | lib->unload(); |
469 | delete lib; | 467 | delete lib; |
470 | } | 468 | } |
471 | } | 469 | } |
472 | } | 470 | } |
473 | 471 | ||
474 | void loadImageCodecs() | 472 | void loadImageCodecs() |
475 | { | 473 | { |
476 | QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs"; | 474 | QString path = QPEApplication::qpeDir() + "/plugins/imagecodecs"; |
477 | #ifdef Q_OS_MACX | 475 | #ifdef Q_OS_MACX |
478 | QDir dir( path, "lib*.dylib" ); | 476 | QDir dir( path, "lib*.dylib" ); |
479 | #else | 477 | #else |
480 | QDir dir( path, "lib*.so" ); | 478 | QDir dir( path, "lib*.so" ); |
481 | #endif | 479 | #endif |
482 | QStringList list; | 480 | QStringList list; |
483 | if ( dir. exists ( )) | 481 | if ( dir. exists ( )) |
484 | list = dir.entryList(); | 482 | list = dir.entryList(); |
485 | QStringList::Iterator it; | 483 | QStringList::Iterator it; |
486 | for ( it = list.begin(); it != list.end(); ++it ) { | 484 | for ( it = list.begin(); it != list.end(); ++it ) { |
487 | ImageCodecInterface *iface = 0; | 485 | ImageCodecInterface *iface = 0; |
488 | QLibrary *lib = new QLibrary( path + "/" + *it ); | 486 | QLibrary *lib = new QLibrary( path + "/" + *it ); |
489 | if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { | 487 | if ( lib->queryInterface( IID_QtopiaImageCodec, (QUnknownInterface**)&iface ) == QS_OK && iface ) { |
490 | QStringList formats = iface->keys(); | 488 | QStringList formats = iface->keys(); |
491 | for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) { | 489 | for (QStringList::ConstIterator i = formats.begin(); i != formats.end(); ++i) { |
492 | (void)iface->installIOHandler(*i); | 490 | (void)iface->installIOHandler(*i); |
493 | // ### it exists now; need to remember if we can delete it | 491 | // ### it exists now; need to remember if we can delete it |
494 | } | 492 | } |
495 | } | 493 | } |
496 | else { | 494 | else { |
497 | lib->unload(); | 495 | lib->unload(); |
498 | delete lib; | 496 | delete lib; |
499 | } | 497 | } |
500 | } | 498 | } |
501 | } | 499 | } |
502 | }; | 500 | }; |
503 | 501 | ||
504 | class ResourceMimeFactory : public QMimeSourceFactory | 502 | class ResourceMimeFactory : public QMimeSourceFactory |
505 | { | 503 | { |
506 | public: | 504 | public: |
507 | ResourceMimeFactory() : resImage( 0 ) | 505 | ResourceMimeFactory() : resImage( 0 ) |
508 | { | 506 | { |
509 | setFilePath( Global::helpPath() ); | 507 | setFilePath( Global::helpPath() ); |
510 | setExtensionType( "html", "text/html;charset=UTF-8" ); | 508 | setExtensionType( "html", "text/html;charset=UTF-8" ); |
511 | } | 509 | } |
512 | ~ResourceMimeFactory() { | 510 | ~ResourceMimeFactory() { |
513 | delete resImage; | 511 | delete resImage; |
514 | } | 512 | } |
515 | 513 | ||
516 | const QMimeSource* data( const QString& abs_name ) const | 514 | const QMimeSource* data( const QString& abs_name ) const |
517 | { | 515 | { |
518 | const QMimeSource * r = QMimeSourceFactory::data( abs_name ); | 516 | const QMimeSource * r = QMimeSourceFactory::data( abs_name ); |
519 | if ( !r ) { | 517 | if ( !r ) { |
520 | int sl = abs_name.length(); | 518 | int sl = abs_name.length(); |
521 | do { | 519 | do { |
522 | sl = abs_name.findRev( '/', sl - 1 ); | 520 | sl = abs_name.findRev( '/', sl - 1 ); |
523 | QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; | 521 | QString name = sl >= 0 ? abs_name.mid( sl + 1 ) : abs_name; |
524 | int dot = name.findRev( '.' ); | 522 | int dot = name.findRev( '.' ); |
525 | if ( dot >= 0 ) | 523 | if ( dot >= 0 ) |
526 | name = name.left( dot ); | 524 | name = name.left( dot ); |
527 | QImage img = Resource::loadImage( name ); | 525 | QImage img = Resource::loadImage( name ); |
528 | if ( !img.isNull() ) { | 526 | if ( !img.isNull() ) { |
529 | delete resImage; | 527 | delete resImage; |
530 | resImage = new QImageDrag( img ); | 528 | resImage = new QImageDrag( img ); |
531 | r = resImage; | 529 | r = resImage; |
532 | } | 530 | } |
533 | } | 531 | } |
534 | while ( !r && sl > 0 ); | 532 | while ( !r && sl > 0 ); |
535 | } | 533 | } |
536 | return r; | 534 | return r; |
537 | } | 535 | } |
538 | private: | 536 | private: |
539 | mutable QImageDrag *resImage; | 537 | mutable QImageDrag *resImage; |
540 | }; | 538 | }; |
541 | 539 | ||
542 | static int& hack(int& i) | 540 | static int& hack(int& i) |
543 | { | 541 | { |
544 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) | 542 | #if QT_VERSION <= 230 && defined(QT_NO_CODECS) |
545 | // These should be created, but aren't in Qt 2.3.0 | 543 | // These should be created, but aren't in Qt 2.3.0 |
546 | (void)new QUtf8Codec; | 544 | (void)new QUtf8Codec; |
547 | (void)new QUtf16Codec; | 545 | (void)new QUtf16Codec; |
548 | #endif | 546 | #endif |
549 | return i; | 547 | return i; |
550 | } | 548 | } |
551 | 549 | ||
552 | static int muted = 0; | 550 | static int muted = 0; |
553 | static int micMuted = 0; | 551 | static int micMuted = 0; |
554 | 552 | ||
555 | static void setVolume( int t = 0, int percent = -1 ) | 553 | static void setVolume( int t = 0, int percent = -1 ) |
556 | { | 554 | { |
557 | switch ( t ) { | 555 | switch ( t ) { |
558 | case 0: { | 556 | case 0: { |
559 | Config cfg( "qpe" ); | 557 | Config cfg( "qpe" ); |
560 | cfg.setGroup( "Volume" ); | 558 | cfg.setGroup( "Volume" ); |
561 | if ( percent < 0 ) | 559 | if ( percent < 0 ) |
562 | percent = cfg.readNumEntry( "VolumePercent", 50 ); | 560 | percent = cfg.readNumEntry( "VolumePercent", 50 ); |
563 | #ifndef QT_NO_SOUND | 561 | #ifndef QT_NO_SOUND |
564 | int fd = 0; | 562 | int fd = 0; |
565 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 563 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
566 | int vol = muted ? 0 : percent; | 564 | int vol = muted ? 0 : percent; |
567 | // set both channels to same volume | 565 | // set both channels to same volume |
568 | vol |= vol << 8; | 566 | vol |= vol << 8; |
569 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_VOLUME ), &vol ); | 567 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_VOLUME ), &vol ); |
570 | ::close( fd ); | 568 | ::close( fd ); |
571 | } | 569 | } |
572 | #endif | 570 | #endif |
573 | } | 571 | } |
574 | break; | 572 | break; |
575 | } | 573 | } |
576 | } | 574 | } |
577 | 575 | ||
578 | static void setMic( int t = 0, int percent = -1 ) | 576 | static void setMic( int t = 0, int percent = -1 ) |
579 | { | 577 | { |
580 | switch ( t ) { | 578 | switch ( t ) { |
581 | case 0: { | 579 | case 0: { |
582 | Config cfg( "qpe" ); | 580 | Config cfg( "qpe" ); |
583 | cfg.setGroup( "Volume" ); | 581 | cfg.setGroup( "Volume" ); |
584 | if ( percent < 0 ) | 582 | if ( percent < 0 ) |
585 | percent = cfg.readNumEntry( "Mic", 50 ); | 583 | percent = cfg.readNumEntry( "Mic", 50 ); |
586 | 584 | ||
587 | #ifndef QT_NO_SOUND | 585 | #ifndef QT_NO_SOUND |
588 | int fd = 0; | 586 | int fd = 0; |
589 | int mic = micMuted ? 0 : percent; | 587 | int mic = micMuted ? 0 : percent; |
590 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 588 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
591 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic ); | 589 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_MIC ), &mic ); |
592 | ::close( fd ); | 590 | ::close( fd ); |
593 | } | 591 | } |
594 | #endif | 592 | #endif |
595 | } | 593 | } |
596 | break; | 594 | break; |
597 | } | 595 | } |
598 | } | 596 | } |
599 | 597 | ||
600 | 598 | ||
601 | static void setBass( int t = 0, int percent = -1 ) | 599 | static void setBass( int t = 0, int percent = -1 ) |
602 | { | 600 | { |
603 | switch ( t ) { | 601 | switch ( t ) { |
604 | case 0: { | 602 | case 0: { |
605 | Config cfg( "qpe" ); | 603 | Config cfg( "qpe" ); |
606 | cfg.setGroup( "Volume" ); | 604 | cfg.setGroup( "Volume" ); |
607 | if ( percent < 0 ) | 605 | if ( percent < 0 ) |
608 | percent = cfg.readNumEntry( "BassPercent", 50 ); | 606 | percent = cfg.readNumEntry( "BassPercent", 50 ); |
609 | 607 | ||
610 | #ifndef QT_NO_SOUND | 608 | #ifndef QT_NO_SOUND |
611 | int fd = 0; | 609 | int fd = 0; |
612 | int bass = percent; | 610 | int bass = percent; |
613 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 611 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
614 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_BASS ), &bass ); | 612 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_BASS ), &bass ); |
615 | ::close( fd ); | 613 | ::close( fd ); |
616 | } | 614 | } |
617 | #endif | 615 | #endif |
618 | } | 616 | } |
619 | break; | 617 | break; |
620 | } | 618 | } |
621 | } | 619 | } |
622 | 620 | ||
623 | 621 | ||
624 | static void setTreble( int t = 0, int percent = -1 ) | 622 | static void setTreble( int t = 0, int percent = -1 ) |
625 | { | 623 | { |
626 | switch ( t ) { | 624 | switch ( t ) { |
627 | case 0: { | 625 | case 0: { |
628 | Config cfg( "qpe" ); | 626 | Config cfg( "qpe" ); |
629 | cfg.setGroup( "Volume" ); | 627 | cfg.setGroup( "Volume" ); |
630 | if ( percent < 0 ) | 628 | if ( percent < 0 ) |
631 | percent = cfg.readNumEntry( "TreblePercent", 50 ); | 629 | percent = cfg.readNumEntry( "TreblePercent", 50 ); |
632 | 630 | ||
633 | #ifndef QT_NO_SOUND | 631 | #ifndef QT_NO_SOUND |
634 | int fd = 0; | 632 | int fd = 0; |
635 | int treble = percent; | 633 | int treble = percent; |
636 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { | 634 | if ( ( fd = open( "/dev/mixer", O_RDWR ) ) >= 0 ) { |
637 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_TREBLE ), &treble ); | 635 | ioctl( fd, MIXER_WRITE( SOUND_MIXER_TREBLE ), &treble ); |
638 | ::close( fd ); | 636 | ::close( fd ); |
639 | } | 637 | } |
640 | #endif | 638 | #endif |
641 | } | 639 | } |
642 | break; | 640 | break; |
643 | } | 641 | } |
644 | } | 642 | } |
645 | 643 | ||
646 | 644 | ||
647 | /** | 645 | /** |
648 | \class QPEApplication | 646 | \class QPEApplication |
649 | \brief The QPEApplication class implements various system services | 647 | \brief The QPEApplication class implements various system services |
650 | that are available to all Qtopia applications. | 648 | that are available to all Qtopia applications. |
651 | 649 | ||
652 | Simply by using QPEApplication instead of QApplication, a standard Qt | 650 | Simply by using QPEApplication instead of QApplication, a standard Qt |
653 | application becomes a Qtopia application. It automatically follows | 651 | application becomes a Qtopia application. It automatically follows |
654 | style changes, quits and raises, and in the | 652 | style changes, quits and raises, and in the |
655 | case of \link docwidget.html document-oriented\endlink applications, | 653 | case of \link docwidget.html document-oriented\endlink applications, |
656 | changes the currently displayed document in response to the environment. | 654 | changes the currently displayed document in response to the environment. |
657 | 655 | ||
658 | To create a \link docwidget.html document-oriented\endlink | 656 | To create a \link docwidget.html document-oriented\endlink |
659 | application use showMainDocumentWidget(); to create a | 657 | application use showMainDocumentWidget(); to create a |
660 | non-document-oriented application use showMainWidget(). The | 658 | non-document-oriented application use showMainWidget(). The |
661 | keepRunning() function indicates whether the application will | 659 | keepRunning() function indicates whether the application will |
662 | continue running after it's processed the last \link qcop.html | 660 | continue running after it's processed the last \link qcop.html |
663 | QCop\endlink message. This can be changed using setKeepRunning(). | 661 | QCop\endlink message. This can be changed using setKeepRunning(). |
664 | 662 | ||
665 | A variety of signals are emitted when certain events occur, for | 663 | A variety of signals are emitted when certain events occur, for |
666 | example, timeChanged(), clockChanged(), weekChanged(), | 664 | example, timeChanged(), clockChanged(), weekChanged(), |
667 | dateFormatChanged() and volumeChanged(). If the application receives | 665 | dateFormatChanged() and volumeChanged(). If the application receives |
668 | a \link qcop.html QCop\endlink message on the application's | 666 | a \link qcop.html QCop\endlink message on the application's |
669 | QPE/Application/\e{appname} channel, the appMessage() signal is | 667 | QPE/Application/\e{appname} channel, the appMessage() signal is |
670 | emitted. There are also flush() and reload() signals, which | 668 | emitted. There are also flush() and reload() signals, which |
671 | are emitted when synching begins and ends respectively - upon these | 669 | are emitted when synching begins and ends respectively - upon these |
672 | signals, the application should save and reload any data | 670 | signals, the application should save and reload any data |
673 | files that are involved in synching. Most of these signals will initially | 671 | files that are involved in synching. Most of these signals will initially |
674 | be received and unfiltered through the appMessage() signal. | 672 | be received and unfiltered through the appMessage() signal. |
675 | 673 | ||
676 | This class also provides a set of useful static functions. The | 674 | This class also provides a set of useful static functions. The |
677 | qpeDir() and documentDir() functions return the respective paths. | 675 | qpeDir() and documentDir() functions return the respective paths. |
678 | The grabKeyboard() and ungrabKeyboard() functions are used to | 676 | The grabKeyboard() and ungrabKeyboard() functions are used to |
679 | control whether the application takes control of the device's | 677 | control whether the application takes control of the device's |
680 | physical buttons (e.g. application launch keys). The stylus' mode of | 678 | physical buttons (e.g. application launch keys). The stylus' mode of |
681 | operation is set with setStylusOperation() and retrieved with | 679 | operation is set with setStylusOperation() and retrieved with |
682 | stylusOperation(). There are also setInputMethodHint() and | 680 | stylusOperation(). There are also setInputMethodHint() and |
683 | inputMethodHint() functions. | 681 | inputMethodHint() functions. |
684 | 682 | ||
685 | \ingroup qtopiaemb | 683 | \ingroup qtopiaemb |
686 | */ | 684 | */ |
687 | 685 | ||
688 | /*! | 686 | /*! |
689 | \fn void QPEApplication::clientMoused() | 687 | \fn void QPEApplication::clientMoused() |
690 | 688 | ||
691 | \internal | 689 | \internal |
692 | */ | 690 | */ |
693 | 691 | ||
694 | /*! | 692 | /*! |
695 | \fn void QPEApplication::timeChanged(); | 693 | \fn void QPEApplication::timeChanged(); |
696 | This signal is emitted when the time changes outside the normal | 694 | This signal is emitted when the time changes outside the normal |
697 | passage of time, i.e. if the time is set backwards or forwards. | 695 | passage of time, i.e. if the time is set backwards or forwards. |
698 | */ | 696 | */ |
699 | 697 | ||
700 | /*! | 698 | /*! |
701 | \fn void QPEApplication::clockChanged( bool ampm ); | 699 | \fn void QPEApplication::clockChanged( bool ampm ); |
702 | 700 | ||
703 | This signal is emitted when the user changes the clock's style. If | 701 | This signal is emitted when the user changes the clock's style. If |
704 | \a ampm is TRUE, the user wants a 12-hour AM/PM clock, otherwise, | 702 | \a ampm is TRUE, the user wants a 12-hour AM/PM clock, otherwise, |
705 | they want a 24-hour clock. | 703 | they want a 24-hour clock. |
706 | */ | 704 | */ |
707 | 705 | ||
708 | /*! | 706 | /*! |
709 | \fn void QPEApplication::volumeChanged( bool muted ) | 707 | \fn void QPEApplication::volumeChanged( bool muted ) |
710 | 708 | ||
711 | This signal is emitted whenever the mute state is changed. If \a | 709 | This signal is emitted whenever the mute state is changed. If \a |
712 | muted is TRUE, then sound output has been muted. | 710 | muted is TRUE, then sound output has been muted. |
713 | */ | 711 | */ |
714 | 712 | ||
715 | /*! | 713 | /*! |
716 | \fn void QPEApplication::weekChanged( bool startOnMonday ) | 714 | \fn void QPEApplication::weekChanged( bool startOnMonday ) |
717 | 715 | ||
718 | This signal is emitted if the week start day is changed. If \a | 716 | This signal is emitted if the week start day is changed. If \a |
719 | startOnMonday is TRUE then the first day of the week is Monday; if | 717 | startOnMonday is TRUE then the first day of the week is Monday; if |
720 | \a startOnMonday is FALSE then the first day of the week is | 718 | \a startOnMonday is FALSE then the first day of the week is |
721 | Sunday. | 719 | Sunday. |
722 | */ | 720 | */ |
723 | 721 | ||
724 | /*! | 722 | /*! |
725 | \fn void QPEApplication::dateFormatChanged(DateFormat) | 723 | \fn void QPEApplication::dateFormatChanged(DateFormat) |
726 | 724 | ||
727 | This signal is emitted whenever the date format is changed. | 725 | This signal is emitted whenever the date format is changed. |
728 | */ | 726 | */ |
729 | 727 | ||
730 | /*! | 728 | /*! |
731 | \fn void QPEApplication::flush() | 729 | \fn void QPEApplication::flush() |
732 | 730 | ||
733 | ### | 731 | ### |
734 | */ | 732 | */ |
735 | 733 | ||
736 | /*! | 734 | /*! |
737 | \fn void QPEApplication::reload() | 735 | \fn void QPEApplication::reload() |
738 | 736 | ||
739 | */ | 737 | */ |
740 | 738 | ||
741 | 739 | ||
742 | 740 | ||
743 | void QPEApplication::processQCopFile() | 741 | void QPEApplication::processQCopFile() |
744 | { | 742 | { |
745 | QString qcopfn("/tmp/qcop-msg-"); | 743 | QString qcopfn("/tmp/qcop-msg-"); |
746 | qcopfn += d->appName; // append command name | 744 | qcopfn += d->appName; // append command name |
747 | 745 | ||
748 | QFile f(qcopfn); | 746 | QFile f(qcopfn); |
749 | if ( f.open(IO_ReadWrite) ) { | 747 | if ( f.open(IO_ReadWrite) ) { |
750 | #ifndef Q_OS_WIN32 | 748 | #ifndef Q_OS_WIN32 |
751 | flock(f.handle(), LOCK_EX); | 749 | flock(f.handle(), LOCK_EX); |
752 | #endif | 750 | #endif |
753 | QDataStream ds(&f); | 751 | QDataStream ds(&f); |
754 | QCString channel, message; | 752 | QCString channel, message; |
755 | QByteArray data; | 753 | QByteArray data; |
756 | while(!ds.atEnd()) { | 754 | while(!ds.atEnd()) { |
757 | ds >> channel >> message >> data; | 755 | ds >> channel >> message >> data; |
758 | d->enqueueQCop(channel,message,data); | 756 | d->enqueueQCop(channel,message,data); |
759 | } | 757 | } |
760 | ::ftruncate(f.handle(), 0); | 758 | ::ftruncate(f.handle(), 0); |
761 | #ifndef Q_OS_WIN32 | 759 | #ifndef Q_OS_WIN32 |
762 | f.flush(); | 760 | f.flush(); |
763 | flock(f.handle(), LOCK_UN); | 761 | flock(f.handle(), LOCK_UN); |
764 | #endif | 762 | #endif |
765 | } | 763 | } |
766 | #endif | 764 | #endif |
767 | } | 765 | } |
768 | 766 | ||
769 | 767 | ||
770 | /*! | 768 | /*! |
771 | \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data ) | 769 | \fn void QPEApplication::appMessage( const QCString& msg, const QByteArray& data ) |
772 | 770 | ||
773 | This signal is emitted when a message is received on this | 771 | This signal is emitted when a message is received on this |
774 | application's QPE/Application/<i>appname</i> \link qcop.html | 772 | application's QPE/Application/<i>appname</i> \link qcop.html |
775 | QCop\endlink channel. | 773 | QCop\endlink channel. |
776 | 774 | ||
777 | The slot to which you connect this signal uses \a msg and \a data | 775 | The slot to which you connect this signal uses \a msg and \a data |
778 | in the following way: | 776 | in the following way: |
779 | 777 | ||
780 | \code | 778 | \code |
781 | void MyWidget::receive( const QCString& msg, const QByteArray& data ) | 779 | void MyWidget::receive( const QCString& msg, const QByteArray& data ) |
782 | { | 780 | { |
783 | QDataStream stream( data, IO_ReadOnly ); | 781 | QDataStream stream( data, IO_ReadOnly ); |
784 | if ( msg == "someMessage(int,int,int)" ) { | 782 | if ( msg == "someMessage(int,int,int)" ) { |
785 | int a,b,c; | 783 | int a,b,c; |
786 | stream >> a >> b >> c; | 784 | stream >> a >> b >> c; |
787 | ... | 785 | ... |
788 | } else if ( msg == "otherMessage(QString)" ) { | 786 | } else if ( msg == "otherMessage(QString)" ) { |
789 | ... | 787 | ... |
790 | } | 788 | } |
791 | } | 789 | } |
792 | \endcode | 790 | \endcode |
793 | 791 | ||
794 | \sa qcop.html | 792 | \sa qcop.html |
795 | Note that messages received here may be processed by qpe application | 793 | Note that messages received here may be processed by qpe application |
796 | and emitted as signals, such as flush() and reload(). | 794 | and emitted as signals, such as flush() and reload(). |
797 | */ | 795 | */ |
798 | 796 | ||
799 | /*! | 797 | /*! |
800 | Constructs a QPEApplication just as you would construct | 798 | Constructs a QPEApplication just as you would construct |
801 | a QApplication, passing \a argc, \a argv, and \a t. | 799 | a QApplication, passing \a argc, \a argv, and \a t. |
802 | 800 | ||
803 | For applications, \a t should be the default, GuiClient. Only | 801 | For applications, \a t should be the default, GuiClient. Only |
804 | the Qtopia server passes GuiServer. | 802 | the Qtopia server passes GuiServer. |
805 | */ | 803 | */ |
806 | QPEApplication::QPEApplication( int & argc, char **argv, Type t ) | 804 | QPEApplication::QPEApplication( int & argc, char **argv, Type t ) |
807 | : QApplication( hack(argc), argv, t ), pidChannel( 0 ) | 805 | : QApplication( hack(argc), argv, t ), pidChannel( 0 ) |
808 | { | 806 | { |
809 | QPixmapCache::setCacheLimit(256); // sensible default for smaller devices. | 807 | QPixmapCache::setCacheLimit(256); // sensible default for smaller devices. |
810 | 808 | ||
811 | d = new QPEApplicationData; | 809 | d = new QPEApplicationData; |
812 | d->loadTextCodecs(); | 810 | d->loadTextCodecs(); |
813 | d->loadImageCodecs(); | 811 | d->loadImageCodecs(); |
814 | int dw = desktop() ->width(); | 812 | int dw = desktop() ->width(); |
815 | 813 | ||
816 | if ( dw < 200 ) { | 814 | if ( dw < 200 ) { |
817 | setFont( QFont( "vera", 8 ) ); | 815 | setFont( QFont( "vera", 8 ) ); |
818 | AppLnk::setSmallIconSize( 10 ); | 816 | AppLnk::setSmallIconSize( 10 ); |
819 | AppLnk::setBigIconSize( 28 ); | 817 | AppLnk::setBigIconSize( 28 ); |
820 | } | 818 | } |
821 | #if defined(OPIE_HIGH_RES_SMALL_PHY) | 819 | #if defined(OPIE_HIGH_RES_SMALL_PHY) |
822 | else if ( dw > 600 ) { | 820 | else if ( dw > 600 ) { |
823 | setFont( QFont( "vera", 16 ) ); | 821 | setFont( QFont( "vera", 16 ) ); |
824 | AppLnk::setSmallIconSize( 24 ); | 822 | AppLnk::setSmallIconSize( 24 ); |
825 | AppLnk::setBigIconSize( 48 ); | 823 | AppLnk::setBigIconSize( 48 ); |
826 | } | 824 | } |
827 | #endif | 825 | #endif |
828 | else if ( dw > 200 ) { | 826 | else if ( dw > 200 ) { |
829 | setFont( QFont( "vera", 10 ) ); | 827 | setFont( QFont( "vera", 10 ) ); |
830 | AppLnk::setSmallIconSize( 14 ); | 828 | AppLnk::setSmallIconSize( 14 ); |
831 | AppLnk::setBigIconSize( 32 ); | 829 | AppLnk::setBigIconSize( 32 ); |
832 | } | 830 | } |
833 | 831 | ||
834 | QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory ); | 832 | QMimeSourceFactory::setDefaultFactory( new ResourceMimeFactory ); |
835 | 833 | ||
836 | connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) ); | 834 | connect( this, SIGNAL( lastWindowClosed() ), this, SLOT( hideOrQuit() ) ); |
837 | 835 | ||
838 | 836 | ||
839 | sysChannel = new QCopChannel( "QPE/System", this ); | 837 | sysChannel = new QCopChannel( "QPE/System", this ); |
840 | connect( sysChannel, SIGNAL( received(const QCString&,const QByteArray&) ), | 838 | connect( sysChannel, SIGNAL( received(const QCString&,const QByteArray&) ), |
841 | this, SLOT( systemMessage(const QCString&,const QByteArray&) ) ); | 839 | this, SLOT( systemMessage(const QCString&,const QByteArray&) ) ); |
842 | 840 | ||
843 | /* COde now in initapp */ | 841 | /* COde now in initapp */ |
844 | #if 0 | 842 | #if 0 |
845 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 843 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
846 | 844 | ||
847 | QString qcopfn( "/tmp/qcop-msg-" ); | 845 | QString qcopfn( "/tmp/qcop-msg-" ); |
848 | qcopfn += QString( argv[ 0 ] ); // append command name | 846 | qcopfn += QString( argv[ 0 ] ); // append command name |
849 | 847 | ||
850 | QFile f( qcopfn ); | 848 | QFile f( qcopfn ); |
851 | if ( f.open( IO_ReadOnly ) ) { | 849 | if ( f.open( IO_ReadOnly ) ) { |
852 | flock( f.handle(), LOCK_EX ); | 850 | flock( f.handle(), LOCK_EX ); |
853 | } | 851 | } |
854 | 852 | ||
855 | 853 | ||
856 | 854 | ||
857 | QCString channel = QCString( argv[ 0 ] ); | 855 | QCString channel = QCString( argv[ 0 ] ); |
858 | channel.replace( QRegExp( ".*/" ), "" ); | 856 | channel.replace( QRegExp( ".*/" ), "" ); |
859 | d->appName = channel; | 857 | d->appName = channel; |
860 | channel = "QPE/Application/" + channel; | 858 | channel = "QPE/Application/" + channel; |
861 | pidChannel = new QCopChannel( channel, this ); | 859 | pidChannel = new QCopChannel( channel, this ); |
862 | connect( pidChannel, SIGNAL( received(const QCString&,const QByteArray&) ), | 860 | connect( pidChannel, SIGNAL( received(const QCString&,const QByteArray&) ), |
863 | this, SLOT( pidMessage(const QCString&,const QByteArray&) ) ); | 861 | this, SLOT( pidMessage(const QCString&,const QByteArray&) ) ); |
864 | 862 | ||
865 | if ( f.isOpen() ) { | 863 | if ( f.isOpen() ) { |
866 | d->keep_running = FALSE; | 864 | d->keep_running = FALSE; |
867 | QDataStream ds( &f ); | 865 | QDataStream ds( &f ); |
868 | QCString channel, message; | 866 | QCString channel, message; |
869 | QByteArray data; | 867 | QByteArray data; |
870 | while ( !ds.atEnd() ) { | 868 | while ( !ds.atEnd() ) { |
871 | ds >> channel >> message >> data; | 869 | ds >> channel >> message >> data; |
872 | d->enqueueQCop( channel, message, data ); | 870 | d->enqueueQCop( channel, message, data ); |
873 | } | 871 | } |
874 | 872 | ||
875 | flock( f.handle(), LOCK_UN ); | 873 | flock( f.handle(), LOCK_UN ); |
876 | f.close(); | 874 | f.close(); |
877 | f.remove(); | 875 | f.remove(); |
878 | } | 876 | } |
879 | 877 | ||
880 | for ( int a = 0; a < argc; a++ ) { | 878 | for ( int a = 0; a < argc; a++ ) { |
881 | if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) { | 879 | if ( qstrcmp( argv[ a ], "-preload" ) == 0 ) { |
882 | argv[ a ] = argv[ a + 1 ]; | 880 | argv[ a ] = argv[ a + 1 ]; |
883 | a++; | 881 | a++; |
884 | d->preloaded = TRUE; | 882 | d->preloaded = TRUE; |
885 | argc -= 1; | 883 | argc -= 1; |
886 | } | 884 | } |
887 | else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) { | 885 | else if ( qstrcmp( argv[ a ], "-preload-show" ) == 0 ) { |
888 | argv[ a ] = argv[ a + 1 ]; | 886 | argv[ a ] = argv[ a + 1 ]; |
889 | a++; | 887 | a++; |
890 | d->preloaded = TRUE; | 888 | d->preloaded = TRUE; |
891 | d->forceshow = TRUE; | 889 | d->forceshow = TRUE; |
892 | argc -= 1; | 890 | argc -= 1; |
893 | } | 891 | } |
894 | } | 892 | } |
895 | 893 | ||
896 | /* overide stored arguments */ | 894 | /* overide stored arguments */ |
897 | setArgs( argc, argv ); | 895 | setArgs( argc, argv ); |
898 | 896 | ||
899 | #endif | 897 | #endif |
900 | #else | 898 | #else |
901 | initApp( argc, argv ); | 899 | initApp( argc, argv ); |
902 | #endif | 900 | #endif |
903 | // qwsSetDecoration( new QPEDecoration() ); | 901 | // qwsSetDecoration( new QPEDecoration() ); |
904 | 902 | ||
905 | #ifndef QT_NO_TRANSLATION | 903 | #ifndef QT_NO_TRANSLATION |
906 | 904 | ||
907 | d->langs = Global::languageList(); | 905 | d->langs = Global::languageList(); |
908 | for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it ) { | 906 | for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it ) { |
909 | QString lang = *it; | 907 | QString lang = *it; |
910 | 908 | ||
911 | installTranslation( lang + "/libopie.qm"); | 909 | installTranslation( lang + "/libopie.qm"); |
912 | installTranslation( lang + "/libqpe.qm" ); | 910 | installTranslation( lang + "/libqpe.qm" ); |
913 | installTranslation( lang + "/" + d->appName + ".qm" ); | 911 | installTranslation( lang + "/" + d->appName + ".qm" ); |
914 | 912 | ||
915 | 913 | ||
916 | //###language/font hack; should look it up somewhere | 914 | //###language/font hack; should look it up somewhere |
917 | #ifdef QWS | 915 | #ifdef QWS |
918 | 916 | ||
919 | if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) { | 917 | if ( lang == "ja" || lang == "zh_CN" || lang == "zh_TW" || lang == "ko" ) { |
920 | QFont fn = FontManager::unicodeFont( FontManager::Proportional ); | 918 | QFont fn = FontManager::unicodeFont( FontManager::Proportional ); |
921 | setFont( fn ); | 919 | setFont( fn ); |
922 | } | 920 | } |
923 | #endif | 921 | #endif |
924 | } | 922 | } |
925 | #endif | 923 | #endif |
926 | 924 | ||
927 | applyStyle(); | 925 | applyStyle(); |
928 | 926 | ||
929 | if ( type() == GuiServer ) { | 927 | if ( type() == GuiServer ) { |
930 | setVolume(); | 928 | setVolume(); |
931 | } | 929 | } |
932 | 930 | ||
933 | installEventFilter( this ); | 931 | installEventFilter( this ); |
934 | 932 | ||
935 | QPEMenuToolFocusManager::initialize(); | 933 | QPEMenuToolFocusManager::initialize(); |
936 | 934 | ||
937 | #ifdef QT_NO_QWS_CURSOR | 935 | #ifdef QT_NO_QWS_CURSOR |
938 | // if we have no cursor, probably don't want tooltips | 936 | // if we have no cursor, probably don't want tooltips |
939 | QToolTip::setEnabled( FALSE ); | 937 | QToolTip::setEnabled( FALSE ); |
940 | #endif | 938 | #endif |
941 | } | 939 | } |
942 | 940 | ||
943 | 941 | ||
944 | #ifdef QTOPIA_INTERNAL_INITAPP | 942 | #ifdef QTOPIA_INTERNAL_INITAPP |
945 | void QPEApplication::initApp( int argc, char **argv ) | 943 | void QPEApplication::initApp( int argc, char **argv ) |
946 | { | 944 | { |
947 | delete pidChannel; | 945 | delete pidChannel; |
948 | d->keep_running = TRUE; | 946 | d->keep_running = TRUE; |
949 | d->preloaded = FALSE; | 947 | d->preloaded = FALSE; |
950 | d->forceshow = FALSE; | 948 | d->forceshow = FALSE; |
951 | 949 | ||
952 | QCString channel = QCString(argv[0]); | 950 | QCString channel = QCString(argv[0]); |
953 | 951 | ||
954 | channel.replace(QRegExp(".*/"),""); | 952 | channel.replace(QRegExp(".*/"),""); |
955 | d->appName = channel; | 953 | d->appName = channel; |
956 | 954 | ||
957 | #if QT_VERSION > 235 | 955 | #if QT_VERSION > 235 |
958 | qt_fbdpy->setIdentity( channel ); // In Qt/E 2.3.6 | 956 | qt_fbdpy->setIdentity( channel ); // In Qt/E 2.3.6 |
959 | #endif | 957 | #endif |
960 | 958 | ||
961 | channel = "QPE/Application/" + channel; | 959 | channel = "QPE/Application/" + channel; |
962 | pidChannel = new QCopChannel( channel, this); | 960 | pidChannel = new QCopChannel( channel, this); |
963 | connect( pidChannel, SIGNAL(received(const QCString&,const QByteArray&)), | 961 | connect( pidChannel, SIGNAL(received(const QCString&,const QByteArray&)), |
964 | this, SLOT(pidMessage(const QCString&,const QByteArray&))); | 962 | this, SLOT(pidMessage(const QCString&,const QByteArray&))); |
965 | 963 | ||
966 | 964 | ||
967 | 965 | ||
968 | processQCopFile(); | 966 | processQCopFile(); |
969 | d->keep_running = d->qcopq.isEmpty(); | 967 | d->keep_running = d->qcopq.isEmpty(); |
970 | 968 | ||
971 | for (int a=0; a<argc; a++) { | 969 | for (int a=0; a<argc; a++) { |
972 | if ( qstrcmp(argv[a],"-preload")==0 ) { | 970 | if ( qstrcmp(argv[a],"-preload")==0 ) { |
973 | argv[a] = argv[a+1]; | 971 | argv[a] = argv[a+1]; |
974 | a++; | 972 | a++; |
975 | d->preloaded = TRUE; | 973 | d->preloaded = TRUE; |
976 | argc-=1; | 974 | argc-=1; |
977 | } else if ( qstrcmp(argv[a],"-preload-show")==0 ) { | 975 | } else if ( qstrcmp(argv[a],"-preload-show")==0 ) { |
978 | argv[a] = argv[a+1]; | 976 | argv[a] = argv[a+1]; |
979 | a++; | 977 | a++; |
980 | d->preloaded = TRUE; | 978 | d->preloaded = TRUE; |
981 | d->forceshow = TRUE; | 979 | d->forceshow = TRUE; |
982 | argc-=1; | 980 | argc-=1; |
983 | } | 981 | } |
984 | } | 982 | } |
985 | 983 | ||
986 | /* overide stored arguments */ | 984 | /* overide stored arguments */ |
987 | setArgs(argc, argv); | 985 | setArgs(argc, argv); |
988 | 986 | ||
989 | /* install translation here */ | 987 | /* install translation here */ |
990 | for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it ) | 988 | for ( QStringList::ConstIterator it = d->langs.begin(); it != d->langs.end(); ++it ) |
991 | installTranslation( (*it) + "/" + d->appName + ".qm" ); | 989 | installTranslation( (*it) + "/" + d->appName + ".qm" ); |
992 | } | 990 | } |
993 | #endif | 991 | #endif |
994 | 992 | ||
995 | 993 | ||
996 | static QPtrDict<void>* inputMethodDict = 0; | 994 | static QPtrDict<void>* inputMethodDict = 0; |
997 | static void createInputMethodDict() | 995 | static void createInputMethodDict() |
998 | { | 996 | { |
999 | if ( !inputMethodDict ) | 997 | if ( !inputMethodDict ) |
1000 | inputMethodDict = new QPtrDict<void>; | 998 | inputMethodDict = new QPtrDict<void>; |
1001 | } | 999 | } |
1002 | 1000 | ||
1003 | /*! | 1001 | /*! |
1004 | Returns the currently set hint to the system as to whether | 1002 | Returns the currently set hint to the system as to whether |
1005 | widget \a w has any use for text input methods. | 1003 | widget \a w has any use for text input methods. |
1006 | 1004 | ||
1007 | 1005 | ||
1008 | \sa setInputMethodHint() InputMethodHint | 1006 | \sa setInputMethodHint() InputMethodHint |
1009 | */ | 1007 | */ |
1010 | QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w ) | 1008 | QPEApplication::InputMethodHint QPEApplication::inputMethodHint( QWidget * w ) |
1011 | { | 1009 | { |
1012 | if ( inputMethodDict && w ) | 1010 | if ( inputMethodDict && w ) |
1013 | return ( InputMethodHint ) ( int ) inputMethodDict->find( w ); | 1011 | return ( InputMethodHint ) ( int ) inputMethodDict->find( w ); |
1014 | return Normal; | 1012 | return Normal; |
1015 | } | 1013 | } |
1016 | 1014 | ||
1017 | /*! | 1015 | /*! |
1018 | \enum QPEApplication::InputMethodHint | 1016 | \enum QPEApplication::InputMethodHint |
1019 | 1017 | ||
1020 | \value Normal the application sometimes needs text input (the default). | 1018 | \value Normal the application sometimes needs text input (the default). |
1021 | \value AlwaysOff the application never needs text input. | 1019 | \value AlwaysOff the application never needs text input. |
1022 | \value AlwaysOn the application always needs text input. | 1020 | \value AlwaysOn the application always needs text input. |
1023 | */ | 1021 | */ |
1024 | 1022 | ||
1025 | /*! | 1023 | /*! |
1026 | Hints to the system that widget \a w has use for text input methods | 1024 | Hints to the system that widget \a w has use for text input methods |
1027 | as specified by \a mode. | 1025 | as specified by \a mode. |
1028 | 1026 | ||
1029 | \sa inputMethodHint() InputMethodHint | 1027 | \sa inputMethodHint() InputMethodHint |
1030 | */ | 1028 | */ |
1031 | void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode ) | 1029 | void QPEApplication::setInputMethodHint( QWidget * w, InputMethodHint mode ) |
1032 | { | 1030 | { |
1033 | createInputMethodDict(); | 1031 | createInputMethodDict(); |
1034 | if ( mode == Normal ) { | 1032 | if ( mode == Normal ) { |
1035 | inputMethodDict->remove | 1033 | inputMethodDict->remove |
1036 | ( w ); | 1034 | ( w ); |
1037 | } | 1035 | } |
1038 | else { | 1036 | else { |
1039 | inputMethodDict->insert( w, ( void* ) mode ); | 1037 | inputMethodDict->insert( w, ( void* ) mode ); |
1040 | } | 1038 | } |
1041 | } | 1039 | } |
1042 | 1040 | ||
1043 | class HackDialog : public QDialog | 1041 | class HackDialog : public QDialog |
1044 | { | 1042 | { |
1045 | public: | 1043 | public: |
1046 | void acceptIt() | 1044 | void acceptIt() |
1047 | { | 1045 | { |
1048 | accept(); | 1046 | accept(); |
1049 | } | 1047 | } |
1050 | void rejectIt() | 1048 | void rejectIt() |
1051 | { | 1049 | { |
1052 | reject(); | 1050 | reject(); |
1053 | } | 1051 | } |
1054 | }; | 1052 | }; |
1055 | 1053 | ||
1056 | 1054 | ||
1057 | void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key ) | 1055 | void QPEApplication::mapToDefaultAction( QWSKeyEvent * ke, int key ) |
1058 | { | 1056 | { |
1059 | // specialised actions for certain widgets. May want to | 1057 | // specialised actions for certain widgets. May want to |
1060 | // add more stuff here. | 1058 | // add more stuff here. |
1061 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QListBox" ) | 1059 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QListBox" ) |
1062 | && activePopupWidget() ->parentWidget() | 1060 | && activePopupWidget() ->parentWidget() |
1063 | && activePopupWidget() ->parentWidget() ->inherits( "QComboBox" ) ) | 1061 | && activePopupWidget() ->parentWidget() ->inherits( "QComboBox" ) ) |
1064 | key = Qt::Key_Return; | 1062 | key = Qt::Key_Return; |
1065 | 1063 | ||
1066 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QPopupMenu" ) ) | 1064 | if ( activePopupWidget() && activePopupWidget() ->inherits( "QPopupMenu" ) ) |
1067 | key = Qt::Key_Return; | 1065 | key = Qt::Key_Return; |
1068 | 1066 | ||
1069 | #ifdef QWS | 1067 | #ifdef QWS |
1070 | 1068 | ||
1071 | ke->simpleData.keycode = key; | 1069 | ke->simpleData.keycode = key; |
1072 | #endif | 1070 | #endif |
1073 | } | 1071 | } |
1074 | 1072 | ||
1075 | // class HackWidget : public QWidget | 1073 | // class HackWidget : public QWidget |
1076 | // { | 1074 | // { |
1077 | // public: | 1075 | // public: |
1078 | // bool needsOk() | 1076 | // bool needsOk() |
1079 | // { | 1077 | // { |
1080 | // return ( getWState() & WState_Reserved1 ); | 1078 | // return ( getWState() & WState_Reserved1 ); |
1081 | // } | 1079 | // } |
1082 | // }; | 1080 | // }; |
1083 | 1081 | ||
1084 | /*! | 1082 | /*! |
1085 | \internal | 1083 | \internal |
1086 | */ | 1084 | */ |
1087 | 1085 | ||
1088 | #ifdef QWS | 1086 | #ifdef QWS |
1089 | bool QPEApplication::qwsEventFilter( QWSEvent * e ) | 1087 | bool QPEApplication::qwsEventFilter( QWSEvent * e ) |
1090 | { | 1088 | { |
1091 | if ( !d->notbusysent && e->type == QWSEvent::Focus ) { | 1089 | if ( !d->notbusysent && e->type == QWSEvent::Focus ) { |
1092 | if ( qApp->type() != QApplication::GuiServer ) { | 1090 | if ( qApp->type() != QApplication::GuiServer ) { |
1093 | QCopEnvelope e( "QPE/System", "notBusy(QString)" ); | 1091 | QCopEnvelope e( "QPE/System", "notBusy(QString)" ); |
1094 | e << d->appName; | 1092 | e << d->appName; |
1095 | } | 1093 | } |
1096 | d->notbusysent = TRUE; | 1094 | d->notbusysent = TRUE; |
1097 | } | 1095 | } |
1098 | if ( type() == GuiServer ) { | 1096 | if ( type() == GuiServer ) { |
1099 | switch ( e->type ) { | 1097 | switch ( e->type ) { |
1100 | case QWSEvent::Mouse: | 1098 | case QWSEvent::Mouse: |
1101 | if ( e->asMouse() ->simpleData.state && !QWidget::find( e->window() ) ) | 1099 | if ( e->asMouse() ->simpleData.state && !QWidget::find( e->window() ) ) |
1102 | emit clientMoused(); | 1100 | emit clientMoused(); |
1103 | break; | 1101 | break; |
1104 | default: | 1102 | default: |
1105 | break; | 1103 | break; |
1106 | } | 1104 | } |
1107 | } | 1105 | } |
1108 | if ( e->type == QWSEvent::Key ) { | 1106 | if ( e->type == QWSEvent::Key ) { |
1109 | QWSKeyEvent *ke = ( QWSKeyEvent * ) e; | 1107 | QWSKeyEvent *ke = ( QWSKeyEvent * ) e; |
1110 | if ( ke->simpleData.keycode == Qt::Key_F33 ) { | 1108 | if ( ke->simpleData.keycode == Qt::Key_F33 ) { |
1111 | // Use special "OK" key to press "OK" on top level widgets | 1109 | // Use special "OK" key to press "OK" on top level widgets |
1112 | QWidget * active = activeWindow(); | 1110 | QWidget * active = activeWindow(); |
1113 | QWidget *popup = 0; | 1111 | QWidget *popup = 0; |
1114 | if ( active && active->isPopup() ) { | 1112 | if ( active && active->isPopup() ) { |
1115 | popup = active; | 1113 | popup = active; |
1116 | active = active->parentWidget(); | 1114 | active = active->parentWidget(); |
1117 | } | 1115 | } |
1118 | if ( active && ( int ) active->winId() == ke->simpleData.window && | 1116 | if ( active && ( int ) active->winId() == ke->simpleData.window && |
1119 | !active->testWFlags( WStyle_Customize | WType_Popup | WType_Desktop ) ) { | 1117 | !active->testWFlags( WStyle_Customize | WType_Popup | WType_Desktop ) ) { |
1120 | if ( ke->simpleData.is_press ) { | 1118 | if ( ke->simpleData.is_press ) { |
1121 | if ( popup ) | 1119 | if ( popup ) |
1122 | popup->close(); | 1120 | popup->close(); |
1123 | if ( active->inherits( "QDialog" ) ) { | 1121 | if ( active->inherits( "QDialog" ) ) { |
1124 | HackDialog * d = ( HackDialog * ) active; | 1122 | HackDialog * d = ( HackDialog * ) active; |
1125 | d->acceptIt(); | 1123 | d->acceptIt(); |
1126 | return TRUE; | 1124 | return TRUE; |
1127 | } | 1125 | } |
1128 | else if ( ( ( HackWidget * ) active ) ->needsOk() ) { | 1126 | else if ( ( ( HackWidget * ) active ) ->needsOk() ) { |
1129 | QSignal s; | 1127 | QSignal s; |
1130 | s.connect( active, SLOT( accept() ) ); | 1128 | s.connect( active, SLOT( accept() ) ); |
1131 | s.activate(); | 1129 | s.activate(); |
1132 | } | 1130 | } |
1133 | else { | 1131 | else { |
1134 | // do the same as with the select key: Map to the default action of the widget: | 1132 | // do the same as with the select key: Map to the default action of the widget: |
1135 | mapToDefaultAction( ke, Qt::Key_Return ); | 1133 | mapToDefaultAction( ke, Qt::Key_Return ); |
1136 | } | 1134 | } |
1137 | } | 1135 | } |
1138 | } | 1136 | } |
1139 | } | 1137 | } |
1140 | else if ( ke->simpleData.keycode == Qt::Key_F30 ) { | 1138 | else if ( ke->simpleData.keycode == Qt::Key_F30 ) { |
1141 | // Use special "select" key to do whatever default action a widget has | 1139 | // Use special "select" key to do whatever default action a widget has |
1142 | mapToDefaultAction( ke, Qt::Key_Space ); | 1140 | mapToDefaultAction( ke, Qt::Key_Space ); |
1143 | } | 1141 | } |
1144 | else if ( ke->simpleData.keycode == Qt::Key_Escape && | 1142 | else if ( ke->simpleData.keycode == Qt::Key_Escape && |
1145 | ke->simpleData.is_press ) { | 1143 | ke->simpleData.is_press ) { |
1146 | // Escape key closes app if focus on toplevel | 1144 | // Escape key closes app if focus on toplevel |
1147 | QWidget * active = activeWindow(); | 1145 | QWidget * active = activeWindow(); |
1148 | if ( active && active->testWFlags( WType_TopLevel ) && | 1146 | if ( active && active->testWFlags( WType_TopLevel ) && |
1149 | ( int ) active->winId() == ke->simpleData.window && | 1147 | ( int ) active->winId() == ke->simpleData.window && |