status-desktop/ui/imports/shared/panels/RoundedIcon.qml

88 lines
2.0 KiB
QML
Raw Normal View History

import QtQuick 2.15
import QtGraphicalEffects 1.15
import StatusQ.Core.Theme 0.1
import utils 1.0
import "../"
2020-05-13 19:41:16 +00:00
Rectangle {
id: root
property alias source: roundedIconImage.source
default property alias content: content.children
property alias icon: roundedIconImage
property bool rotates: false
signal clicked
width: 36
height: 36
property alias iconWidth: roundedIconImage.width
property alias iconHeight: roundedIconImage.height
property alias rotation: roundedIconImage.rotation
property color iconColor: Theme.palette.transparent
2020-05-13 19:41:16 +00:00
color: Theme.palette.primaryColor1
radius: width / 2
2020-05-13 19:41:16 +00:00
Item {
id: iconContainer
2020-05-13 19:41:16 +00:00
anchors.horizontalCenter: parent.horizontalCenter
anchors.verticalCenter: parent.verticalCenter
width: roundedIconImage.width
height: roundedIconImage.height
SVGImage {
id: roundedIconImage
width: 12
height: 12
fillMode: Image.PreserveAspectFit
source: Theme.svg("new_chat")
}
ColorOverlay {
anchors.fill: roundedIconImage
source: roundedIconImage
color: root.iconColor
2020-09-17 06:40:41 +00:00
rotation: roundedIconImage.rotation
}
}
Loader {
active: rotates
sourceComponent: rotatorComponent
}
Component {
id: rotatorComponent
RotationAnimator {
target: iconContainer
from: 0;
to: 360;
duration: 1200
running: visible
loops: Animation.Infinite
}
}
Item {
id: content
anchors.left: iconContainer.right
anchors.leftMargin: 6 + (root.width - iconContainer.width)
2020-05-13 19:41:16 +00:00
}
MouseArea {
id: mouseArea
anchors.fill: parent
acceptedButtons: Qt.LeftButton | Qt.RightButton
cursorShape: Qt.PointingHandCursor
onClicked: {
root.clicked()
}
}
2020-05-13 19:41:16 +00:00
}
/*##^##
Designer {
D{i:0;formeditorZoom:1.75}
}
##^##*/