diff options
author | J-P Nurmi <jpnurmi@qt.io> | 2016-11-17 10:31:25 +0100 |
---|---|---|
committer | J-P Nurmi <jpnurmi@qt.io> | 2016-11-17 10:24:21 +0000 |
commit | 6a86efd93906c688b22b8a847e9c7d380d951dab (patch) | |
tree | 99a720d34858efcc1af8e3526e49859a48ff7088 /examples/quickcontrols2/gallery | |
parent | 884a754ab44a95263fab13972433ae2d9327b45f (diff) |
Gallery: improve designer compatibility
Get rid of some unnecessary Math.min/max() calculations, and let the
controls just stay at their implicit size. As for the buttons, we can
use ColumnLayout + Layout.fillWidth to ensure that they all have the
same size.
Change-Id: Iaed29b330d7edc1f5d2c05d8815a559d52d52bcc
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'examples/quickcontrols2/gallery')
9 files changed, 5 insertions, 27 deletions
diff --git a/examples/quickcontrols2/gallery/pages/BusyIndicatorPage.qml b/examples/quickcontrols2/gallery/pages/BusyIndicatorPage.qml index d9e5f788..403da14e 100644 --- a/examples/quickcontrols2/gallery/pages/BusyIndicatorPage.qml +++ b/examples/quickcontrols2/gallery/pages/BusyIndicatorPage.qml @@ -57,9 +57,6 @@ ScrollablePage { } BusyIndicator { - readonly property int size: Math.min(page.availableWidth, page.availableHeight) / 5 - width: size - height: size anchors.horizontalCenter: parent.horizontalCenter } } diff --git a/examples/quickcontrols2/gallery/pages/ButtonPage.qml b/examples/quickcontrols2/gallery/pages/ButtonPage.qml index 7e945fa1..39776380 100644 --- a/examples/quickcontrols2/gallery/pages/ButtonPage.qml +++ b/examples/quickcontrols2/gallery/pages/ButtonPage.qml @@ -39,13 +39,12 @@ ****************************************************************************/ import QtQuick 2.6 +import QtQuick.Layouts 1.0 import QtQuick.Controls 2.1 ScrollablePage { id: page - readonly property int itemWidth: Math.max(button.implicitWidth, Math.min(button.implicitWidth * 2, page.availableWidth / 3)) - Column { spacing: 40 width: parent.width @@ -58,24 +57,24 @@ ScrollablePage { + "Buttons are normally used to perform an action, or to answer a question." } - Column { + ColumnLayout { spacing: 20 anchors.horizontalCenter: parent.horizontalCenter Button { text: "First" - width: itemWidth + Layout.fillWidth: true } Button { id: button text: "Second" - width: itemWidth highlighted: true + Layout.fillWidth: true } Button { text: "Third" enabled: false - width: itemWidth + Layout.fillWidth: true } } } diff --git a/examples/quickcontrols2/gallery/pages/ComboBoxPage.qml b/examples/quickcontrols2/gallery/pages/ComboBoxPage.qml index c800ba73..a52fcb67 100644 --- a/examples/quickcontrols2/gallery/pages/ComboBoxPage.qml +++ b/examples/quickcontrols2/gallery/pages/ComboBoxPage.qml @@ -58,7 +58,6 @@ ScrollablePage { ComboBox { model: ["First", "Second", "Third"] - width: Math.max(implicitWidth, Math.min(implicitWidth * 2, page.availableWidth / 3)) anchors.horizontalCenter: parent.horizontalCenter } } diff --git a/examples/quickcontrols2/gallery/pages/ProgressBarPage.qml b/examples/quickcontrols2/gallery/pages/ProgressBarPage.qml index 1548192f..a2646fd0 100644 --- a/examples/quickcontrols2/gallery/pages/ProgressBarPage.qml +++ b/examples/quickcontrols2/gallery/pages/ProgressBarPage.qml @@ -44,8 +44,6 @@ import QtQuick.Controls 2.1 ScrollablePage { id: page - readonly property int itemWidth: Math.max(bar.implicitWidth, page.availableWidth / 3) - Column { spacing: 40 width: parent.width @@ -61,13 +59,11 @@ ScrollablePage { ProgressBar { id: bar value: 0.5 - width: itemWidth anchors.horizontalCenter: parent.horizontalCenter } ProgressBar { indeterminate: true - width: itemWidth anchors.horizontalCenter: parent.horizontalCenter } } diff --git a/examples/quickcontrols2/gallery/pages/RangeSliderPage.qml b/examples/quickcontrols2/gallery/pages/RangeSliderPage.qml index 6a74e348..629a788b 100644 --- a/examples/quickcontrols2/gallery/pages/RangeSliderPage.qml +++ b/examples/quickcontrols2/gallery/pages/RangeSliderPage.qml @@ -44,8 +44,6 @@ import QtQuick.Controls 2.1 ScrollablePage { id: page - readonly property int itemWidth: Math.max(slider.implicitWidth, Math.min(slider.implicitWidth * 2, page.availableWidth / 3)) - Column { spacing: 40 width: parent.width @@ -61,7 +59,6 @@ ScrollablePage { id: slider first.value: 0.25 second.value: 0.75 - width: itemWidth anchors.horizontalCenter: parent.horizontalCenter } @@ -69,7 +66,6 @@ ScrollablePage { orientation: Qt.Vertical first.value: 0.25 second.value: 0.75 - height: itemWidth anchors.horizontalCenter: parent.horizontalCenter } } diff --git a/examples/quickcontrols2/gallery/pages/SliderPage.qml b/examples/quickcontrols2/gallery/pages/SliderPage.qml index 03cb7696..83ae32ef 100644 --- a/examples/quickcontrols2/gallery/pages/SliderPage.qml +++ b/examples/quickcontrols2/gallery/pages/SliderPage.qml @@ -44,8 +44,6 @@ import QtQuick.Controls 2.1 ScrollablePage { id: page - readonly property int itemWidth: Math.max(slider.implicitWidth, Math.min(slider.implicitWidth * 2, page.availableWidth / 3)) - Column { spacing: 40 width: parent.width @@ -60,14 +58,12 @@ ScrollablePage { Slider { id: slider value: 0.5 - width: itemWidth anchors.horizontalCenter: parent.horizontalCenter } Slider { orientation: Qt.Vertical value: 0.5 - height: itemWidth anchors.horizontalCenter: parent.horizontalCenter } } diff --git a/examples/quickcontrols2/gallery/pages/SpinBoxPage.qml b/examples/quickcontrols2/gallery/pages/SpinBoxPage.qml index c75982c2..93adc01a 100644 --- a/examples/quickcontrols2/gallery/pages/SpinBoxPage.qml +++ b/examples/quickcontrols2/gallery/pages/SpinBoxPage.qml @@ -44,8 +44,6 @@ import QtQuick.Controls 2.1 ScrollablePage { id: page - readonly property int itemWidth: Math.max(box.implicitWidth, Math.min(box.implicitWidth * 2, pane.availableWidth / 3)) - Column { spacing: 40 width: parent.width @@ -61,7 +59,6 @@ ScrollablePage { SpinBox { id: box value: 50 - width: itemWidth anchors.horizontalCenter: parent.horizontalCenter editable: true } diff --git a/examples/quickcontrols2/gallery/pages/TextFieldPage.qml b/examples/quickcontrols2/gallery/pages/TextFieldPage.qml index 9917da33..1b22fd08 100644 --- a/examples/quickcontrols2/gallery/pages/TextFieldPage.qml +++ b/examples/quickcontrols2/gallery/pages/TextFieldPage.qml @@ -58,7 +58,6 @@ ScrollablePage { TextField { id: field placeholderText: "TextField" - width: Math.max(implicitWidth, Math.min(implicitWidth * 2, pane.availableWidth / 3)) anchors.horizontalCenter: parent.horizontalCenter } } diff --git a/examples/quickcontrols2/gallery/pages/ToolTipPage.qml b/examples/quickcontrols2/gallery/pages/ToolTipPage.qml index 98ecd92e..d9bc969d 100644 --- a/examples/quickcontrols2/gallery/pages/ToolTipPage.qml +++ b/examples/quickcontrols2/gallery/pages/ToolTipPage.qml @@ -58,7 +58,6 @@ ScrollablePage { Button { text: "Tip" anchors.horizontalCenter: parent.horizontalCenter - width: Math.max(implicitWidth, Math.min(implicitWidth * 2, pane.availableWidth / 3)) ToolTip.timeout: 5000 ToolTip.visible: pressed |