summaryrefslogtreecommitdiff
path: root/components/custom/SpinBox.qml
diff options
context:
space:
mode:
authorJens Bache-Wiig <jens.bache-wiig@nokia.com>2012-06-29 13:29:24 +0200
committerGabriel de Dietrich <gabriel.dietrich-de@nokia.com>2012-06-29 14:46:51 +0200
commit94307aacbf5c3596236648567234d55ac46eeeb2 (patch)
treef4e207e66f8a267e4bf587dbe11d30b7dcc04991 /components/custom/SpinBox.qml
parent3f93278a9ba299d5ca0a5c57f55f0f76ea29b666 (diff)
downloadqtquickcontrols-94307aacbf5c3596236648567234d55ac46eeeb2.tar.gz
Refactor and remove "custom" components
The custom subdirectory doesnt make much sense for desktop and adds an uneccessary abstraction layer. This patch removes it and removes some of the properties that are no longer required. Change-Id: I65c44db54f6f97bbc1e69d85d35d55464dac794e Reviewed-by: Gabriel de Dietrich <gabriel.dietrich-de@nokia.com>
Diffstat (limited to 'components/custom/SpinBox.qml')
-rw-r--r--components/custom/SpinBox.qml204
1 files changed, 0 insertions, 204 deletions
diff --git a/components/custom/SpinBox.qml b/components/custom/SpinBox.qml
deleted file mode 100644
index ceb7578d..00000000
--- a/components/custom/SpinBox.qml
+++ /dev/null
@@ -1,204 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
-** All rights reserved.
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the Qt Components project.
-**
-** $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
-
-FocusScope {
- id: spinbox
-
- SystemPalette {
- id: syspal
- colorGroup: enabled ? SystemPalette.Active : SystemPalette.Disabled
- }
-
- property int minimumWidth: 0
- property int minimumHeight: 0
-
- property int leftMargin: 0
- property int topMargin: 0
- property int rightMargin: 0
- property int bottomMargin: 0
-
- property real value: 0.0
- property real maximumValue: 99
- property real minimumValue: 0
- property real singleStep: 1
- property string postfix
-
- property bool upEnabled: value != maximumValue;
- property bool downEnabled: value != minimumValue;
- property alias upPressed: mouseUp.pressed
- property alias downPressed: mouseDown.pressed
- property alias upHovered: mouseUp.containsMouse
- property alias downHovered: mouseDown.containsMouse
- property alias containsMouse: mouseArea.containsMouse
- property alias textColor: syspal.text
- property alias font: input.font
-
- property Component background: null
- property Item backgroundItem: backgroundComponent.item
- property Component up: null
- property Component down: null
-
- Accessible.name: input.text
- Accessible.role: Accessible.SpinBox
-
- QtObject {
- id: componentPrivate
- property bool valueUpdate: false
- }
-
- function increment() {
- setValue(input.text)
- value += singleStep
- if (value > maximumValue)
- value = maximumValue
- input.text = value
- }
-
- function decrement() {
- setValue(input.text)
- value -= singleStep
- if (value < minimumValue)
- value = minimumValue
- input.text = value
- }
-
- function setValue(v) {
- var newval = parseFloat(v)
- if (newval > maximumValue)
- newval = maximumValue
- else if (v < minimumValue)
- newval = minimumValue
- value = newval
- input.text = value
- }
-
- Component.onCompleted: setValue(value)
-
- onValueChanged: {
- componentPrivate.valueUpdate = true
- input.text = value
- componentPrivate.valueUpdate = false
- }
-
- // background
- Loader {
- id: backgroundComponent
- anchors.fill: parent
- sourceComponent: background
- }
-
- MouseArea {
- id: mouseArea
- anchors.fill: parent
- hoverEnabled: true
- }
-
- TextInput {
- id: input
-
- anchors.margins: 5
- anchors.leftMargin: leftMargin
- anchors.topMargin: topMargin
- anchors.rightMargin: rightMargin
- anchors.bottomMargin: bottomMargin
- anchors.fill: parent
- selectByMouse: true
-
- // validator: DoubleValidator { bottom: minimumValue; top: maximumValue; }
- onAccepted: {setValue(input.text)}
- onActiveFocusChanged: setValue(input.text)
- color: textColor
- opacity: parent.enabled ? 1 : 0.5
- Text {
- text: postfix
- anchors.rightMargin: 4
- anchors.right: parent.right
- anchors.verticalCenter: parent.verticalCenter
- }
- }
-
- Loader {
- id: upButton
- property alias pressed : spinbox.upPressed
- property alias hover : spinbox.upHovered
- property alias enabled : spinbox.upEnabled
- sourceComponent: up
- MouseArea {
- id: mouseUp
- anchors.fill: upButton.item
- onClicked: increment()
-
- property bool autoincrement: false;
- onReleased: autoincrement = false
- Timer { running: mouseUp.pressed; interval: 350 ; onTriggered: mouseUp.autoincrement = true }
- Timer { running: mouseUp.autoincrement; interval: 60 ; repeat: true ; onTriggered: increment() }
- }
- onLoaded: {
- item.parent = spinbox
- mouseUp.parent = item
- }
- }
-
- Loader {
- id: downButton
- property alias pressed : spinbox.downPressed
- property alias hover : spinbox.downHovered
- property alias enabled : spinbox.downEnabled
- sourceComponent: down
- MouseArea {
- id: mouseDown
- anchors.fill: downButton.item
- onClicked: decrement()
-
- property bool autoincrement: false;
- onReleased: autoincrement = false
- Timer { running: mouseDown.pressed; interval: 350 ; onTriggered: mouseDown.autoincrement = true }
- Timer { running: mouseDown.autoincrement; interval: 60 ; repeat: true ; onTriggered: decrement() }
- }
- onLoaded: {
- item.parent = spinbox
- mouseDown.parent = item
- }
- }
- Keys.onUpPressed: increment()
- Keys.onDownPressed: decrement()
-}