diff options
author | Assam Boudjelthia <assam.boudjelthia@qt.io> | 2019-07-15 14:34:20 +0300 |
---|---|---|
committer | Assam Boudjelthia <assam.boudjelthia@qt.io> | 2019-07-23 06:14:03 +0000 |
commit | 7f29eb621478e42999984935197e396d2b782359 (patch) | |
tree | 0c9c3c726abb99f9c132a26d44cccd5223a2395b | |
parent | 8d82e92fcb04d42fa5efbd23e155ac9f076c7c9c (diff) |
Make demo header as overlay on top of loader and add auto-hide timer
* Revert Anchoring demo loader under demo header because it causes crash
out-of-memory for qt5-cinematicdemo and lags for charts demo.
* Add a timer to auto-hide the demo header while app is running
Task-number: QTBUG-69818
Change-Id: I566e108b0275588ddff0b3f6e020e47bd3cc0e29
Reviewed-by: Jani Launonen <jani.launonen@qt.io>
-rw-r--r-- | qml/DemoHeader.qml | 29 | ||||
-rw-r--r-- | qml/MainWindow.qml | 6 | ||||
-rw-r--r-- | qml/ViewSettings.qml | 1 |
3 files changed, 28 insertions, 8 deletions
diff --git a/qml/DemoHeader.qml b/qml/DemoHeader.qml index 555fff2..0ee83bc 100644 --- a/qml/DemoHeader.qml +++ b/qml/DemoHeader.qml @@ -111,11 +111,13 @@ Rectangle { anchors.horizontalCenter: parent.horizontalCenter y: open ? parent.height - height/2 : parent.height rotation: open ? 180 : 0 + Drag.active: headerToggleMouseArea.drag.active Behavior on rotation { NumberAnimation { duration: 100 } } Behavior on y { NumberAnimation { duration: 100 } } MouseArea { + id: headerToggleMouseArea anchors.fill: parent anchors.margins: -parent.height * 0.5 drag.target: demoHeaderBar @@ -123,13 +125,34 @@ Rectangle { drag.minimumX: -demoHeaderBar.height drag.maximumY: 0 + DropArea { + anchors.fill: parent + onDropped: demoHeaderVisibilityDelay.restart() + } + onClicked: { - if (demoHeaderBar.y < -demoHeaderBar.height / 2) + if (demoHeaderBar.y < -demoHeaderBar.height / 2) { demoHeaderBar.y = 0 - else + demoHeaderVisibilityDelay.restart() + } else { demoHeaderBar.y = -demoHeaderBar.height + } + } + onReleased: { + demoHeaderBar.y = demoHeaderBar.y > -demoHeaderBar.height / 4 ? 0 : -demoHeaderBar.height + parent.Drag.drop() } - onReleased: demoHeaderBar.y = demoHeaderBar.y > -demoHeaderBar.height / 4 ? 0 : -demoHeaderBar.height + } + } + + Component.onCompleted: demoHeaderVisibilityDelay.start() + + Timer { + id: demoHeaderVisibilityDelay + interval: viewSettings.headerAutoHideDelay + onTriggered: { + if (!demoHeaderVisibilityDelay.running) + demoHeaderBar.y = -demoHeaderBar.height } } } diff --git a/qml/MainWindow.qml b/qml/MainWindow.qml index d957468..c1f4e54 100644 --- a/qml/MainWindow.qml +++ b/qml/MainWindow.qml @@ -180,11 +180,7 @@ Item { objectName: "applicationLoader" opacity: 0; visible: opacity > 0.1 - height: root.demoHeaderEnabled ? parent.height - (demoHeader.height + demoHeader.y) : parent.height - - anchors.top: root.demoHeaderEnabled ? demoHeader.bottom : root.top - anchors.left: parent.left - anchors.right: parent.right + anchors.fill: parent asynchronous: true; onStatusChanged: { diff --git a/qml/ViewSettings.qml b/qml/ViewSettings.qml index 3798e68..82f4241 100644 --- a/qml/ViewSettings.qml +++ b/qml/ViewSettings.qml @@ -37,6 +37,7 @@ Item { property real demoHeaderHeight: 2.5 * pageMargin property string appFont: "TitilliumWeb" property int stateDelay: 200; + property int headerAutoHideDelay: 3000 property string backgroundColor: "#09102b" property string borderColor: "#9d9faa" property string buttonGreenColor: "#41cd52" |