import QtQuick import "../core" import "../theme" // A bar module that is one glyph switching something on and off (Caffeine, // Night Light). Lit in the accent colour while on. `bare` (the spots beside // the notch) drops the pill and keeps only a soft hover circle. Item { id: root property string glyph property bool on: false property bool bare: false property string tip: "" signal clicked implicitWidth: ModuleRegistry.pillHeight implicitHeight: ModuleRegistry.pillHeight opacity: enabled ? 1 : 0.45 GlassPill { anchors.fill: parent visible: !root.bare } Rectangle { anchors.centerIn: parent width: parent.height - 6 height: width radius: width / 2 color: root.on ? Qt.alpha(Theme.accent, 0.16) : Theme.hover opacity: area.containsMouse || root.on ? 1 : 0 Behavior on opacity { NumberAnimation { duration: Theme.duration / 2 } } } Text { anchors.centerIn: parent text: root.glyph color: root.on ? Theme.accent : Theme.text font.pixelSize: Math.round(root.height * 0.46) Behavior on color { ColorAnimation { duration: Theme.duration } } } scale: area.pressed ? 1 - 0.06 * Theme.intensity : 1 Behavior on scale { NumberAnimation { duration: Theme.duration / 2; easing.type: Easing.OutCubic } } MouseArea { id: area anchors.fill: parent hoverEnabled: true cursorShape: Qt.PointingHandCursor onClicked: root.clicked() } Accessible.role: Accessible.CheckBox Accessible.name: root.tip Accessible.checked: root.on }