2015-12-14 18:06:53 +00:00
|
|
|
/****************************************************************************
|
|
|
|
**
|
|
|
|
** Copyright (C) 2015 The Qt Company Ltd.
|
|
|
|
** Contact: http://www.qt.io/licensing/
|
|
|
|
**
|
|
|
|
** This file is part of the examples of the Qt Toolkit.
|
|
|
|
**
|
|
|
|
** $QT_BEGIN_LICENSE:BSD$
|
|
|
|
** 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.6
|
|
|
|
import QtQuick.Layouts 1.3
|
2016-05-21 08:17:39 +00:00
|
|
|
import QtQuick.Controls 2.1
|
2016-07-07 14:04:29 +00:00
|
|
|
import QtQuick.Controls.Material 2.1
|
|
|
|
import QtQuick.Controls.Universal 2.1
|
2015-12-14 18:06:53 +00:00
|
|
|
import Qt.labs.settings 1.0
|
|
|
|
|
|
|
|
ApplicationWindow {
|
|
|
|
id: window
|
|
|
|
width: 360
|
|
|
|
height: 520
|
|
|
|
visible: true
|
2016-04-04 10:29:07 +00:00
|
|
|
title: "Qt Quick Controls 2"
|
2015-12-14 18:06:53 +00:00
|
|
|
|
|
|
|
Settings {
|
|
|
|
id: settings
|
2016-06-15 12:28:58 +00:00
|
|
|
property string style: "Default"
|
2015-12-14 18:06:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
header: ToolBar {
|
2016-05-24 12:07:26 +00:00
|
|
|
Material.foreground: "white"
|
|
|
|
|
2015-12-14 18:06:53 +00:00
|
|
|
RowLayout {
|
|
|
|
spacing: 20
|
|
|
|
anchors.fill: parent
|
|
|
|
|
|
|
|
ToolButton {
|
2016-02-05 14:40:42 +00:00
|
|
|
contentItem: Image {
|
|
|
|
fillMode: Image.Pad
|
|
|
|
horizontalAlignment: Image.AlignHCenter
|
|
|
|
verticalAlignment: Image.AlignVCenter
|
2016-09-24 11:31:08 +00:00
|
|
|
source: stackView.depth > 1 ? "images/back.png" : "images/drawer.png"
|
|
|
|
}
|
|
|
|
onClicked: {
|
|
|
|
if (stackView.depth > 1) {
|
|
|
|
stackView.pop()
|
|
|
|
listView.currentIndex = -1
|
|
|
|
} else {
|
|
|
|
drawer.open()
|
|
|
|
}
|
2015-12-14 18:06:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Label {
|
|
|
|
id: titleLabel
|
2016-09-24 11:31:08 +00:00
|
|
|
text: listView.currentItem ? listView.currentItem.text : "Gallery"
|
2015-12-14 18:06:53 +00:00
|
|
|
font.pixelSize: 20
|
|
|
|
elide: Label.ElideRight
|
|
|
|
horizontalAlignment: Qt.AlignHCenter
|
|
|
|
verticalAlignment: Qt.AlignVCenter
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
|
|
|
|
|
|
|
ToolButton {
|
2016-02-05 14:40:42 +00:00
|
|
|
contentItem: Image {
|
|
|
|
fillMode: Image.Pad
|
|
|
|
horizontalAlignment: Image.AlignHCenter
|
|
|
|
verticalAlignment: Image.AlignVCenter
|
2015-12-14 18:06:53 +00:00
|
|
|
source: "qrc:/images/menu.png"
|
|
|
|
}
|
|
|
|
onClicked: optionsMenu.open()
|
2016-01-22 14:20:04 +00:00
|
|
|
|
|
|
|
Menu {
|
|
|
|
id: optionsMenu
|
|
|
|
x: parent.width - width
|
2016-01-25 10:49:24 +00:00
|
|
|
transformOrigin: Menu.TopRight
|
2016-01-22 14:20:04 +00:00
|
|
|
|
|
|
|
MenuItem {
|
|
|
|
text: "Settings"
|
2016-05-21 08:17:39 +00:00
|
|
|
onTriggered: settingsDialog.open()
|
2016-01-22 14:20:04 +00:00
|
|
|
}
|
|
|
|
MenuItem {
|
|
|
|
text: "About"
|
|
|
|
onTriggered: aboutDialog.open()
|
|
|
|
}
|
|
|
|
}
|
2015-12-14 18:06:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Drawer {
|
|
|
|
id: drawer
|
2016-02-26 12:52:56 +00:00
|
|
|
width: Math.min(window.width, window.height) / 3 * 2
|
|
|
|
height: window.height
|
2016-09-24 11:31:08 +00:00
|
|
|
dragMargin: stackView.depth > 1 ? 0 : undefined
|
2015-12-14 18:06:53 +00:00
|
|
|
|
2016-02-26 12:52:56 +00:00
|
|
|
ListView {
|
|
|
|
id: listView
|
|
|
|
currentIndex: -1
|
|
|
|
anchors.fill: parent
|
2015-12-14 18:06:53 +00:00
|
|
|
|
2016-02-26 12:52:56 +00:00
|
|
|
delegate: ItemDelegate {
|
|
|
|
width: parent.width
|
|
|
|
text: model.title
|
|
|
|
highlighted: ListView.isCurrentItem
|
|
|
|
onClicked: {
|
|
|
|
if (listView.currentIndex != index) {
|
|
|
|
listView.currentIndex = index
|
2016-09-24 11:31:08 +00:00
|
|
|
stackView.push(model.source)
|
2016-02-26 12:52:56 +00:00
|
|
|
}
|
|
|
|
drawer.close()
|
2015-12-14 18:06:53 +00:00
|
|
|
}
|
2016-02-26 12:52:56 +00:00
|
|
|
}
|
2015-12-14 18:06:53 +00:00
|
|
|
|
2016-02-26 12:52:56 +00:00
|
|
|
model: ListModel {
|
|
|
|
ListElement { title: "BusyIndicator"; source: "qrc:/pages/BusyIndicatorPage.qml" }
|
|
|
|
ListElement { title: "Button"; source: "qrc:/pages/ButtonPage.qml" }
|
|
|
|
ListElement { title: "CheckBox"; source: "qrc:/pages/CheckBoxPage.qml" }
|
|
|
|
ListElement { title: "ComboBox"; source: "qrc:/pages/ComboBoxPage.qml" }
|
|
|
|
ListElement { title: "Dial"; source: "qrc:/pages/DialPage.qml" }
|
|
|
|
ListElement { title: "Delegates"; source: "qrc:/pages/DelegatePage.qml" }
|
|
|
|
ListElement { title: "Drawer"; source: "qrc:/pages/DrawerPage.qml" }
|
|
|
|
ListElement { title: "Frame"; source: "qrc:/pages/FramePage.qml" }
|
|
|
|
ListElement { title: "GroupBox"; source: "qrc:/pages/GroupBoxPage.qml" }
|
|
|
|
ListElement { title: "Menu"; source: "qrc:/pages/MenuPage.qml" }
|
|
|
|
ListElement { title: "PageIndicator"; source: "qrc:/pages/PageIndicatorPage.qml" }
|
|
|
|
ListElement { title: "Popup"; source: "qrc:/pages/PopupPage.qml" }
|
|
|
|
ListElement { title: "ProgressBar"; source: "qrc:/pages/ProgressBarPage.qml" }
|
|
|
|
ListElement { title: "RadioButton"; source: "qrc:/pages/RadioButtonPage.qml" }
|
|
|
|
ListElement { title: "RangeSlider"; source: "qrc:/pages/RangeSliderPage.qml" }
|
|
|
|
ListElement { title: "ScrollBar"; source: "qrc:/pages/ScrollBarPage.qml" }
|
|
|
|
ListElement { title: "ScrollIndicator"; source: "qrc:/pages/ScrollIndicatorPage.qml" }
|
|
|
|
ListElement { title: "Slider"; source: "qrc:/pages/SliderPage.qml" }
|
|
|
|
ListElement { title: "SpinBox"; source: "qrc:/pages/SpinBoxPage.qml" }
|
|
|
|
ListElement { title: "StackView"; source: "qrc:/pages/StackViewPage.qml" }
|
|
|
|
ListElement { title: "SwipeView"; source: "qrc:/pages/SwipeViewPage.qml" }
|
|
|
|
ListElement { title: "Switch"; source: "qrc:/pages/SwitchPage.qml" }
|
|
|
|
ListElement { title: "TabBar"; source: "qrc:/pages/TabBarPage.qml" }
|
|
|
|
ListElement { title: "TextArea"; source: "qrc:/pages/TextAreaPage.qml" }
|
|
|
|
ListElement { title: "TextField"; source: "qrc:/pages/TextFieldPage.qml" }
|
|
|
|
ListElement { title: "ToolTip"; source: "qrc:/pages/ToolTipPage.qml" }
|
|
|
|
ListElement { title: "Tumbler"; source: "qrc:/pages/TumblerPage.qml" }
|
2015-12-14 18:06:53 +00:00
|
|
|
}
|
2016-02-26 12:52:56 +00:00
|
|
|
|
|
|
|
ScrollIndicator.vertical: ScrollIndicator { }
|
2015-12-14 18:06:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
StackView {
|
|
|
|
id: stackView
|
|
|
|
anchors.fill: parent
|
|
|
|
|
|
|
|
initialItem: Pane {
|
|
|
|
id: pane
|
|
|
|
|
|
|
|
Image {
|
|
|
|
id: logo
|
|
|
|
width: pane.availableWidth / 2
|
|
|
|
height: pane.availableHeight / 2
|
|
|
|
anchors.centerIn: parent
|
|
|
|
anchors.verticalCenterOffset: -50
|
|
|
|
fillMode: Image.PreserveAspectFit
|
|
|
|
source: "qrc:/images/qt-logo.png"
|
|
|
|
}
|
|
|
|
|
|
|
|
Label {
|
2016-04-04 10:29:07 +00:00
|
|
|
text: "Qt Quick Controls 2 provides a set of controls that can be used to build complete interfaces in Qt Quick."
|
2015-12-14 18:06:53 +00:00
|
|
|
anchors.margins: 20
|
|
|
|
anchors.top: logo.bottom
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.right: parent.right
|
|
|
|
anchors.bottom: arrow.top
|
|
|
|
horizontalAlignment: Label.AlignHCenter
|
|
|
|
verticalAlignment: Label.AlignVCenter
|
|
|
|
wrapMode: Label.Wrap
|
|
|
|
}
|
|
|
|
|
|
|
|
Image {
|
|
|
|
id: arrow
|
|
|
|
source: "qrc:/images/arrow.png"
|
|
|
|
anchors.left: parent.left
|
|
|
|
anchors.bottom: parent.bottom
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-15 20:04:24 +00:00
|
|
|
Dialog {
|
2016-05-21 08:17:39 +00:00
|
|
|
id: settingsDialog
|
2016-07-15 14:02:47 +00:00
|
|
|
x: Math.round((window.width - width) / 2)
|
|
|
|
y: Math.round(window.height / 6)
|
|
|
|
width: Math.round(Math.min(window.width, window.height) / 3 * 2)
|
2015-12-14 18:06:53 +00:00
|
|
|
modal: true
|
|
|
|
focus: true
|
|
|
|
|
2016-06-15 20:04:24 +00:00
|
|
|
standardButtons: Dialog.Ok | Dialog.Cancel
|
|
|
|
onAccepted: {
|
|
|
|
settings.style = styleBox.displayText
|
|
|
|
settingsDialog.close()
|
|
|
|
}
|
|
|
|
onRejected: {
|
|
|
|
styleBox.currentIndex = styleBox.styleIndex
|
|
|
|
settingsDialog.close()
|
|
|
|
}
|
|
|
|
|
2016-01-22 11:10:12 +00:00
|
|
|
contentItem: ColumnLayout {
|
|
|
|
id: settingsColumn
|
|
|
|
spacing: 20
|
2015-12-14 18:06:53 +00:00
|
|
|
|
2016-01-22 11:10:12 +00:00
|
|
|
Label {
|
|
|
|
text: "Settings"
|
|
|
|
font.bold: true
|
|
|
|
}
|
2015-12-14 18:06:53 +00:00
|
|
|
|
2016-01-22 11:10:12 +00:00
|
|
|
RowLayout {
|
|
|
|
spacing: 10
|
2015-12-14 18:06:53 +00:00
|
|
|
|
|
|
|
Label {
|
2016-01-22 11:10:12 +00:00
|
|
|
text: "Style:"
|
2015-12-14 18:06:53 +00:00
|
|
|
}
|
|
|
|
|
2016-01-22 11:10:12 +00:00
|
|
|
ComboBox {
|
|
|
|
id: styleBox
|
|
|
|
property int styleIndex: -1
|
|
|
|
model: ["Default", "Material", "Universal"]
|
|
|
|
Component.onCompleted: {
|
2016-03-15 14:32:54 +00:00
|
|
|
styleIndex = find(settings.style, Qt.MatchFixedString)
|
2016-01-22 11:10:12 +00:00
|
|
|
if (styleIndex !== -1)
|
|
|
|
currentIndex = styleIndex
|
2015-12-14 18:06:53 +00:00
|
|
|
}
|
|
|
|
Layout.fillWidth: true
|
|
|
|
}
|
2016-01-22 11:10:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Label {
|
|
|
|
text: "Restart required"
|
2016-01-28 10:26:16 +00:00
|
|
|
color: "#e41e25"
|
2016-01-22 11:10:12 +00:00
|
|
|
opacity: styleBox.currentIndex !== styleBox.styleIndex ? 1.0 : 0.0
|
|
|
|
horizontalAlignment: Label.AlignHCenter
|
|
|
|
verticalAlignment: Label.AlignVCenter
|
|
|
|
Layout.fillWidth: true
|
|
|
|
Layout.fillHeight: true
|
|
|
|
}
|
2015-12-14 18:06:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-15 20:04:24 +00:00
|
|
|
Dialog {
|
2015-12-14 18:06:53 +00:00
|
|
|
id: aboutDialog
|
|
|
|
modal: true
|
|
|
|
focus: true
|
2016-01-22 11:10:12 +00:00
|
|
|
x: (window.width - width) / 2
|
2016-01-23 13:16:22 +00:00
|
|
|
y: window.height / 6
|
2016-01-22 11:10:12 +00:00
|
|
|
width: Math.min(window.width, window.height) / 3 * 2
|
2016-01-23 13:16:22 +00:00
|
|
|
contentHeight: aboutColumn.height
|
2015-12-14 18:06:53 +00:00
|
|
|
|
2016-01-23 13:16:22 +00:00
|
|
|
Column {
|
2016-01-22 11:10:12 +00:00
|
|
|
id: aboutColumn
|
|
|
|
spacing: 20
|
2015-12-14 18:06:53 +00:00
|
|
|
|
2016-01-22 11:10:12 +00:00
|
|
|
Label {
|
|
|
|
text: "About"
|
|
|
|
font.bold: true
|
|
|
|
}
|
2015-12-14 18:06:53 +00:00
|
|
|
|
2016-01-22 11:10:12 +00:00
|
|
|
Label {
|
2016-01-23 13:16:22 +00:00
|
|
|
width: aboutDialog.availableWidth
|
2016-04-13 08:38:53 +00:00
|
|
|
text: "The Qt Quick Controls 2 module delivers the next generation user interface controls based on Qt Quick."
|
2016-01-22 11:10:12 +00:00
|
|
|
wrapMode: Label.Wrap
|
|
|
|
font.pixelSize: 12
|
|
|
|
}
|
2015-12-14 18:06:53 +00:00
|
|
|
|
2016-01-22 11:10:12 +00:00
|
|
|
Label {
|
2016-01-23 13:16:22 +00:00
|
|
|
width: aboutDialog.availableWidth
|
2016-04-13 08:38:53 +00:00
|
|
|
text: "In comparison to the desktop-oriented Qt Quick Controls 1, Qt Quick Controls 2 "
|
|
|
|
+ "are an order of magnitude simpler, lighter and faster, and are primarily targeted "
|
|
|
|
+ "towards embedded and mobile platforms."
|
2016-01-22 11:10:12 +00:00
|
|
|
wrapMode: Label.Wrap
|
|
|
|
font.pixelSize: 12
|
2015-12-14 18:06:53 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|