From dac9c3f46650ef69a32f09280f3e78f9bba0f77b Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Tue, 27 Oct 2015 09:26:10 +0100 Subject: Make testbench work with all styles Take advantage of file selectors to display different styles. Change-Id: I2722fdbeedd343682622a9eb5084f65f11dee371 Reviewed-by: J-P Nurmi --- tests/manual/testbench/Controls.qml | 367 +++++++++++++++++++++ tests/manual/testbench/main.qml | 362 +------------------- tests/manual/testbench/qml.qrc | 5 +- tests/manual/testbench/styles/+material/Style.qml | 8 + tests/manual/testbench/styles/+universal/Style.qml | 9 + tests/manual/testbench/styles/Style.qml | 12 + 6 files changed, 403 insertions(+), 360 deletions(-) create mode 100644 tests/manual/testbench/Controls.qml create mode 100644 tests/manual/testbench/styles/+material/Style.qml create mode 100644 tests/manual/testbench/styles/+universal/Style.qml create mode 100644 tests/manual/testbench/styles/Style.qml (limited to 'tests') diff --git a/tests/manual/testbench/Controls.qml b/tests/manual/testbench/Controls.qml new file mode 100644 index 00000000..7c9d430e --- /dev/null +++ b/tests/manual/testbench/Controls.qml @@ -0,0 +1,367 @@ +import QtQuick 2.6 +import QtQuick.Layouts 1.2 +import Qt.labs.controls 1.0 + +Rectangle { + id: root + + property alias themeSwitch: themeSwitch + + property int margins: 30 + property int spacing: 10 + + Switch { + id: themeSwitch + text: "Light/Dark" + anchors.right: parent.right + } + + Flow { + id: flow + anchors.fill: parent + anchors.margins: 30 + spacing: 30 + + RowLayout { + BusyIndicator { + } + BusyIndicator { + enabled: false + } + } + + RowLayout { + spacing: root.spacing + + Button { + text: "Normal" + } + Button { + text: "Pressed" + pressed: true + } + Button { + text: "Disabled" + enabled: false + } + } + + RowLayout { + Frame { + Label { + text: "Normal\nLabel" + horizontalAlignment: Text.AlignHCenter + } + } + Frame { + enabled: false + + Label { + text: "Disabled\nLabel" + horizontalAlignment: Text.AlignHCenter + } + } + } + + RowLayout { + CheckBox { + text: "Normal" + } + CheckBox { + text: "Pressed" + pressed: true + } + CheckBox { + text: "Checked" + checked: true + } + CheckBox { + text: "Checked + Pressed" + checked: true + pressed: true + } + CheckBox { + text: "Disabled" + enabled: false + } + } + + RowLayout { + Dial { + } + Dial { + enabled: false + } + } + + RowLayout { + GroupBox { + title: "Normal" + + Item { + implicitWidth: 100 + implicitHeight: 100 + } + } + GroupBox { + enabled: false + title: "Disabled" + + Item { + implicitWidth: 100 + implicitHeight: 100 + } + } + } + + RowLayout { + PageIndicator { + count: 5 + } + PageIndicator { + count: 5 + enabled: false + } + } + + RowLayout { + ProgressBar { + value: 0.5 + } + ProgressBar { + value: 0.5 + enabled: false + } + } + + RowLayout { + RadioButton { + text: "Normal" + } + RadioButton { + text: "Pressed" + pressed: true + } + RadioButton { + text: "Checked" + checked: true + } + RadioButton { + text: "Checked + Pressed" + checked: true + pressed: true + } + RadioButton { + text: "Disabled" + enabled: false + } + } + + RowLayout { + Frame { + Layout.preferredWidth: 100 + Layout.preferredHeight: 100 + + ScrollBar { + size: 0.3 + position: 0.2 + active: true + orientation: Qt.Vertical + height: parent.height + anchors.right: parent.right + } + } + + Frame { + Layout.preferredWidth: 100 + Layout.preferredHeight: 100 + + ScrollBar { + size: 0.3 + position: 0.2 + active: true + orientation: Qt.Vertical + height: parent.height + anchors.right: parent.right + pressed: true + } + } + + Frame { + Layout.preferredWidth: 100 + Layout.preferredHeight: 100 + + ScrollBar { + size: 0.3 + position: 0.2 + active: true + orientation: Qt.Vertical + height: parent.height + anchors.right: parent.right + enabled: false + } + } + } + + RowLayout { + Rectangle { + width: 100 + height: 100 + color: "transparent" + border.color: "#cccccc" + + ScrollIndicator { + size: 0.3 + position: 0.2 + active: true + orientation: Qt.Vertical + height: parent.height + anchors.right: parent.right + } + } + + Rectangle { + width: 100 + height: 100 + color: "transparent" + border.color: "#cccccc" + + ScrollIndicator { + size: 0.3 + position: 0.2 + active: true + orientation: Qt.Vertical + height: parent.height + anchors.right: parent.right + enabled: false + } + } + } + + RowLayout { + Slider { + value: 0.5 + } + Slider { + value: 0.5 + pressed: true + } + Slider { + value: 0.5 + enabled: false + } + } + + RowLayout { + RangeSlider { + first.value: 0.25 + second.value: 0.75 + } + RangeSlider { + first.value: 0.25 + first.pressed: true + second.value: 0.75 + } + RangeSlider { + first.value: 0.25 + second.value: 0.75 + enabled: false + } + } + + RowLayout { + Switch { + text: "Normal" + } + Switch { + text: "Pressed" + pressed: true + } + Switch { + text: "Checked" + checked: true + } + Switch { + text: "Checked + Pressed" + checked: true + pressed: true + } + Switch { + text: "Disabled" + enabled: false + } + } + + RowLayout { + TabBar { + TabButton { + text: "Normal" + } + TabButton { + text: "Pressed" + pressed: true + } + TabButton { + text: "Disabled" + enabled: false + } + } + } + + RowLayout { + TextArea { + text: "Normal" + } + TextArea { + text: "Disabled" + enabled: false + } + } + + RowLayout { + TextField { + text: "Normal" + } + TextField { + text: "Disabled" + enabled: false + } + } + + RowLayout { + ToolBar { + Row { + ToolButton { + text: "Normal!" + } + ToolButton { + text: "Pressed!" + pressed: true + } + ToolButton { + text: "Disabled!" + enabled: false + } + } + } + } + + RowLayout { + Frame { + Tumbler { + model: 5 + implicitWidth: 100 + implicitHeight: 100 + } + } + Frame { + Tumbler { + model: 5 + implicitWidth: 100 + implicitHeight: 100 + enabled: false + } + } + } + } +} diff --git a/tests/manual/testbench/main.qml b/tests/manual/testbench/main.qml index 44d7678d..7de5a529 100644 --- a/tests/manual/testbench/main.qml +++ b/tests/manual/testbench/main.qml @@ -44,370 +44,14 @@ import QtQuick.Layouts 1.0 import Qt.labs.controls 1.0 ApplicationWindow { + id: window visible: true width: 700 height: 1000 - Flow { - id: mainColumn + Loader { anchors.fill: parent - anchors.margins: 30 - spacing: 30 - - RowLayout { - BusyIndicator { - } - BusyIndicator { - enabled: false - } - } - - RowLayout { - Button { - text: "Normal" - } - Button { - text: "Pressed" - pressed: true - } - Button { - text: "Disabled" - enabled: false - } - } - - RowLayout { - CheckBox { - text: "Normal" - } - CheckBox { - text: "Pressed" - pressed: true - } - CheckBox { - text: "Checked" - checked: true - } - CheckBox { - text: "Checked + Pressed" - checked: true - pressed: true - } - CheckBox { - text: "Disabled" - enabled: false - } - } - - RowLayout { - Dial { - } - Dial { - enabled: false - } - } - - RowLayout { - Frame { - Text { - text: "Normal" - } - } - Frame { - enabled: false - - Text { - text: "Disabled" - } - } - } - - RowLayout { - GroupBox { - title: "Normal" - - Item { - width: 100 - height: 20 - } - } - GroupBox { - enabled: false - title: "Disabled" - - Item { - width: 100 - height: 20 - } - } - } - - RowLayout { - Label { - text: "Normal" - } - Label { - text: "Disabled" - enabled: false - } - } - - RowLayout { - PageIndicator { - count: 5 - } - PageIndicator { - count: 5 - enabled: false - } - } - - RowLayout { - ProgressBar { - value: 0.5 - } - ProgressBar { - value: 0.5 - enabled: false - } - } - - RowLayout { - RadioButton { - text: "Normal" - } - RadioButton { - text: "Pressed" - pressed: true - } - RadioButton { - text: "Checked" - checked: true - } - RadioButton { - text: "Checked + Pressed" - checked: true - pressed: true - } - RadioButton { - text: "Disabled" - enabled: false - } - } - - RowLayout { - RangeSlider { - first.value: 0.25 - second.value: 0.75 - } - RangeSlider { - first.value: 0.25 - first.pressed: true - second.value: 0.75 - } - RangeSlider { - first.value: 0.25 - second.value: 0.75 - enabled: false - } - } - - RowLayout { - Rectangle { - width: 100 - height: 100 - border.color: Theme.frameColor - - ScrollBar { - size: 0.3 - position: 0.2 - active: true - orientation: Qt.Vertical - height: parent.height - anchors.right: parent.right - } - } - - Rectangle { - width: 100 - height: 100 - border.color: Theme.frameColor - - ScrollBar { - size: 0.3 - position: 0.2 - active: true - orientation: Qt.Vertical - height: parent.height - anchors.right: parent.right - pressed: true - } - } - - Rectangle { - width: 100 - height: 100 - border.color: Theme.frameColor - - ScrollBar { - size: 0.3 - position: 0.2 - active: true - orientation: Qt.Vertical - height: parent.height - anchors.right: parent.right - enabled: false - } - } - } - - RowLayout { - Rectangle { - width: 100 - height: 100 - border.color: Theme.frameColor - - ScrollIndicator { - size: 0.3 - position: 0.2 - active: true - orientation: Qt.Vertical - height: parent.height - anchors.right: parent.right - } - } - - Rectangle { - width: 100 - height: 100 - border.color: Theme.frameColor - - ScrollIndicator { - size: 0.3 - position: 0.2 - active: true - orientation: Qt.Vertical - height: parent.height - anchors.right: parent.right - enabled: false - } - } - } - - RowLayout { - Slider { - value: 0.5 - } - Slider { - value: 0.5 - pressed: true - } - Slider { - value: 0.5 - enabled: false - } - } - - RowLayout { - Switch { - text: "Normal" - } - Switch { - text: "Pressed" - pressed: true - } - Switch { - text: "Checked" - checked: true - } - Switch { - text: "Checked + Pressed" - checked: true - pressed: true - } - Switch { - text: "Disabled" - enabled: false - } - } - - RowLayout { - TabBar { - TabButton { - text: "Normal" - } - TabButton { - text: "Pressed" - pressed: true - } - TabButton { - text: "Disabled" - enabled: false - } - } - } - - RowLayout { - TextArea { - text: "Normal" - } - TextArea { - text: "Disabled" - enabled: false - } - } - - RowLayout { - TextField { - text: "Normal" - } - TextField { - text: "Disabled" - enabled: false - } - } - - RowLayout { - ToolBar { - Row { - ToolButton { - text: "Normal" - } - ToolButton { - text: "Pressed" - pressed: true - } - ToolButton { - text: "Disabled" - enabled: false - } - } - } - } - - RowLayout { - Rectangle { - width: 100 - height: 100 - border.color: Theme.frameColor - - Tumbler { - model: 5 - anchors.fill: parent - } - } - Rectangle { - width: 100 - height: 100 - border.color: Theme.frameColor - - Tumbler { - model: 5 - anchors.fill: parent - enabled: false - } - } - } + source: "qrc:/styles/Style.qml" } } diff --git a/tests/manual/testbench/qml.qrc b/tests/manual/testbench/qml.qrc index 0ff3892d..3da6988d 100644 --- a/tests/manual/testbench/qml.qrc +++ b/tests/manual/testbench/qml.qrc @@ -1,6 +1,9 @@ main.qml + styles/+material/Style.qml + styles/+universal/Style.qml + styles/Style.qml + Controls.qml - diff --git a/tests/manual/testbench/styles/+material/Style.qml b/tests/manual/testbench/styles/+material/Style.qml new file mode 100644 index 00000000..109f4bc6 --- /dev/null +++ b/tests/manual/testbench/styles/+material/Style.qml @@ -0,0 +1,8 @@ +import Qt.labs.controls.material 1.0 + +import "../.." + +Controls { + color: Material.backgroundColor + Material.theme: themeSwitch.checked ? Material.Dark : Material.Light +} diff --git a/tests/manual/testbench/styles/+universal/Style.qml b/tests/manual/testbench/styles/+universal/Style.qml new file mode 100644 index 00000000..b7a64c2b --- /dev/null +++ b/tests/manual/testbench/styles/+universal/Style.qml @@ -0,0 +1,9 @@ +import Qt.labs.controls.universal 1.0 + +import "../.." + +Controls { + color: Universal.backgroundColor + Universal.theme: themeSwitch.checked ? Universal.Dark : Universal.Light +} + diff --git a/tests/manual/testbench/styles/Style.qml b/tests/manual/testbench/styles/Style.qml new file mode 100644 index 00000000..bf0c1414 --- /dev/null +++ b/tests/manual/testbench/styles/Style.qml @@ -0,0 +1,12 @@ +import Qt.labs.controls 1.0 + +import ".." + +Controls { + color: Theme.backgroundColor + Theme.backgroundColor: themeSwitch.checked ? "#444" : "#fff" + Theme.frameColor: themeSwitch.checked ? "#666" : "#ccc" + Theme.textColor: themeSwitch.checked ? "#eee" : "#111" + Theme.pressColor: themeSwitch.checked ? "#33ffffff" : "#33333333" + Theme.baseColor: themeSwitch.checked ? "#444" : "#eee" +} -- cgit v1.2.3