From 92ee9380d360ca1c01c351ed6d5106e1799b0889 Mon Sep 17 00:00:00 2001 From: Andy Nichols Date: Mon, 1 Dec 2014 11:02:18 +0100 Subject: Support Flat style and add new Controls demo The Flat style for Qt Quick Controls is now enabled by defualt for the launcher and there are a few places that needed to be tweeked for use the correct style. In addition there is a new controls demo that shows off both the Enterprise Controls from before along side the existing controls, but both using the new Flat style which is only available to customers and is intended for touch devices. So we add one new demo, and disable 2 others (via exclude.txt) Change-Id: I8aa6ddd7d48375fdf64150b0c5e2d451da07d00d Reviewed-by: Eirik Aavitsland --- basicsuite/enterprise-flat-controls/Content.qml | 665 +++++++++++++++++++++ .../enterprise-flat-controls/SettingsIcon.qml | 98 +++ .../enterprise-flat-controls/description.txt | 1 + .../enterprise-flat-controls.pro | 15 + .../images/piemenu-bw-normal.png | Bin 0 -> 1716 bytes .../images/piemenu-bw-pressed.png | Bin 0 -> 1394 bytes .../images/piemenu-image-bw.jpg | Bin 0 -> 1065560 bytes .../images/piemenu-image-rgb.jpg | Bin 0 -> 1152261 bytes .../images/piemenu-image-sepia.jpg | Bin 0 -> 1513238 bytes .../images/piemenu-rgb-normal.png | Bin 0 -> 1665 bytes .../images/piemenu-rgb-pressed.png | Bin 0 -> 1571 bytes .../images/piemenu-sepia-normal.png | Bin 0 -> 1410 bytes .../images/piemenu-sepia-pressed.png | Bin 0 -> 1386 bytes basicsuite/enterprise-flat-controls/main.cpp | 35 ++ basicsuite/enterprise-flat-controls/main.qml | 447 ++++++++++++++ basicsuite/enterprise-flat-controls/preview_l.jpg | Bin 0 -> 43851 bytes basicsuite/enterprise-flat-controls/title.txt | 1 + 17 files changed, 1262 insertions(+) create mode 100644 basicsuite/enterprise-flat-controls/Content.qml create mode 100644 basicsuite/enterprise-flat-controls/SettingsIcon.qml create mode 100644 basicsuite/enterprise-flat-controls/description.txt create mode 100644 basicsuite/enterprise-flat-controls/enterprise-flat-controls.pro create mode 100644 basicsuite/enterprise-flat-controls/images/piemenu-bw-normal.png create mode 100644 basicsuite/enterprise-flat-controls/images/piemenu-bw-pressed.png create mode 100644 basicsuite/enterprise-flat-controls/images/piemenu-image-bw.jpg create mode 100644 basicsuite/enterprise-flat-controls/images/piemenu-image-rgb.jpg create mode 100644 basicsuite/enterprise-flat-controls/images/piemenu-image-sepia.jpg create mode 100644 basicsuite/enterprise-flat-controls/images/piemenu-rgb-normal.png create mode 100644 basicsuite/enterprise-flat-controls/images/piemenu-rgb-pressed.png create mode 100644 basicsuite/enterprise-flat-controls/images/piemenu-sepia-normal.png create mode 100644 basicsuite/enterprise-flat-controls/images/piemenu-sepia-pressed.png create mode 100644 basicsuite/enterprise-flat-controls/main.cpp create mode 100644 basicsuite/enterprise-flat-controls/main.qml create mode 100644 basicsuite/enterprise-flat-controls/preview_l.jpg create mode 100644 basicsuite/enterprise-flat-controls/title.txt (limited to 'basicsuite/enterprise-flat-controls') diff --git a/basicsuite/enterprise-flat-controls/Content.qml b/basicsuite/enterprise-flat-controls/Content.qml new file mode 100644 index 0000000..51569ce --- /dev/null +++ b/basicsuite/enterprise-flat-controls/Content.qml @@ -0,0 +1,665 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the QtQuick Enterprise Controls Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.4 +import QtQuick.Layouts 1.1 +import QtQuick.Controls 1.2 +import QtQuick.Controls.Styles.Flat 1.0 as Flat +import QtQuick.Enterprise.Controls 1.3 +import QtQuick.Enterprise.Controls.Styles 1.3 +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 + 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 + } + } + } + } + } + } + } + } + } + + 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 + Image { + id: pieMenuImage + source: "images/piemenu-image-rgb.jpg" + fillMode: Image.PreserveAspectFit + anchors.fill: parent + } + PinchArea { + anchors.fill: parent + pinch.target: pieMenuImage + pinch.minimumScale: 0.5 + pinch.maximumScale: 3 + + MouseArea { + id: mouseArea + anchors.fill: parent + onPressAndHold: pieMenu.popup(mouse.x, mouse.y) + } + } + PieMenu { + id: pieMenu + triggerMode: TriggerMode.TriggerOnClick + + MenuItem { + iconSource: "images/piemenu-rgb-" + (pieMenu.currentIndex === 0 ? "pressed" : "normal") + ".png" + onTriggered: pieMenuImage.source = "images/piemenu-image-rgb.jpg" + } + MenuItem { + iconSource: "images/piemenu-bw-" + (pieMenu.currentIndex === 1 ? "pressed" : "normal") + ".png" + onTriggered: pieMenuImage.source = "images/piemenu-image-bw.jpg" + } + MenuItem { + iconSource: "images/piemenu-sepia-" + (pieMenu.currentIndex === 2 ? "pressed" : "normal") + ".png" + onTriggered: pieMenuImage.source = "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/basicsuite/enterprise-flat-controls/SettingsIcon.qml b/basicsuite/enterprise-flat-controls/SettingsIcon.qml new file mode 100644 index 0000000..376a3ca --- /dev/null +++ b/basicsuite/enterprise-flat-controls/SettingsIcon.qml @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the QtQuick Enterprise Controls Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $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/basicsuite/enterprise-flat-controls/description.txt b/basicsuite/enterprise-flat-controls/description.txt new file mode 100644 index 0000000..81038e7 --- /dev/null +++ b/basicsuite/enterprise-flat-controls/description.txt @@ -0,0 +1 @@ +The Flat Style Gallery example showcases the Qt Quick Controls. This demo combines both the standard Qt Quick Controls as well as the Qt Quick Enterprise Controls both of which are using the new Flat style. The Flat style for Qt Quick Controls has a modern look and feel and is perfect for the touch driven interfaces commonly developed by device creators. diff --git a/basicsuite/enterprise-flat-controls/enterprise-flat-controls.pro b/basicsuite/enterprise-flat-controls/enterprise-flat-controls.pro new file mode 100644 index 0000000..accbc9d --- /dev/null +++ b/basicsuite/enterprise-flat-controls/enterprise-flat-controls.pro @@ -0,0 +1,15 @@ +TARGET = enterprise-gallery + +include(../shared/shared.pri) +b2qtdemo_deploy_defaults() + +content.files = \ + *.qml \ + qml \ + fonts \ + images +content.path = $$DESTPATH + +OTHER_FILES += $${content.files} + +INSTALLS += target content diff --git a/basicsuite/enterprise-flat-controls/images/piemenu-bw-normal.png b/basicsuite/enterprise-flat-controls/images/piemenu-bw-normal.png new file mode 100644 index 0000000..ef57111 Binary files /dev/null and b/basicsuite/enterprise-flat-controls/images/piemenu-bw-normal.png differ diff --git a/basicsuite/enterprise-flat-controls/images/piemenu-bw-pressed.png b/basicsuite/enterprise-flat-controls/images/piemenu-bw-pressed.png new file mode 100644 index 0000000..b6bd1d2 Binary files /dev/null and b/basicsuite/enterprise-flat-controls/images/piemenu-bw-pressed.png differ diff --git a/basicsuite/enterprise-flat-controls/images/piemenu-image-bw.jpg b/basicsuite/enterprise-flat-controls/images/piemenu-image-bw.jpg new file mode 100644 index 0000000..ce4d8ff Binary files /dev/null and b/basicsuite/enterprise-flat-controls/images/piemenu-image-bw.jpg differ diff --git a/basicsuite/enterprise-flat-controls/images/piemenu-image-rgb.jpg b/basicsuite/enterprise-flat-controls/images/piemenu-image-rgb.jpg new file mode 100644 index 0000000..2d7d220 Binary files /dev/null and b/basicsuite/enterprise-flat-controls/images/piemenu-image-rgb.jpg differ diff --git a/basicsuite/enterprise-flat-controls/images/piemenu-image-sepia.jpg b/basicsuite/enterprise-flat-controls/images/piemenu-image-sepia.jpg new file mode 100644 index 0000000..3ef7b1f Binary files /dev/null and b/basicsuite/enterprise-flat-controls/images/piemenu-image-sepia.jpg differ diff --git a/basicsuite/enterprise-flat-controls/images/piemenu-rgb-normal.png b/basicsuite/enterprise-flat-controls/images/piemenu-rgb-normal.png new file mode 100644 index 0000000..2278f4a Binary files /dev/null and b/basicsuite/enterprise-flat-controls/images/piemenu-rgb-normal.png differ diff --git a/basicsuite/enterprise-flat-controls/images/piemenu-rgb-pressed.png b/basicsuite/enterprise-flat-controls/images/piemenu-rgb-pressed.png new file mode 100644 index 0000000..f45846b Binary files /dev/null and b/basicsuite/enterprise-flat-controls/images/piemenu-rgb-pressed.png differ diff --git a/basicsuite/enterprise-flat-controls/images/piemenu-sepia-normal.png b/basicsuite/enterprise-flat-controls/images/piemenu-sepia-normal.png new file mode 100644 index 0000000..f1e9ffd Binary files /dev/null and b/basicsuite/enterprise-flat-controls/images/piemenu-sepia-normal.png differ diff --git a/basicsuite/enterprise-flat-controls/images/piemenu-sepia-pressed.png b/basicsuite/enterprise-flat-controls/images/piemenu-sepia-pressed.png new file mode 100644 index 0000000..0f2b351 Binary files /dev/null and b/basicsuite/enterprise-flat-controls/images/piemenu-sepia-pressed.png differ diff --git a/basicsuite/enterprise-flat-controls/main.cpp b/basicsuite/enterprise-flat-controls/main.cpp new file mode 100644 index 0000000..013e574 --- /dev/null +++ b/basicsuite/enterprise-flat-controls/main.cpp @@ -0,0 +1,35 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the QtQuick Enterprise Controls Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include + +int main(int argc, char *argv[]) +{ + QGuiApplication app(argc, argv); + if (qgetenv("QT_QUICK_CONTROLS_STYLE").isEmpty()) { + qputenv("QT_QUICK_CONTROLS_STYLE", "Flat"); + } + QQmlApplicationEngine engine; + engine.load(QUrl("qrc:/main.qml")); + return app.exec(); +} diff --git a/basicsuite/enterprise-flat-controls/main.qml b/basicsuite/enterprise-flat-controls/main.qml new file mode 100644 index 0000000..0b9f4e9 --- /dev/null +++ b/basicsuite/enterprise-flat-controls/main.qml @@ -0,0 +1,447 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the QtQuick Enterprise Controls Add-on. +** +** $QT_BEGIN_LICENSE$ +** Licensees holding valid Qt Commercial licenses may use this file in +** accordance with the Qt Commercial License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** $QT_END_LICENSE$ +** +****************************************************************************/ + +import QtQuick 2.4 +import QtQuick.Layouts 1.0 +import QtQuick.Controls 1.2 +import QtQuick.Controls.Styles.Flat 1.0 as Flat +import QtQuick.Enterprise.Controls 1.3 +import QtQuick.Enterprise.Controls.Styles 1.3 +import QtQuick.Enterprise.Controls.Private 1.0 + +Rectangle { + id: window + color: "white" + 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..." +// 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 + 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.defaultColor + + Label { + text: "Controls" + font.family: Flat.FlatStyle.fontFamily + font.pixelSize: Math.round(16 * Flat.FlatStyle.scaleFactor) + 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: { + controlView.currentIndex = controlView.currentIndex == index ? 0 : index; + currentMenu = -1; + } + + Rectangle { + width: parent.width + height: Flat.FlatStyle.onePixel + anchors.bottom: parent.bottom + color: "#cccccc" + } + + Label { + text: delegateItem.ListView.view.model[index].name + font.pixelSize: Math.round(15 * Flat.FlatStyle.scaleFactor) + font.family: Flat.FlatStyle.fontFamily + color: delegateItem.ListView.isCurrentItem ? Flat.FlatStyle.styleColor : Flat.FlatStyle.defaultColor + 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 + 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.defaultColor + } + } + } + } + + Text { + text: "Qt Quick Controls" + 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 + source: "Content.qml" + + 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 + hoverEnabled: true + anchors.fill: parent + preventStealing: true + onClicked: currentMenu = -1 + focus: enabled + z: 1000 + } + } + } + + Rectangle { + id: settingsMenu + width: menuWidth + height: parent.height + anchors.left: contentContainer.right + + Rectangle { + id: optionsTitleBar + width: parent.width + height: toolBar.height + color: Flat.FlatStyle.defaultColor + + Label { + text: "Options" + font.family: Flat.FlatStyle.fontFamily + font.pixelSize: Math.round(16 * Flat.FlatStyle.scaleFactor) + 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 }, + ] + delegate: Rectangle { + id: optionDelegateItem + width: parent.width + height: optionsListView.delegateHeight + + Rectangle { + width: parent.width + height: Flat.FlatStyle.onePixel + anchors.bottom: parent.bottom + color: "#cccccc" + } + + 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 + anchors.left: parent.left + anchors.right: checkBox.left + anchors.rightMargin: Flat.FlatStyle.twoPixels + height: parent.height + font.family: Flat.FlatStyle.fontFamily + font.pixelSize: Math.round(15 * Flat.FlatStyle.scaleFactor) + fontSizeMode: Text.Fit + verticalAlignment: Text.AlignVCenter + color: Flat.FlatStyle.defaultColor + } + + 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) + anchors.verticalCenter: parent.verticalCenter + color: Flat.FlatStyle.defaultColor + } + } + + 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 + } + } + } + } + } + } +} diff --git a/basicsuite/enterprise-flat-controls/preview_l.jpg b/basicsuite/enterprise-flat-controls/preview_l.jpg new file mode 100644 index 0000000..7791a76 Binary files /dev/null and b/basicsuite/enterprise-flat-controls/preview_l.jpg differ diff --git a/basicsuite/enterprise-flat-controls/title.txt b/basicsuite/enterprise-flat-controls/title.txt new file mode 100644 index 0000000..118f0e0 --- /dev/null +++ b/basicsuite/enterprise-flat-controls/title.txt @@ -0,0 +1 @@ +070. Qt Quick Controls - Flat Style Gallery -- cgit v1.2.3