2024-10-15 19:26:12 +00:00
|
|
|
import QtQuick 2.15
|
2021-09-28 15:04:06 +00:00
|
|
|
|
|
|
|
import utils 1.0
|
2020-12-29 15:31:26 +00:00
|
|
|
import ".."
|
2021-10-14 11:53:56 +00:00
|
|
|
import "../panels"
|
2020-12-29 15:31:26 +00:00
|
|
|
|
2021-10-26 09:30:05 +00:00
|
|
|
import StatusQ.Controls 0.1 as StatusQControls
|
2023-04-25 10:32:57 +00:00
|
|
|
import StatusQ.Core 0.1 as StatusQCore
|
2024-10-15 19:26:12 +00:00
|
|
|
import StatusQ.Core.Theme 0.1
|
2021-10-26 09:30:05 +00:00
|
|
|
|
2021-01-19 19:26:59 +00:00
|
|
|
Rectangle {
|
2020-12-29 15:31:26 +00:00
|
|
|
property string text
|
|
|
|
property bool isSwitch: false
|
|
|
|
property bool switchChecked: false
|
|
|
|
property string currentValue
|
2021-01-15 19:21:19 +00:00
|
|
|
property bool isBadge: false
|
|
|
|
property string badgeText: "1"
|
2021-03-16 15:12:28 +00:00
|
|
|
property int badgeRadius: 9
|
2021-01-15 19:21:19 +00:00
|
|
|
property bool isEnabled: true
|
2020-12-29 15:31:26 +00:00
|
|
|
signal clicked(bool checked)
|
2021-01-19 19:26:59 +00:00
|
|
|
property bool isHovered: false
|
2021-03-16 15:12:28 +00:00
|
|
|
property int badgeSize: 18
|
2021-05-25 19:38:18 +00:00
|
|
|
property url iconSource
|
2020-12-29 15:31:26 +00:00
|
|
|
|
|
|
|
id: root
|
2021-05-25 19:38:18 +00:00
|
|
|
implicitHeight: 52
|
2024-10-15 19:26:12 +00:00
|
|
|
color: isHovered ? Theme.palette.backgroundHover : Theme.palette.transparent
|
|
|
|
radius: Theme.radius
|
2021-01-19 19:26:59 +00:00
|
|
|
border.width: 0
|
|
|
|
anchors.left: parent.left
|
2024-10-15 19:26:12 +00:00
|
|
|
anchors.leftMargin: -Theme.padding
|
2021-01-19 19:26:59 +00:00
|
|
|
anchors.right: parent.right
|
2024-10-15 19:26:12 +00:00
|
|
|
anchors.rightMargin: -Theme.padding
|
2020-12-29 15:31:26 +00:00
|
|
|
|
2021-05-25 19:38:18 +00:00
|
|
|
RoundedIcon {
|
|
|
|
id: pinImage
|
|
|
|
visible: !!root.iconSource.toString()
|
|
|
|
source: root.iconSource
|
2024-10-15 19:26:12 +00:00
|
|
|
iconColor: Theme.palette.primaryColor1
|
|
|
|
color: Theme.palette.secondaryBackground
|
2021-05-25 19:38:18 +00:00
|
|
|
width: 40
|
|
|
|
height: 40
|
|
|
|
iconWidth: 24
|
|
|
|
iconHeight: 24
|
|
|
|
anchors.left: parent.left
|
2024-10-15 19:26:12 +00:00
|
|
|
anchors.leftMargin: Theme.padding
|
2021-05-25 19:38:18 +00:00
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
|
|
|
}
|
|
|
|
|
2020-12-29 15:31:26 +00:00
|
|
|
StyledText {
|
|
|
|
id: textItem
|
2021-05-25 19:38:18 +00:00
|
|
|
anchors.left: pinImage.visible ? pinImage.right : parent.left
|
2024-10-15 19:26:12 +00:00
|
|
|
anchors.leftMargin: Theme.padding
|
2021-01-19 19:26:59 +00:00
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
2020-12-29 15:31:26 +00:00
|
|
|
text: root.text
|
|
|
|
font.pixelSize: 15
|
2024-10-15 19:26:12 +00:00
|
|
|
color: Theme.palette.textColor
|
2020-12-29 15:31:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
StyledText {
|
|
|
|
id: valueText
|
|
|
|
visible: !!root.currentValue
|
|
|
|
text: root.currentValue
|
2021-01-04 20:34:46 +00:00
|
|
|
elide: Text.ElideRight
|
2020-12-29 15:31:26 +00:00
|
|
|
font.pixelSize: 15
|
2021-01-04 20:34:46 +00:00
|
|
|
horizontalAlignment: Text.AlignRight
|
2024-10-15 19:26:12 +00:00
|
|
|
color: Theme.palette.secondaryText
|
2021-01-04 20:34:46 +00:00
|
|
|
anchors.left: textItem.right
|
2024-10-15 19:26:12 +00:00
|
|
|
anchors.leftMargin: Theme.padding
|
2020-12-29 15:31:26 +00:00
|
|
|
anchors.right: root.isSwitch ? switchItem.left : caret.left
|
2024-10-15 19:26:12 +00:00
|
|
|
anchors.rightMargin: Theme.padding
|
2020-12-29 15:31:26 +00:00
|
|
|
anchors.verticalCenter: textItem.verticalCenter
|
2021-01-19 19:26:59 +00:00
|
|
|
|
2020-12-29 15:31:26 +00:00
|
|
|
}
|
|
|
|
|
2021-10-26 09:30:05 +00:00
|
|
|
StatusQControls.StatusSwitch {
|
2020-12-29 15:31:26 +00:00
|
|
|
id: switchItem
|
2021-01-15 19:21:19 +00:00
|
|
|
enabled: root.isEnabled
|
2020-12-29 15:31:26 +00:00
|
|
|
visible: root.isSwitch
|
|
|
|
checked: root.switchChecked
|
|
|
|
anchors.right: parent.right
|
2024-10-15 19:26:12 +00:00
|
|
|
anchors.rightMargin: Theme.padding
|
2020-12-29 15:31:26 +00:00
|
|
|
anchors.verticalCenter: textItem.verticalCenter
|
|
|
|
}
|
|
|
|
|
2021-01-15 19:21:19 +00:00
|
|
|
Rectangle {
|
|
|
|
id: badge
|
|
|
|
visible: root.isBadge & !root.isSwitch
|
|
|
|
anchors.right: root.isSwitch ? switchItem.left : caret.left
|
2024-10-15 19:26:12 +00:00
|
|
|
anchors.rightMargin: Theme.padding
|
2021-01-15 19:21:19 +00:00
|
|
|
anchors.verticalCenter: textItem.verticalCenter
|
2021-03-16 15:12:28 +00:00
|
|
|
radius: root.badgeRadius
|
2024-10-15 19:26:12 +00:00
|
|
|
color: Theme.palette.primaryColor1
|
2021-03-16 15:12:28 +00:00
|
|
|
width: root.badgeSize
|
|
|
|
height: root.badgeSize
|
2021-01-15 19:21:19 +00:00
|
|
|
Text {
|
|
|
|
font.pixelSize: 12
|
2024-10-15 19:26:12 +00:00
|
|
|
color: Theme.palette.white
|
2021-01-15 19:21:19 +00:00
|
|
|
anchors.centerIn: parent
|
|
|
|
text: root.badgeText
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-04-25 10:32:57 +00:00
|
|
|
StatusQCore.StatusIcon {
|
2020-12-29 15:31:26 +00:00
|
|
|
id: caret
|
|
|
|
visible: !root.isSwitch
|
|
|
|
anchors.right: parent.right
|
2024-10-15 19:26:12 +00:00
|
|
|
anchors.rightMargin: Theme.padding
|
2020-12-29 15:31:26 +00:00
|
|
|
anchors.verticalCenter: textItem.verticalCenter
|
2023-04-25 10:32:57 +00:00
|
|
|
icon: "next"
|
2024-10-15 19:26:12 +00:00
|
|
|
color: Theme.palette.secondaryText
|
2020-12-29 15:31:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
MouseArea {
|
|
|
|
anchors.fill: parent
|
2021-01-15 19:21:19 +00:00
|
|
|
enabled: root.isEnabled
|
2021-01-19 19:26:59 +00:00
|
|
|
hoverEnabled: true
|
|
|
|
onEntered: root.isHovered = true
|
|
|
|
onExited: root.isHovered = false
|
2020-12-29 15:31:26 +00:00
|
|
|
onClicked: {
|
|
|
|
root.clicked(!root.switchChecked)
|
|
|
|
}
|
|
|
|
cursorShape: Qt.PointingHandCursor
|
|
|
|
}
|
|
|
|
}
|