summaryrefslogtreecommitdiff
path: root/src/controls/ApplicationWindow.qml
diff options
context:
space:
mode:
authorJan Arve Saether <jan-arve.saether@digia.com>2013-10-15 17:39:13 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-01-14 23:53:20 +0100
commitd16f084b267140b4a901e437c3facebbdf08d89f (patch)
tree708ec90c92fa525981ce46930ca5bad44c9501df /src/controls/ApplicationWindow.qml
parent1618e1938275afd6dcf3225aa1f933eb568d13d2 (diff)
downloadqtquickcontrols-d16f084b267140b4a901e437c3facebbdf08d89f.tar.gz
Expose contentArea as contentItem in ApplicationWindow
This will intentionally shadow the QQuickWindow::contentItem This enables users of ApplicationWindow to correctly set the {min,max}imumHeight for the contents of the ApplicationWindow (excluding menubar, toolbar and statusbar). With this information at hand, the ApplicationWindow can easily deduct the correct total size of its {min,max}imumHeight *including* the menubar, toolbar and statusbar. Previously, it was for instance not possible to set an exact minimumHeight because it didn't take the toolbar, statusbar or menubar into consideration One small disadvantage is that the contentItem.minimumWidth cannot be autocompleted. qmlplugindump does not inspect the members of ContentItem. Task-number: QTBUG-32443 Change-Id: I9903e7d4b5e6db7bd7c3c46351a2bb5578f67a57 Reviewed-by: J-P Nurmi <jpnurmi@digia.com>
Diffstat (limited to 'src/controls/ApplicationWindow.qml')
-rw-r--r--src/controls/ApplicationWindow.qml44
1 files changed, 43 insertions, 1 deletions
diff --git a/src/controls/ApplicationWindow.qml b/src/controls/ApplicationWindow.qml
index 6e0160df..f54fa8f5 100644
--- a/src/controls/ApplicationWindow.qml
+++ b/src/controls/ApplicationWindow.qml
@@ -115,6 +115,48 @@ Window {
*/
property Item statusBar
+ // The below documentation was supposed to be written as a grouped property, but qdoc would
+ // not render it correctly due to a bug (https://bugreports.qt-project.org/browse/QTBUG-34206)
+ /*!
+ \qmlproperty ApplicationWindow::contentItem
+
+ This group holds the size constraints of the content item. This is the area between the
+ \l ToolBar and the \l StatusBar.
+ The \l ApplicationWindow will use this as input when calculating the effective size
+ constraints of the actual window.
+ It holds these 6 properties for describing the minimum, implicit and maximum sizes:
+ \table
+ \header \li Grouped property \li Description
+ \row \li contentItem.minimumWidth \li The minimum width of the content item.
+ \row \li contentItem.minimumHeight \li The minimum height of the content item.
+ \row \li contentItem.implicitWidth \li The implicit width of the content item.
+ \row \li contentItem.implicitHeight \li The implicit height of the content item.
+ \row \li contentItem.maximumWidth \li The maximum width of the content item.
+ \row \li contentItem.maximumHeight \li The maximum height of the content item.
+ \endtable
+ */
+ property alias contentItem : contentArea
+
+ /*! \internal */
+ property real __topBottomMargins: contentArea.y + statusBarArea.height
+ /*! \internal
+ There is a similar macro QWINDOWSIZE_MAX in qwindow_p.h that is used to limit the
+ range of QWindow::maximum{Width,Height}
+ However, in case we have a very big number (> 2^31) conversion will fail, and it will be
+ converted to 0, resulting in that we will call setMaximumWidth(0)....
+ We therefore need to enforce the limit at a level where we are still operating on
+ floating point values.
+ */
+ readonly property real __qwindowsize_max: (1 << 24) - 1
+
+ width: contentArea.__noImplicitWidthGiven ? 0 : Math.min(Math.max(minimumWidth, contentArea.implicitWidth), maximumWidth)
+ height: contentArea.__noImplicitHeightGiven ? 0 : Math.min(Math.max(minimumHeight, contentArea.implicitHeight + __topBottomMargins), maximumHeight)
+
+ minimumWidth: contentArea.__noMinimumWidthGiven ? 0 : contentArea.minimumWidth
+ minimumHeight: contentArea.__noMinimumHeightGiven ? 0 : (contentArea.minimumHeight + __topBottomMargins)
+
+ maximumWidth: Math.min(__qwindowsize_max, contentArea.maximumWidth)
+ maximumHeight: Math.min(__qwindowsize_max, contentArea.maximumHeight + __topBottomMargins)
onToolBarChanged: { if (toolBar) { toolBar.parent = toolBarArea } }
onStatusBarChanged: { if (statusBar) { statusBar.parent = statusBarArea } }
@@ -140,7 +182,7 @@ Window {
Keys.forwardTo: menuBar ? [menuBar.__contentItem] : []
- Item {
+ ContentItem {
id: contentArea
anchors.top: toolBarArea.bottom
anchors.left: parent.left