Krolyxon
Commit 84eb284

Branches

Refs →

aurora.configquickshellauroraBarPill.qml

74 lines · 2.2 KB · QML

1import QtQuick
2
3// A waybar-style block: flat, 12px padding, 1px accent underline.
4Item {
5 id: p
6 property string icon: ""
7 property string text: ""
8 property color tint: Theme.fg
9 property color underline: Theme.accent
10 // optional second icon in the same block, with its own click (activated2)
11 property string icon2: ""
12 property color tint2: Theme.fg
13 signal activated(int button)
14 signal activated2(int button)
15 signal scrolled(int dir)
16
17 implicitWidth: row.implicitWidth + 24
18 implicitHeight: parent ? parent.height : Theme.barHeight
19
20 Rectangle {
21 anchors.fill: parent
22 color: m.containsMouse ? Theme.surface : "transparent"
23 }
24 Rectangle {
25 anchors.left: parent.left
26 anchors.right: parent.right
27 anchors.bottom: parent.bottom
28 height: 1
29 color: p.underline
30 }
31 Row {
32 id: row
33 anchors.centerIn: parent
34 spacing: 6
35 Text {
36 visible: p.icon !== ""
37 text: p.icon
38 color: p.tint
39 font.family: Theme.font
40 font.pixelSize: Theme.fontSize + 1
41 anchors.verticalCenter: parent.verticalCenter
42 }
43 Text {
44 visible: p.text !== ""
45 text: p.text
46 color: p.tint
47 font.family: Theme.font
48 font.pixelSize: Theme.fontSize
49 font.bold: true
50 anchors.verticalCenter: parent.verticalCenter
51 }
52 Text {
53 id: second
54 visible: p.icon2 !== ""
55 text: p.icon2
56 color: p.tint2
57 font.family: Theme.font
58 font.pixelSize: Theme.fontSize + 1
59 anchors.verticalCenter: parent.verticalCenter
60 }
61 }
62 MouseArea {
63 id: m
64 anchors.fill: parent
65 hoverEnabled: true
66 acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MiddleButton
67 onClicked: mouse => {
68 // split at the middle of the gap before the second icon
69 if (second.visible && mouse.x >= row.x + second.x - row.spacing / 2) p.activated2(mouse.button)
70 else p.activated(mouse.button)
71 }
72 onWheel: w => p.scrolled(w.angleDelta.y > 0 ? 1 : -1)
73 }
74}