status-desktop/ui/shared/status/StatusIconButton.qml
Alexandra Betouni 4ee21ada05 feat(desktop) Added image function in Style
Introduced Style.svg() Style.png() Style.emoji() and
Style.icon() in Style.qml. Those should be used to
set the source in Images instead of using relative
paths. Usage:
Image {
   source: Style.svg("check)
   ....

Also moved all Singletons inside a new "utils"
folder and made it a QML module, to use
import utils 1.0 instead of relative paths

Closes #3678
2021-09-28 15:28:00 -04:00

88 lines
2.3 KiB
QML

import QtQuick 2.13
import QtQuick.Controls 2.13
import QtGraphicalEffects 1.13
import utils 1.0
import "../../shared"
RoundButton {
id: control
property string type: "primary"
property color iconColor: Style.current.secondaryText
property color highlightedIconColor: Style.current.blue
property color hoveredIconColor: Style.current.blue
property color highlightedBackgroundColor: Style.current.secondaryBackground
property real highlightedBackgroundOpacity: 1.0
property color disabledColor: iconColor
property int iconRotation: 0
implicitHeight: 32
implicitWidth: 32
icon.height: 20
icon.width: 20
icon.color: {
if (!enabled) {
return control.disabledColor
}
if (hovered) {
return control.hoveredIconColor
}
if (highlighted) {
return control.highlightedIconColor
}
return control.iconColor
}
radius: Style.current.radius
onIconChanged: {
icon.source = icon.name ? Style.svg(icon.name) : ""
}
background: Rectangle {
anchors.fill: parent
opacity: control.highlightedBackgroundOpacity
color: {
if (type === "secondary") {
return "transparent"
}
return hovered || highlighted ? control.highlightedBackgroundColor : "transparent"
}
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
rotation: control.iconRotation
}
ColorOverlay {
visible: control.visible
anchors.fill: iconImg
source: iconImg
color: control.icon.color
antialiasing: true
smooth: true
rotation: control.iconRotation
}
}
MouseArea {
cursorShape: Qt.PointingHandCursor
anchors.fill: parent
onPressed: mouse.accepted = false
}
}