Krolyxon
Commit 8ab0f85

Branches

Refs →

aurora.configquickshellauroraBarPill.qml

68 lines · 2.1 KB · QML

1import QtQuick
2
3// One block of the bar: icon, caps label, optional second icon with its own click (activated2), anything else declared
4// inside goes after them (the battery capsule, the clock). Hover = a rounded highlight.
5Item {
6 id: p
7 property string icon: ""
8 property string text: ""
9 property color tint: Theme.fg
10 property color underline: "transparent" // old style, unused
11 property string icon2: ""
12 property color tint2: Theme.fg
13 default property alias extra: row.data
14 signal activated(int button)
15 signal activated2(int button)
16 signal scrolled(int dir)
17
18 implicitWidth: row.implicitWidth + 22
19 implicitHeight: parent ? parent.height : Theme.barSize
20
21 Rectangle {
22 anchors.fill: parent
23 anchors.topMargin: 5
24 anchors.bottomMargin: 5
25 radius: height / 2
26 color: m.containsMouse ? Theme.s2 : "transparent"
27 }
28 Row {
29 id: row
30 anchors.centerIn: parent
31 spacing: 7
32 Icon {
33 visible: p.icon !== ""
34 anchors.verticalCenter: parent.verticalCenter
35 text: p.icon
36 font.pixelSize: 16
37 color: p.tint
38 }
39 Lb {
40 visible: p.text !== ""
41 anchors.verticalCenter: parent.verticalCenter
42 text: p.text
43 px: 11
44 color: p.tint
45 }
46 Icon {
47 id: second
48 visible: p.icon2 !== ""
49 anchors.verticalCenter: parent.verticalCenter
50 text: p.icon2
51 font.pixelSize: 16
52 color: p.tint2
53 }
54 }
55 MouseArea {
56 id: m
57 anchors.fill: parent
58 hoverEnabled: true
59 cursorShape: Qt.PointingHandCursor
60 acceptedButtons: Qt.LeftButton | Qt.RightButton | Qt.MiddleButton
61 onClicked: mouse => {
62 // split at the middle of the gap before the second icon
63 if (second.visible && mouse.x >= row.x + second.x - row.spacing / 2) p.activated2(mouse.button)
64 else p.activated(mouse.button)
65 }
66 onWheel: w => p.scrolled(w.angleDelta.y > 0 ? 1 : -1)
67 }
68}