2023-04-04 11:31:04 +00:00
|
|
|
import QtQuick 2.15
|
|
|
|
|
|
|
|
import StatusQ.Controls 0.1
|
|
|
|
|
|
|
|
Item {
|
|
|
|
id: root
|
|
|
|
property string aliasedObjectName
|
|
|
|
property string text
|
|
|
|
property string icon
|
|
|
|
property alias tooltipText: tooltip.text
|
|
|
|
property int buttonType: DisabledTooltipButton.Normal
|
|
|
|
property bool interactive: true
|
2023-08-07 13:35:14 +00:00
|
|
|
property Component buttonComponent: buttonType === DisabledTooltipButton.Normal ? normalButton : flatButton
|
|
|
|
|
2023-04-04 11:31:04 +00:00
|
|
|
signal clicked()
|
|
|
|
|
|
|
|
enum Type {
|
|
|
|
Normal, // 0
|
|
|
|
Flat // 1
|
|
|
|
}
|
|
|
|
|
2023-07-10 14:12:25 +00:00
|
|
|
implicitWidth: !!buttonLoader.item ? buttonLoader.item.width : 0
|
|
|
|
implicitHeight: !!buttonLoader.item ? buttonLoader.item.height : 0
|
2023-04-04 11:31:04 +00:00
|
|
|
|
|
|
|
Loader {
|
|
|
|
id: buttonLoader
|
|
|
|
anchors.centerIn: parent
|
2023-08-07 13:35:14 +00:00
|
|
|
sourceComponent: buttonComponent
|
2023-04-04 11:31:04 +00:00
|
|
|
active: root.visible
|
|
|
|
}
|
|
|
|
HoverHandler {
|
|
|
|
id: hoverHandler
|
|
|
|
enabled: !root.interactive
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
}
|
|
|
|
StatusToolTip {
|
|
|
|
id: tooltip
|
|
|
|
visible: hoverHandler.hovered
|
|
|
|
}
|
|
|
|
|
|
|
|
Component{
|
|
|
|
id: flatButton
|
|
|
|
StatusFlatButton {
|
|
|
|
objectName: root.aliasedObjectName
|
|
|
|
icon.name: root.icon
|
|
|
|
text: root.text
|
|
|
|
enabled: root.interactive
|
|
|
|
onClicked: root.clicked()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Component{
|
|
|
|
id: normalButton
|
|
|
|
StatusButton {
|
|
|
|
objectName: root.aliasedObjectName
|
|
|
|
icon.name: root.icon
|
|
|
|
text: root.text
|
|
|
|
enabled: root.interactive
|
|
|
|
onClicked: root.clicked()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|