-rw-r--r-- | library/qpeapplication.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp index 86dbe85..d0e9613 100644 --- a/library/qpeapplication.cpp +++ b/library/qpeapplication.cpp | |||
@@ -82,192 +82,202 @@ | |||
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 | // ugly hack, remove that later after finding a sane solution | ||
179 | // Addendum: Only Sharp currently has models with high resolution but (physically) small displays, | ||
180 | // so this is only useful if QT_QWS_SIMPAD is NOT defined. E.g. SIMpad has 800x600 but has | ||
181 | // a (physically) large enough display to use the small icons | ||
182 | #if defined(OPIE_HIGH_RES_SMALL_PHY) | ||
183 | if ( QPEApplication::desktop() ->width() >= 600 && ( mw->inherits("QMainWindow") || mw->isA("QMainWindow") ) ) { | ||
184 | ( ( QMainWindow* ) mw )->setUsesBigPixmaps( true ); | ||
185 | } | ||
186 | #endif | ||
187 | |||
178 | QPoint p; | 188 | QPoint p; |
179 | QSize s; | 189 | QSize s; |
180 | bool max; | 190 | bool max; |
181 | if ( mw->isVisible() ) { | 191 | if ( mw->isVisible() ) { |
182 | if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { | 192 | if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { |
183 | mw->resize(s); | 193 | mw->resize(s); |
184 | mw->move(p); | 194 | mw->move(p); |
185 | } | 195 | } |
186 | mw->raise(); | 196 | mw->raise(); |
187 | } else { | 197 | } else { |
188 | 198 | ||
189 | if ( mw->layout() && mw->inherits("QDialog") ) { | 199 | if ( mw->layout() && mw->inherits("QDialog") ) { |
190 | if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { | 200 | if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { |
191 | mw->resize(s); | 201 | mw->resize(s); |
192 | mw->move(p); | 202 | mw->move(p); |
193 | 203 | ||
194 | if ( max && !nomaximize ) { | 204 | if ( max && !nomaximize ) { |
195 | mw->showMaximized(); | 205 | mw->showMaximized(); |
196 | } else { | 206 | } else { |
197 | mw->show(); | 207 | mw->show(); |
198 | } | 208 | } |
199 | } else { | 209 | } else { |
200 | qpe_show_dialog((QDialog*)mw,nomaximize); | 210 | qpe_show_dialog((QDialog*)mw,nomaximize); |
201 | } | 211 | } |
202 | } else { | 212 | } else { |
203 | if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { | 213 | if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { |
204 | mw->resize(s); | 214 | mw->resize(s); |
205 | mw->move(p); | 215 | mw->move(p); |
206 | } else { //no stored rectangle, make an estimation | 216 | } else { //no stored rectangle, make an estimation |
207 | int x = (qApp->desktop()->width()-mw->frameGeometry().width())/2; | 217 | int x = (qApp->desktop()->width()-mw->frameGeometry().width())/2; |
208 | int y = (qApp->desktop()->height()-mw->frameGeometry().height())/2; | 218 | int y = (qApp->desktop()->height()-mw->frameGeometry().height())/2; |
209 | mw->move( QMAX(x,0), QMAX(y,0) ); | 219 | mw->move( QMAX(x,0), QMAX(y,0) ); |
210 | #ifdef Q_WS_QWS | 220 | #ifdef Q_WS_QWS |
211 | if ( !nomaximize ) | 221 | if ( !nomaximize ) |
212 | mw->showMaximized(); | 222 | mw->showMaximized(); |
213 | #endif | 223 | #endif |
214 | } | 224 | } |
215 | if ( max && !nomaximize ) | 225 | if ( max && !nomaximize ) |
216 | mw->showMaximized(); | 226 | mw->showMaximized(); |
217 | else | 227 | else |
218 | mw->show(); | 228 | mw->show(); |
219 | } | 229 | } |
220 | } | 230 | } |
221 | } | 231 | } |
222 | 232 | ||
223 | static void qpe_show_dialog( QDialog* d, bool nomax ) | 233 | static void qpe_show_dialog( QDialog* d, bool nomax ) |
224 | { | 234 | { |
225 | QSize sh = d->sizeHint(); | 235 | QSize sh = d->sizeHint(); |
226 | int w = QMAX(sh.width(),d->width()); | 236 | int w = QMAX(sh.width(),d->width()); |
227 | int h = QMAX(sh.height(),d->height()); | 237 | int h = QMAX(sh.height(),d->height()); |
228 | 238 | ||
229 | if ( d->parentWidget() && !d->parentWidget()->topLevelWidget()->isMaximized() ) | 239 | if ( d->parentWidget() && !d->parentWidget()->topLevelWidget()->isMaximized() ) |
230 | nomax = TRUE; | 240 | nomax = TRUE; |
231 | 241 | ||
232 | #ifndef Q_WS_QWS | 242 | #ifndef Q_WS_QWS |
233 | QSize s(qApp->desktop()->width(), qApp->desktop()->height() ); | 243 | QSize s(qApp->desktop()->width(), qApp->desktop()->height() ); |
234 | #else | 244 | #else |
235 | QSize s(qt_maxWindowRect.width(), qt_maxWindowRect.height() ); | 245 | QSize s(qt_maxWindowRect.width(), qt_maxWindowRect.height() ); |
236 | #endif | 246 | #endif |
237 | 247 | ||
238 | int maxX = s.width() - (d->frameGeometry().width() - d->geometry().width()); | 248 | int maxX = s.width() - (d->frameGeometry().width() - d->geometry().width()); |
239 | int maxY = s.height() - (d->frameGeometry().height() - d->geometry().height()); | 249 | int maxY = s.height() - (d->frameGeometry().height() - d->geometry().height()); |
240 | 250 | ||
241 | if ( (w >= maxX && h >= maxY) || ( (!nomax) && ( w > s.width()*3/4 || h > s.height()*3/4 ) ) ) { | 251 | if ( (w >= maxX && h >= maxY) || ( (!nomax) && ( w > s.width()*3/4 || h > s.height()*3/4 ) ) ) { |
242 | d->showMaximized(); | 252 | d->showMaximized(); |
243 | } else { | 253 | } else { |
244 | // try centering the dialog around its parent | 254 | // try centering the dialog around its parent |
245 | QPoint p(0,0); | 255 | QPoint p(0,0); |
246 | if ( d->parentWidget() ) { | 256 | if ( d->parentWidget() ) { |
247 | QPoint pp = d->parentWidget()->mapToGlobal( QPoint(0,0) ); | 257 | QPoint pp = d->parentWidget()->mapToGlobal( QPoint(0,0) ); |
248 | p = QPoint( pp.x() + d->parentWidget()->width()/2, | 258 | p = QPoint( pp.x() + d->parentWidget()->width()/2, |
249 | pp.y() + d->parentWidget()->height()/ 2 ); | 259 | pp.y() + d->parentWidget()->height()/ 2 ); |
250 | } else { | 260 | } else { |
251 | p = QPoint( maxX/2, maxY/2 ); | 261 | p = QPoint( maxX/2, maxY/2 ); |
252 | } | 262 | } |
253 | 263 | ||
254 | p = QPoint( p.x() - w/2, p.y() - h/2 ); | 264 | p = QPoint( p.x() - w/2, p.y() - h/2 ); |
255 | //qDebug("p(x,y) is %d %d", p.x(), p.y() ); | 265 | //qDebug("p(x,y) is %d %d", p.x(), p.y() ); |
256 | 266 | ||
257 | if ( w >= maxX ) { | 267 | if ( w >= maxX ) { |
258 | if ( p.y() < 0 ) | 268 | if ( p.y() < 0 ) |
259 | p.setY(0); | 269 | p.setY(0); |
260 | if ( p.y() + h > maxY ) | 270 | if ( p.y() + h > maxY ) |
261 | p.setY( maxY - h); | 271 | p.setY( maxY - h); |
262 | 272 | ||
263 | d->resize(maxX, h); | 273 | d->resize(maxX, h); |
264 | d->move(0, p.y() ); | 274 | d->move(0, p.y() ); |
265 | } else if ( h >= maxY ) { | 275 | } else if ( h >= maxY ) { |
266 | if ( p.x() < 0 ) | 276 | if ( p.x() < 0 ) |
267 | p.setX(0); | 277 | p.setX(0); |
268 | if ( p.x() + w > maxX ) | 278 | if ( p.x() + w > maxX ) |
269 | p.setX( maxX - w); | 279 | p.setX( maxX - w); |
270 | 280 | ||
271 | d->resize(w, maxY); | 281 | d->resize(w, maxY); |
272 | d->move(p.x(),0); | 282 | d->move(p.x(),0); |
273 | } else { | 283 | } else { |