Refine quickshell bar and Noctalia compatibility
This commit is contained in:
@@ -1,16 +1,26 @@
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
import qs.Commons
|
||||
|
||||
Switch {
|
||||
Rectangle {
|
||||
id: root
|
||||
property string label: ""
|
||||
|
||||
indicator: Rectangle {
|
||||
implicitWidth: 32
|
||||
implicitHeight: 18
|
||||
x: root.leftPadding
|
||||
y: root.height / 2 - height / 2
|
||||
property string label: ""
|
||||
property string text: ""
|
||||
property bool checked: false
|
||||
|
||||
signal toggled(var value)
|
||||
signal clicked()
|
||||
|
||||
implicitWidth: labelItem.visible ? indicator.width + 8 + labelItem.implicitWidth : indicator.width
|
||||
implicitHeight: Math.max(indicator.height, labelItem.implicitHeight)
|
||||
color: "transparent"
|
||||
opacity: enabled ? 1 : 0.4
|
||||
|
||||
Rectangle {
|
||||
id: indicator
|
||||
width: 32
|
||||
height: 18
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
radius: height / 2
|
||||
color: root.checked ? Color.mPrimary : Color.mSurfaceVariant
|
||||
border.color: Color.mOutline
|
||||
@@ -27,12 +37,28 @@ Switch {
|
||||
}
|
||||
}
|
||||
|
||||
contentItem: Text {
|
||||
leftPadding: 38
|
||||
Text {
|
||||
id: labelItem
|
||||
visible: (root.label || root.text) !== ""
|
||||
anchors.left: indicator.right
|
||||
anchors.leftMargin: 8
|
||||
anchors.verticalCenter: parent.verticalCenter
|
||||
text: root.label || root.text
|
||||
color: Color.mOnSurface
|
||||
font.family: "JetBrainsMono Nerd Font"
|
||||
font.pixelSize: Style.fontSizeS
|
||||
verticalAlignment: Text.AlignVCenter
|
||||
}
|
||||
|
||||
MouseArea {
|
||||
anchors.fill: parent
|
||||
hoverEnabled: true
|
||||
enabled: root.enabled
|
||||
cursorShape: Qt.PointingHandCursor
|
||||
onClicked: {
|
||||
root.checked = !root.checked
|
||||
root.clicked()
|
||||
root.toggled(root.checked)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user