diff --git a/modules/Services/WidgetTracker.qml b/modules/Services/WidgetTracker.qml new file mode 100644 index 0000000..0fac38b --- /dev/null +++ b/modules/Services/WidgetTracker.qml @@ -0,0 +1,15 @@ +pragma Singleton +import Quickshell + +Singleton { + id: root + property string current: "" + property ShellScreen screen: null + function toggle(name, scr) { + current = (current === name && screen === scr) ? "" : name; + screen = scr; + } + function close() { + current = ""; + } +} diff --git a/modules/applets/VolPopup.qml b/modules/applets/VolPopup.qml index 9721192..1e68684 100644 --- a/modules/applets/VolPopup.qml +++ b/modules/applets/VolPopup.qml @@ -5,116 +5,87 @@ import Quickshell import Quickshell.Wayland import QtQuick import qs.widgets +import qs import qs.modules.Services import QtQuick.Layouts import QtQuick.Controls -WlrLayershell { - id: win - - required property ShellScreen barScreen - screen: barScreen - - visible: false - color: 'transparent' - layer: WlrLayer.Overlay - exclusionMode: ExclusionMode.Ignore - - keyboardFocus: visible ? WlrKeyboardFocus.Exclusive : WlrKeyboardFocus.None - - anchors { - top: true - right: true - } - margins { - top: Config.cfg.bar.height + (Config.cfg.bar.floating ? 20 : 10) - right: Config.cfg.bar.floating ? 10 : 0 +Rectangle { + id: root + focus: true + color: Colors.barBg + radius: Config.cfg.appearance.rounding + Keys.onEscapePressed: event => { + win.visible = false; + event.accepted = true; } + implicitWidth: audioLayout.implicitWidth + 10 + implicitHeight: audioLayout.implicitHeight + 10 - implicitWidth: audioLayout.implicitWidth + 20 - implicitHeight: audioLayout.implicitHeight + 20 - onVisibleChanged: { - if (visible) - root.forceActiveFocus(); - } + ColumnLayout { + id: audioLayout + anchors.centerIn: parent + spacing: 8 - Rectangle { - id: root - anchors.fill: parent - focus: true - color: Colors.barBg - radius: Config.cfg.appearance.rounding + Repeater { + id: audioRep + model: Audio.sinks - Keys.onEscapePressed: event => { - win.visible = false; - event.accepted = true; - } + delegate: Rectangle { + id: audioDelContainer + Layout.fillWidth: true + color: Colors.moduleBg + radius: Config.cfg.appearance.rounding / 1.5 + required property var modelData + implicitHeight: audioRow.implicitHeight + 8 + implicitWidth: audioRow.implicitWidth - ColumnLayout { - id: audioLayout - anchors.centerIn: parent - spacing: 8 + RowLayout { + id: audioRow + anchors.fill: parent - Repeater { - id: audioRep - model: Audio.sinks - - delegate: Rectangle { - id: audioDelContainer - Layout.fillWidth: true - color: Colors.moduleBg - radius: Config.cfg.appearance.rounding - required property var modelData - implicitHeight: audioRow.implicitHeight + 8 - implicitWidth: audioRow.implicitWidth - - RowLayout { - id: audioRow - anchors.fill: parent - - StyledText { - text: audioDelContainer.modelData.nickname - Layout.leftMargin: 10 - Layout.fillWidth: true - Layout.maximumWidth: 200 - elide: Text.ElideRight - } - StyledIcon { - Layout.leftMargin: 10 - iconName: Audio.getVolumeIcon(audioDelContainer.modelData) - MouseArea { - anchors.fill: parent - cursorShape: Qt.PointingHandCursor - acceptedButtons: Qt.LeftButton - onClicked: { - audioDelContainer.modelData.audio.muted = !audioDelContainer.modelData.audio.muted; - } + StyledText { + text: audioDelContainer.modelData.nickname + Layout.leftMargin: 10 + Layout.fillWidth: true + Layout.maximumWidth: 200 + elide: Text.ElideRight + } + StyledIcon { + Layout.leftMargin: 10 + iconName: Audio.getVolumeIcon(audioDelContainer.modelData) + MouseArea { + anchors.fill: parent + cursorShape: Qt.PointingHandCursor + acceptedButtons: Qt.LeftButton + onClicked: { + audioDelContainer.modelData.audio.muted = !audioDelContainer.modelData.audio.muted; } } - StyledIcon { - readonly property bool isDefault: audioDelContainer.modelData === Audio.defaultAudio - readonly property bool isPreferred: audioDelContainer.modelData === Audio.preferredAudio - iconName: isDefault ? "radio-checked-symbolic" : "radio-symbolic" - opacity: (isPreferred && !isDefault) ? 0.5 : 1.0 - MouseArea { - anchors.fill: parent - cursorShape: Qt.PointingHandCursor - acceptedButtons: Qt.LeftButton - onClicked: { - Audio.setDefaultSink(audioDelContainer.modelData); - } + } + StyledIcon { + readonly property bool isDefault: audioDelContainer.modelData === Audio.defaultAudio + readonly property bool isPreferred: audioDelContainer.modelData === Audio.preferredAudio + iconName: isDefault ? "radio-checked-symbolic" : "radio-symbolic" + opacity: (isPreferred && !isDefault) ? 0.5 : 1.0 + MouseArea { + anchors.fill: parent + cursorShape: Qt.PointingHandCursor + acceptedButtons: Qt.LeftButton + onClicked: { + Audio.setDefaultSink(audioDelContainer.modelData); } } - Slider { - Layout.rightMargin: 10 + } + Slider { + Layout.rightMargin: 10 - focusPolicy: Qt.NoFocus - value: audioDelContainer.modelData.audio.volume - from: 0 - to: 1 - onMoved: { - audioDelContainer.modelData.audio.volume = value; - } + focusPolicy: Qt.NoFocus + value: audioDelContainer.modelData.audio.volume + from: 0 + to: 1 + onMoved: { + audioDelContainer.modelData.audio.volume = value; } } } diff --git a/modules/applets/WallPicker.qml b/modules/applets/WallPicker.qml index 31f860d..d29ab4c 100644 --- a/modules/applets/WallPicker.qml +++ b/modules/applets/WallPicker.qml @@ -1,107 +1,65 @@ pragma ComponentBehavior: Bound -import Quickshell -import Quickshell.Wayland import Quickshell.Widgets import QtQuick import Qt.labs.folderlistmodel 2.11 import qs import qs.settings -import qs.widgets -BarComponent { - id: main - implicitWidth: implicitHeight - required property int screenHeight - StyledIcon { - iconName: "preferences-desktop-wallpaper-symbolic" - anchors.centerIn: parent - } - MouseArea { - id: clickHandler - anchors.fill: main - acceptedButtons: Qt.LeftButton - cursorShape: Qt.PointingHandCursor - onClicked: { - wallPicker.visible = !wallPicker.visible; - } - } - WlrLayershell { - id: wallPicker - visible: false - exclusionMode: ExclusionMode.Ignore - keyboardFocus: visible ? WlrKeyboardFocus.Exclusive : WlrKeyboardFocus.None - implicitHeight: main.screenHeight / 8 - color: 'transparent' - anchors { - bottom: true - left: true - right: true - } - margins { - bottom: 20 - left: 20 - right: 20 - } - onVisibleChanged: { - if (wallPicker.visible) - container.forceActiveFocus(); - } - Rectangle { - id: container - focus: true - Keys.onEscapePressed: { - wallPicker.visible = false; - } +Rectangle { + id: wallPicker + color: "transparent" + Rectangle { + id: container + focus: true + anchors.fill: parent + color: Colors.base02 + radius: Config.cfg.appearance.rounding + GridView { + id: wallpaperLayout + clip: true + snapMode: GridView.SnapOneRow + flow: GridView.FlowTopToBottom + cellHeight: container.height + cellWidth: container.width / 8 anchors.fill: parent - color: Colors.base02 - radius: Config.cfg.appearance.rounding - GridView { - id: wallpaperLayout + anchors.centerIn: parent + anchors.margins: 10 + model: wallpaperList + delegate: ClippingRectangle { + id: wallTile clip: true - snapMode: GridView.SnapOneRow - flow: GridView.FlowTopToBottom - cellHeight: container.height - cellWidth: container.width / 8 - anchors.fill: parent - anchors.centerIn: parent - anchors.margins: 10 - model: wallpaperList - delegate: ClippingRectangle { - id: wallTile - clip: true - required property var modelData - radius: Config.cfg.appearance.rounding / 1.5 - color: 'transparent' - implicitWidth: wallpaperLayout.cellWidth - 20 - implicitHeight: wallpaperLayout.cellHeight - 20 - Image { - id: wallpaper - anchors.fill: parent - source: wallTile.modelData.filePath - sourceSize.width: 16 * 30 - sourceSize.height: 9 * 30 - asynchronous: true - cache: true - } - MouseArea { - id: wpClickHandler - anchors.fill: parent - cursorShape: Qt.PointingHandCursor - acceptedButtons: Qt.LeftButton - hoverEnabled: true - onClicked: { - Config.cfg.wallpaper.wallpaper = wallTile.modelData.filePath; - Config.save(); - } + required property var modelData + radius: Config.cfg.appearance.rounding / 1.5 + color: 'transparent' + implicitWidth: wallpaperLayout.cellWidth - 20 + implicitHeight: wallpaperLayout.cellHeight - 20 + Image { + id: wallpaper + anchors.fill: parent + source: wallTile.modelData.filePath + sourceSize.width: 16 * 30 + sourceSize.height: 9 * 30 + asynchronous: true + cache: true + } + MouseArea { + id: wpClickHandler + anchors.fill: parent + cursorShape: Qt.PointingHandCursor + acceptedButtons: Qt.LeftButton + hoverEnabled: true + onClicked: { + Config.cfg.wallpaper.wallpaper = wallTile.modelData.filePath; + Config.save(); } } } - FolderListModel { - id: wallpaperList - folder: Qt.resolvedUrl(Config.cfg.wallpaper.wallDir) - nameFilters: ["*.png"] - } + } + FolderListModel { + id: wallpaperList + folder: Qt.resolvedUrl(Config.cfg.wallpaper.wallDir) + nameFilters: ["*.png"] } } } diff --git a/modules/bar/Bar.qml b/modules/bar/Bar.qml index c2a78fd..76e950c 100644 --- a/modules/bar/Bar.qml +++ b/modules/bar/Bar.qml @@ -16,7 +16,7 @@ Variants { left: true right: true } - + color: 'transparent' implicitHeight: Config.cfg.bar.height margins.top: Config.cfg.bar.floating ? 10 : 0 @@ -46,11 +46,11 @@ Variants { Mpris {} Bat {} Tray {} - WallPicker { - screenHeight: root.screen.height - } + WallPickerButton {barScreen: root.modelData} - Pw {barScreen: root.modelData} + Pw { + barScreen: root.modelData + } Netstatus {} } } diff --git a/modules/bar/Pw.qml b/modules/bar/Pw.qml index 8379b2d..dbeab97 100644 --- a/modules/bar/Pw.qml +++ b/modules/bar/Pw.qml @@ -30,10 +30,7 @@ BarComponent { acceptedButtons: Qt.LeftButton cursorShape: Qt.PointingHandCursor anchors.fill: root - onClicked: volPopup.visible = !volPopup.visible - } - VolPopup { - barScreen: root.barScreen - id: volPopup + onClicked: WidgetTracker.toggle("volume", root.barScreen) } + } diff --git a/modules/bar/WallPickerButton.qml b/modules/bar/WallPickerButton.qml new file mode 100644 index 0000000..705b83d --- /dev/null +++ b/modules/bar/WallPickerButton.qml @@ -0,0 +1,24 @@ +import QtQuick +import qs.widgets +import qs.modules.Services +import Quickshell + + +BarComponent { + id: main + implicitWidth: implicitHeight + required property ShellScreen barScreen + StyledIcon { + iconName: "preferences-desktop-wallpaper-symbolic" + anchors.centerIn: parent + } + MouseArea { + id: clickHandler + anchors.fill: main + acceptedButtons: Qt.LeftButton + cursorShape: Qt.PointingHandCursor + onClicked: { + WidgetTracker.toggle("wallpapers", main.barScreen); + } + } +} diff --git a/modules/wallpaper/Wallpaper.qml b/modules/overlays/Bottom.qml similarity index 100% rename from modules/wallpaper/Wallpaper.qml rename to modules/overlays/Bottom.qml diff --git a/modules/overlays/Top.qml b/modules/overlays/Top.qml new file mode 100644 index 0000000..8079d61 --- /dev/null +++ b/modules/overlays/Top.qml @@ -0,0 +1,58 @@ +import QtQuick +import Quickshell +import Quickshell.Wayland +import qs.modules.Services +import qs.modules.applets +import qs.settings + +Variants { + model: Quickshell.screens + delegate: PanelWindow { + required property ShellScreen modelData + aboveWindows: true + screen: modelData + anchors { + top: true + left: true + bottom: true + right: true + } + exclusionMode: ExclusionMode.Ignore + color: 'transparent' + visible: WidgetTracker.current !== "" && WidgetTracker.screen === modelData + WlrLayershell.keyboardFocus: visible ? WlrKeyboardFocus.Exclusive : WlrKeyboardFocus.None + Item { + anchors.fill: parent + focus: true + Keys.onEscapePressed: event => { + WidgetTracker.close(); + event.accepted = true; + } + VolPopup { + z: 1 + visible: WidgetTracker.current === "volume" + anchors.right: parent.right + anchors.top: parent.top + anchors.topMargin: Config.cfg.bar.floating ? Config.cfg.bar.height + 20 : Config.cfg.bar.height + anchors.rightMargin: 10 + + } + WallPicker { + z: 1 + anchors.bottom: parent.bottom + anchors.left: parent.left + anchors.right: parent.right + anchors.margins: 20 + implicitWidth: 1000 + implicitHeight: 200 + visible: WidgetTracker.current === "wallpapers" + } + MouseArea { + z: 0 + anchors.fill: parent + acceptedButtons: Qt.LeftButton + onClicked: WidgetTracker.close() + } + } + } +} diff --git a/settings/settings.json b/settings/settings.json index 3595180..aed29ed 100644 --- a/settings/settings.json +++ b/settings/settings.json @@ -12,6 +12,6 @@ }, "wallpaper": { "wallDir": "/home/lucy/.walls/", - "wallpaper": "/home/lucy/.walls/frierensuff.png" + "wallpaper": "/home/lucy/.walls/walkingcastle.png" } } diff --git a/shell.qml b/shell.qml index 18e0d90..7a0a6e9 100644 --- a/shell.qml +++ b/shell.qml @@ -2,12 +2,13 @@ //@ pragma IconTheme Papirus-Dark import Quickshell import qs.modules.bar -import qs.modules.wallpaper import qs.modules.notifications +import qs.modules.overlays import qs.modules.Services ShellRoot { Bar {} - Wallpaper {} NotiPopup {} + Bottom {} + Top {} }