2023-03-30 21:52:55 +08:00
|
|
|
|
import QtQuick
|
|
|
|
|
import QtQuick.Controls
|
|
|
|
|
import FluentUI
|
2023-02-26 23:47:07 +08:00
|
|
|
|
|
2023-03-12 21:49:11 +08:00
|
|
|
|
Button {
|
2023-02-26 23:47:07 +08:00
|
|
|
|
|
2023-02-27 18:46:39 +08:00
|
|
|
|
property int iconSize: 20
|
2023-03-12 21:49:11 +08:00
|
|
|
|
property int iconSource
|
2023-02-28 18:29:00 +08:00
|
|
|
|
property bool disabled: false
|
2023-03-28 11:53:25 +08:00
|
|
|
|
property int radius:4
|
2023-03-28 21:37:10 +08:00
|
|
|
|
property color hoverColor: FluTheme.dark ? Qt.rgba(62/255,62/255,62/255,1) : Qt.rgba(0,0,0,0.03)
|
|
|
|
|
property color normalColor: FluTheme.dark ? Qt.rgba(0,0,0,0) : Qt.rgba(0,0,0,0)
|
2023-03-29 18:10:34 +08:00
|
|
|
|
property color disableColor: FluTheme.dark ? Qt.rgba(0,0,0,0) : Qt.rgba(0,0,0,0)
|
2023-03-12 14:26:03 +08:00
|
|
|
|
property color color: {
|
|
|
|
|
if(disabled){
|
|
|
|
|
return disableColor
|
|
|
|
|
}
|
|
|
|
|
return hovered ? hoverColor : normalColor
|
|
|
|
|
}
|
2023-03-06 14:22:13 +08:00
|
|
|
|
property color textColor: {
|
2023-03-28 21:37:10 +08:00
|
|
|
|
if(FluTheme.dark){
|
2023-03-06 14:22:13 +08:00
|
|
|
|
if(disabled){
|
|
|
|
|
return Qt.rgba(130/255,130/255,130/255,1)
|
|
|
|
|
}
|
|
|
|
|
return Qt.rgba(1,1,1,1)
|
|
|
|
|
}else{
|
|
|
|
|
if(disabled){
|
|
|
|
|
return Qt.rgba(161/255,161/255,161/255,1)
|
|
|
|
|
}
|
|
|
|
|
return Qt.rgba(0,0,0,1)
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-02-27 18:46:39 +08:00
|
|
|
|
|
2023-03-12 22:36:31 +08:00
|
|
|
|
id:control
|
|
|
|
|
width: 30
|
|
|
|
|
height: 30
|
|
|
|
|
implicitWidth: width
|
|
|
|
|
implicitHeight: height
|
|
|
|
|
padding: 0
|
|
|
|
|
enabled: !disabled
|
|
|
|
|
focusPolicy:Qt.TabFocus
|
|
|
|
|
Keys.onSpacePressed: control.visualFocus&&clicked()
|
2023-03-12 14:26:03 +08:00
|
|
|
|
background: Rectangle{
|
2023-03-28 11:53:25 +08:00
|
|
|
|
radius: control.radius
|
2023-03-12 14:26:03 +08:00
|
|
|
|
color:control.color
|
|
|
|
|
FluFocusRectangle{
|
2023-03-12 22:36:31 +08:00
|
|
|
|
visible: control.visualFocus
|
2023-03-12 14:26:03 +08:00
|
|
|
|
}
|
2023-02-26 23:47:07 +08:00
|
|
|
|
}
|
2023-03-12 14:26:03 +08:00
|
|
|
|
contentItem: Item{
|
|
|
|
|
Text {
|
|
|
|
|
id:text_icon
|
|
|
|
|
font.family: "Segoe Fluent Icons"
|
|
|
|
|
font.pixelSize: iconSize
|
2023-03-12 21:49:11 +08:00
|
|
|
|
width: iconSize
|
|
|
|
|
height: iconSize
|
2023-03-12 14:26:03 +08:00
|
|
|
|
horizontalAlignment: Text.AlignHCenter
|
|
|
|
|
verticalAlignment: Text.AlignVCenter
|
|
|
|
|
anchors.centerIn: parent
|
|
|
|
|
color:control.textColor
|
2023-03-12 21:49:11 +08:00
|
|
|
|
text: (String.fromCharCode(iconSource).toString(16));
|
2023-02-27 18:46:39 +08:00
|
|
|
|
}
|
2023-03-12 14:26:03 +08:00
|
|
|
|
FluTooltip{
|
|
|
|
|
id:tool_tip
|
|
|
|
|
visible: {
|
|
|
|
|
if(control.text === ""){
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
return hovered
|
2023-02-28 18:29:00 +08:00
|
|
|
|
}
|
2023-03-12 21:49:11 +08:00
|
|
|
|
text:control.text
|
2023-03-12 14:26:03 +08:00
|
|
|
|
delay: 1000
|
2023-02-28 18:29:00 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2023-02-26 23:47:07 +08:00
|
|
|
|
}
|