2020-09-25 12:13:40 +00:00
|
|
|
import QtQuick 2.13
|
|
|
|
import QtQuick.Controls 2.13
|
|
|
|
import QtGraphicalEffects 1.13
|
2021-09-28 15:04:06 +00:00
|
|
|
|
|
|
|
import utils 1.0
|
2020-09-25 12:13:40 +00:00
|
|
|
import "../../shared"
|
2021-10-14 12:14:11 +00:00
|
|
|
import "../../shared/panels"
|
2020-09-25 12:13:40 +00:00
|
|
|
|
|
|
|
RoundButton {
|
|
|
|
id: control
|
|
|
|
|
|
|
|
property string type: "primary"
|
2020-10-08 18:36:44 +00:00
|
|
|
property color iconColor: Style.current.secondaryText
|
2020-12-04 10:32:59 +00:00
|
|
|
property color highlightedIconColor: Style.current.blue
|
|
|
|
property color hoveredIconColor: Style.current.blue
|
|
|
|
property color highlightedBackgroundColor: Style.current.secondaryBackground
|
2021-01-20 16:16:45 +00:00
|
|
|
property real highlightedBackgroundOpacity: 1.0
|
2020-10-08 18:36:44 +00:00
|
|
|
property color disabledColor: iconColor
|
2020-10-08 15:31:53 +00:00
|
|
|
property int iconRotation: 0
|
2020-09-25 12:13:40 +00:00
|
|
|
|
|
|
|
implicitHeight: 32
|
|
|
|
implicitWidth: 32
|
|
|
|
|
|
|
|
icon.height: 20
|
|
|
|
icon.width: 20
|
2020-10-08 15:31:53 +00:00
|
|
|
icon.color: {
|
|
|
|
if (!enabled) {
|
|
|
|
return control.disabledColor
|
|
|
|
}
|
|
|
|
|
2020-12-04 10:32:59 +00:00
|
|
|
if (hovered) {
|
|
|
|
return control.hoveredIconColor
|
|
|
|
}
|
|
|
|
|
|
|
|
if (highlighted) {
|
|
|
|
return control.highlightedIconColor
|
|
|
|
}
|
|
|
|
return control.iconColor
|
2020-10-08 15:31:53 +00:00
|
|
|
}
|
2020-09-25 12:13:40 +00:00
|
|
|
radius: Style.current.radius
|
|
|
|
|
|
|
|
onIconChanged: {
|
2021-09-28 15:04:06 +00:00
|
|
|
icon.source = icon.name ? Style.svg(icon.name) : ""
|
2020-09-25 12:13:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
background: Rectangle {
|
|
|
|
anchors.fill: parent
|
2021-01-20 16:16:45 +00:00
|
|
|
opacity: control.highlightedBackgroundOpacity
|
2020-09-25 12:13:40 +00:00
|
|
|
color: {
|
|
|
|
if (type === "secondary") {
|
|
|
|
return "transparent"
|
|
|
|
}
|
2020-12-04 10:32:59 +00:00
|
|
|
return hovered || highlighted ? control.highlightedBackgroundColor : "transparent"
|
2020-09-25 12:13:40 +00:00
|
|
|
}
|
|
|
|
radius: control.radius
|
|
|
|
}
|
|
|
|
|
|
|
|
contentItem: Item {
|
|
|
|
anchors.fill: parent
|
|
|
|
|
|
|
|
SVGImage {
|
|
|
|
id: iconImg
|
|
|
|
visible: false
|
|
|
|
source: control.icon.source
|
|
|
|
height: control.icon.height
|
|
|
|
width: control.icon.width
|
|
|
|
anchors.horizontalCenter: parent.horizontalCenter
|
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
fillMode: Image.PreserveAspectFit
|
2020-10-08 15:31:53 +00:00
|
|
|
rotation: control.iconRotation
|
2020-09-25 12:13:40 +00:00
|
|
|
}
|
|
|
|
ColorOverlay {
|
2020-12-04 10:32:59 +00:00
|
|
|
visible: control.visible
|
2020-09-25 12:13:40 +00:00
|
|
|
anchors.fill: iconImg
|
|
|
|
source: iconImg
|
|
|
|
color: control.icon.color
|
|
|
|
antialiasing: true
|
|
|
|
smooth: true
|
2020-10-08 15:31:53 +00:00
|
|
|
rotation: control.iconRotation
|
2020-09-25 12:13:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
anchors.fill: parent
|
|
|
|
onPressed: mouse.accepted = false
|
|
|
|
}
|
|
|
|
}
|