-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 | |||
@@ -223,13 +223,13 @@ public: | |||
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 |
@@ -246,70 +246,12 @@ public: | |||
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; |