| 1 |
import QtQuick 2.4 |
| 2 |
import FlightGear 1.0 |
| 3 |
|
| 4 |
Rectangle { |
| 5 |
id: root |
| 6 |
|
| 7 |
property string text |
| 8 |
property string hoverText: "" |
| 9 |
property bool enabled: true |
| 10 |
property bool destructiveAction: false |
| 11 |
|
| 12 |
readonly property string __baseColor: destructiveAction ? Style.destructiveActionColor : |
| 13 |
(invertColor ? "white" : Style.themeColor) |
| 14 |
|
| 15 |
readonly property string __activeColor: invertColor ? Style.inverseActiveColor : Style.activeColor |
| 16 |
readonly property string __textColor: invertColor ? Style.frameColor : "white" |
| 17 |
|
| 18 |
signal clicked |
| 19 |
|
| 20 |
property bool invertColor: false |
| 21 |
|
| 22 |
width: Math.max(Style.strutSize * 2, buttonText.implicitWidth + radius * 2) |
| 23 |
height: buttonText.implicitHeight + (radius * 2) |
| 24 |
radius: Style.roundRadius |
| 25 |
|
| 26 |
color: enabled ? (mouse.containsMouse ? __activeColor : __baseColor) : Style.disabledThemeColor |
| 27 |
|
| 28 |
Text { |
| 29 |
id: buttonText |
| 30 |
anchors.centerIn: parent |
| 31 |
color: root.__textColor |
| 32 |
text: (mouse.containsMouse && hoverText != "") ? root.hoverText : root.text |
| 33 |
font.pixelSize: Style.baseFontPixelSize |
| 34 |
} |
| 35 |
|
| 36 |
MouseArea { |
| 37 |
id: mouse |
| 38 |
anchors.fill: parent |
| 39 |
enabled: root.enabled |
| 40 |
|
| 41 |
hoverEnabled: true |
| 42 |
|
| 43 |
onClicked: { |
| 44 |
root.clicked(); |
| 45 |
} |
| 46 |
|
| 47 |
} |
| 48 |
} |