author | llornkcor <llornkcor> | 2004-04-25 08:54:30 (UTC) |
---|---|---|
committer | llornkcor <llornkcor> | 2004-04-25 08:54:30 (UTC) |
commit | 5d3c80f70109bee75d55db2a11d7112eb7ebaa99 (patch) (unidiff) | |
tree | 4215d0bce8d8b270cead8afa829e59da173ae63f | |
parent | ea4380df897798cf4bbadaf786868a18b3dee975 (diff) | |
download | opie-5d3c80f70109bee75d55db2a11d7112eb7ebaa99.zip opie-5d3c80f70109bee75d55db2a11d7112eb7ebaa99.tar.gz opie-5d3c80f70109bee75d55db2a11d7112eb7ebaa99.tar.bz2 |
remove commented out ugly hack
-rw-r--r-- | library/qpeapplication.cpp | 25 |
1 files changed, 0 insertions, 25 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp index 5ce3011..10c6c40 100644 --- a/library/qpeapplication.cpp +++ b/library/qpeapplication.cpp | |||
@@ -126,217 +126,192 @@ public: | |||
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 | ||
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 | ||
225 | // // a (physically) large enough display to use the small icons | ||
226 | // #if defined(OPIE_HIGH_RES_SMALL_PHY) | ||
227 | // if ( QPEApplication::desktop() ->width() >= 600 && ( mw->inherits("QMainWindow") || mw->isA("QMainWindow") ) ) { | ||
228 | // ( ( QMainWindow* ) mw )->setUsesBigPixmaps( true ); | ||
229 | // } | ||
230 | // #endif | ||
231 | |||
232 | // if ( mw->layout() && mw->inherits("QDialog") ) { | ||
233 | // QPEApplication::showDialog((QDialog*)mw, nomaximize); | ||
234 | // } | ||
235 | // else { | ||
236 | // #ifdef Q_WS_QWS | ||
237 | // if ( !nomaximize ) { | ||
238 | // qDebug("QDialog special case XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); | ||
239 | // mw->showMaximized(); | ||
240 | // //QPEApplication::showWidget( mw, !nomaximize ); | ||
241 | // }else | ||
242 | // #endif | ||
243 | // mw->show(); | ||
244 | // } | ||
245 | //} | ||
246 | |||
247 | 222 | ||
248 | static void qpe_show_dialog( QDialog* d, bool nomax ) | 223 | static void qpe_show_dialog( QDialog* d, bool nomax ) |
249 | { | 224 | { |
250 | QSize sh = d->sizeHint(); | 225 | QSize sh = d->sizeHint(); |
251 | int w = QMAX(sh.width(),d->width()); | 226 | int w = QMAX(sh.width(),d->width()); |
252 | int h = QMAX(sh.height(),d->height()); | 227 | int h = QMAX(sh.height(),d->height()); |
253 | 228 | ||
254 | if ( d->parentWidget() && !d->parentWidget()->topLevelWidget()->isMaximized() ) | 229 | if ( d->parentWidget() && !d->parentWidget()->topLevelWidget()->isMaximized() ) |
255 | nomax = TRUE; | 230 | nomax = TRUE; |
256 | 231 | ||
257 | #ifndef Q_WS_QWS | 232 | #ifndef Q_WS_QWS |
258 | QSize s(qApp->desktop()->width(), qApp->desktop()->height() ); | 233 | QSize s(qApp->desktop()->width(), qApp->desktop()->height() ); |
259 | #else | 234 | #else |
260 | QSize s(qt_maxWindowRect.width(), qt_maxWindowRect.height() ); | 235 | QSize s(qt_maxWindowRect.width(), qt_maxWindowRect.height() ); |
261 | #endif | 236 | #endif |
262 | 237 | ||
263 | int maxX = s.width() - (d->frameGeometry().width() - d->geometry().width()); | 238 | int maxX = s.width() - (d->frameGeometry().width() - d->geometry().width()); |
264 | int maxY = s.height() - (d->frameGeometry().height() - d->geometry().height()); | 239 | int maxY = s.height() - (d->frameGeometry().height() - d->geometry().height()); |
265 | 240 | ||
266 | if ( (w >= maxX && h >= maxY) || ( (!nomax) && ( w > s.width()*3/4 || h > s.height()*3/4 ) ) ) { | 241 | if ( (w >= maxX && h >= maxY) || ( (!nomax) && ( w > s.width()*3/4 || h > s.height()*3/4 ) ) ) { |
267 | d->showMaximized(); | 242 | d->showMaximized(); |
268 | } else { | 243 | } else { |
269 | // try centering the dialog around its parent | 244 | // try centering the dialog around its parent |
270 | QPoint p(0,0); | 245 | QPoint p(0,0); |
271 | if ( d->parentWidget() ) { | 246 | if ( d->parentWidget() ) { |
272 | QPoint pp = d->parentWidget()->mapToGlobal( QPoint(0,0) ); | 247 | QPoint pp = d->parentWidget()->mapToGlobal( QPoint(0,0) ); |
273 | p = QPoint( pp.x() + d->parentWidget()->width()/2, | 248 | p = QPoint( pp.x() + d->parentWidget()->width()/2, |
274 | pp.y() + d->parentWidget()->height()/ 2 ); | 249 | pp.y() + d->parentWidget()->height()/ 2 ); |
275 | } else { | 250 | } else { |
276 | p = QPoint( maxX/2, maxY/2 ); | 251 | p = QPoint( maxX/2, maxY/2 ); |
277 | } | 252 | } |
278 | 253 | ||
279 | p = QPoint( p.x() - w/2, p.y() - h/2 ); | 254 | p = QPoint( p.x() - w/2, p.y() - h/2 ); |
280 | //qDebug("p(x,y) is %d %d", p.x(), p.y() ); | 255 | //qDebug("p(x,y) is %d %d", p.x(), p.y() ); |
281 | 256 | ||
282 | if ( w >= maxX ) { | 257 | if ( w >= maxX ) { |
283 | if ( p.y() < 0 ) | 258 | if ( p.y() < 0 ) |
284 | p.setY(0); | 259 | p.setY(0); |
285 | if ( p.y() + h > maxY ) | 260 | if ( p.y() + h > maxY ) |
286 | p.setY( maxY - h); | 261 | p.setY( maxY - h); |
287 | 262 | ||
288 | d->resize(maxX, h); | 263 | d->resize(maxX, h); |
289 | d->move(0, p.y() ); | 264 | d->move(0, p.y() ); |
290 | } else if ( h >= maxY ) { | 265 | } else if ( h >= maxY ) { |
291 | if ( p.x() < 0 ) | 266 | if ( p.x() < 0 ) |
292 | p.setX(0); | 267 | p.setX(0); |
293 | if ( p.x() + w > maxX ) | 268 | if ( p.x() + w > maxX ) |
294 | p.setX( maxX - w); | 269 | p.setX( maxX - w); |
295 | 270 | ||
296 | d->resize(w, maxY); | 271 | d->resize(w, maxY); |
297 | d->move(p.x(),0); | 272 | d->move(p.x(),0); |
298 | } else { | 273 | } else { |
299 | d->resize(w, h); | 274 | d->resize(w, h); |
300 | } | 275 | } |
301 | 276 | ||
302 | d->show(); | 277 | d->show(); |
303 | } | 278 | } |
304 | } | 279 | } |
305 | 280 | ||
306 | static bool read_widget_rect(const QString &app, bool &maximized, QPoint &p, QSize &s) | 281 | static bool read_widget_rect(const QString &app, bool &maximized, QPoint &p, QSize &s) |
307 | { | 282 | { |
308 | maximized = TRUE; | 283 | maximized = TRUE; |
309 | // 350 is the trigger in qwsdefaultdecoration for providing a resize button | 284 | // 350 is the trigger in qwsdefaultdecoration for providing a resize button |
310 | if ( qApp->desktop()->width() <= 350 ) | 285 | if ( qApp->desktop()->width() <= 350 ) |
311 | return FALSE; | 286 | return FALSE; |
312 | 287 | ||
313 | Config cfg( "qpe" ); | 288 | Config cfg( "qpe" ); |
314 | cfg.setGroup("ApplicationPositions"); | 289 | cfg.setGroup("ApplicationPositions"); |
315 | QString str = cfg.readEntry( app, QString::null ); | 290 | QString str = cfg.readEntry( app, QString::null ); |
316 | QStringList l = QStringList::split(",", str); | 291 | QStringList l = QStringList::split(",", str); |
317 | 292 | ||
318 | if ( l.count() == 5) { | 293 | if ( l.count() == 5) { |
319 | p.setX( l[0].toInt() ); | 294 | p.setX( l[0].toInt() ); |
320 | p.setY( l[1].toInt() ); | 295 | p.setY( l[1].toInt() ); |
321 | 296 | ||
322 | s.setWidth( l[2].toInt() ); | 297 | s.setWidth( l[2].toInt() ); |
323 | s.setHeight( l[3].toInt() ); | 298 | s.setHeight( l[3].toInt() ); |
324 | 299 | ||
325 | maximized = l[4].toInt(); | 300 | maximized = l[4].toInt(); |
326 | 301 | ||
327 | return TRUE; | 302 | return TRUE; |
328 | } | 303 | } |
329 | 304 | ||
330 | return FALSE; | 305 | return FALSE; |
331 | } | 306 | } |
332 | 307 | ||
333 | 308 | ||
334 | static bool validate_widget_size(const QWidget *w, QPoint &p, QSize &s) | 309 | static bool validate_widget_size(const QWidget *w, QPoint &p, QSize &s) |
335 | { | 310 | { |
336 | #ifndef Q_WS_QWS | 311 | #ifndef Q_WS_QWS |
337 | QRect qt_maxWindowRect = qApp->desktop()->geometry(); | 312 | QRect qt_maxWindowRect = qApp->desktop()->geometry(); |
338 | #endif | 313 | #endif |
339 | int maxX = qt_maxWindowRect.width(); | 314 | int maxX = qt_maxWindowRect.width(); |
340 | int maxY = qt_maxWindowRect.height(); | 315 | int maxY = qt_maxWindowRect.height(); |
341 | int wWidth = s.width() + ( w->frameGeometry().width() - w->geometry().width() ); | 316 | int wWidth = s.width() + ( w->frameGeometry().width() - w->geometry().width() ); |
342 | int wHeight = s.height() + ( w->frameGeometry().height() - w->geometry().height() ); | 317 | int wHeight = s.height() + ( w->frameGeometry().height() - w->geometry().height() ); |