Alisa/native/TextButton.qml

46 lines
855 B
QML
Raw Normal View History

2024-07-08 16:08:21 +02:00
import QtQuick
Item {
2024-07-09 12:36:14 +02:00
SystemPalette { id: systemColors; colorGroup: SystemPalette.Active }
2024-07-08 16:08:21 +02:00
id: root
2024-07-09 12:36:14 +02:00
property color color: systemColors.window
2024-07-08 16:08:21 +02:00
property alias text: buttonText.text
signal clicked()
Rectangle {
id: background
anchors.fill: parent
color: getModifiedColor(buttonMouseArea, root.color)
}
Text {
id: buttonText
anchors.centerIn: parent
}
MouseArea {
id: buttonMouseArea
anchors.fill: parent
hoverEnabled: true
onClicked: {
root.clicked()
}
}
function getModifiedColor(item, color)
{
if (item.containsPress) {
return Qt.darker(color)
} else if (item.containsMouse) {
return Qt.lighter(color)
} else {
return color
}
}
}