From a61c9f0c41e9dcc4680038bb875ef7ce3fcc80ab Mon Sep 17 00:00:00 2001 From: Wolfgang Beck Date: Wed, 18 Jan 2012 15:49:55 +1000 Subject: Replace Radiobutton with -+ buttons Change-Id: I127ad9b7f51762f5b1d959d0f0439d254a535e4a Sanity-Review: Qt Sanity Bot Reviewed-by: Lincoln Ramsay --- examples/sensors/qmlqtsensors/RadioButton.qml | 87 ----------- .../images/radiobutton_background_checked.png | Bin 473 -> 0 bytes .../images/radiobutton_background_disabled.png | Bin 447 -> 0 bytes .../radiobutton_background_disabled_checked.png | Bin 629 -> 0 bytes .../images/radiobutton_background_unchecked.png | Bin 568 -> 0 bytes examples/sensors/qmlqtsensors/main.qml | 164 ++++++++++----------- 6 files changed, 81 insertions(+), 170 deletions(-) delete mode 100644 examples/sensors/qmlqtsensors/RadioButton.qml delete mode 100644 examples/sensors/qmlqtsensors/images/radiobutton_background_checked.png delete mode 100644 examples/sensors/qmlqtsensors/images/radiobutton_background_disabled.png delete mode 100644 examples/sensors/qmlqtsensors/images/radiobutton_background_disabled_checked.png delete mode 100644 examples/sensors/qmlqtsensors/images/radiobutton_background_unchecked.png (limited to 'examples') diff --git a/examples/sensors/qmlqtsensors/RadioButton.qml b/examples/sensors/qmlqtsensors/RadioButton.qml deleted file mode 100644 index d7ed8747..00000000 --- a/examples/sensors/qmlqtsensors/RadioButton.qml +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtSensors module 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 Nokia Corporation and its Subsidiary(-ies) 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.0 - -Rectangle { - id: button - width: 100 - height: 30 - property alias text: innerText.text - property bool checked - signal clicked - color: "transparent" - - Image{ - id: image - width: button.height - height: button.height - anchors.right: button.right - source: (button.checked == true ? (button.enabled ? - "images/radiobutton_background_checked.png" : "images/radiobutton_background_disabled_checked.png") : - (button.enabled ? - "images/radiobutton_background_unchecked.png" : "images/radiobutton_background_disabled.png")) - } - - Text{ - id: innerText - anchors.fill: parent - enabled: button.enabled - color: "black" - verticalAlignment: Text.AlignVCenter - - onEnabledChanged: { - (enabled ? innerText.color = "black" : innerText.color = "gray"); - } - } - - MouseArea{ - anchors.fill: button - onClicked: { - setCheck(true); - button.clicked(); - } - } - - function setCheck(val) - { - checked = val; - } -} diff --git a/examples/sensors/qmlqtsensors/images/radiobutton_background_checked.png b/examples/sensors/qmlqtsensors/images/radiobutton_background_checked.png deleted file mode 100644 index a5c7ef31..00000000 Binary files a/examples/sensors/qmlqtsensors/images/radiobutton_background_checked.png and /dev/null differ diff --git a/examples/sensors/qmlqtsensors/images/radiobutton_background_disabled.png b/examples/sensors/qmlqtsensors/images/radiobutton_background_disabled.png deleted file mode 100644 index 2fce913a..00000000 Binary files a/examples/sensors/qmlqtsensors/images/radiobutton_background_disabled.png and /dev/null differ diff --git a/examples/sensors/qmlqtsensors/images/radiobutton_background_disabled_checked.png b/examples/sensors/qmlqtsensors/images/radiobutton_background_disabled_checked.png deleted file mode 100644 index 46b56378..00000000 Binary files a/examples/sensors/qmlqtsensors/images/radiobutton_background_disabled_checked.png and /dev/null differ diff --git a/examples/sensors/qmlqtsensors/images/radiobutton_background_unchecked.png b/examples/sensors/qmlqtsensors/images/radiobutton_background_unchecked.png deleted file mode 100644 index b09b5d9f..00000000 Binary files a/examples/sensors/qmlqtsensors/images/radiobutton_background_unchecked.png and /dev/null differ diff --git a/examples/sensors/qmlqtsensors/main.qml b/examples/sensors/qmlqtsensors/main.qml index 44481b6e..87ab24a0 100644 --- a/examples/sensors/qmlqtsensors/main.qml +++ b/examples/sensors/qmlqtsensors/main.qml @@ -38,13 +38,6 @@ ** ****************************************************************************/ -//Import the declarative plugins -import QtQuick 2.0 - -//! [0] -import QtSensors 5.0 -//! [0] - /* Layout mainWnd / @@ -59,9 +52,10 @@ import QtSensors 5.0 | / accuracyRect / speedRect |-------------------------------------------||----------------------------------| || Accuracy <----- textAccuracy || Speed <-----textSpeed | -|| @ 0 Degree <- selButton0DegreeAccuracy || @ Slow <- selButtonSlowSpeed | -|| O 1 Degree <- selButton1DegreeAccuracy || O Medium <- selButtonMediumSpeed | -|| O 5 Degree <- selButton5DegreeAccuracy || O Fast <- selButtonFastSpeed | +|| value <- textAccuracyValue || value <- textSpeedValue | +|| ----------------- ------------------ || --------------- ---------------- | +|| | accuracyLower | | accuracyHigher | || | speedLower | | speedHigher | | +|| ----------------- ------------------ || --------------- ---------------- | |------------------------------------------ ||----------------------------------| | ----------- | |Calibrate| <------------------ calibrate @@ -87,16 +81,25 @@ import QtSensors 5.0 | |Start | <-------------------- proxiStart Proximity: - <--------------- proxitext | --------- ------------------------------------------------------------------------------ - */ +//Import the declarative plugins +import QtQuick 2.0 + +//! [0] +import QtSensors 5.0 +//! [0] + Rectangle { id: mainWnd x: 0 y: 0 width: 320 height: 480 - color: "#ececec" + color: "transparent" + + property int accuracy: 1 + property string speed: "Slow" Text { id: labelTitle @@ -144,6 +147,7 @@ Rectangle { unit: TiltSensor.Degrees enabled: false accuracy: 1.0 + speed: TiltSensor.Slow } //! [1] @@ -166,51 +170,45 @@ Rectangle { font.bold: true } - RadioButton{ - id: selButton0DegreeAccuracy + Text{ + id: textAccuracyValue anchors.top: textAccuracy.bottom - anchors.left: accuracyRect.left - anchors.right: accuracyRect.right - anchors.rightMargin: 10 - checked: true - text: "0 Degree" - - onClicked:{ - selButton1DegreeAccuracy.setCheck(false); - selButton5DegreeAccuracy.setCheck(false); - tilt.accuracy = 0.0; - } + anchors.topMargin: 5 + anchors.left: accuracyHigher.left + anchors.right: accuracyHigher.right + text: mainWnd.accuracy + verticalAlignment: Text.AlignVCenter } - RadioButton{ - id: selButton1DegreeAccuracy - anchors.top: selButton0DegreeAccuracy.bottom + Button{ + id: accuracyLower + anchors.top: textAccuracyValue.bottom anchors.left: accuracyRect.left - anchors.right: accuracyRect.right - anchors.rightMargin: 10 - checked: false - text: "1 Degree" + height: 30 + width: 40 + text: "-" onClicked:{ - selButton0DegreeAccuracy.setCheck(false); - selButton5DegreeAccuracy.setCheck(false); - tilt.accuracy = (tilt.unit == TiltSensor.Degrees ? 1.0 : (3.14 / 180.0)); + if (mainWnd.accuracy > 1){ + mainWnd.accuracy--; + tilt.accuracy = mainWnd.accuracy; + } } } - RadioButton{ - id: selButton5DegreeAccuracy - anchors.top: selButton1DegreeAccuracy.bottom - anchors.left: accuracyRect.left - anchors.right: accuracyRect.right - anchors.rightMargin: 10 - checked: false - text: "5 Degree" + Button{ + id: accuracyHigher + anchors.top: textAccuracyValue.bottom + anchors.left: accuracyLower.right + height: 30 + width: 40 + text: "+" onClicked:{ - selButton0DegreeAccuracy.setCheck(false); - selButton1DegreeAccuracy.setCheck(false); - tilt.accuracy = (tilt.unit == TiltSensor.Degrees ? 5.0 : (5.0 * 3.14 / 180.0)); + if (mainWnd.accuracy < 10){ + mainWnd.accuracy++; + tilt.accuracy = mainWnd.accuracy; + } } } } @@ -234,58 +232,57 @@ Rectangle { font.bold: true } - RadioButton{ - id: selButtonSlowSpeed + Text{ + id: textSpeedValue anchors.top: textSpeed.bottom - anchors.left: speedRect.left - anchors.right: speedRect.right - anchors.rightMargin: 10 - checked: true - text: "Slow" - - onClicked:{ - selButtonMediumSpeed.setCheck(false); - selButtonFastSpeed.setCheck(false); - tilt.speed = TiltSensor.Slow; - } + anchors.topMargin: 5 + anchors.left: speedLower.left + anchors.right: speedHigher.right + text: mainWnd.speed + verticalAlignment: Text.AlignVCenter } - - RadioButton{ - id: selButtonMediumSpeed - anchors.top: selButtonSlowSpeed.bottom + Button{ + id: speedLower + anchors.top: textSpeedValue.bottom anchors.left: speedRect.left - anchors.right: speedRect.right - anchors.rightMargin: 10 - checked: false - text: "Medium" + height: 30 + width: 40 + text: "-" onClicked:{ - selButtonSlowSpeed.setCheck(false); - selButtonFastSpeed.setCheck(false); - tilt.speed = TiltSensor.Medium; + if (tilt.speed === TiltSensor.Fast) { + mainWnd.speed = "Medium"; + tilt.speed = TiltSensor.Medium; + } + else if (tilt.speed === TiltSensor.Medium) { + mainWnd.speed = "Slow"; + tilt.speed = TiltSensor.Slow; + } } } - - RadioButton{ - id: selButtonFastSpeed - anchors.top: selButtonMediumSpeed.bottom - anchors.left: speedRect.left - anchors.right: speedRect.right - anchors.rightMargin: 10 - checked: false - text: "Fast" + Button{ + id: speedHigher + anchors.top: textSpeedValue.bottom + anchors.left: speedLower.right + height: 30 + width: 40 + text: "+" onClicked:{ - selButtonSlowSpeed.setCheck(false); - selButtonMediumSpeed.setCheck(false); - tilt.speed = TiltSensor.Fast; + if (tilt.speed === TiltSensor.Slow) { + mainWnd.speed = "Medium"; + tilt.speed = TiltSensor.Medium; + } + else if (tilt.speed === TiltSensor.Medium) { + mainWnd.speed = "Fast"; + tilt.speed = TiltSensor.Fast; + } } } } - Button{ id: calibrate anchors.left: mainWnd.left @@ -489,3 +486,4 @@ Rectangle { //! [6] } } + -- cgit v1.2.3