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

68 lines
1.8 KiB
QML

import QtQuick 2.13
import QtGraphicalEffects 1.13
import utils 1.0
import "../../../../shared"
Rectangle {
id: headerButton
width: buttonImage.width + buttonText.width + Style.current.smallPadding * 2
+ (text === "" ? 0 : headerButton.btnMargin)
height: buttonText.height + Style.current.smallPadding * 2
border.width: 0
color: Style.current.transparent
radius: Style.current.radius
property int btnMargin
property string text: ""
property url imageSource
property bool flipImage: false
signal clicked()
SVGImage {
id: buttonImage
height: 18
anchors.left: parent.left
anchors.leftMargin: Style.current.smallPadding
anchors.verticalCenter: parent.verticalCenter
fillMode: Image.PreserveAspectFit
source: headerButton.imageSource
rotation: flipImage ? 180 : 0
ColorOverlay {
anchors.fill: parent
source: parent
color: Style.current.primary
}
}
StyledText {
id: buttonText
visible: !!headerButton.text
text: headerButton.text
anchors.left: buttonImage.right
anchors.leftMargin: headerButton.btnMargin
anchors.verticalCenter: parent.verticalCenter
font.pixelSize: 13
font.family: Style.current.fontMedium.name
font.weight: Font.Medium
color: Style.current.blue
}
MouseArea {
anchors.fill: parent
hoverEnabled: true
cursorShape: Qt.PointingHandCursor
onEntered: {
headerButton.color = Style.current.secondaryBackground;
}
onExited: {
headerButton.color = Style.current.transparent;
}
onClicked: {
headerButton.clicked();
}
}
}