summaryrefslogtreecommitdiff
path: root/modules/bar/components/Tray.qml
blob: 8aaa533ca3fb62ceafdb05caa70f3d68738e4ce3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import "root:/widgets"
import "root:/services"
import "root:/config"
import Quickshell
import Quickshell.Widgets
import Quickshell.Services.SystemTray
import QtQuick
import Qt5Compat.GraphicalEffects

StyledRect {
    animate: true
    clip: true
    visible: width > 0 && height > 0 // To avoid warnings about being visible with no size

    BoxLayout {
        Repeater {
            model: SystemTray.items

            MouseArea {
                id: item

                required property SystemTrayItem modelData

                acceptedButtons: Qt.LeftButton | Qt.RightButton
                width: Appearance.font.size.smaller * 2
                height: Appearance.font.size.smaller * 2

                onClicked: event => {
                    if (event.button === Qt.LeftButton)
                        modelData.activate();
                    else if (modelData.hasMenu)
                        menu.open();
                }

                // TODO custom menu
                QsMenuAnchor {
                    id: menu

                    menu: item.modelData.menu
                    anchor.window: QsWindow.window
                }

                IconImage {
                    id: icon

                    visible: !BarConfig.tray.recolourIcons
                    source: item.modelData.icon
                    anchors.fill: parent
                }

                ColorOverlay {
                    visible: BarConfig.tray.recolourIcons
                    anchors.fill: icon
                    source: icon
                    color: Appearance.colours.lavender
                }
            }
        }
    }
}