FluentUI/src/controls/FluIconButton.qml

45 lines
901 B
QML
Raw Normal View History

2023-02-26 23:47:07 +08:00
import QtQuick 2.15
Rectangle {
2023-02-27 18:46:39 +08:00
id:button
width: 30
height: 30
2023-02-26 23:47:07 +08:00
2023-02-27 18:46:39 +08:00
property int iconSize: 20
2023-02-26 23:47:07 +08:00
property int icon
2023-02-27 18:46:39 +08:00
property color iconColor: "#000000"
signal clicked
radius: 4
color: {
if(FluApp.isDark){
return button_mouse.containsMouse ? "#000000" : "#00000000"
}else{
return button_mouse.containsMouse ? "#F4F4F4" : "#00000000"
}
}
2023-02-26 23:47:07 +08:00
Text {
2023-02-27 18:46:39 +08:00
id:text_icon
2023-02-26 23:47:07 +08:00
font.family: "fontawesome"
2023-02-27 18:46:39 +08:00
font.pixelSize: iconSize
2023-02-26 23:47:07 +08:00
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
2023-02-27 18:46:39 +08:00
anchors.centerIn: parent
color: iconColor
2023-02-26 23:47:07 +08:00
text: (String.fromCharCode(icon).toString(16));
}
2023-02-27 18:46:39 +08:00
MouseArea{
id:button_mouse
anchors.fill: parent
hoverEnabled: true
onClicked: {
button.clicked()
}
}
2023-02-26 23:47:07 +08:00
}