add support for tooltips

use qwidget tooltips, not plasma ones
BUG:335131
This commit is contained in:
Marco Martin 2014-05-22 12:18:30 +02:00
parent 88275439d4
commit 524ff23f25
2 changed files with 29 additions and 1 deletions

View File

@ -30,6 +30,8 @@
*/
import QtQuick 2.1
import org.kde.plasma.core 2.0 as PlasmaCore
import QtQuick.Controls.Private 1.0
import QtQuick.Controls 1.0
import "private" as Private
@ -70,6 +72,9 @@ Item {
*/
property alias text: label.text
/*! This property holds the button tooltip. */
property string tooltip
/**
* type:string
*
@ -261,7 +266,17 @@ Item {
hoverEnabled: true
onPressed: internal.userPressed = true
onReleased: internal.userPressed = false
onCanceled: internal.userPressed = false
onCanceled: {
internal.userPressed = false
Tooltip.hideText()
}
onClicked: internal.clickButton()
onExited: Tooltip.hideText()
Timer {
interval: 1000
running: mouse.containsMouse && !pressed && tooltip.length
onTriggered: Tooltip.showText(mouse, Qt.point(mouse.mouseX, mouse.mouseY), tooltip)
}
}
}

View File

@ -20,6 +20,8 @@
import QtQuick 2.1
import org.kde.plasma.core 2.0 as PlasmaCore
import QtQuick.Controls.Private 1.0
import QtQuick.Controls 1.0
import "private" as Private
/**
@ -56,6 +58,9 @@ Item {
*/
property alias text: label.text
/*! This property holds the button tooltip. */
property string tooltip
/**
* type:variant
*
@ -386,6 +391,7 @@ Item {
onCanceled: {
internal.userPressed = false
delegate.shadowState = "shadow"
Tooltip.hideText()
}
onClicked: internal.clickButton()
@ -406,6 +412,13 @@ Item {
}
}
button.z -= 2
Tooltip.hideText()
}
Timer {
interval: 1000
running: mouse.containsMouse && !pressed && tooltip.length
onTriggered: Tooltip.showText(mouse, Qt.point(mouse.mouseX, mouse.mouseY), tooltip)
}
}
}