49 lines
1.2 KiB
QML
49 lines
1.2 KiB
QML
import QtQuick 2.14
|
|
import QtQuick.Controls 2.14
|
|
import "qrc:/QmlFiles/qml/components"
|
|
|
|
Button {
|
|
id: toolBarButton
|
|
property string iconSource: ""
|
|
property color hoverColor: Colors.sColor_GoldWithBlack
|
|
property int buttonWidth: 40 // 默认宽度
|
|
property int buttonHeight: 40 // 默认高度
|
|
|
|
width: buttonWidth
|
|
height: buttonHeight
|
|
implicitWidth: buttonWidth
|
|
implicitHeight: buttonHeight
|
|
|
|
background: Rectangle {
|
|
width: parent.width
|
|
height: parent.height
|
|
color: "transparent"
|
|
border.color: "red"
|
|
border.width: 0
|
|
radius: 0
|
|
|
|
MouseArea {
|
|
id: mouseArea
|
|
anchors.fill: parent
|
|
hoverEnabled: true
|
|
|
|
onEntered: {
|
|
parent.color = toolBarButton.hoverColor
|
|
}
|
|
|
|
onExited: {
|
|
parent.color = "transparent"
|
|
}
|
|
onClicked: toolBarButton.clicked()
|
|
}
|
|
}
|
|
|
|
contentItem: Image {
|
|
id: image
|
|
source: toolBarButton.iconSource
|
|
width: toolBarButton.buttonWidth
|
|
height: toolBarButton.buttonHeight
|
|
fillMode: Image.PreserveAspectFit
|
|
anchors.centerIn: parent
|
|
}
|
|
} |