author | zecke <zecke> | 2004-09-19 18:48:56 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-09-19 18:48:56 (UTC) |
commit | 4564befecf3df38911d48f216ab216faf93b9c1d (patch) (unidiff) | |
tree | 9d4ec4264de74230e9fba4f9963535be604db90a /library | |
parent | 84166797fd3caa436d38e312957d5542046f10b0 (diff) | |
download | opie-4564befecf3df38911d48f216ab216faf93b9c1d.zip opie-4564befecf3df38911d48f216ab216faf93b9c1d.tar.gz opie-4564befecf3df38911d48f216ab216faf93b9c1d.tar.bz2 |
Have only one showDialog function.
If the dialog sizeHint is smaller than the width of the desktop
qpe_show_dialog didn't 'maximize' the widget and just showed it.
QPEApplication::showDialog does better in that respect but does not
have custom 'centering' of the dialog. But that doesn't matter
as we save/restore size and position for BigScreen.
-rw-r--r-- | library/qpeapplication.cpp | 60 |
1 files changed, 1 insertions, 59 deletions
diff --git a/library/qpeapplication.cpp b/library/qpeapplication.cpp index e1edd4c..df313ce 100644 --- a/library/qpeapplication.cpp +++ b/library/qpeapplication.cpp | |||
@@ -205,129 +205,71 @@ public: | |||
205 | ( ( QMainWindow* ) mw )->setUsesBigPixmaps( useBigPixmaps ); | 205 | ( ( QMainWindow* ) mw )->setUsesBigPixmaps( useBigPixmaps ); |
206 | } | 206 | } |
207 | QPoint p; | 207 | QPoint p; |
208 | QSize s; | 208 | QSize s; |
209 | bool max; | 209 | bool max; |
210 | if ( mw->isVisible() ) { | 210 | if ( mw->isVisible() ) { |
211 | if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { | 211 | if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { |
212 | mw->resize(s); | 212 | mw->resize(s); |
213 | mw->move(p); | 213 | mw->move(p); |
214 | } | 214 | } |
215 | mw->raise(); | 215 | mw->raise(); |
216 | } else { | 216 | } else { |
217 | 217 | ||
218 | if ( mw->layout() && mw->inherits("QDialog") ) { | 218 | if ( mw->layout() && mw->inherits("QDialog") ) { |
219 | if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { | 219 | if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { |
220 | mw->resize(s); | 220 | mw->resize(s); |
221 | mw->move(p); | 221 | mw->move(p); |
222 | 222 | ||
223 | if ( max && !nomaximize ) { | 223 | if ( max && !nomaximize ) { |
224 | mw->showMaximized(); | 224 | mw->showMaximized(); |
225 | } else { | 225 | } else { |
226 | mw->show(); | 226 | mw->show(); |
227 | } | 227 | } |
228 | } else { | 228 | } else { |
229 | qpe_show_dialog((QDialog*)mw,nomaximize); | 229 | QPEApplication::showDialog((QDialog*)mw,nomaximize); |
230 | } | 230 | } |
231 | } else { | 231 | } else { |
232 | if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { | 232 | if ( read_widget_rect(strName, max, p, s) && validate_widget_size(mw, p, s) ) { |
233 | mw->resize(s); | 233 | mw->resize(s); |
234 | mw->move(p); | 234 | mw->move(p); |
235 | } else { //no stored rectangle, make an estimation | 235 | } else { //no stored rectangle, make an estimation |
236 | int x = (qApp->desktop()->width()-mw->frameGeometry().width())/2; | 236 | int x = (qApp->desktop()->width()-mw->frameGeometry().width())/2; |
237 | int y = (qApp->desktop()->height()-mw->frameGeometry().height())/2; | 237 | int y = (qApp->desktop()->height()-mw->frameGeometry().height())/2; |
238 | mw->move( QMAX(x,0), QMAX(y,0) ); | 238 | mw->move( QMAX(x,0), QMAX(y,0) ); |
239 | #ifdef Q_WS_QWS | 239 | #ifdef Q_WS_QWS |
240 | if ( !nomaximize ) | 240 | if ( !nomaximize ) |
241 | mw->showMaximized(); | 241 | mw->showMaximized(); |
242 | #endif | 242 | #endif |
243 | } | 243 | } |
244 | if ( max && !nomaximize ) | 244 | if ( max && !nomaximize ) |
245 | mw->showMaximized(); | 245 | mw->showMaximized(); |
246 | else | 246 | else |
247 | mw->show(); | 247 | mw->show(); |
248 | } | 248 | } |
249 | } | 249 | } |
250 | } | 250 | } |
251 | 251 | ||
252 | static void qpe_show_dialog( QDialog* d, bool nomax ) | ||
253 | { | ||
254 | QSize sh = d->sizeHint(); | ||
255 | int w = QMAX(sh.width(),d->width()); | ||
256 | int h = QMAX(sh.height(),d->height()); | ||
257 | |||
258 | if ( d->parentWidget() && !d->parentWidget()->topLevelWidget()->isMaximized() ) | ||
259 | nomax = TRUE; | ||
260 | |||
261 | #ifndef Q_WS_QWS | ||
262 | QSize s(qApp->desktop()->width(), qApp->desktop()->height() ); | ||
263 | #else | ||
264 | QSize s(qt_maxWindowRect.width(), qt_maxWindowRect.height() ); | ||
265 | #endif | ||
266 | |||
267 | int maxX = s.width() - (d->frameGeometry().width() - d->geometry().width()); | ||
268 | int maxY = s.height() - (d->frameGeometry().height() - d->geometry().height()); | ||
269 | |||
270 | if ( (w >= maxX && h >= maxY) || ( (!nomax) && ( w > s.width()*3/4 || h > s.height()*3/4 ) ) ) { | ||
271 | d->showMaximized(); | ||
272 | } else { | ||
273 | // try centering the dialog around its parent | ||
274 | QPoint p(0,0); | ||
275 | if ( d->parentWidget() ) { | ||
276 | QPoint pp = d->parentWidget()->mapToGlobal( QPoint(0,0) ); | ||
277 | p = QPoint( pp.x() + d->parentWidget()->width()/2, | ||
278 | pp.y() + d->parentWidget()->height()/ 2 ); | ||
279 | } else { | ||
280 | p = QPoint( maxX/2, maxY/2 ); | ||
281 | } | ||
282 | |||
283 | p = QPoint( p.x() - w/2, p.y() - h/2 ); | ||
284 | // qDebug("p(x,y) is %d %d", p.x(), p.y() ); | ||
285 | |||
286 | if ( w >= maxX ) { | ||
287 | if ( p.y() < 0 ) | ||
288 | p.setY(0); | ||
289 | if ( p.y() + h > maxY ) | ||
290 | p.setY( maxY - h); | ||
291 | |||
292 | d->resize(maxX, h); | ||
293 | d->move(0, p.y() ); | ||
294 | } else if ( h >= maxY ) { | ||
295 | if ( p.x() < 0 ) | ||
296 | p.setX(0); | ||
297 | if ( p.x() + w > maxX ) | ||
298 | p.setX( maxX - w); | ||
299 | |||
300 | d->resize(w, maxY); | ||
301 | d->move(p.x(),0); | ||
302 | } else { | ||
303 | d->resize(w, h); | ||
304 | } | ||
305 | |||
306 | d->show(); | ||
307 | } | ||
308 | } | ||
309 | |||
310 | static bool read_widget_rect(const QString &app, bool &maximized, QPoint &p, QSize &s) | 252 | static bool read_widget_rect(const QString &app, bool &maximized, QPoint &p, QSize &s) |
311 | { | 253 | { |
312 | maximized = TRUE; | 254 | maximized = TRUE; |
313 | // 350 is the trigger in qwsdefaultdecoration for providing a resize button | 255 | // 350 is the trigger in qwsdefaultdecoration for providing a resize button |
314 | if ( qApp->desktop()->width() <= 350 ) | 256 | if ( qApp->desktop()->width() <= 350 ) |
315 | return FALSE; | 257 | return FALSE; |
316 | 258 | ||
317 | Config cfg( "qpe" ); | 259 | Config cfg( "qpe" ); |
318 | cfg.setGroup("ApplicationPositions"); | 260 | cfg.setGroup("ApplicationPositions"); |
319 | QString str = cfg.readEntry( app, QString::null ); | 261 | QString str = cfg.readEntry( app, QString::null ); |
320 | QStringList l = QStringList::split(",", str); | 262 | QStringList l = QStringList::split(",", str); |
321 | 263 | ||
322 | if ( l.count() == 5) { | 264 | if ( l.count() == 5) { |
323 | p.setX( l[0].toInt() ); | 265 | p.setX( l[0].toInt() ); |
324 | p.setY( l[1].toInt() ); | 266 | p.setY( l[1].toInt() ); |
325 | 267 | ||
326 | s.setWidth( l[2].toInt() ); | 268 | s.setWidth( l[2].toInt() ); |
327 | s.setHeight( l[3].toInt() ); | 269 | s.setHeight( l[3].toInt() ); |
328 | 270 | ||
329 | maximized = l[4].toInt(); | 271 | maximized = l[4].toInt(); |
330 | 272 | ||
331 | return TRUE; | 273 | return TRUE; |
332 | } | 274 | } |
333 | 275 | ||