forked from qt-creator/qt-creator
Implements new XML-based format for examples, demos & tutorials Done-with: Primrose Mbanefo <ext-primrose.mbanefo@nokia.com> Change-Id: I42c0afdb419cffe5637cd4f298e828d09e0fb15a Reviewed-on: http://codereview.qt.nokia.com/840 Reviewed-by: Eike Ziller <eike.ziller@nokia.com>
52 lines
1.3 KiB
QML
52 lines
1.3 KiB
QML
import QtQuick 1.0
|
|
import "./behaviors" // ButtonBehavior
|
|
|
|
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 Component background: null
|
|
property Item backgroundItem: backgroundLoader.item
|
|
|
|
property color textColor: syspal.text;
|
|
property bool activeFocusOnPress: true
|
|
property string tooltip
|
|
|
|
signal toolTipTriggered
|
|
|
|
// implementation
|
|
|
|
property string __position: "only"
|
|
width: backgroundLoader.item.width
|
|
height: backgroundLoader.item.height
|
|
|
|
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 }
|
|
}
|