summaryrefslogtreecommitdiff
path: root/components
diff options
context:
space:
mode:
Diffstat (limited to 'components')
-rw-r--r--components/Button.qml8
-rw-r--r--components/CheckBox.qml2
-rw-r--r--components/ToolButton.qml8
-rw-r--r--components/private/BasicButton.qml24
-rw-r--r--components/private/ButtonBehavior.qml39
5 files changed, 27 insertions, 54 deletions
diff --git a/components/Button.qml b/components/Button.qml
index 19dd394a..10908b7f 100644
--- a/components/Button.qml
+++ b/components/Button.qml
@@ -45,7 +45,6 @@ import QtDesktop 0.2
BasicButton {
id: button
- property alias containsMouse: tooltip.containsMouse
property bool defaultbutton: false
property string styleHint
property string text
@@ -55,13 +54,6 @@ BasicButton {
Keys.onSpacePressed:animateClick()
- TooltipArea {
- // Note this will eat hover events
- id: tooltip
- anchors.fill: parent
- text: button.tooltip
- }
-
delegate: StyleItem {
id: styleitem
anchors.fill: parent
diff --git a/components/CheckBox.qml b/components/CheckBox.qml
index a97e5052..c4c152de 100644
--- a/components/CheckBox.qml
+++ b/components/CheckBox.qml
@@ -47,7 +47,7 @@ FocusScope {
signal clicked
- property alias pressed: behavior.pressed
+ property alias pressed: behavior.effectivePressed
property alias checked: behavior.checked
property alias containsMouse: behavior.containsMouse
diff --git a/components/ToolButton.qml b/components/ToolButton.qml
index 5952a6f4..55dd7bbc 100644
--- a/components/ToolButton.qml
+++ b/components/ToolButton.qml
@@ -45,19 +45,11 @@ import "private" as Private
Private.BasicButton {
id:button
- property alias containsMouse: tooltip.containsMouse
property string iconName
property string styleHint
property url iconSource
property string text
- TooltipArea {
- // Note this will eat hover events
- id: tooltip
- anchors.fill: parent
- text: button.tooltip
- }
-
delegate: StyleItem {
id: styleitem
anchors.fill: parent
diff --git a/components/private/BasicButton.qml b/components/private/BasicButton.qml
index 2427060c..daa17adf 100644
--- a/components/private/BasicButton.qml
+++ b/components/private/BasicButton.qml
@@ -39,12 +39,13 @@
****************************************************************************/
import QtQuick 2.0
+import QtDesktop.Internal 0.2 as Internal
Item {
id: button
signal clicked
- property alias pressed: behavior.pressed
+ property alias pressed: behavior.effectivePressed
property alias containsMouse: behavior.containsMouse
property alias checkable: behavior.checkable // button toggles between checked and !checked
property alias checked: behavior.checked
@@ -67,15 +68,15 @@ Item {
implicitHeight: loader.item.implicitHeight
function animateClick() {
- behavior.pressed = true
- behavior.clicked()
+ behavior.keyPressed = true
+ button.clicked()
animateClickTimer.start()
}
Timer {
id: animateClickTimer
interval: 250
- onTriggered: behavior.pressed = false
+ onTriggered: behavior.keyPressed = false
}
Loader {
@@ -90,13 +91,14 @@ Item {
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()
+ onExited: Internal.hideToolTip()
+ onCanceled: Internal.hideToolTip()
+ onPressed: if (activeFocusOnPress) button.focus = true
+
+ Timer {
+ interval: 1000
+ running: containsMouse && !pressed && tooltip.length
+ onTriggered: Internal.showToolTip(behavior, Qt.point(behavior.mouseX, behavior.mouseY), tooltip)
}
}
diff --git a/components/private/ButtonBehavior.qml b/components/private/ButtonBehavior.qml
index 4942d62f..fdf0c79c 100644
--- a/components/private/ButtonBehavior.qml
+++ b/components/private/ButtonBehavior.qml
@@ -40,34 +40,21 @@
import QtQuick 2.0
-Item {
- id: behavior
-
- signal clicked
- property bool pressed: false // Can't be alias of mouseArea.pressed because the latter is read-only
- property alias containsMouse: mouseArea.containsMouse
+MouseArea {
property bool checkable: false
property bool checked: false
- property bool triState: false
- signal mouseMoved
+ property bool keyPressed: false
+ property bool effectivePressed: pressed && containsMouse || keyPressed
+
+ hoverEnabled: true
+
+ onCheckableChanged: {
+ if (!checkable)
+ checked = false;
+ }
- onCheckableChanged: { if(!checkable) checked = false }
- MouseArea {
- id: mouseArea
- anchors.fill: parent
- hoverEnabled: true
- onPositionChanged: behavior.mouseMoved()
- onPressed: behavior.pressed = true // needed when hover is enabled
- onEntered: if(pressed && enabled) behavior.pressed = true
- onExited: behavior.pressed = false
- onCanceled: behavior.pressed = false // mouse stolen e.g. by Flickable
- onReleased: {
- if(behavior.pressed && behavior.enabled) { // No click if release outside area
- behavior.pressed = false
- if(behavior.checkable)
- behavior.checked = !behavior.checked;
- behavior.clicked()
- }
- }
+ onReleased: {
+ if (checkable && containsMouse)
+ checked = !checked;
}
}