aboutsummaryrefslogtreecommitdiffstats
path: root/examples/labs/controls/theme
diff options
context:
space:
mode:
Diffstat (limited to 'examples/labs/controls/theme')
-rw-r--r--examples/labs/controls/theme/main.cpp52
-rw-r--r--examples/labs/controls/theme/main.qml175
-rw-r--r--examples/labs/controls/theme/theme.pro15
-rw-r--r--examples/labs/controls/theme/theme.qrc5
4 files changed, 247 insertions, 0 deletions
diff --git a/examples/labs/controls/theme/main.cpp b/examples/labs/controls/theme/main.cpp
new file mode 100644
index 00000000..2abdc16d
--- /dev/null
+++ b/examples/labs/controls/theme/main.cpp
@@ -0,0 +1,52 @@
+/****************************************************************************
+**
+** 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$
+**
+****************************************************************************/
+
+#include <QGuiApplication>
+#include <QQmlApplicationEngine>
+
+int main(int argc, char *argv[])
+{
+ QGuiApplication app(argc, argv);
+ QQmlApplicationEngine engine;
+ engine.load(QUrl("qrc:/main.qml"));
+ if (engine.rootObjects().isEmpty())
+ return -1;
+ return app.exec();
+}
diff --git a/examples/labs/controls/theme/main.qml b/examples/labs/controls/theme/main.qml
new file mode 100644
index 00000000..d3a3f7a0
--- /dev/null
+++ b/examples/labs/controls/theme/main.qml
@@ -0,0 +1,175 @@
+/****************************************************************************
+**
+** 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 Qt.labs.controls 1.0
+import Qt.labs.templates 1.0 as T
+
+ApplicationWindow {
+ id: window
+ width: 360
+ height: 520
+ visible: true
+ title: "Qt Labs Controls - Theme Example"
+
+ header: ToolBar {
+ ToolButton {
+ label: Text {
+ // \u25C0 (black left-pointing triangle is) missing in some fonts
+ // => use a rotated \u25B2 (black up-pointing triangle) instead
+ text: "\u25B2"
+ rotation: -90
+ color: enabled ? Theme.accentColor : Theme.frameColor
+ anchors.centerIn: parent
+ }
+ enabled: stackview.depth > 1
+ onClicked: stackview.pop()
+ }
+ }
+
+ StackView {
+ id: stackview
+ anchors.fill: parent
+ initialItem: pageComponent
+ }
+
+ Component {
+ id: pageComponent
+ Rectangle {
+ id: page
+ Theme.accentColor: Qt.hsla(colorSlider.position, 0.5, 0.5, 1.0)
+ Theme.backgroundColor: darkButton.checked ? "#444" : "#fff"
+ Theme.frameColor: darkButton.checked ? "#666" : "#ccc"
+ Theme.textColor: darkButton.checked ? "#eee" : "#111"
+ Theme.pressColor: darkButton.checked ? "#33ffffff" : "#33333333"
+ Theme.baseColor: darkButton.checked ? "#444" : "#eee"
+ color: Theme.backgroundColor
+ Flickable {
+ anchors.fill: parent
+ contentHeight: column.height + 48
+
+ Column {
+ id: column
+
+ x: (window.width - width) / 2
+ y: 24
+ width: window.width / 2
+ spacing: 12
+
+ Label {
+ text: "Code less. Create more."
+ color: Theme.accentColor
+ width: parent.width
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
+ wrapMode: Text.WordWrap
+ font.pointSize: 26
+ }
+
+ Item { width: 1; height: 48 }
+
+ Rectangle {
+ width: parent.width
+ height: 1
+ color: Theme.frameColor
+ }
+
+ Column {
+ spacing: 6
+ width: parent.width
+ Label {
+ text: "Accent color"
+ color: Theme.textColor
+ }
+ Slider {
+ id: colorSlider
+ width: parent.width
+ value: 0.275
+ }
+ }
+
+ Rectangle {
+ width: parent.width
+ height: 1
+ color: Theme.frameColor
+ }
+
+ ExclusiveGroup {
+ id: themeGroup
+ }
+
+ Column {
+ width: parent.width
+ spacing: 6
+ RadioButton {
+ id: lightButton
+ text: "Light"
+ width: parent.width
+ checked: true
+ layoutDirection: Qt.RightToLeft
+ ExclusiveGroup.group: themeGroup
+ }
+ RadioButton {
+ id: darkButton
+ text: "Dark"
+ width: parent.width
+ layoutDirection: Qt.RightToLeft
+ ExclusiveGroup.group: themeGroup
+ }
+ }
+
+ Rectangle {
+ width: parent.width
+ height: 1
+ color: Theme.frameColor
+ }
+
+ Button {
+ text: "Push"
+ anchors.right: parent.right
+ onClicked: stackview.push(pageComponent)
+ }
+ }
+
+ T.ScrollIndicator.vertical: ScrollIndicator { }
+ }
+ }
+ }
+}
diff --git a/examples/labs/controls/theme/theme.pro b/examples/labs/controls/theme/theme.pro
new file mode 100644
index 00000000..7672a2cb
--- /dev/null
+++ b/examples/labs/controls/theme/theme.pro
@@ -0,0 +1,15 @@
+TEMPLATE = app
+TARGET = theme
+QT += quick
+
+SOURCES += \
+ main.cpp
+
+OTHER_FILES += \
+ main.qml
+
+RESOURCES += \
+ theme.qrc
+
+target.path = $$[QT_INSTALL_EXAMPLES]/labs/controls/theme
+INSTALLS += target
diff --git a/examples/labs/controls/theme/theme.qrc b/examples/labs/controls/theme/theme.qrc
new file mode 100644
index 00000000..5f6483ac
--- /dev/null
+++ b/examples/labs/controls/theme/theme.qrc
@@ -0,0 +1,5 @@
+<RCC>
+ <qresource prefix="/">
+ <file>main.qml</file>
+ </qresource>
+</RCC>