diff --git a/config/Dimensions.qml b/config/Dimensions.qml index 81f0a7e..6fa759f 100644 --- a/config/Dimensions.qml +++ b/config/Dimensions.qml @@ -11,7 +11,6 @@ Singleton { property Bar bar: Bar {} property Mpris mpris: Mpris {} property Clock clock: Clock {} - property Caffeine caffeine: Caffeine {} property Workspace workspace: Workspace {} property Tray tray: Tray {} property TrayMenu trayMenu: TrayMenu {} @@ -46,15 +45,6 @@ Singleton { property int verticalPadding: 6 } - component Caffeine: QtObject { - id: clock - - property int iconSize: 14 - property int height: 30 - property int horizontalPadding: 8 - property int verticalPadding: 6 - } - component Workspace: QtObject { id: workspace diff --git a/constants/Icons.qml b/constants/Icons.qml index 5c28d27..d7c0930 100644 --- a/constants/Icons.qml +++ b/constants/Icons.qml @@ -3,7 +3,6 @@ pragma Singleton import Quickshell Singleton { - property string coffee: "\u{E09a}" property string triangle: "\u{E192}" property string triangleDashed: "\u{E642}" } diff --git a/modules/bar/Bar.qml b/modules/bar/Bar.qml index c4b766a..cbc77d0 100644 --- a/modules/bar/Bar.qml +++ b/modules/bar/Bar.qml @@ -75,9 +75,7 @@ Scope { spacing: Dimensions.bar.spacing - Mpris { - anchors.verticalCenter: parent.verticalCenter - } + Mpris {} } Row { @@ -92,13 +90,7 @@ Scope { spacing: Dimensions.bar.spacing - Caffeine { - anchors.verticalCenter: parent.verticalCenter - } - - Clock { - anchors.verticalCenter: parent.verticalCenter - } + Clock {} } } } diff --git a/modules/bar/components/Caffeine.qml b/modules/bar/components/Caffeine.qml deleted file mode 100644 index 4e5f1cf..0000000 --- a/modules/bar/components/Caffeine.qml +++ /dev/null @@ -1,46 +0,0 @@ -import QtQuick -import Quickshell.Io -import "../../../config/" -import "../../../constants/" -import "../../../styled/" - -Clickable { - id: clickable - - implicitWidth: text.width - implicitHeight: Dimensions.caffeine.height - - border.color: process.running ? Theme.palette.secondary : 'transparent' - border.width: 2 - - onClicked: { - if (process.running) { - process.signal(888); - process.running = false; - } else { - process.running = true; - } - } - - StyledText { - id: text - - font.family: Theme.lucide.font.family - font.pixelSize: Dimensions.workspace.iconSize - font.bold: true - text: Icons.coffee - - color: clickable.containsMouse ? Theme.palette.base300 : Theme.palette.basecontent - - anchors.verticalCenter: parent.verticalCenter - topPadding: Dimensions.mpris.verticalPadding - bottomPadding: Dimensions.mpris.verticalPadding - leftPadding: Dimensions.mpris.horizontalPadding - rightPadding: Dimensions.mpris.horizontalPadding - } - - Process { - id: process - command: ["sh", "-c", "systemd-inhibit --what=idle --who=Caffeine --why=Caffeine --mode=block sleep inf"] - } -} diff --git a/modules/bar/components/Clock.qml b/modules/bar/components/Clock.qml index 878e744..6e8bd8c 100644 --- a/modules/bar/components/Clock.qml +++ b/modules/bar/components/Clock.qml @@ -1,11 +1,19 @@ import Quickshell +import Quickshell.Io +import QtQuick import "../../../styled/" import "../../../config/" -StyledLabel { +Item { + id: root + implicitWidth: childrenRect.width implicitHeight: Dimensions.clock.height + StyledLabel { + anchors.fill: parent + } + StyledText { id: text anchors.verticalCenter: parent.verticalCenter diff --git a/modules/bar/components/tray/Tray.qml b/modules/bar/components/tray/Tray.qml index 0a95718..a907abc 100644 --- a/modules/bar/components/tray/Tray.qml +++ b/modules/bar/components/tray/Tray.qml @@ -16,7 +16,7 @@ Row { sourceComponent: item property Component item: TrayItem { - trayItem: modelData + trayItem: modelData } } } diff --git a/modules/bar/components/tray/TrayItem.qml b/modules/bar/components/tray/TrayItem.qml index 055171f..6e8fff6 100644 --- a/modules/bar/components/tray/TrayItem.qml +++ b/modules/bar/components/tray/TrayItem.qml @@ -38,17 +38,32 @@ Clickable { anchors.centerIn: parent } - Menu { - id: menu + PopupWindow { + id: popup - opened: root.menuOpened + visible: root.menuOpened + + color: 'transparent' anchor.item: root anchor.rect.x: root.width / 2 - width / 2 anchor.rect.y: root.height + 8 - menuOpener: QsMenuOpener { - menu: trayItem.menu + implicitWidth: menu.width + implicitHeight: menu.height + + Rectangle { + anchors.fill: parent + color: Theme.palette.base300 + radius: 8 + } + + Menu { + id: menu + + menuOpener: QsMenuOpener { + menu: trayItem.menu + } } } } diff --git a/modules/bar/components/tray/menu/Menu.qml b/modules/bar/components/tray/menu/Menu.qml index 38d66bd..b7268ff 100644 --- a/modules/bar/components/tray/menu/Menu.qml +++ b/modules/bar/components/tray/menu/Menu.qml @@ -1,145 +1,29 @@ -pragma ComponentBehavior: Bound - import QtQuick import QtQuick.Layouts import Quickshell import "../../../../../config/" import "../../../../../styled/" -PopupWindow { - id: window - +ColumnLayout { + id: menu property QsMenuOpener menuOpener - property bool opened: false - color: 'transparent' + anchors.margins: 8 - implicitWidth: menu.width - implicitHeight: menu.height + Repeater { + model: menuOpener.children + delegate: Loader { + required property QsMenuEntry modelData + active: true - Rectangle { - id: background - - anchors.fill: menu - color: Theme.palette.base300 - border.color: Theme.palette.base200 - border.width: 2 - radius: 8 - - opacity: 0 - - states: State { - name: "opened" - when: window.opened - PropertyChanges { - background { - opacity: 1 - } + sourceComponent: modelData.isSeparator ? menuSeperator : menuItem + property Component menuSeperator: Rectangle { + implicitHeight: 1 + implicitWidth: menu.width + color: Theme.palette.basecontent } - } - - transitions: [ - Transition { - from: "" - to: "opened" - SequentialAnimation { - ScriptAction { - script: window.visible = true - } - NumberAnimation { - property: "background.opacity" - duration: 200 - } - } - }, - Transition { - from: "opened" - to: "" - SequentialAnimation { - PauseAnimation { - duration: repeater.count * 15 - } - NumberAnimation { - property: "background.opacity" - duration: 200 - } - ScriptAction { - script: window.visible = false - } - } - } - ] - } - - ColumnLayout { - id: menu - - anchors.margins: 30 - - Repeater { - id: repeater - model: window.menuOpener.children - delegate: Loader { - id: loader - - required property QsMenuEntry modelData - required property int index - - active: true - - opacity: 0 - - Layout.minimumWidth: 120 - - sourceComponent: modelData.isSeparator ? menuSeperator : menuItem - property Component menuSeperator: Rectangle { - implicitWidth: menu.width - implicitHeight: 2 - - color: Theme.palette.base100 - } - property Component menuItem: MenuItem { - menuEntry: modelData - } - - states: State { - name: "opened" - when: window.opened - PropertyChanges { - loader { - opacity: 1 - } - } - } - - transitions: [ - Transition { - from: "" - to: "opened" - SequentialAnimation { - PauseAnimation { - duration: 15 * loader.index - } - NumberAnimation { - property: "opacity" - duration: 100 - } - } - }, - Transition { - from: "opened" - to: "" - SequentialAnimation { - PauseAnimation { - duration: 15 * (repeater.count - loader.index) - } - NumberAnimation { - property: "opacity" - duration: 200 - } - } - } - ] + property Component menuItem: MenuItem { + menuEntry: modelData } } } diff --git a/modules/bar/components/tray/menu/MenuItem.qml b/modules/bar/components/tray/menu/MenuItem.qml index 5624ddc..dbf7272 100644 --- a/modules/bar/components/tray/menu/MenuItem.qml +++ b/modules/bar/components/tray/menu/MenuItem.qml @@ -16,8 +16,6 @@ Clickable { StyledText { id: text - opacity: item.opacity - font.pixelSize: Dimensions.clock.fontSize anchors.verticalCenter: parent.verticalCenter topPadding: Dimensions.clock.verticalPadding diff --git a/styled/Clickable.qml b/styled/Clickable.qml index c012668..7d9158e 100644 --- a/styled/Clickable.qml +++ b/styled/Clickable.qml @@ -6,11 +6,8 @@ MouseArea { hoverEnabled: true cursorShape: Qt.PointingHandCursor - property alias color: rectangle.color - property alias border: rectangle.border Rectangle { - id: rectangle anchors.fill: parent radius: Dimensions.radius