summaryrefslogtreecommitdiff
path: root/src/dialogs/qquickabstractdialog.cpp
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@digia.com>2014-10-08 17:39:02 +0200
committerShawn Rutledge <shawn.rutledge@digia.com>2014-10-13 12:21:06 +0200
commit35589b1f5a4e86856c7024bbfb067e0835c703f6 (patch)
tree8975b9c221897dec7d5bc15a6551d399009c002d /src/dialogs/qquickabstractdialog.cpp
parentaecdaf53ceb2f3fbb5b37b1977fbd74bc21bbb4f (diff)
downloadqtquickcontrols-35589b1f5a4e86856c7024bbfb067e0835c703f6.tar.gz
Dialogs: added private maximumDimension property for initial size
The Screen.attached property does not know which screen will be used until the dialog is shown, but we need to know how big the desktop is before it is shown in order to constrain a reasonable dialog size, before the Flow lays out the buttons. Otherwise it will be too tall. Task-number: QTBUG-41734 Change-Id: I44349fab4ad0254d2c6faf30c759fb9e52eebf03 Reviewed-by: J-P Nurmi <jpnurmi@theqtcompany.com>
Diffstat (limited to 'src/dialogs/qquickabstractdialog.cpp')
-rw-r--r--src/dialogs/qquickabstractdialog.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/dialogs/qquickabstractdialog.cpp b/src/dialogs/qquickabstractdialog.cpp
index 1883b348..b8f4e18c 100644
--- a/src/dialogs/qquickabstractdialog.cpp
+++ b/src/dialogs/qquickabstractdialog.cpp
@@ -295,6 +295,25 @@ int QQuickAbstractDialog::height() const
return m_sizeAspiration.height();
}
+/*
+ A non-fullscreen dialog is not allowed to be too large
+ to fit on the screen in either orientation (portrait or landscape).
+ That way on platforms which can do rotation, the dialog does not
+ change its size when the screen is rotated. So the value returned
+ here is the maximum for both width and height. We need to know
+ at init time, not wait until the dialog's content item is shown in
+ a window so that the desktopAvailableWidth and Height will be valid
+ in the Screen attached property. And to allow space for window borders,
+ the max is further reduced by 10%.
+*/
+int QQuickAbstractDialog::__maximumDimension() const
+{
+ QScreen *screen = QGuiApplication::primaryScreen();
+ return (screen ?
+ qMin(screen->availableVirtualGeometry().width(), screen->availableVirtualGeometry().height()) :
+ 480) * 9 / 10;
+}
+
void QQuickAbstractDialog::setX(int arg)
{
m_hasAspiredPosition = true;