summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJens Bache-Wiig <jens.bache-wiig@nokia.com>2012-06-29 15:21:23 +0200
committerJens Bache-Wiig <jens.bache-wiig@nokia.com>2012-06-29 16:09:44 +0200
commit8e6bb99db7fe610cf7729a24d07459b43bf2d6ba (patch)
tree1a6a661c7e1b5f398ef52303a800086cb3f1b6e1
parent84ad688dabbcde68e6b03f6859f9a89d72dc8faf (diff)
downloadqtquickcontrols-8e6bb99db7fe610cf7729a24d07459b43bf2d6ba.tar.gz
Add back BasicButton
Change-Id: I4dd0a3d579650d8798b47cde9ff1bbf48a5cab47 Reviewed-by: Leonardo Sobral Cunha <leo.cunha@nokia.com> Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@nokia.com>
-rw-r--r--components/private/BasicButton.qml105
1 files changed, 105 insertions, 0 deletions
diff --git a/components/private/BasicButton.qml b/components/private/BasicButton.qml
new file mode 100644
index 00000000..e7d40792
--- /dev/null
+++ b/components/private/BasicButton.qml
@@ -0,0 +1,105 @@
+/****************************************************************************
+**
+** 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
+
+Item {
+ id: button
+
+ signal clicked
+ property alias pressed: behavior.pressed
+ property alias containsMouse: behavior.containsMouse
+ property alias checkable: behavior.checkable // button toggles between checked and !checked
+ property alias checked: behavior.checked
+ property bool activeFocusOnPress: false
+
+ property Component background: null
+ property Item backgroundItem: backgroundLoader.item
+
+ property color textColor: syspal.text;
+ property string tooltip
+
+ Accessible.role: Accessible.Button
+ Accessible.description: tooltip
+
+ signal toolTipTriggered
+
+ // implementation
+
+ property string __position: "only"
+ implicitWidth: backgroundLoader.item.width
+ implicitHeight: backgroundLoader.item.height
+
+ function animateClick() {
+ behavior.pressed = true
+ behavior.clicked()
+ animateClickTimer.start()
+ }
+
+ Timer {
+ id: animateClickTimer
+ interval: 250
+ onTriggered: behavior.pressed = false
+ }
+
+ Loader {
+ id: backgroundLoader
+ anchors.fill: parent
+ sourceComponent: background
+ property alias styledItem: button
+ property alias position: button.__position
+ }
+
+ ButtonBehavior {
+ id: behavior
+ anchors.fill: parent
+ onClicked: button.clicked()
+ onPressedChanged: if (activeFocusOnPress) button.focus = true
+ onMouseMoved: {tiptimer.restart()}
+ Timer{
+ id: tiptimer
+ interval:1000
+ running:containsMouse && tooltip.length
+ onTriggered: button.toolTipTriggered()
+ }
+ }
+
+ SystemPalette { id: syspal }
+}