From 31965a0dbacb08d3dea714eb55103ab8647686c6 Mon Sep 17 00:00:00 2001 From: lucy Date: Thu, 27 Aug 2026 18:10:37 +0200 Subject: [PATCH] make config use json instead of shitty qt implementation --- modules/Services/#WallpaperService.qml# | 10 ++ modules/Services/.#WallpaperService.qml | 1 + modules/Services/Audio.qml~ | 10 -- modules/Services/Network.qml~ | 21 ----- modules/applets/VolPopup.qml | 93 +++++++++++++++++++ .../VolPopup.qml => applets/VolPopup.qml~} | 0 modules/{wallpaper => applets}/WallPicker.qml | 13 ++- .../{wallpaper => applets}/WallPicker.qml~ | 41 ++------ modules/bar/#Bat.qml# | 52 +++++++++++ modules/bar/.#Bat.qml | 1 + modules/bar/ActiveWindow.qml~ | 31 ------- modules/bar/Bar.qml | 13 ++- modules/bar/Bar.qml~ | 13 --- modules/bar/Bat.qml | 17 ++-- modules/bar/Bat.qml~ | 58 ------------ modules/bar/Date.qml~ | 26 ------ modules/bar/Mpris.qml | 14 +-- modules/bar/Mpris.qml~ | 49 ---------- modules/bar/Netstatus.qml~ | 29 ------ modules/bar/Pw.qml | 7 +- modules/bar/Pw.qml~ | 77 --------------- modules/bar/Tray.qml | 1 - modules/bar/Tray.qml~ | 53 ----------- modules/bar/VolPopup.qml~ | 39 -------- modules/bar/Ws.qml | 4 +- modules/bar/Ws.qml~ | 27 ------ modules/bar/volPopup.qml~ | 40 -------- modules/notifications/NotiCard.qml | 2 +- modules/notifications/NotiCard.qml~ | 92 ------------------ modules/notifications/NotiPopup.qml | 2 +- modules/notifications/NotiPopup.qml~ | 46 --------- modules/notifications/NotiServer.qml~ | 18 ---- modules/wallpaper/Wallpaper.qml | 2 +- settings/Config.qml | 60 +++++++----- settings/settings.ini | 10 +- settings/settings.json | 17 ++++ settings/settings.json~ | 18 ++++ widgets/BarComponent.qml | 4 +- widgets/StyledIcon.qml | 2 +- widgets/StyledText.qml | 4 +- 40 files changed, 272 insertions(+), 745 deletions(-) create mode 100644 modules/Services/#WallpaperService.qml# create mode 120000 modules/Services/.#WallpaperService.qml delete mode 100644 modules/Services/Audio.qml~ delete mode 100644 modules/Services/Network.qml~ create mode 100644 modules/applets/VolPopup.qml rename modules/{bar/VolPopup.qml => applets/VolPopup.qml~} (100%) rename modules/{wallpaper => applets}/WallPicker.qml (90%) rename modules/{wallpaper => applets}/WallPicker.qml~ (78%) create mode 100644 modules/bar/#Bat.qml# create mode 120000 modules/bar/.#Bat.qml delete mode 100644 modules/bar/ActiveWindow.qml~ delete mode 100644 modules/bar/Bar.qml~ delete mode 100644 modules/bar/Bat.qml~ delete mode 100644 modules/bar/Date.qml~ delete mode 100644 modules/bar/Mpris.qml~ delete mode 100644 modules/bar/Netstatus.qml~ delete mode 100644 modules/bar/Pw.qml~ delete mode 100644 modules/bar/Tray.qml~ delete mode 100644 modules/bar/VolPopup.qml~ delete mode 100644 modules/bar/Ws.qml~ delete mode 100644 modules/bar/volPopup.qml~ delete mode 100644 modules/notifications/NotiCard.qml~ delete mode 100644 modules/notifications/NotiPopup.qml~ delete mode 100644 modules/notifications/NotiServer.qml~ create mode 100644 settings/settings.json create mode 100644 settings/settings.json~ diff --git a/modules/Services/#WallpaperService.qml# b/modules/Services/#WallpaperService.qml# new file mode 100644 index 0000000..7e2899b --- /dev/null +++ b/modules/Services/#WallpaperService.qml# @@ -0,0 +1,10 @@ +pragma Singleton +import Quickshell +import qs +import qs.settings + +Singleton { + id: root + readonly property url wallDir: Config.wallDir + property url currentWallpaper: Config.wallpaper +} diff --git a/modules/Services/.#WallpaperService.qml b/modules/Services/.#WallpaperService.qml new file mode 120000 index 0000000..a138299 --- /dev/null +++ b/modules/Services/.#WallpaperService.qml @@ -0,0 +1 @@ +lucy@nerv.1006:1787837190 \ No newline at end of file diff --git a/modules/Services/Audio.qml~ b/modules/Services/Audio.qml~ deleted file mode 100644 index d0575c6..0000000 --- a/modules/Services/Audio.qml~ +++ /dev/null @@ -1,10 +0,0 @@ -pragma Singleton -import Quickshell -import QtQuick -import Quickshell.Pipewire - - - -Singleton { - property -} diff --git a/modules/Services/Network.qml~ b/modules/Services/Network.qml~ deleted file mode 100644 index edc95dd..0000000 --- a/modules/Services/Network.qml~ +++ /dev/null @@ -1,21 +0,0 @@ -pragma Singleton -import Quickshell -import Quickshell.Networking - - -Singleton { - id: root - property bool wifiEnabled: Networking.wifiEnabled - property string connectivity: Networking.connectivity.toString(Networking.connectivity) - readonly property list devices: Networking.devices.values - - function getConnectedDevice() { - for(let i=0; i < devices.length; ++i) { - console.log(i) - if(devices[i].connected) { - return devices[i]; - } - return null; - } - } -} diff --git a/modules/applets/VolPopup.qml b/modules/applets/VolPopup.qml new file mode 100644 index 0000000..557d485 --- /dev/null +++ b/modules/applets/VolPopup.qml @@ -0,0 +1,93 @@ +pragma ComponentBehavior: Bound +import qs +import qs.settings +import Quickshell +import QtQuick +import qs.widgets +import qs.modules.Services +import QtQuick.Layouts +import QtQuick.Controls + + +PopupWindow { + implicitWidth: audioLayout.implicitWidth + 2 * audioLayout.anchors.margins + implicitHeight: audioLayout.implicitHeight + 24 + anchor.edges: Edges.Top | Edges.Right + anchor.gravity: Edges.Bottom | Edges.Left + anchor.margins.top: 40 + color: 'transparent' + grabFocus: true + Rectangle { + id: root + anchors.fill: parent + color: Colors.barBg + radius: Config.cfg.appearance.rounding + ColumnLayout { + id: audioLayout + anchors.centerIn: parent + anchors.margins: 10 + spacing: 8 + Repeater { + id: audioRep + model: Audio.sinks + + delegate: Rectangle { + Layout.fillWidth: true + id: audioDelContainer + color: Colors.moduleBg + radius: Config.cfg.appearance.rounding + required property var modelData + implicitHeight: audioRow.implicitHeight + 8 + implicitWidth: audioRow.implicitWidth + + RowLayout { + id: audioRow + anchors.left: parent.left + anchors.verticalCenter: parent.verticalCenter + 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; + } + } + } + StyledIcon { + iconName: audioDelContainer.modelData === Audio.preferredAudio ? "radio-checked-symbolic" : "radio-symbolic" + MouseArea { + anchors.fill: parent + cursorShape: Qt.PointingHandCursor + acceptedButtons: Qt.LeftButton + onClicked: { + Audio.setDefaultSink(audioDelContainer.modelData); + } + } + } + Slider { + Layout.rightMargin: 10 + value: audioDelContainer.modelData.audio.volume + from: 0 + to: 1 + onMoved: { + audioDelContainer.modelData.audio.volume = value; + } + } + } + } + } + } + } +} diff --git a/modules/bar/VolPopup.qml b/modules/applets/VolPopup.qml~ similarity index 100% rename from modules/bar/VolPopup.qml rename to modules/applets/VolPopup.qml~ diff --git a/modules/wallpaper/WallPicker.qml b/modules/applets/WallPicker.qml similarity index 90% rename from modules/wallpaper/WallPicker.qml rename to modules/applets/WallPicker.qml index 30e30da..14b5839 100644 --- a/modules/wallpaper/WallPicker.qml +++ b/modules/applets/WallPicker.qml @@ -4,15 +4,13 @@ import Quickshell.Wayland import Quickshell.Widgets import QtQuick import Qt.labs.folderlistmodel 2.11 -import QtQuick.Effects import qs import qs.settings import qs.widgets BarComponent { - implicitHeight: Config.moduleHeight - implicitWidth: Config.moduleHeight + implicitWidth: implicitHeight required property int screenHeight id: main StyledIcon { @@ -57,7 +55,7 @@ BarComponent { } anchors.fill: parent color: Colors.base02 - radius: Config.rounding + radius: Config.cfg.appearance.rounding GridView { id: wallpaperLayout clip: true @@ -73,7 +71,7 @@ BarComponent { id: wallTile clip: true required property var modelData - radius: Config.rounding / 1.5 + radius: Config.cfg.appearance.rounding / 1.5 color: 'transparent' implicitWidth: wallpaperLayout.cellWidth - 20 implicitHeight: wallpaperLayout.cellHeight - 20 @@ -93,14 +91,15 @@ BarComponent { acceptedButtons: Qt.LeftButton hoverEnabled: true onClicked: { - Config.wallpaper = wallTile.modelData.filePath; + Config.cfg.wallpaper.wallpaper = wallTile.modelData.filePath; + Config.save() } } } } FolderListModel { id: wallpaperList - folder: Config.wallDir + folder: Qt.resolvedUrl(Config.cfg.wallpaper.wallDir) nameFilters: ["*.png"] } } diff --git a/modules/wallpaper/WallPicker.qml~ b/modules/applets/WallPicker.qml~ similarity index 78% rename from modules/wallpaper/WallPicker.qml~ rename to modules/applets/WallPicker.qml~ index feeb973..a3cb704 100644 --- a/modules/wallpaper/WallPicker.qml~ +++ b/modules/applets/WallPicker.qml~ @@ -2,38 +2,21 @@ pragma ComponentBehavior: Bound import Quickshell import Quickshell.Wayland import Quickshell.Widgets -import Quickshell.Hyprland import QtQuick import Qt.labs.folderlistmodel 2.11 -import QtQuick.Effects import qs import qs.settings import qs.widgets -Rectangle { - id: main - - layer.enabled: true - layer.effect: MultiEffect { - id: dropShadow - source: main - shadowEnabled: true - shadowHorizontalOffset: 4 - shadowVerticalOffset: 2 - shadowOpacity: 0.5 - shadowColor: "#020202" - } - required property real moduleHeight +BarComponent { + implicitHeight: Config.moduleHeight + implicitWidth: Config.moduleHeight required property int screenHeight - color: Colors.moduleBg - radius: Config.rounding - implicitWidth: moduleHeight - implicitHeight: moduleHeight - MaterialIcon { - anchors.centerIn: main - text: "\ue1bc" - font.bold: true + id: main + StyledIcon { + iconName: "preferences-desktop-wallpaper-symbolic" + anchors.centerIn: parent } MouseArea { id: clickHandler @@ -61,12 +44,6 @@ Rectangle { left: 20 right: 20 } - HyprlandFocusGrab { - id: grabber - active: wallPicker.visible - windows: [wallPicker] - onCleared: wallPicker.visible = false - } onVisibleChanged: { if (wallPicker.visible) container.forceActiveFocus(); @@ -78,7 +55,7 @@ Rectangle { wallPicker.visible = false; } anchors.fill: parent - color: Colors.base00 + color: Colors.base02 radius: Config.rounding GridView { id: wallpaperLayout @@ -122,7 +99,7 @@ Rectangle { } FolderListModel { id: wallpaperList - folder: Config.wallDir + folder: Qt.resolvedUrl(Config.wallDir) nameFilters: ["*.png"] } } diff --git a/modules/bar/#Bat.qml# b/modules/bar/#Bat.qml# new file mode 100644 index 0000000..340630c --- /dev/null +++ b/modules/bar/#Bat.qml# @@ -0,0 +1,52 @@ +import Quickshell.Services.UPower +import Quickshell +import Quickshell.Widgets +import QtQuick +import QtQuick.Layouts +import QtQuick.Effects +import qs +import qs.widgets +import qs.settings + +BarComponent { + id: root + visible: UPower.displayDevice.isLaptopBattery + property double percent: UPower.displayDevice.percentage * 100 + property bool hasBattery: UPower.displayDevice.isLaptopBattery + property bool charging: UPower.displayDevice.state === UPowerDeviceState.Charging + implicitWidth: batLayout.implicitWidth + 16 + + function batteryIcon() { + let charging = root.charging; + let percent = root.percent; + if (percent <= 10) + return charging ? "battery-empty-charging" : "battery-empty"; + if (percent < 40) + return charging ? "battery-level-30-charging" : "battery-level-30"; + if (percent < 50) + return charging ? "battery-level-40-charging" : "battery-level-40"; + if (percent < 60) + return charging ? "battery-level-50-charging" : "battery-level-50"; + if (percent < 70) + return charging ? "battery-level-60-charging" : "battery-level-60"; + if (percent < 80) + return charging ? "battery-level-70-charging" : "battery-level-70"; + if (percent < 90) + return charging ? "battery-level-80-charging" : "battery-level-80"; + if (percent > 90) + return charging ? "battery-level-90-charging" : "battery-level-90"; + if (percent == 100) + return charging ? "battery-level-100-charging" : "battery-level-100"; + } + RowLayout { + id: batLayout + anchors.centerIn: root + StyledIcon { + iconName: root.batteryIcon() + } + + StyledText { + text: Math.floor(root.percent, root.charging) + "%" + } + } +} diff --git a/modules/bar/.#Bat.qml b/modules/bar/.#Bat.qml new file mode 120000 index 0000000..a138299 --- /dev/null +++ b/modules/bar/.#Bat.qml @@ -0,0 +1 @@ +lucy@nerv.1006:1787837190 \ No newline at end of file diff --git a/modules/bar/ActiveWindow.qml~ b/modules/bar/ActiveWindow.qml~ deleted file mode 100644 index 9020ca4..0000000 --- a/modules/bar/ActiveWindow.qml~ +++ /dev/null @@ -1,31 +0,0 @@ -pragma ComponentBehavior: Bound -import Quickshell.Widgets -import Quickshell.Hyprland -import QtQuick -import QtQuick.Layouts -import qs -import qs.widgets -import qs.settings -import QtQuick.Effects - -BarComponent { - id: root - implicitHeight: moduleHeight - implicitWidth: titleLayout.width + 32 - color: Colors.moduleBg - radius: Config.rounding - RowLayout { - id: titleLayout - anchors.centerIn: root - WrapperRectangle { - Layout.maximumWidth: 400 - color: 'transparent' - clip: true - StyledText { - property bool onWs: Hyprland.activeToplevel?.workspace == Hyprland.focusedWorkspace - text: onWs ? Hyprland.activeToplevel?.title ?? "Desktop" : "Desktop" - elide: Text.ElideRight - } - } - } -} diff --git a/modules/bar/Bar.qml b/modules/bar/Bar.qml index 37efff2..c4759d1 100644 --- a/modules/bar/Bar.qml +++ b/modules/bar/Bar.qml @@ -1,8 +1,8 @@ import Quickshell import QtQuick import QtQuick.Layouts -import qs.modules.wallpaper import qs.settings +import qs.modules.applets import qs Variants { @@ -17,14 +17,14 @@ Variants { right: true } color: 'transparent' - implicitHeight: Config.barHeight - margins.top: Config.floating ? 10 : 0 - margins.left: Config.floating ? 10 : 0 - margins.right: Config.floating ? 10 : 0 + implicitHeight: Config.cfg.bar.height + margins.top: Config.cfg.bar.floating ? 10 : 0 + margins.left: Config.cfg.bar.floating ? 10 : 0 + margins.right: Config.cfg.bar.floating ? 10 : 0 Rectangle { anchors.fill: parent color: Colors.barBg - radius: Config.floating ? Config.rounding : 0 + radius: Config.cfg.bar.floating ? Config.cfg.appearance.rounding : 0 RowLayout { anchors.leftMargin: 4 anchors.left: parent.left @@ -44,7 +44,6 @@ Variants { anchors.verticalCenter: parent.verticalCenter Mpris {} Bat {} - Tray {} WallPicker { screenHeight: root.screen.height diff --git a/modules/bar/Bar.qml~ b/modules/bar/Bar.qml~ deleted file mode 100644 index d4d4aea..0000000 --- a/modules/bar/Bar.qml~ +++ /dev/null @@ -1,13 +0,0 @@ -import Quickshell -import QtQuick - -Variants { - model: Quickshell.screens - delegate: PanelWindow { - anchors { - top: true - left: true - right: true - } - } -} diff --git a/modules/bar/Bat.qml b/modules/bar/Bat.qml index 82d1a30..6906f38 100644 --- a/modules/bar/Bat.qml +++ b/modules/bar/Bat.qml @@ -14,10 +14,11 @@ BarComponent { property double percent: UPower.displayDevice.percentage * 100 property bool hasBattery: UPower.displayDevice.isLaptopBattery property bool charging: UPower.displayDevice.state === UPowerDeviceState.Charging - implicitHeight: Config.moduleHeight implicitWidth: batLayout.implicitWidth + 16 - function batteryIcon(percent, charging) { + function batteryIcon() { + let charging = root.charging + let percent = root.percent if(percent <= 10) return charging ? "battery-empty-charging" : "battery-empty" if(percent < 40) return charging ? "battery-level-30-charging" : "battery-level-30" if(percent < 50) return charging ? "battery-level-40-charging" : "battery-level-40" @@ -32,16 +33,10 @@ BarComponent { RowLayout { id: batLayout anchors.centerIn: root - IconImage { - source: Quickshell.iconPath(root.batteryIcon(root.percent, root.charging) + "-symbolic") - implicitSize: Config.iconSize - layer.enabled: true - layer.effect: MultiEffect { - colorization: 1.0 - colorizationColor: Colors.text - brightness: 0.5 +StyledIcon { + iconName: root.batteryIcon() } - } + StyledText { text: Math.floor(root.percent,root.charging) + "%" } diff --git a/modules/bar/Bat.qml~ b/modules/bar/Bat.qml~ deleted file mode 100644 index 8a44028..0000000 --- a/modules/bar/Bat.qml~ +++ /dev/null @@ -1,58 +0,0 @@ -import Quickshell.Services.UPower -import QtQuick -import QtQuick.Layouts -import QtQuick.Effects -import qs -import qs.widgets -import qs.settings - -BarComponent { - id: root - layer.enabled: true - layer.effect: MultiEffect { - id: dropShadow - source: root - shadowEnabled: true - shadowHorizontalOffset: 4 - shadowVerticalOffset: 2 - shadowOpacity: 0.5 - shadowColor: "#020202" - } - clip: true - color: Colors.moduleBg - visible: UPower.displayDevice.isLaptopBattery - property double percent: UPower.displayDevice.percentage * 100 - property bool hasBattery: UPower.displayDevice.isLaptopBattery - property bool charging: UPower.displayDevice.state === UPowerDeviceState.Charging - required property double moduleHeight - implicitHeight: moduleHeight - implicitWidth: batLayout.implicitWidth + 16 - radius: Config.rounding - - function batteryIcon(percent) { - if (root.charging) - return "battery_android_frame_bolt"; - if (percent <= 15) - return "battery_android_alert"; - if (percent <= 30) - return "battery_android_frame_2"; - if (percent <= 50) - return "battery_android_frame_3"; - if (percent <= 70) - return "battery_android_frame_4"; - if (percent <= 85) - return "battery_android_frame_5"; - if (percent <= 100) - return "battery_android_frame_full"; - } - RowLayout { - id: batLayout - anchors.centerIn: root - MaterialIcon { - text: root.batteryIcon(root.percent) - } - StyledText { - text: Math.floor(root.percent) + "%" - } - } -} diff --git a/modules/bar/Date.qml~ b/modules/bar/Date.qml~ deleted file mode 100644 index fa6ab8a..0000000 --- a/modules/bar/Date.qml~ +++ /dev/null @@ -1,26 +0,0 @@ -pragma ComponentBehavior: Bound -import Quickshell -import QtQuick -import QtQuick.Effects -import qs -import qs.widgets -import qs.settings - -BarComponent { - id: root - clip: true - required property double moduleHeight - implicitHeight: moduleHeight - implicitWidth: clockText.implicitWidth + 32 - color: Colors.moduleBg - radius: Config.rounding - SystemClock { - id: clock - precision: SystemClock.Seconds - } - StyledText { - id: clockText - anchors.centerIn: root - text: Qt.formatDateTime(clock.date, "d.M.yy - hh:mm:ss") - } -} diff --git a/modules/bar/Mpris.qml b/modules/bar/Mpris.qml index 0b05852..047a555 100644 --- a/modules/bar/Mpris.qml +++ b/modules/bar/Mpris.qml @@ -11,7 +11,6 @@ import qs.settings BarComponent { id: root - implicitHeight: Config.moduleHeight implicitWidth: songLayout.implicitWidth + 16 property MprisPlayer spotify: { for (const player of Mpris.players.values) { @@ -25,19 +24,12 @@ BarComponent { RowLayout { id: songLayout anchors.centerIn: root - IconImage { - source: Quickshell.iconPath("folder-music-symbolic") - implicitSize: Config.iconSize - layer.enabled: true - layer.effect: MultiEffect { - colorization: 1.0 - colorizationColor: Colors.text - brightness: 0.5 - } + StyledIcon { + iconName: "folder-music-symbolic" } StyledText { Layout.maximumWidth: 400 - Layout.maximumHeight: Config.barHeight / 1.6 + Layout.maximumHeight: Config.cfg.bar.barHeight / 1.6 text: root.spotify?.trackTitle + " - " + root.spotify?.trackArtists elide: Text.ElideRight } diff --git a/modules/bar/Mpris.qml~ b/modules/bar/Mpris.qml~ deleted file mode 100644 index c60ebf1..0000000 --- a/modules/bar/Mpris.qml~ +++ /dev/null @@ -1,49 +0,0 @@ -pragma ComponentBehavior: Bound -import Quickshell.Services.Mpris -import QtQuick -import QtQuick.Layouts -import QtQuick.Effects -import qs -import qs.widgets -import qs.settings - -Rectangle { - id: root - layer.enabled: true - layer.effect: MultiEffect { - id: dropShadow - source: root - shadowEnabled: true - shadowHorizontalOffset: 4 - shadowVerticalOffset: 2 - shadowOpacity: 0.5 - shadowColor: "#020202" - } - required property double moduleHeight - implicitHeight: moduleHeight - implicitWidth: songLayout.implicitWidth + 32 - property MprisPlayer spotify: { - for (const player of Mpris.players.values) { - if (player.identity === "Spotify") - return player; - } - return null; - } - visible: spotify !== null && spotify.playbackState === MprisPlaybackState.Playing - clip: true - color: Colors.moduleBg - radius: Config.rounding - RowLayout { - id: songLayout - anchors.centerIn: root - MaterialIcon { - text: "music_note_2" - } - StyledText { - Layout.maximumWidth: 400 - Layout.maximumHeight: Config.barHeight / 1.6 - text: root.spotify?.trackTitle + " - " + root.spotify?.trackArtists - elide: Text.ElideRight - } - } -} diff --git a/modules/bar/Netstatus.qml~ b/modules/bar/Netstatus.qml~ deleted file mode 100644 index 09e2785..0000000 --- a/modules/bar/Netstatus.qml~ +++ /dev/null @@ -1,29 +0,0 @@ -import qs -import qs.modules.Services -import qs.widgets -import qs.settings -import Quickshell -import Quickshell.Widgets -import QtQuick -import QtQuick.Layouts - -BarComponent { - id: root - implicitWidth: networkLayout.implicitWidth + 24 - RowLayout { - anchors.centerIn: root - id: networkLayout - StyledText { - id: status - text: Network.wifiEnabled ? "Wifi enabled :3" : "Wifi disabled :(" - } - StyledText { - id: wifiDevName - text: Network.connectedWifiDev?.name ?? "not connected via wifi" - } - StyledText{ - id: wiredDevName - text: Network.connectedWiredDev?.name ?? "not connected via wired" - } - } -} diff --git a/modules/bar/Pw.qml b/modules/bar/Pw.qml index 8076e39..5f759d4 100644 --- a/modules/bar/Pw.qml +++ b/modules/bar/Pw.qml @@ -1,11 +1,7 @@ -pragma ComponentBehavior: Bound -import Quickshell.Services.Pipewire -import Quickshell.Widgets import Quickshell import QtQuick import QtQuick.Layouts -import QtQuick.Effects -import qs +import qs.modules.applets import qs.widgets import qs.settings import qs.modules.Services @@ -13,7 +9,6 @@ import qs.modules.Services BarComponent { id: root active: clickHandler.containsMouse - implicitHeight: Config.moduleHeight implicitWidth: pwLayout.implicitWidth + 16 RowLayout { id: pwLayout diff --git a/modules/bar/Pw.qml~ b/modules/bar/Pw.qml~ deleted file mode 100644 index b26c8ca..0000000 --- a/modules/bar/Pw.qml~ +++ /dev/null @@ -1,77 +0,0 @@ -pragma ComponentBehavior: Bound -import Quickshell.Services.Pipewire -import Quickshell.Io -import QtQuick -import QtQuick.Layouts -import QtQuick.Effects -import qs -import qs.widgets -import qs.settings - -BarComponent { - id: root - layer.enabled: true - layer.effect: MultiEffect { - id: dropShadow - source: root - shadowEnabled: true - shadowHorizontalOffset: 4 - shadowVerticalOffset: 2 - shadowOpacity: 0.5 - shadowColor: "#020202" - } - color: clickHandler.containsMouse ? Colors.activeModuleBg : Colors.moduleBg - property PwNode defaultAudio: Pipewire.ready ? Pipewire.defaultAudioSink : null - property bool mute: Pipewire.ready ? defaultAudio?.audio.muted : null - radius: Config.rounding - required property double moduleHeight - implicitHeight: moduleHeight - implicitWidth: pwLayout.implicitWidth + 16 - function getVolumeIcon() { - let volume = Pipewire.ready ? root.defaultAudio.audio.volume : null; - if (root.mute) { - return "\ue04f"; - } - if (volume <= 0.33) { - return "\ue04e"; - } - if (volume <= 0.66) { - return "\ue04d"; - } - if (volume >= 0.66) { - return "\ue050"; - } - } - - PwObjectTracker { - objects: [Pipewire.ready ? Pipewire.defaultAudioSink : null] - } - - Process { - id: pavuLauncher - command: ["pavucontrol"] - running: false - } - - RowLayout { - id: pwLayout - anchors.centerIn: root - spacing: 4 - MaterialIcon { - text: root.getVolumeIcon() - opacity: root.defaultAudio?.audio.muted ? 0.6 : 1.0 - } - StyledText { - text: Math.round(root.defaultAudio?.audio.volume * 100) + "%" - opacity: root.defaultAudio?.audio.muted ? 0.6 : 1.0 - } - } - MouseArea { - id: clickHandler - hoverEnabled: true - acceptedButtons: Qt.LeftButton - cursorShape: Qt.PointingHandCursor - anchors.fill: root - onClicked: pavuLauncher.running = true - } -} diff --git a/modules/bar/Tray.qml b/modules/bar/Tray.qml index 4f5109c..3cece72 100644 --- a/modules/bar/Tray.qml +++ b/modules/bar/Tray.qml @@ -12,7 +12,6 @@ import qs.widgets BarComponent { id: root visible: iconRepeater.count != 0 - implicitHeight: Config.moduleHeight implicitWidth: iconlayout.width + 16 RowLayout { diff --git a/modules/bar/Tray.qml~ b/modules/bar/Tray.qml~ deleted file mode 100644 index fcb18ac..0000000 --- a/modules/bar/Tray.qml~ +++ /dev/null @@ -1,53 +0,0 @@ -pragma ComponentBehavior: Bound -import Quickshell -import Quickshell.Services.SystemTray -import Quickshell.Widgets -import QtQuick -import QtQuick.Layouts -import QtQuick.Effects -import qs -import qs.settings - -BarComponent { - id: root - visible: iconRepeater.count != 0 - implicitHeight: Config.moduleHeight - implicitWidth: iconlayout.width + 16 - color: Colors.moduleBg - radius: Config.rounding - - RowLayout { - id: iconlayout - anchors.centerIn: root - spacing: 8 - Repeater { - id: iconRepeater - model: SystemTray.items - delegate: Item { - id: iconWrapper - required property var modelData - implicitWidth: 16 - implicitHeight: 16 - IconImage { - anchors.centerIn: parent - source: iconWrapper.modelData.icon - implicitSize: 16 - } - QsMenuAnchor { - id: menu - anchor.item: iconWrapper - menu: iconWrapper.modelData.menu - } - MouseArea { - anchors.fill: parent - acceptedButtons: Qt.LeftButton | Qt.RightButton - onClicked: mouse => { - if (mouse.button == Qt.RightButton) { - menu.open(); - } - } - } - } - } - } -} diff --git a/modules/bar/VolPopup.qml~ b/modules/bar/VolPopup.qml~ deleted file mode 100644 index 18d925a..0000000 --- a/modules/bar/VolPopup.qml~ +++ /dev/null @@ -1,39 +0,0 @@ -import qs -import qs.settings -import Quickshell -import QtQuick -import qs.widgets - - - -PopupWindow { - id: volPopup - anchor.item: root - implicitWidth: 500 - implicitHeight: 600 - - anchor.edges: Edges.Top | Edges.Right - anchor.gravity: Edges.Bottom | Edges.Left - anchor.margins.top: 40 - anchor.margins.right: 0 - color: 'transparent' - Rectangle { - id: test - anchors.fill: parent - color: Colors.activeModuleBg - radius: Config.rounding - ListView { - id: sourceLayout - - model: Pipewire.nodes - delegate: Rectangle { - implicitHeight: 10 - - required property var modelData - StyledText { - text: parent.modelData.nickname - } - } - } - } - } diff --git a/modules/bar/Ws.qml b/modules/bar/Ws.qml index 9272a9c..5e4ecc8 100644 --- a/modules/bar/Ws.qml +++ b/modules/bar/Ws.qml @@ -16,14 +16,12 @@ BarComponent { spacing: 0 Repeater { model: WindowManager.screenProjection(root.barScreen).windowsets - delegate: Rectangle { + delegate: BarComponent { id: wsContainer required property var modelData visible: modelData.shouldDisplay implicitWidth: modelData.active ? 50 : 20 - implicitHeight: Config.moduleHeight - 4 color: modelData.active ? Colors.base0D : Colors.moduleBg - radius: Config.rounding Behavior on implicitWidth { PropertyAnimation { duration: 350 diff --git a/modules/bar/Ws.qml~ b/modules/bar/Ws.qml~ deleted file mode 100644 index 4c18d5f..0000000 --- a/modules/bar/Ws.qml~ +++ /dev/null @@ -1,27 +0,0 @@ -import Quickshell -import Quickshell.WindowManager -import QtQuick -import QtQuick.Layouts -import qs -import qs.widgets - -BarComponent { - id: root - required property ShellScreen barScreen - RowLayout { - spacing: 15 - anchors.fill: parent - Repeater { - model: WindowManager.screenProjection(root.barScreen).windowsets - delegate: Rectangle { - required property var modelData - visible: modelData.shouldDisplay - StyledText { - id: wsText - text: parent.modelData.name - color: parent.modelData.active ? Colors.base0D: Colors.base03 - } - } - } - } -} diff --git a/modules/bar/volPopup.qml~ b/modules/bar/volPopup.qml~ deleted file mode 100644 index 582c1d1..0000000 --- a/modules/bar/volPopup.qml~ +++ /dev/null @@ -1,40 +0,0 @@ -import qs -import qs.settings -import Quickshell -import Quickshell.Widgets -import QtQuick -import qs.widgets - - - -PopupWindow { - id: volPopup - anchor.item: root - implicitWidth: 500 - implicitHeight: 600 - - anchor.edges: Edges.Top | Edges.Right - anchor.gravity: Edges.Bottom | Edges.Left - anchor.margins.top: 40 - anchor.margins.right: 0 - color: 'transparent' - Rectangle { - id: test - anchors.fill: parent - color: Colors.activeModuleBg - radius: Config.rounding - ListView { - id: sourceLayout - - model: Pipewire.nodes - delegate: Rectangle { - implicitHeight: 10 - - required property var modelData - StyledText { - text: parent.modelData.nickname - } - } - } - } - } diff --git a/modules/notifications/NotiCard.qml b/modules/notifications/NotiCard.qml index 5120d76..40dfd98 100644 --- a/modules/notifications/NotiCard.qml +++ b/modules/notifications/NotiCard.qml @@ -13,7 +13,7 @@ WrapperRectangle { property alias timerStart: dismissTimer implicitWidth: nScreen.width / 6 implicitHeight: 100 - radius: Config.rounding + radius: Config.cfg.appearance.rounding anchors.right: parent?.right color: Colors.barBg clip: true diff --git a/modules/notifications/NotiCard.qml~ b/modules/notifications/NotiCard.qml~ deleted file mode 100644 index 168591a..0000000 --- a/modules/notifications/NotiCard.qml~ +++ /dev/null @@ -1,92 +0,0 @@ -import Quickshell -import Quickshell.Widgets -import QtQuick.Layouts -import QtQuick -import qs -import qs.settings -import qs.widgets - -WrapperRectangle { - id: root - required property var notification - required property ShellScreen nScreen - implicitWidth: nScreen.width / 6 - implicitHeight: 100 - radius: Config.rounding - anchors.right: parent?.right - color: Colors.barBg - clip: true - Timer { - id: dismissTimer - running: true - interval: 5000 - repeat: false - onTriggered: root.notification?.dismiss() - } - child: WrapperMouseArea { - id: mouseHandler - child: RowLayout { - spacing: 10 - IconImage { - id: appIcon - Layout.leftMargin: 8 - visible: root.notification?.image ? true : false - source: root.notification?.image ? root.notification.image : '' - implicitSize: 64 - } - ColumnLayout { - Layout.alignment: Qt.AlignLeft - Layout.fillWidth: true - Layout.preferredWidth: 0 - Layout.fillHeight: true - Layout.leftMargin: appIcon.visible ? 0 : 16 - RowLayout { - Layout.alignment: Qt.AlignTop - MaterialIcon { - text: "\ue7f7" - font.pixelSize: 12 - } - StyledText { - id: appId - text: root.notification?.appName ? root.notification.appName : '' - opacity: 0.4 - } - } - ColumnLayout { - spacing: 0 - Layout.rightMargin: 40 - StyledText { - id: title - Layout.bottomMargin: 0 - Layout.topMargin: 5 - Layout.alignment: Qt.AlignBottom - Layout.fillWidth: true - text: root.notification?.summary == null ? '' : root.notification.summary - elide: Text.ElideRight - } - StyledText { - id: body - Layout.alignment: Qt.AlignBottom - text: root.notification?.body ? root.notification.body : '' - elide: Text.ElideRight - maximumLineCount: 1 - Layout.fillWidth: true - opacity: 0.6 - } - } - } - } - acceptedButtons: Qt.LeftButton - cursorShape: Qt.PointingHandCursor - hoverEnabled: true - onEntered: { - root.color = Colors.base03; - } - onExited: { - root.color = Colors.base01; - } - onClicked: { - root.notification ? root.notification.dismiss() : ''; - } - } -} diff --git a/modules/notifications/NotiPopup.qml b/modules/notifications/NotiPopup.qml index b03803b..dfbc980 100644 --- a/modules/notifications/NotiPopup.qml +++ b/modules/notifications/NotiPopup.qml @@ -16,7 +16,7 @@ Variants { top: true right: true } - margins.top: Config.barHeight + 8 + (Config.floating ? 10 : 0) + margins.top: Config.cfg.bar.height + 8 + (Config.cfg.bar.floating ? 10 : 0) margins.right: 8 implicitHeight: notiList.contentHeight implicitWidth: modelData.width / 6 diff --git a/modules/notifications/NotiPopup.qml~ b/modules/notifications/NotiPopup.qml~ deleted file mode 100644 index ac509e8..0000000 --- a/modules/notifications/NotiPopup.qml~ +++ /dev/null @@ -1,46 +0,0 @@ -pragma ComponentBehavior: Bound -import Quickshell -import QtQuick -import Quickshell.Wayland -import qs.settings -import Quickshell.Hyprland - -WlrLayershell { - id: notiPopup - property ShellScreen activeScreen: getActiveScreen() - function getActiveScreen() { - let current = Quickshell.screens[0]; - for (let i = 0; i < Quickshell.screens.length; i++) { - current = Quickshell.screens[i]; - if (Hyprland.monitorFor(current) == Hyprland.focusedMonitor) { - return current; - } - } - return current; - } - exclusionMode: ExclusionMode.Ignore - layer: WlrLayer.Overlay - screen: activeScreen - anchors { - top: true - right: true - } - margins.top: Config.barHeight + 8 + (Config.floating ? 10 : 0) - margins.right: 8 - implicitHeight: notiList.contentHeight - implicitWidth: activeScreen.width / 6 - color: 'transparent' - visible: NotiServer.notifications.values.length > 0 - - ListView { - id: notiList - anchors.fill: parent - model: NotiServer.notifications - spacing: 6 - delegate: NotiCard { - required property var modelData - nScreen: notiPopup.activeScreen - notification: modelData - } - } -} diff --git a/modules/notifications/NotiServer.qml~ b/modules/notifications/NotiServer.qml~ deleted file mode 100644 index db79793..0000000 --- a/modules/notifications/NotiServer.qml~ +++ /dev/null @@ -1,18 +0,0 @@ -pragma Singleton -import Quickshell -import Quickshell.Services.Notifications -import QtQuick - -Singleton { - id: root - property alias notifications: server.trackedNotifications - NotificationServer { - id: server - imageSupported: true - bodyImagesSupported: true - - onNotification: notification => { - notification.tracked = true; - } - } -} diff --git a/modules/wallpaper/Wallpaper.qml b/modules/wallpaper/Wallpaper.qml index 966c7ff..2e1ce0c 100644 --- a/modules/wallpaper/Wallpaper.qml +++ b/modules/wallpaper/Wallpaper.qml @@ -21,7 +21,7 @@ Variants { Image { cache: false anchors.fill: parent - source: Config.wallpaper + source: Qt.resolvedUrl(Config.cfg.wallpaper.wallpaper) } } } diff --git a/settings/Config.qml b/settings/Config.qml index f492035..ef392f6 100644 --- a/settings/Config.qml +++ b/settings/Config.qml @@ -2,33 +2,43 @@ pragma Singleton import QtCore import QtQuick import Quickshell +import Quickshell.Io Singleton { id: root - property string font: "Maple Mono" - property int fontSize: 12 - property int iconSize: 14 - property int barHeight: 30 - property int rounding: 16 - property url wallpaper: "file:///home/lucy/.walls/frierensuff.png" - property bool floating: false - property double opacity: 1.0 - property string primaryMon: "eDP-1" - property string wallDir: "file://" + Quickshell.env("HOME") + "/.walls" - property bool showCorners: true - property real moduleHeight: barHeight - 8 - Settings { - location: Qt.resolvedUrl("file:///home/lucy/.config/quickshell/settings/settings.ini") - property alias font: root.font - property alias fontSize: root.fontSize - property alias barHeight: root.barHeight - property alias rounding: root.rounding - property alias wallpaper: root.wallpaper - property alias opacity: root.opacity - property alias primaryMon: root.primaryMon - property alias floating: root.floating - property alias wallDir: root.wallDir - property alias showCorners: root.showCorners - property alias iconSize: root.iconSize + property alias cfg: cfg + function save() { + if (cfgView.loaded) + cfgView.writeAdapter(); + } + FileView { + id: cfgView + path: Qt.resolvedUrl(Quickshell.shellDir + "/settings/settings.json") + watchChanges: true + onFileChanged: { + this.reload(); + } + onLoadFailed: error => { + if (error === FileViewError.FileNotFound) + writeAdapter(); + } + adapter: JsonAdapter { + id: cfg + property JsonObject appearance: JsonObject { + property string font: "Iosevka" + property int fontSize: 14 + property int iconSize: 16 + property int rounding: 16 + } + property JsonObject bar: JsonObject { + property bool floating: true + property int height: 40 + property real opacity: 1.0 + } + property JsonObject wallpaper: JsonObject { + property string wallDir: Quickshell.env("HOME") + "/.walls/" + property string wallpaper: "" + } + } } } diff --git a/settings/settings.ini b/settings/settings.ini index c3c021d..a93161e 100644 --- a/settings/settings.ini +++ b/settings/settings.ini @@ -1,12 +1,12 @@ [General] barHeight=30 -floating=true +floating=false font=Iosevka -fontSize=16 -iconSize=18 +fontSize=14 +iconSize=16 opacity=1 primaryMon=eDP-1 rounding=16 showCorners=true -wallDir=file:///home/lucy/.walls -wallpaper=@Variant(\0\0\0\x11\0\0\0\x1f/home/lucy/.walls/lain_blue.png) +wallDir=/home/lucy/.walls/ +wallpaper=/home/lucy/.walls/walkingcastle.png diff --git a/settings/settings.json b/settings/settings.json new file mode 100644 index 0000000..2e3458a --- /dev/null +++ b/settings/settings.json @@ -0,0 +1,17 @@ +{ + "appearance": { + "font": "Iosevka", + "fontSize": 14, + "iconSize": 16, + "rounding": 16 + }, + "bar": { + "floating": true, + "height": 40, + "opacity": 1 + }, + "wallpaper": { + "wallDir": "/home/lucy/.walls/", + "wallpaper": "/home/lucy/.walls/frierensuff.png" + } +} diff --git a/settings/settings.json~ b/settings/settings.json~ new file mode 100644 index 0000000..e564936 --- /dev/null +++ b/settings/settings.json~ @@ -0,0 +1,18 @@ +{ + "appearance": { + "font": "Iosevka", + "fontSize": 14, + "iconSize": 16, + "rounding": 16 + }, + "bar": { + "floating": true, + "height": 38, + "moduleHeight": 30, + "opacity": 1 + }, + "wallpaper": { + "wallDir": "/home/lucy/.walls/", + "wallpaper": "/home/lucy/.walls/frierensuff.png" + } +} diff --git a/widgets/BarComponent.qml b/widgets/BarComponent.qml index ace44d2..011ab86 100644 --- a/widgets/BarComponent.qml +++ b/widgets/BarComponent.qml @@ -6,6 +6,6 @@ import qs.settings Rectangle { property bool active: false color: active ? Colors.activeModuleBg : Colors.moduleBg - implicitHeight: Config.moduleHeight - radius: Config.rounding + implicitHeight: Config.cfg.bar.height - 8 + radius: Config.cfg.appearance.rounding } diff --git a/widgets/StyledIcon.qml b/widgets/StyledIcon.qml index e58f4f2..86de77f 100644 --- a/widgets/StyledIcon.qml +++ b/widgets/StyledIcon.qml @@ -6,7 +6,7 @@ import qs.settings IconImage { required property string iconName - implicitSize: Config.iconSize + implicitSize: Config.cfg.appearance.iconSize source: Quickshell.iconPath(iconName) layer.enabled: true layer.effect: MultiEffect { diff --git a/widgets/StyledText.qml b/widgets/StyledText.qml index 117d6ba..3bc1f1b 100644 --- a/widgets/StyledText.qml +++ b/widgets/StyledText.qml @@ -4,6 +4,6 @@ import qs.settings Text { color: Colors.text - font.family: Config.font - font.pixelSize: Config.fontSize + font.family: Config.cfg.appearance.font + font.pixelSize: Config.cfg.appearance.fontSize }