2018-03-19 22:32:23 +00:00
|
|
|
import QtQuick 2.4
|
2017-12-05 20:53:47 +00:00
|
|
|
import "."
|
2017-06-22 09:45:47 +00:00
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
id: root
|
|
|
|
|
|
|
|
property string text
|
|
|
|
property string hoverText: ""
|
2017-12-15 15:42:36 +00:00
|
|
|
property bool enabled: true
|
2018-03-16 22:01:21 +00:00
|
|
|
property bool destructiveAction: false
|
2017-06-22 09:45:47 +00:00
|
|
|
|
2018-03-16 22:01:21 +00:00
|
|
|
readonly property string __baseColor: destructiveAction ? Style.destructiveActionColor : Style.themeColor
|
2017-06-22 09:45:47 +00:00
|
|
|
signal clicked
|
|
|
|
|
2018-03-16 22:01:21 +00:00
|
|
|
width: Math.max(Style.strutSize * 2, buttonText.implicitWidth + radius * 2)
|
2017-10-13 15:48:24 +00:00
|
|
|
height: buttonText.implicitHeight + (radius * 2)
|
2017-12-05 20:53:47 +00:00
|
|
|
radius: Style.roundRadius
|
2017-06-22 09:45:47 +00:00
|
|
|
|
2018-03-16 22:01:21 +00:00
|
|
|
color: enabled ? (mouse.containsMouse ? Style.activeColor : __baseColor) : Style.disabledThemeColor
|
2017-06-22 09:45:47 +00:00
|
|
|
|
|
|
|
Text {
|
|
|
|
id: buttonText
|
|
|
|
anchors.centerIn: parent
|
|
|
|
color: "white"
|
|
|
|
text: (mouse.containsMouse && hoverText != "") ? root.hoverText : root.text
|
2018-03-02 21:09:10 +00:00
|
|
|
font.pixelSize: Style.baseFontPixelSize
|
2017-06-22 09:45:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
id: mouse
|
|
|
|
anchors.fill: parent
|
2017-12-15 15:42:36 +00:00
|
|
|
enabled: root.enabled
|
|
|
|
|
2017-06-22 09:45:47 +00:00
|
|
|
hoverEnabled: true
|
|
|
|
|
|
|
|
onClicked: {
|
|
|
|
root.clicked();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|