summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>2015-03-20 16:57:09 +0100
committerTor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>2015-03-27 14:18:55 +0000
commit10a57f37d0f03e8642a7c92dcacf287c95777342 (patch)
tree123950f0d8c555bd44886fe73b74b0eb8d90e785 /src
parent1c0deaf9805903f4f33ff09056b3153fd92b5618 (diff)
downloadqtquickcontrols-10a57f37d0f03e8642a7c92dcacf287c95777342.tar.gz
iOS: Make ApplicationWindow fill entire screen, including under statusbar
We take advantage of the new Qt::WindowFlag that asks the OS to maximize the window using as much as possible of the available screen geometry, and then make sure that the contentItem is shifted accordingly so that it doesn't end up under the statusbar. This allow setting a custom background image/color on the application window, or adding toolbars or menu bars that underlay the iOS system status bar. Change-Id: I6efab2aced7efd274a65f2524ae8c270d20de187 Reviewed-by: J-P Nurmi <jpnurmi@theqtcompany.com> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com> Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@theqtcompany.com>
Diffstat (limited to 'src')
-rw-r--r--src/controls/ApplicationWindow.qml24
-rw-r--r--src/controls/MenuBar.qml13
-rw-r--r--src/controls/Private/ContentItem.qml33
-rw-r--r--src/controls/ToolBar.qml10
4 files changed, 66 insertions, 14 deletions
diff --git a/src/controls/ApplicationWindow.qml b/src/controls/ApplicationWindow.qml
index 542cfe4e..2f019d31 100644
--- a/src/controls/ApplicationWindow.qml
+++ b/src/controls/ApplicationWindow.qml
@@ -198,11 +198,19 @@ Window {
/*! \internal */
default property alias data: contentArea.data
- flags: Qt.Window | Qt.WindowFullscreenButtonHint |
- Qt.WindowTitleHint | Qt.WindowSystemMenuHint | Qt.WindowMinMaxButtonsHint |
- Qt.WindowCloseButtonHint | Qt.WindowFullscreenButtonHint
- // QTBUG-35049: Windows is removing features we didn't ask for, even though Qt::CustomizeWindowHint is not set
- // Otherwise Qt.Window | Qt.WindowFullscreenButtonHint would be enough
+ flags: {
+ var flags = Qt.Window | Qt.WindowFullscreenButtonHint;
+
+ // QTBUG-35049: Windows is removing features we didn't ask for, even though Qt::CustomizeWindowHint is not set
+ // Otherwise Qt.Window | Qt.WindowFullscreenButtonHint would be enough
+ flags |= Qt.WindowTitleHint | Qt.WindowSystemMenuHint | Qt.WindowMinMaxButtonsHint |
+ Qt.WindowCloseButtonHint | Qt.WindowFullscreenButtonHint
+
+ if (Settings.styleName === "iOS")
+ flags |= Qt.MaximizeUsingFullscreenGeometryHint;
+
+ return flags;
+ }
Loader {
id: panelLoader
@@ -235,8 +243,12 @@ Window {
ContentItem {
id: contentArea
- anchors.fill: parent
parent: __panel.contentArea
+ anchors {
+ fill: parent
+ topMargin: systemPadding.top; bottomMargin: systemPadding.bottom
+ leftMargin: systemPadding.left; rightMargin: systemPadding.right
+ }
}
}
}
diff --git a/src/controls/MenuBar.qml b/src/controls/MenuBar.qml
index 7a92c1ec..f1f702f6 100644
--- a/src/controls/MenuBar.qml
+++ b/src/controls/MenuBar.qml
@@ -132,6 +132,11 @@ MenuBarPrivate {
value: menuMouseArea.z - 1
}
+ ContentItem {
+ // Only used for system padding, the real content item is the Row below
+ id: contentItem
+ }
+
QtObject {
id: d
@@ -139,7 +144,8 @@ MenuBarPrivate {
property int openedMenuIndex: -1
property bool preselectMenuItem: false
- property real heightPadding: style ? style.padding.top + style.padding.bottom : 0
+ property real heightPadding: (style ? style.padding.top + style.padding.bottom : 0)
+ + contentItem.systemPadding.top + contentItem.systemPadding.bottom
property bool altPressed: false
property bool altPressedAgain: false
@@ -219,9 +225,10 @@ MenuBarPrivate {
Row {
id: row
- x: d.style ? d.style.padding.left : 0
- y: d.style ? d.style.padding.top : 0
+ x: (d.style ? d.style.padding.left : 0) + contentItem.systemPadding.left
+ y: (d.style ? d.style.padding.top : 0) + contentItem.systemPadding.top
width: parent.width - (d.style ? d.style.padding.left + d.style.padding.right : 0)
+ - (contentItem.systemPadding.left + contentItem.systemPadding.right)
LayoutMirroring.enabled: Qt.application.layoutDirection === Qt.RightToLeft
Repeater {
diff --git a/src/controls/Private/ContentItem.qml b/src/controls/Private/ContentItem.qml
index e131f1d4..2f6f1d70 100644
--- a/src/controls/Private/ContentItem.qml
+++ b/src/controls/Private/ContentItem.qml
@@ -36,6 +36,9 @@
import QtQuick 2.2
import QtQuick.Layouts 1.1
+import QtQuick.Controls 1.0
+import QtQuick.Controls.Private 1.0
+import QtQuick.Window 2.2
Item {
id: contentItem
@@ -46,6 +49,8 @@ Item {
implicitWidth: __calcImplicitWidth()
implicitHeight: __calcImplicitHeight()
+ property Padding systemPadding: Padding { top: 0; left: 0; bottom: 0; right: 0 }
+
/*! \internal */
property Item __layoutItem: contentItem.visibleChildren.length === 1 ? contentItem.visibleChildren[0] : null
/*! \internal */
@@ -102,4 +107,32 @@ Item {
extent += contentItem['__margins' + hw]
return extent
}
+
+ /*! \internal */
+ property rect __screenReservedArea: {
+ return Qt.rect(
+ Screen.width - Screen.desktopAvailableWidth,
+ Screen.height - Screen.desktopAvailableHeight,
+ 0, 0
+ );
+ }
+
+ /*! \internal */
+ property rect __systemPadding: {
+ if (Window.visibility != Window.Maximized)
+ return Qt.rect(0, 0, 0, 0)
+
+ return Qt.rect(
+ Math.max(0, __screenReservedArea.x - contentItem.parent.x - Controls.window.x),
+ Math.max(0, __screenReservedArea.y - contentItem.parent.y - Controls.window.y),
+ 0, 0
+ );
+ }
+
+ on__SystemPaddingChanged: {
+ systemPadding.top = __systemPadding.y
+ systemPadding.left = __systemPadding.x
+ systemPadding.right = __systemPadding.width
+ systemPadding.bottom = __systemPadding.height
+ }
}
diff --git a/src/controls/ToolBar.qml b/src/controls/ToolBar.qml
index 48f62f16..6a72a9b2 100644
--- a/src/controls/ToolBar.qml
+++ b/src/controls/ToolBar.qml
@@ -139,7 +139,7 @@ FocusScope {
sourceComponent: style
}
},
- Item {
+ ContentItem {
id: container
z: 1
focus: true
@@ -150,10 +150,10 @@ FocusScope {
anchors.rightMargin: rightMargin + (buttonLoader.active ? buttonLoader.width + rightMargin : 0)
anchors.bottomMargin: bottomMargin
- property int topMargin: __style ? __style.padding.top : 0
- property int bottomMargin: __style ? __style.padding.bottom : 0
- property int leftMargin: __style ? __style.padding.left : 0
- property int rightMargin: __style ? __style.padding.right : 0
+ property int topMargin: (__style ? __style.padding.top : 0) + systemPadding.top
+ property int bottomMargin: (__style ? __style.padding.bottom : 0) + systemPadding.bottom
+ property int leftMargin: (__style ? __style.padding.left : 0) + systemPadding.left
+ property int rightMargin: (__style ? __style.padding.right : 0) + systemPadding.right
property Item layoutItem: container.children.length === 1 ? container.children[0] : null
property real layoutWidth: layoutItem ? (layoutItem.implicitWidth || layoutItem.width) +