summaryrefslogtreecommitdiffstats
path: root/examples/quickcontrols/extras/flat
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2016-05-10 21:11:23 +0200
committerLiang Qi <liang.qi@qt.io>2016-05-10 21:11:23 +0200
commitc6713e212ef0b97c45d6466b73220567e94a05f1 (patch)
tree8774d26bf05f2087c510d16da42bfd0dc59a54b1 /examples/quickcontrols/extras/flat
parentce97d9c8ef4e6f8cb2166065b6732cad3cccf604 (diff)
parent0e00f9fa1cbdbdd2128f2ca31172d88f701ecb59 (diff)
Merge remote-tracking branch 'origin/5.6' into 5.7
Conflicts: examples/quickcontrols/extras/flat/main.cpp src/controls/Private/qquickcontrolsettings.cpp Change-Id: I9eb9342a2ee994611f3cb18daab6dd89eb924ccc
Diffstat (limited to 'examples/quickcontrols/extras/flat')
-rw-r--r--examples/quickcontrols/extras/flat/Content.qml716
-rw-r--r--examples/quickcontrols/extras/flat/SettingsIcon.qml128
-rw-r--r--examples/quickcontrols/extras/flat/flat.pro19
-rw-r--r--examples/quickcontrols/extras/flat/flat.qrc16
-rw-r--r--examples/quickcontrols/extras/flat/images/piemenu-bw-normal.pngbin0 -> 1716 bytes
-rw-r--r--examples/quickcontrols/extras/flat/images/piemenu-bw-pressed.pngbin0 -> 1394 bytes
-rw-r--r--examples/quickcontrols/extras/flat/images/piemenu-image-bw.jpgbin0 -> 1065560 bytes
-rw-r--r--examples/quickcontrols/extras/flat/images/piemenu-image-rgb.jpgbin0 -> 1152261 bytes
-rw-r--r--examples/quickcontrols/extras/flat/images/piemenu-image-sepia.jpgbin0 -> 1513238 bytes
-rw-r--r--examples/quickcontrols/extras/flat/images/piemenu-rgb-normal.pngbin0 -> 1665 bytes
-rw-r--r--examples/quickcontrols/extras/flat/images/piemenu-rgb-pressed.pngbin0 -> 1571 bytes
-rw-r--r--examples/quickcontrols/extras/flat/images/piemenu-sepia-normal.pngbin0 -> 1410 bytes
-rw-r--r--examples/quickcontrols/extras/flat/images/piemenu-sepia-pressed.pngbin0 -> 1386 bytes
-rw-r--r--examples/quickcontrols/extras/flat/main.cpp72
-rw-r--r--examples/quickcontrols/extras/flat/main.qml489
15 files changed, 1440 insertions, 0 deletions
diff --git a/examples/quickcontrols/extras/flat/Content.qml b/examples/quickcontrols/extras/flat/Content.qml
new file mode 100644
index 000000000..e9b3e869f
--- /dev/null
+++ b/examples/quickcontrols/extras/flat/Content.qml
@@ -0,0 +1,716 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.4
+import QtQuick.Layouts 1.1
+import QtQuick.Controls 1.4
+import QtQuick.Controls.Styles.Flat 1.0 as Flat
+import QtQuick.Extras 1.4
+import QtQuick.XmlListModel 2.0
+
+Item {
+ anchors.fill: parent
+
+ Text {
+ id: text
+ visible: false
+ }
+
+ FontMetrics {
+ id: fontMetrics
+ font.family: Flat.FlatStyle.fontFamily
+ }
+
+ readonly property int layoutSpacing: Math.round(5 * Flat.FlatStyle.scaleFactor)
+
+ property var componentModel: [
+ { name: "Buttons", component: buttonsComponent },
+ { name: "Calendar", component: calendarComponent },
+ { name: "DelayButton", component: delayButtonComponent },
+ { name: "Dial", component: dialComponent },
+ { name: "Input", component: inputComponent },
+ { name: "PieMenu", component: pieMenuComponent },
+ { name: "Progress", component: progressComponent },
+ { name: "TableView", component: tableViewComponent },
+ { name: "TextArea", component: textAreaComponent },
+ { name: "Tumbler", component: tumblerComponent }
+ ]
+
+ Loader {
+ id: componentLoader
+ anchors.fill: parent
+ sourceComponent: componentModel[controlData.componentIndex].component
+ }
+
+ property Component buttonsComponent: ScrollView {
+ id: scrollView
+ horizontalScrollBarPolicy: Qt.ScrollBarAlwaysOff
+
+ Flickable {
+ anchors.fill: parent
+ contentWidth: viewport.width
+ contentHeight: buttoncolumn.implicitHeight + textMargins * 1.5
+ ColumnLayout {
+ id: buttoncolumn
+ anchors.fill: parent
+ anchors.margins: textMargins
+ anchors.topMargin: textMargins / 2
+ spacing: textMargins / 2
+ enabled: !settingsData.allDisabled
+
+ GroupBox {
+ title: "Button"
+ checkable: settingsData.checks
+ flat: !settingsData.frames
+ Layout.fillWidth: true
+ GridLayout {
+ columns: Math.max(1, Math.floor(scrollView.width / button.implicitWidth - 0.5))
+ Button {
+ id: button
+ text: "Normal"
+ }
+ Button {
+ text: "Default"
+ isDefault: true
+ }
+ Button {
+ text: "Checkable"
+ checkable: true
+ }
+ Button {
+ text: "Menu"
+ menu: Menu {
+ MenuItem { text: "Normal"; shortcut: "Ctrl+N" }
+ MenuSeparator { }
+ MenuItem { text: "Checkable 1"; checkable: true; checked: true }
+ MenuItem { text: "Checkable 2"; checkable: true; checked: true }
+ MenuSeparator { }
+ }
+ visible: Qt.application.supportsMultipleWindows
+ }
+ }
+ }
+
+ GroupBox {
+ title: "RadioButton"
+ checkable: settingsData.checks
+ flat: !settingsData.frames
+ Layout.fillWidth: true
+ ExclusiveGroup { id: radiobuttongroup }
+ ColumnLayout {
+ anchors.fill: parent
+ Repeater {
+ model: ["First", "Second", "Third"]
+ RadioButton {
+ text: modelData
+ checked: index === 0
+ exclusiveGroup: radiobuttongroup
+ Layout.fillWidth: true
+ }
+ }
+ }
+ }
+
+ GroupBox {
+ title: "CheckBox"
+ checkable: settingsData.checks
+ flat: !settingsData.frames
+ Layout.fillWidth: true
+ ColumnLayout {
+ anchors.fill: parent
+ Repeater {
+ model: ["First", "Second", "Third"]
+ CheckBox {
+ text: modelData
+ checked: index === 0
+ Layout.fillWidth: true
+ }
+ }
+ }
+ }
+
+ GroupBox {
+ title: "Switch"
+ checkable: settingsData.checks
+ flat: !settingsData.frames
+ Layout.fillWidth: true
+ ColumnLayout {
+ anchors.fill: parent
+ Repeater {
+ model: ["First", "Second", "Third"]
+ RowLayout {
+ spacing: layoutSpacing * 2
+ Label {
+ text: modelData
+ font.family: Flat.FlatStyle.fontFamily
+ renderType: Text.QtRendering
+ Layout.preferredWidth: fontMetrics.advanceWidth("Second")
+ }
+ Switch { checked: index == 0 }
+ }
+ }
+ }
+ }
+
+ GroupBox {
+ title: "ToggleButton"
+ checkable: settingsData.checks
+ flat: !settingsData.frames
+ Layout.fillWidth: true
+ GridLayout {
+ columns: Math.max(1, !!children[0] ? Math.floor(scrollView.width / children[0].implicitWidth - 0.5) : children.length)
+ ToggleButton {
+ text: "Pump 1"
+ checked: true
+ }
+ ToggleButton {
+ text: "Pump 2"
+ checked: false
+ }
+ }
+ }
+
+ GroupBox {
+ title: "StatusIndicator"
+ checkable: settingsData.checks
+ flat: !settingsData.frames
+ Layout.fillWidth: true
+ GridLayout {
+ columns: Math.max(1, Math.floor(scrollView.width / recordButton.implicitWidth - 0.5))
+ columnSpacing: layoutSpacing * 4
+
+ Button {
+ id: recordButton
+ text: "Record"
+ Layout.alignment: Qt.AlignTop
+ onClicked: recordStatusIndicator.active = !recordStatusIndicator.active
+
+ StatusIndicator {
+ id: recordStatusIndicator
+ active: false
+ anchors.left: parent.left
+ anchors.leftMargin: Math.max(6, Math.round(text.implicitHeight * 0.4))
+ anchors.verticalCenter: parent.verticalCenter
+ rotation: 90
+ }
+ }
+ ColumnLayout {
+ Repeater {
+ model: 3
+ delegate: RowLayout {
+ Layout.alignment: Qt.AlignCenter
+ StatusIndicator {
+ active: true
+ color: "#f09116"
+ }
+ Label {
+ text: "Camera " + (index + 1)
+ font.family: Flat.FlatStyle.fontFamily
+ renderType: Text.QtRendering
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ property Component progressComponent: ScrollView {
+ id: scrollView
+ horizontalScrollBarPolicy: Qt.ScrollBarAlwaysOff
+ Flickable {
+ anchors.fill: parent
+ contentWidth: viewport.width
+ contentHeight: progresscolumn.implicitHeight + textMargins * 1.5
+ ColumnLayout {
+ id: progresscolumn
+ anchors.fill: parent
+ anchors.leftMargin: textMargins
+ anchors.rightMargin: textMargins
+ anchors.bottomMargin: textMargins
+ anchors.topMargin: textMargins / 2
+ spacing: textMargins / 2
+ enabled: !settingsData.allDisabled
+
+ GroupBox {
+ title: "BusyIndicator"
+ checkable: settingsData.checks
+ flat: !settingsData.frames
+ Layout.fillWidth: true
+ BusyIndicator {
+ id: busyindicator
+ anchors.centerIn: parent
+ running: scrollView.visible
+ }
+ }
+
+ GroupBox {
+ title: "ProgressBar"
+ checkable: settingsData.checks
+ flat: !settingsData.frames
+ Layout.fillWidth: true
+ ColumnLayout {
+ anchors.fill: parent
+ ProgressBar {
+ value: slider.value
+ maximumValue: slider.maximumValue
+ Layout.fillWidth: true
+ }
+ ProgressBar {
+ indeterminate: true
+ value: slider.value
+ maximumValue: slider.maximumValue
+ Layout.fillWidth: true
+ }
+ }
+ }
+
+ GroupBox {
+ title: "Slider"
+ checkable: settingsData.checks
+ flat: !settingsData.frames
+ Layout.fillWidth: true
+ ColumnLayout {
+ anchors.fill: parent
+ Slider {
+ id: slider
+ // TODO: can't use maximumValue / 2 here, otherwise the gauges
+ // initially show up as empty; find out why.
+ value: 50
+ // If we use the default value of 1 here, we run into QTBUG-42358,
+ // even though that report specifically uses 100 as an example...
+ maximumValue: 100
+ Layout.fillWidth: true
+ }
+ }
+ }
+
+ GroupBox {
+ title: "Gauge"
+ checkable: settingsData.checks
+ flat: !settingsData.frames
+ Layout.fillWidth: true
+ Gauge {
+ id: gauge
+ value: slider.value * 1.4
+ orientation: window.width < window.height ? Qt.Vertical : Qt.Horizontal
+ minimumValue: slider.minimumValue * 1.4
+ maximumValue: slider.maximumValue * 1.4
+ tickmarkStepSize: 20
+
+ anchors.centerIn: parent
+ }
+ }
+
+ GroupBox {
+ title: "CircularGauge"
+ checkable: settingsData.checks
+ flat: !settingsData.frames
+ Layout.fillWidth: true
+ Layout.minimumWidth: 0
+ CircularGauge {
+ id: circularGauge
+ value: slider.value * 3.2
+ minimumValue: slider.minimumValue * 3.2
+ maximumValue: slider.maximumValue * 3.2
+
+ anchors.centerIn: parent
+ width: Math.min(implicitWidth, parent.width)
+ height: Math.min(implicitHeight, parent.height)
+
+ style: Flat.CircularGaugeStyle {
+ tickmarkStepSize: 20
+ labelStepSize: 40
+ minorTickmarkCount: 2
+ }
+
+ Column {
+ anchors.centerIn: parent
+
+ Label {
+ text: Math.floor(circularGauge.value)
+ anchors.horizontalCenter: parent.horizontalCenter
+ renderType: Text.QtRendering
+ font.pixelSize: unitLabel.font.pixelSize * 2
+ font.family: Flat.FlatStyle.fontFamily
+ font.weight: Font.Light
+ }
+ Label {
+ id: unitLabel
+ text: "km/h"
+ renderType: Text.QtRendering
+ font.family: Flat.FlatStyle.fontFamily
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ property Component inputComponent: ScrollView {
+ id: scrollView
+ horizontalScrollBarPolicy: Qt.ScrollBarAlwaysOff
+ Flickable {
+ anchors.fill: parent
+ contentWidth: viewport.width
+ contentHeight: inputcolumn.implicitHeight + textMargins * 1.5
+ ColumnLayout {
+ id: inputcolumn
+ anchors.fill: parent
+ anchors.margins: textMargins
+ spacing: textMargins / 2
+ enabled: !settingsData.allDisabled
+
+ GroupBox {
+ title: "TextField"
+ checkable: settingsData.checks
+ flat: !settingsData.frames
+ Layout.fillWidth: true
+ ColumnLayout {
+ anchors.fill: parent
+ TextField {
+ z: 1
+ placeholderText: "TextField"
+ Layout.fillWidth: true
+ }
+ TextField {
+ placeholderText: "Password"
+ echoMode: TextInput.Password // TODO: PasswordEchoOnEdit
+ Layout.fillWidth: true
+ }
+ }
+ }
+
+ GroupBox {
+ title: "ComboBox"
+ checkable: settingsData.checks
+ flat: !settingsData.frames
+ Layout.fillWidth: true
+ visible: Qt.application.supportsMultipleWindows
+ ColumnLayout {
+ anchors.fill: parent
+ ComboBox {
+ model: ["Option 1", "Option 2", "Option 3"]
+ Layout.fillWidth: true
+ }
+ ComboBox {
+ editable: true
+ model: ListModel {
+ id: combomodel
+ ListElement { text: "Option 1" }
+ ListElement { text: "Option 2" }
+ ListElement { text: "Option 3" }
+ }
+ onAccepted: {
+ if (find(currentText) === -1) {
+ combomodel.append({text: editText})
+ currentIndex = find(editText)
+ }
+ }
+ Layout.fillWidth: true
+ }
+ }
+ }
+
+ GroupBox {
+ title: "SpinBox"
+ checkable: settingsData.checks
+ flat: !settingsData.frames
+ Layout.fillWidth: true
+ GridLayout {
+ anchors.fill: parent
+ columns: Math.max(1, Math.floor(scrollView.width / spinbox.implicitWidth - 0.5))
+ SpinBox {
+ id: spinbox
+ Layout.fillWidth: true
+ }
+ SpinBox {
+ decimals: 1
+ Layout.fillWidth: true
+ }
+ }
+ }
+ }
+ }
+ }
+
+ Component {
+ id: tableViewComponent
+ TableView {
+ id: view
+ enabled: !settingsData.allDisabled
+ TableViewColumn {
+ role: "title"
+ title: "Title"
+ width: view.width / 2
+ resizable: false
+ movable: false
+ }
+ TableViewColumn {
+ role: "author"
+ title: "Author"
+ width: view.width / 2
+ resizable: false
+ movable: false
+ }
+
+ frameVisible: false
+ backgroundVisible: true
+ alternatingRowColors: false
+ model: ListModel {
+ ListElement {
+ title: "Moby-Dick"
+ author: "Herman Melville"
+ }
+ ListElement {
+ title: "The Adventures of Tom Sawyer"
+ author: "Mark Twain"
+ }
+ ListElement {
+ title: "Cat’s Cradle"
+ author: "Kurt Vonnegut"
+ }
+ ListElement {
+ title: "Farenheit 451"
+ author: "Ray Bradbury"
+ }
+ ListElement {
+ title: "It"
+ author: "Stephen King"
+ }
+ ListElement {
+ title: "On the Road"
+ author: "Jack Kerouac"
+ }
+ ListElement {
+ title: "Of Mice and Men"
+ author: "John Steinbeck"
+ }
+ ListElement {
+ title: "Do Androids Dream of Electric Sheep?"
+ author: "Philip K. Dick"
+ }
+ ListElement {
+ title: "Uncle Tom’s Cabin"
+ author: "Harriet Beecher Stowe"
+ }
+ ListElement {
+ title: "The Call of the Wild"
+ author: "Jack London"
+ }
+ ListElement {
+ title: "The Old Man and the Sea"
+ author: "Ernest Hemingway"
+ }
+ ListElement {
+ title: "A Streetcar Named Desire"
+ author: "Tennessee Williams"
+ }
+ ListElement {
+ title: "Catch-22"
+ author: "Joseph Heller"
+ }
+ ListElement {
+ title: "One Flew Over the Cuckoo’s Nest"
+ author: "Ken Kesey"
+ }
+ ListElement {
+ title: "The Murders in the Rue Morgue"
+ author: "Edgar Allan Poe"
+ }
+ ListElement {
+ title: "Breakfast at Tiffany’s"
+ author: "Truman Capote"
+ }
+ ListElement {
+ title: "Death of a Salesman"
+ author: "Arthur Miller"
+ }
+ ListElement {
+ title: "Post Office"
+ author: "Charles Bukowski"
+ }
+ ListElement {
+ title: "Herbert West—Reanimator"
+ author: "H. P. Lovecraft"
+ }
+ }
+ }
+ }
+ Component {
+ id: calendarComponent
+ Item {
+ enabled: !settingsData.allDisabled
+ Calendar {
+ anchors.centerIn: parent
+ weekNumbersVisible: true
+ frameVisible: settingsData.frames
+ }
+ }
+ }
+ Component {
+ id: textAreaComponent
+ TextArea {
+ enabled: !settingsData.allDisabled
+ frameVisible: false
+ flickableItem.flickableDirection: Flickable.VerticalFlick
+ text: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum quis justo a sem faucibus mattis nec vitae nisi. Fusce fringilla nulla a tellus vehicula sodales. Etiam volutpat suscipit erat vitae adipiscing. Sed vestibulum massa nisl, eget posuere urna porta ac. Morbi at nunc ligula. Cras et mauris aliquet ligula sodales suscipit eget imperdiet augue. Ut eget dui eu magna malesuada imperdiet. Donec imperdiet urna eu consequat ornare. Cras at metus tristique, ullamcorper nisl ut, faucibus mauris. Fusce in euismod arcu. Donec tristique rutrum porta. Praesent mattis ac tortor quis scelerisque. Integer luctus nulla ut lacinia tempus."
+ }
+ }
+ Component {
+ id: pieMenuComponent
+ Item {
+ enabled: !settingsData.allDisabled
+
+ Column {
+ anchors.fill: parent
+ anchors.bottom: parent.bottom
+ anchors.bottomMargin: controlData.textMargins
+ spacing: Math.round(controlData.textMargins * 0.5)
+
+ Image {
+ id: pieMenuImage
+ source: "qrc:/images/piemenu-image-rgb.jpg"
+ fillMode: Image.PreserveAspectFit
+ width: parent.width
+ height: Math.min((width / sourceSize.width) * sourceSize.height, (parent.height - parent.spacing) * 0.88)
+ }
+ Item {
+ width: parent.width
+ height: parent.height - pieMenuImage.height - parent.spacing
+
+ Text {
+ id: instructionText
+ anchors.fill: parent
+ anchors.leftMargin: controlData.textMargins
+ anchors.rightMargin: controlData.textMargins
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ text: "Tap and hold to open menu"
+ font.family: Flat.FlatStyle.fontFamily
+ font.pixelSize: Math.round(20 * Flat.FlatStyle.scaleFactor)
+ fontSizeMode: Text.Fit
+ color: Flat.FlatStyle.lightFrameColor
+ }
+ }
+ }
+ MouseArea {
+ id: mouseArea
+ anchors.fill: parent
+ onPressAndHold: pieMenu.popup(mouse.x, mouse.y)
+ }
+ PieMenu {
+ id: pieMenu
+ triggerMode: TriggerMode.TriggerOnClick
+
+ MenuItem {
+ iconSource: "qrc:/images/piemenu-rgb-" + (pieMenu.currentIndex === 0 ? "pressed" : "normal") + ".png"
+ onTriggered: pieMenuImage.source = "qrc:/images/piemenu-image-rgb.jpg"
+ }
+ MenuItem {
+ iconSource: "qrc:/images/piemenu-bw-" + (pieMenu.currentIndex === 1 ? "pressed" : "normal") + ".png"
+ onTriggered: pieMenuImage.source = "qrc:/images/piemenu-image-bw.jpg"
+ }
+ MenuItem {
+ iconSource: "qrc:/images/piemenu-sepia-" + (pieMenu.currentIndex === 2 ? "pressed" : "normal") + ".png"
+ onTriggered: pieMenuImage.source = "qrc:/images/piemenu-image-sepia.jpg"
+ }
+ }
+ }
+ }
+ Component {
+ id: delayButtonComponent
+ Item {
+ enabled: !settingsData.allDisabled
+ DelayButton {
+ text: progress < 1 ? "START" : "STOP"
+ anchors.centerIn: parent
+ }
+ }
+ }
+ Component {
+ id: dialComponent
+ Item {
+ enabled: !settingsData.allDisabled
+ Dial {
+ anchors.centerIn: parent
+ }
+ }
+ }
+ Component {
+ id: tumblerComponent
+ Item {
+ enabled: !settingsData.allDisabled
+ Tumbler {
+ anchors.centerIn: parent
+ TumblerColumn {
+ model: {
+ var hours = [];
+ for (var i = 1; i <= 24; ++i)
+ hours.push(i < 10 ? "0" + i : i);
+ hours;
+ }
+ }
+ TumblerColumn {
+ model: {
+ var minutes = [];
+ for (var i = 0; i < 60; ++i)
+ minutes.push(i < 10 ? "0" + i : i);
+ minutes;
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/examples/quickcontrols/extras/flat/SettingsIcon.qml b/examples/quickcontrols/extras/flat/SettingsIcon.qml
new file mode 100644
index 000000000..756426c49
--- /dev/null
+++ b/examples/quickcontrols/extras/flat/SettingsIcon.qml
@@ -0,0 +1,128 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.4
+
+Canvas {
+ onPaint: {
+ var ctx = getContext("2d");
+ ctx.reset();
+
+ ctx.scale(width, height);
+
+ ctx.beginPath();
+ ctx.moveTo(0.706,0.542);
+ ctx.bezierCurveTo(0.709,0.527,0.711,0.512,0.711,0.49700000000000005);
+ ctx.bezierCurveTo(0.711,0.4820000000000001,0.709,0.465,0.706,0.451);
+ ctx.lineTo(0.752,0.41600000000000004);
+ ctx.lineTo(0.759,0.41);
+ ctx.lineTo(0.756,0.4);
+ ctx.bezierCurveTo(0.756,0.399,0.749,0.382,0.737,0.36200000000000004);
+ ctx.bezierCurveTo(0.725,0.3420000000000001,0.714,0.328,0.714,0.327);
+ ctx.lineTo(0.708,0.319);
+ ctx.lineTo(0.698,0.324);
+ ctx.lineTo(0.645,0.346);
+ ctx.bezierCurveTo(0.623,0.32499999999999996,0.595,0.309,0.5650000000000001,0.3);
+ ctx.lineTo(0.558,0.243);
+ ctx.lineTo(0.557,0.23299999999999998);
+ ctx.lineTo(0.547,0.23099999999999998);
+ ctx.bezierCurveTo(0.546,0.23099999999999998,0.528,0.22799999999999998,0.505,0.22799999999999998);
+ ctx.bezierCurveTo(0.481,0.22799999999999998,0.463,0.23099999999999998,0.463,0.23099999999999998);
+ ctx.lineTo(0.453,0.23299999999999998);
+ ctx.lineTo(0.452,0.243);
+ ctx.lineTo(0.444,0.299);
+ ctx.bezierCurveTo(0.41400000000000003,0.308,0.387,0.324,0.364,0.345);
+ ctx.lineTo(0.312,0.323);
+ ctx.lineTo(0.302,0.319);
+ ctx.lineTo(0.296,0.327);
+ ctx.bezierCurveTo(0.296,0.327,0.284,0.342,0.27299999999999996,0.362);
+ ctx.bezierCurveTo(0.26,0.383,0.254,0.399,0.254,0.4);
+ ctx.lineTo(0.25,0.41);
+ ctx.lineTo(0.258,0.416);
+ ctx.lineTo(0.303,0.45099999999999996);
+ ctx.bezierCurveTo(0.3,0.465,0.299,0.48,0.299,0.497);
+ ctx.bezierCurveTo(0.299,0.513,0.3,0.528,0.304,0.543);
+ ctx.lineTo(0.259,0.577);
+ ctx.lineTo(0.25,0.584);
+ ctx.lineTo(0.254,0.593);
+ ctx.bezierCurveTo(0.254,0.594,0.261,0.61,0.273,0.63);
+ ctx.bezierCurveTo(0.28500000000000003,0.65,0.29500000000000004,0.664,0.29600000000000004,0.665);
+ ctx.lineTo(0.30200000000000005,0.673);
+ ctx.lineTo(0.31200000000000006,0.669);
+ ctx.lineTo(0.36500000000000005,0.647);
+ ctx.bezierCurveTo(0.38700000000000007,0.668,0.41400000000000003,0.684,0.44400000000000006,0.6930000000000001);
+ ctx.lineTo(0.45200000000000007,0.7510000000000001);
+ ctx.lineTo(0.45300000000000007,0.7620000000000001);
+ ctx.lineTo(0.4640000000000001,0.7630000000000001);
+ ctx.bezierCurveTo(0.4640000000000001,0.7630000000000001,0.4820000000000001,0.7640000000000001,0.5060000000000001,0.7640000000000001);
+ ctx.bezierCurveTo(0.5300000000000001,0.7640000000000001,0.5470000000000002,0.7620000000000001,0.5480000000000002,0.7620000000000001);
+ ctx.lineTo(0.5580000000000002,0.7610000000000001);
+ ctx.lineTo(0.5590000000000002,0.7510000000000001);
+ ctx.lineTo(0.5660000000000002,0.6940000000000001);
+ ctx.bezierCurveTo(0.5960000000000002,0.685,0.6230000000000002,0.669,0.6460000000000001,0.648);
+ ctx.lineTo(0.6990000000000002,0.67);
+ ctx.lineTo(0.7090000000000002,0.674);
+ ctx.lineTo(0.7150000000000002,0.665);
+ ctx.bezierCurveTo(0.7150000000000002,0.665,0.7260000000000002,0.65,0.7370000000000002,0.63);
+ ctx.bezierCurveTo(0.7490000000000002,0.61,0.7560000000000002,0.594,0.7560000000000002,0.593);
+ ctx.lineTo(0.7600000000000002,0.584);
+ ctx.lineTo(0.751,0.577);
+ ctx.lineTo(0.706,0.542);
+ ctx.closePath();
+ ctx.moveTo(0.505,0.622);
+ ctx.bezierCurveTo(0.436,0.622,0.38,0.566,0.38,0.497);
+ ctx.bezierCurveTo(0.38,0.428,0.436,0.372,0.505,0.372);
+ ctx.bezierCurveTo(0.5740000000000001,0.372,0.63,0.428,0.63,0.497);
+ ctx.bezierCurveTo(0.63,0.565,0.574,0.622,0.505,0.622);
+ ctx.closePath();
+ ctx.fillStyle = "#333333";
+ ctx.fill();
+ }
+}
diff --git a/examples/quickcontrols/extras/flat/flat.pro b/examples/quickcontrols/extras/flat/flat.pro
new file mode 100644
index 000000000..6a6906648
--- /dev/null
+++ b/examples/quickcontrols/extras/flat/flat.pro
@@ -0,0 +1,19 @@
+TEMPLATE = app
+TARGET = flat
+QT += quick
+
+SOURCES += \
+ main.cpp
+
+RESOURCES += \
+ flat.qrc
+
+OTHER_FILES += \
+ main.qml
+
+DISTFILES += \
+ Content.qml \
+ SettingsIcon.qml
+
+target.path = $$[QT_INSTALL_EXAMPLES]/quickcontrols/extras/flat
+INSTALLS += target
diff --git a/examples/quickcontrols/extras/flat/flat.qrc b/examples/quickcontrols/extras/flat/flat.qrc
new file mode 100644
index 000000000..5b06a55ce
--- /dev/null
+++ b/examples/quickcontrols/extras/flat/flat.qrc
@@ -0,0 +1,16 @@
+<RCC>
+ <qresource prefix="/">
+ <file>main.qml</file>
+ <file>images/piemenu-bw-normal.png</file>
+ <file>images/piemenu-bw-pressed.png</file>
+ <file>images/piemenu-rgb-normal.png</file>
+ <file>images/piemenu-rgb-pressed.png</file>
+ <file>images/piemenu-sepia-normal.png</file>
+ <file>images/piemenu-sepia-pressed.png</file>
+ <file>images/piemenu-image-bw.jpg</file>
+ <file>images/piemenu-image-rgb.jpg</file>
+ <file>images/piemenu-image-sepia.jpg</file>
+ <file>Content.qml</file>
+ <file>SettingsIcon.qml</file>
+ </qresource>
+</RCC>
diff --git a/examples/quickcontrols/extras/flat/images/piemenu-bw-normal.png b/examples/quickcontrols/extras/flat/images/piemenu-bw-normal.png
new file mode 100644
index 000000000..ef57111fb
--- /dev/null
+++ b/examples/quickcontrols/extras/flat/images/piemenu-bw-normal.png
Binary files differ
diff --git a/examples/quickcontrols/extras/flat/images/piemenu-bw-pressed.png b/examples/quickcontrols/extras/flat/images/piemenu-bw-pressed.png
new file mode 100644
index 000000000..b6bd1d20d
--- /dev/null
+++ b/examples/quickcontrols/extras/flat/images/piemenu-bw-pressed.png
Binary files differ
diff --git a/examples/quickcontrols/extras/flat/images/piemenu-image-bw.jpg b/examples/quickcontrols/extras/flat/images/piemenu-image-bw.jpg
new file mode 100644
index 000000000..ce4d8ffda
--- /dev/null
+++ b/examples/quickcontrols/extras/flat/images/piemenu-image-bw.jpg
Binary files differ
diff --git a/examples/quickcontrols/extras/flat/images/piemenu-image-rgb.jpg b/examples/quickcontrols/extras/flat/images/piemenu-image-rgb.jpg
new file mode 100644
index 000000000..2d7d22056
--- /dev/null
+++ b/examples/quickcontrols/extras/flat/images/piemenu-image-rgb.jpg
Binary files differ
diff --git a/examples/quickcontrols/extras/flat/images/piemenu-image-sepia.jpg b/examples/quickcontrols/extras/flat/images/piemenu-image-sepia.jpg
new file mode 100644
index 000000000..3ef7b1f0f
--- /dev/null
+++ b/examples/quickcontrols/extras/flat/images/piemenu-image-sepia.jpg
Binary files differ
diff --git a/examples/quickcontrols/extras/flat/images/piemenu-rgb-normal.png b/examples/quickcontrols/extras/flat/images/piemenu-rgb-normal.png
new file mode 100644
index 000000000..2278f4a9e
--- /dev/null
+++ b/examples/quickcontrols/extras/flat/images/piemenu-rgb-normal.png
Binary files differ
diff --git a/examples/quickcontrols/extras/flat/images/piemenu-rgb-pressed.png b/examples/quickcontrols/extras/flat/images/piemenu-rgb-pressed.png
new file mode 100644
index 000000000..f45846b17
--- /dev/null
+++ b/examples/quickcontrols/extras/flat/images/piemenu-rgb-pressed.png
Binary files differ
diff --git a/examples/quickcontrols/extras/flat/images/piemenu-sepia-normal.png b/examples/quickcontrols/extras/flat/images/piemenu-sepia-normal.png
new file mode 100644
index 000000000..f1e9ffd26
--- /dev/null
+++ b/examples/quickcontrols/extras/flat/images/piemenu-sepia-normal.png
Binary files differ
diff --git a/examples/quickcontrols/extras/flat/images/piemenu-sepia-pressed.png b/examples/quickcontrols/extras/flat/images/piemenu-sepia-pressed.png
new file mode 100644
index 000000000..0f2b35171
--- /dev/null
+++ b/examples/quickcontrols/extras/flat/images/piemenu-sepia-pressed.png
Binary files differ
diff --git a/examples/quickcontrols/extras/flat/main.cpp b/examples/quickcontrols/extras/flat/main.cpp
new file mode 100644
index 000000000..61b1e9b3e
--- /dev/null
+++ b/examples/quickcontrols/extras/flat/main.cpp
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui/QGuiApplication>
+#include <QtQml/QQmlApplicationEngine>
+#include <QtGui/QFontDatabase>
+#include <QtCore/QDir>
+
+int main(int argc, char *argv[])
+{
+ QGuiApplication app(argc, argv);
+ if (qgetenv("QT_QUICK_CONTROLS_1_STYLE").isEmpty()) {
+#ifdef QT_STATIC
+ // Need a full path to find the style when built statically
+ qputenv("QT_QUICK_CONTROLS_1_STYLE", ":/ExtrasImports/QtQuick/Controls/Styles/Flat");
+#else
+ qputenv("QT_QUICK_CONTROLS_1_STYLE", "Flat");
+#endif
+ }
+ QQmlApplicationEngine engine;
+ engine.load(QUrl("qrc:/main.qml"));
+ if (engine.rootObjects().isEmpty())
+ return -1;
+ return app.exec();
+}
diff --git a/examples/quickcontrols/extras/flat/main.qml b/examples/quickcontrols/extras/flat/main.qml
new file mode 100644
index 000000000..d91c20633
--- /dev/null
+++ b/examples/quickcontrols/extras/flat/main.qml
@@ -0,0 +1,489 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** BSD License Usage
+** Alternatively, you may use this file under the terms of the BSD license
+** as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.4
+import QtQuick.Layouts 1.0
+import QtQuick.Controls 1.4
+import QtQuick.Controls.Styles.Flat 1.0 as Flat
+import QtQuick.Extras 1.4
+import QtQuick.Extras.Private 1.0
+
+ApplicationWindow {
+ id: window
+ width: 480
+ height: 860
+ title: "Flat Example"
+ visible: true
+
+ readonly property bool contentLoaded: contentLoader.item
+ readonly property alias anchorItem: controlsMenu
+ property int currentMenu: -1
+ readonly property int textMargins: Math.round(32 * Flat.FlatStyle.scaleFactor)
+ readonly property int menuMargins: Math.round(13 * Flat.FlatStyle.scaleFactor)
+ readonly property int menuWidth: Math.min(window.width, window.height) * 0.75
+
+ onCurrentMenuChanged: {
+ xBehavior.enabled = true;
+ anchorCurrentMenu();
+ }
+
+ onMenuWidthChanged: anchorCurrentMenu()
+
+ function anchorCurrentMenu() {
+ switch (currentMenu) {
+ case -1:
+ anchorItem.x = -menuWidth;
+ break;
+ case 0:
+ anchorItem.x = 0;
+ break;
+ case 1:
+ anchorItem.x = -menuWidth * 2;
+ break;
+ }
+ }
+
+ Item {
+ id: container
+ anchors.fill: parent
+
+ Item {
+ id: loadingScreen
+ anchors.fill: parent
+ visible: !contentLoaded
+
+ Timer {
+ running: true
+ interval: 100
+ // TODO: Find a way to know when the loading screen has been rendered instead
+ // of using an abritrary amount of time.
+ onTriggered: contentLoader.sourceComponent = Qt.createComponent("Content.qml")
+ }
+
+ Column {
+ anchors.centerIn: parent
+ spacing: Math.round(10 * Flat.FlatStyle.scaleFactor)
+
+ BusyIndicator {
+ anchors.horizontalCenter: parent.horizontalCenter
+ }
+
+ Label {
+ text: "Loading Light Flat UI..."
+ width: Math.min(loadingScreen.width, loadingScreen.height) * 0.8
+ height: font.pixelSize
+ anchors.horizontalCenter: parent.horizontalCenter
+ renderType: Text.QtRendering
+ font.pixelSize: Math.round(26 * Flat.FlatStyle.scaleFactor)
+ horizontalAlignment: Text.AlignHCenter
+ fontSizeMode: Text.Fit
+ font.family: Flat.FlatStyle.fontFamily
+ font.weight: Font.Light
+ }
+ }
+ }
+
+ Rectangle {
+ id: controlsMenu
+ x: container.x - width
+ z: contentContainer.z + 1
+ width: menuWidth
+ height: parent.height
+
+ // Don't let the menus become visible when resizing the window
+ Binding {
+ target: controlsMenu
+ property: "x"
+ value: container.x - controlsMenu.width
+ when: !xBehavior.enabled && !xNumberAnimation.running && currentMenu == -1
+ }
+
+ Behavior on x {
+ id: xBehavior
+ enabled: false
+ NumberAnimation {
+ id: xNumberAnimation
+ easing.type: Easing.OutExpo
+ duration: 500
+ onRunningChanged: xBehavior.enabled = false
+ }
+ }
+
+ Rectangle {
+ id: controlsTitleBar
+ width: parent.width
+ height: toolBar.height
+ color: Flat.FlatStyle.defaultTextColor
+
+ Label {
+ text: "Controls"
+ font.family: Flat.FlatStyle.fontFamily
+ font.pixelSize: Math.round(16 * Flat.FlatStyle.scaleFactor)
+ renderType: Text.QtRendering
+ color: "white"
+ anchors.left: parent.left
+ anchors.leftMargin: menuMargins
+ anchors.verticalCenter: parent.verticalCenter
+ }
+ }
+
+ ListView {
+ id: controlView
+ width: parent.width
+ anchors.top: controlsTitleBar.bottom
+ anchors.bottom: parent.bottom
+ clip: true
+ currentIndex: 0
+ model: contentLoaded ? contentLoader.item.componentModel : null
+ delegate: MouseArea {
+ id: delegateItem
+ width: parent.width
+ height: 64 * Flat.FlatStyle.scaleFactor
+ onClicked: {
+ if (controlView.currentIndex != index)
+ controlView.currentIndex = index;
+
+ currentMenu = -1;
+ }
+
+ Rectangle {
+ width: parent.width
+ height: Flat.FlatStyle.onePixel
+ anchors.bottom: parent.bottom
+ color: Flat.FlatStyle.lightFrameColor
+ }
+
+ Label {
+ text: delegateItem.ListView.view.model[index].name
+ font.pixelSize: Math.round(15 * Flat.FlatStyle.scaleFactor)
+ font.family: Flat.FlatStyle.fontFamily
+ renderType: Text.QtRendering
+ color: delegateItem.ListView.isCurrentItem ? Flat.FlatStyle.styleColor : Flat.FlatStyle.defaultTextColor
+ anchors.left: parent.left
+ anchors.leftMargin: menuMargins
+ anchors.verticalCenter: parent.verticalCenter
+ }
+ }
+
+ Rectangle {
+ width: parent.height
+ height: 8 * Flat.FlatStyle.scaleFactor
+ rotation: 90
+ anchors.left: parent.right
+ transformOrigin: Item.TopLeft
+
+ gradient: Gradient {
+ GradientStop {
+ color: Qt.rgba(0, 0, 0, 0.15)
+ position: 0
+ }
+ GradientStop {
+ color: Qt.rgba(0, 0, 0, 0.05)
+ position: 0.5
+ }
+ GradientStop {
+ color: Qt.rgba(0, 0, 0, 0)
+ position: 1
+ }
+ }
+ }
+ }
+ }
+
+ Item {
+ id: contentContainer
+ anchors.top: parent.top
+ anchors.bottom: parent.bottom
+ anchors.left: controlsMenu.right
+ width: parent.width
+
+ ToolBar {
+ id: toolBar
+ visible: !loadingScreen.visible
+ width: parent.width
+ height: 54 * Flat.FlatStyle.scaleFactor
+ z: contentLoader.z + 1
+ style: Flat.ToolBarStyle {
+ padding.left: 0
+ padding.right: 0
+ }
+
+ RowLayout {
+ anchors.fill: parent
+
+ MouseArea {
+ id: controlsButton
+ Layout.preferredWidth: toolBar.height + textMargins
+ Layout.preferredHeight: toolBar.height
+ onClicked: currentMenu = currentMenu == 0 ? -1 : 0
+
+ Column {
+ id: controlsIcon
+ anchors.left: parent.left
+ anchors.leftMargin: textMargins
+ anchors.verticalCenter: parent.verticalCenter
+ spacing: Math.round(2 * Flat.FlatStyle.scaleFactor)
+
+ Repeater {
+ model: 3
+
+ Rectangle {
+ width: Math.round(4 * Flat.FlatStyle.scaleFactor)
+ height: width
+ radius: width / 2
+ color: Flat.FlatStyle.defaultTextColor
+ }
+ }
+ }
+ }
+
+ Text {
+ text: "Light Flat UI Demo"
+ font.family: Flat.FlatStyle.fontFamily
+ font.pixelSize: Math.round(16 * Flat.FlatStyle.scaleFactor)
+ horizontalAlignment: Text.AlignHCenter
+ color: "#666666"
+ Layout.fillWidth: true
+ }
+
+ MouseArea {
+ id: settingsButton
+ Layout.preferredWidth: controlsButton.Layout.preferredWidth
+ Layout.preferredHeight: controlsButton.Layout.preferredHeight
+ onClicked: currentMenu = currentMenu == 1 ? -1 : 1
+
+ SettingsIcon {
+ width: Math.round(32 * Flat.FlatStyle.scaleFactor)
+ height: Math.round(32 * Flat.FlatStyle.scaleFactor)
+ anchors.verticalCenter: parent.verticalCenter
+ anchors.right: parent.right
+ anchors.rightMargin: textMargins - Math.round(8 * Flat.FlatStyle.scaleFactor)
+ }
+ }
+ }
+ }
+
+ Loader {
+ id: contentLoader
+ anchors.left: parent.left
+ anchors.right: parent.right
+ anchors.top: toolBar.bottom
+ anchors.bottom: parent.bottom
+
+ property QtObject settingsData: QtObject {
+ readonly property bool checks: disableSingleItemsAction.checked
+ readonly property bool frames: !greyBackgroundAction.checked
+ readonly property bool allDisabled: disableAllAction.checked
+ }
+ property QtObject controlData: QtObject {
+ readonly property int componentIndex: controlView.currentIndex
+ readonly property int textMargins: window.textMargins
+ }
+
+ MouseArea {
+ enabled: currentMenu != -1
+ // We would be able to just set this to true here, if it weren't for QTBUG-43083.
+ hoverEnabled: enabled
+ anchors.fill: parent
+ preventStealing: true
+ onClicked: currentMenu = -1
+ focus: enabled
+ z: 1000
+ }
+ }
+ }
+
+ Rectangle {
+ id: settingsMenu
+ z: contentContainer.z + 1
+ width: menuWidth
+ height: parent.height
+ anchors.left: contentContainer.right
+
+ Rectangle {
+ id: optionsTitleBar
+ width: parent.width
+ height: toolBar.height
+ color: Flat.FlatStyle.defaultTextColor
+
+ Label {
+ text: "Options"
+ font.family: Flat.FlatStyle.fontFamily
+ font.pixelSize: Math.round(16 * Flat.FlatStyle.scaleFactor)
+ renderType: Text.QtRendering
+ color: "white"
+ anchors.left: parent.left
+ anchors.leftMargin: menuMargins
+ anchors.verticalCenter: parent.verticalCenter
+ }
+ }
+
+ Action {
+ id: disableAllAction
+ checkable: true
+ checked: false
+ }
+
+ Action {
+ id: disableSingleItemsAction
+ checkable: true
+ checked: false
+ }
+
+ Action {
+ id: greyBackgroundAction
+ checkable: true
+ checked: false
+ }
+
+ ListView {
+ id: optionsListView
+ width: parent.width
+ anchors.top: optionsTitleBar.bottom
+ anchors.bottom: parent.bottom
+ clip: true
+ interactive: delegateHeight * count > height
+
+ readonly property int delegateHeight: 64 * Flat.FlatStyle.scaleFactor
+
+ model: [
+ { name: "Disable all", action: disableAllAction },
+ { name: "Disable single items", action: disableSingleItemsAction },
+ { name: "Grey background", action: greyBackgroundAction },
+ { name: "Exit", action: null }
+ ]
+ delegate: Rectangle {
+ id: optionDelegateItem
+ width: parent.width
+ height: optionsListView.delegateHeight
+
+ Rectangle {
+ width: parent.width
+ height: Flat.FlatStyle.onePixel
+ anchors.bottom: parent.bottom
+ color: Flat.FlatStyle.lightFrameColor
+ }
+
+ Loader {
+ sourceComponent: optionText !== "Exit"
+ ? optionsListView.checkBoxComponent : optionsListView.exitComponent
+ anchors.fill: parent
+ anchors.leftMargin: menuMargins
+
+ property string optionText: optionsListView.model[index].name
+ property int optionIndex: index
+ }
+ }
+
+ property Component checkBoxComponent: Item {
+ Label {
+ text: optionText
+ font.family: Flat.FlatStyle.fontFamily
+ font.pixelSize: Math.round(15 * Flat.FlatStyle.scaleFactor)
+ fontSizeMode: Text.Fit
+ renderType: Text.QtRendering
+ verticalAlignment: Text.AlignVCenter
+ color: Flat.FlatStyle.defaultTextColor
+ height: parent.height
+ anchors.left: parent.left
+ anchors.right: checkBox.left
+ anchors.rightMargin: Flat.FlatStyle.twoPixels
+ }
+
+ CheckBox {
+ id: checkBox
+ checked: optionsListView.model[optionIndex].action.checked
+ anchors.right: parent.right
+ anchors.rightMargin: menuMargins
+ anchors.verticalCenter: parent.verticalCenter
+ onCheckedChanged: optionsListView.model[optionIndex].action.checked = checkBox.checked
+ }
+ }
+
+ property Component exitComponent: MouseArea {
+ anchors.fill: parent
+ onClicked: Qt.quit()
+
+ Label {
+ text: optionText
+ font.family: Flat.FlatStyle.fontFamily
+ font.pixelSize: Math.round(15 * Flat.FlatStyle.scaleFactor)
+ renderType: Text.QtRendering
+ color: Flat.FlatStyle.defaultTextColor
+ anchors.verticalCenter: parent.verticalCenter
+ }
+ }
+
+ Rectangle {
+ width: parent.height
+ height: 8 * Flat.FlatStyle.scaleFactor
+ rotation: -90
+ anchors.right: parent.left
+ transformOrigin: Item.TopRight
+
+ gradient: Gradient {
+ GradientStop {
+ color: Qt.rgba(0, 0, 0, 0.15)
+ position: 0
+ }
+ GradientStop {
+ color: Qt.rgba(0, 0, 0, 0.05)
+ position: 0.5
+ }
+ GradientStop {
+ color: Qt.rgba(0, 0, 0, 0)
+ position: 1
+ }
+ }
+ }
+ }
+ }
+ }
+}