summaryrefslogtreecommitdiff
path: root/accounts/gkleen@sif/shell/quickshell/WaylandInhibitorWidget.qml
blob: 0512ff511bbd18a5d719b7b2f8726009d658bd38 (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
import Quickshell
import QtQuick
import Quickshell.Widgets
import Quickshell.Wayland
import qs.Services

Item {
  id: root

  required property var window

  width: icon.width + 8
  height: parent.height
  anchors.verticalCenter: parent.verticalCenter

  IdleInhibitor {
    id: inhibitor
    enabled: InhibitorState.waylandIdleInhibited
    window: root.window
  }

  WrapperMouseArea {
    id: widgetMouseArea

    anchors.fill: parent

    hoverEnabled: true
    cursorShape: Qt.PointingHandCursor

    onClicked: InhibitorState.waylandIdleInhibited = !InhibitorState.waylandIdleInhibited

    Rectangle {
      anchors.fill: parent
      color: {
	if (widgetMouseArea.containsMouse) {
	  return "#33808080";
	}
	return "transparent";
      }

      Item {
	anchors.fill: parent

	MaterialDesignIcon {
	  id: icon

	  implicitSize: 14
	  anchors.centerIn: parent

	  icon: inhibitor.enabled ? "eye" : "eye-off"
	  color: inhibitor.enabled ? "white" : "#555"
	}
      }
    }
  }
}