Alisa/native/TextButton.qml

45 lines
855 B
QML

import QtQuick
Item {
SystemPalette { id: systemColors; colorGroup: SystemPalette.Active }
id: root
property color color: systemColors.window
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
}
}
}