From 9ffae63e55249e7d510b09908eb2a3ea27defa02 Mon Sep 17 00:00:00 2001 From: Zacharias-Brohn Date: Tue, 11 Nov 2025 01:50:05 +0100 Subject: [PATCH] starting to use config files --- Bar.qml | 4 ++-- Config/AccentColor.qml | 11 +++++++++++ Config/Config.qml | 30 ++++++++++++++++++++++++++++++ Modules/Launcher.qml | 4 ++-- Modules/Notification.qml | 3 ++- Modules/NotificationCenter.qml | 5 +++-- Modules/Resource.qml | 3 ++- Modules/Workspaces.qml | 5 +++-- launcher/MaterialEasing.qml | 27 --------------------------- 9 files changed, 55 insertions(+), 37 deletions(-) create mode 100644 Config/AccentColor.qml create mode 100644 Config/Config.qml delete mode 100644 launcher/MaterialEasing.qml diff --git a/Bar.qml b/Bar.qml index 7d9c09d..5934f6d 100644 --- a/Bar.qml +++ b/Bar.qml @@ -1,4 +1,3 @@ - import QtQuick import QtQuick.Controls import QtQuick.Layouts @@ -9,6 +8,7 @@ import Quickshell.Wayland import Qt5Compat.GraphicalEffects import Quickshell.Hyprland import qs.Modules +import qs.Config Scope { Variants { @@ -39,7 +39,7 @@ Scope { Rectangle { id: backgroundRect anchors.fill: parent - color: "#801a1a1a" + color: Config.baseBgColor radius: 0 RowLayout { diff --git a/Config/AccentColor.qml b/Config/AccentColor.qml new file mode 100644 index 0000000..e7720af --- /dev/null +++ b/Config/AccentColor.qml @@ -0,0 +1,11 @@ +import Quickshell.Io + +JsonObject { + property Accents accents: Accents {} + + component Accents: JsonObject { + property string primary: "#4080ff" + property string warning: "#ff6b6b" + property string primaryAlt: "#60a0ff" + } +} diff --git a/Config/Config.qml b/Config/Config.qml new file mode 100644 index 0000000..15a8728 --- /dev/null +++ b/Config/Config.qml @@ -0,0 +1,30 @@ +pragma Singleton + +import Quickshell +import Quickshell.Io + +Singleton { + + property alias appCount: adapter.appCount + property alias baseBgColor: adapter.baseBgColor + property alias accentColor: adapter.accentColor + + FileView { + id: root + property var configRoot: Quickshell.env("HOME") + + path: configRoot + "/.config/z-bar/config.json" + + watchChanges: true + onFileChanged: reload() + + onAdapterChanged: writeAdapter() + + JsonAdapter { + id: adapter + property int appCount: 20 + property string baseBgColor: "#801a1a1a" + property AccentColor accentColor: AccentColor {} + } + } +} diff --git a/Modules/Launcher.qml b/Modules/Launcher.qml index 489765f..85a4403 100644 --- a/Modules/Launcher.qml +++ b/Modules/Launcher.qml @@ -5,7 +5,7 @@ import QtQuick import QtQuick.Controls import QtQuick.Effects import QtQuick.Layouts -import qs +import qs.Config Scope { id: root @@ -224,7 +224,7 @@ Scope { } verticalLayoutDirection: ListView.BottomToTop - implicitHeight: Math.min( count, 20 ) * 48 + implicitHeight: Math.min( count, Config.appCount ) * 48 preferredHighlightBegin: 0 preferredHighlightEnd: appListRect.height diff --git a/Modules/Notification.qml b/Modules/Notification.qml index 726fd5b..9a0881d 100644 --- a/Modules/Notification.qml +++ b/Modules/Notification.qml @@ -4,6 +4,7 @@ import Quickshell.Wayland import QtQuick.Layouts import QtQuick import Quickshell.Services.Notifications +import qs.Config PanelWindow { id: root @@ -66,7 +67,7 @@ PanelWindow { implicitHeight: 90 x: root.centerX - implicitWidth - 20 y: 34 + 20 + ( root.index * ( implicitHeight + 10 )) - color: "#801a1a1a" + color: Config.baseBgColor border.color: "#555555" radius: 8 diff --git a/Modules/NotificationCenter.qml b/Modules/NotificationCenter.qml index 229ebe0..ca022f2 100644 --- a/Modules/NotificationCenter.qml +++ b/Modules/NotificationCenter.qml @@ -7,6 +7,7 @@ import QtQuick.Controls.FluentWinUI3 import QtQuick.Effects import QtQuick import Quickshell.Services.Notifications +import qs.Config PanelWindow { id: root @@ -125,7 +126,7 @@ PanelWindow { x: Screen.width implicitWidth: 400 implicitHeight: root.height - 20 - color: "#801a1a1a" + color: Config.baseBgColor radius: 8 border.color: "#555555" border.width: 1 @@ -276,7 +277,7 @@ PanelWindow { required property var index width: parent.width height: groupColumn.isExpanded ? ( modelData.actions.length > 1 ? 130 : 80 ) : ( groupColumn.notifications.length === 1 ? ( modelData.actions.length > 1 ? 130 : 80 ) : 80 ) - color: "#801a1a1a" + color: Config.baseBgColor border.color: "#555555" border.width: 1 radius: 8 diff --git a/Modules/Resource.qml b/Modules/Resource.qml index 432d5ce..6c5f971 100644 --- a/Modules/Resource.qml +++ b/Modules/Resource.qml @@ -2,6 +2,7 @@ import qs.Modules import QtQuick import QtQuick.Layouts import Quickshell +import qs.Config Item { id: root @@ -71,7 +72,7 @@ Item { var startAngle = -Math.PI / 2; // Start at top var endAngle = startAngle + (2 * Math.PI * percentage); - ctx.fillStyle = warning ? "#ff6b6b" : "#4080ff"; + ctx.fillStyle = warning ? Config.accentColor.accents.warning : Config.accentColor.accents.primary; ctx.beginPath(); ctx.moveTo(centerX, centerY); ctx.arc(centerX, centerY, radius, startAngle, endAngle); diff --git a/Modules/Workspaces.qml b/Modules/Workspaces.qml index 732e935..95d4a0d 100644 --- a/Modules/Workspaces.qml +++ b/Modules/Workspaces.qml @@ -3,6 +3,7 @@ import QtQuick.Controls import QtQuick.Layouts import Quickshell import Quickshell.Hyprland +import qs.Config Rectangle { id: root @@ -37,9 +38,9 @@ Rectangle { height: 14 radius: height / 2 - color: modelData.id === Hyprland.focusedWorkspace.id ? "#4080ff" : "#606060" + color: modelData.id === Hyprland.focusedWorkspace.id ? Config.accentColor.accents.primary : "#606060" - border.color: modelData.id === Hyprland.focusedWorkspace.id ? "#60a0ff" : "#808080" + border.color: modelData.id === Hyprland.focusedWorkspace.id ? Config.accentColor.accents.primaryAlt : "#808080" border.width: 1 scale: 1.0 diff --git a/launcher/MaterialEasing.qml b/launcher/MaterialEasing.qml deleted file mode 100644 index 846da9f..0000000 --- a/launcher/MaterialEasing.qml +++ /dev/null @@ -1,27 +0,0 @@ -pragma Singleton -import Quickshell - -Singleton { - id: root - - // thanks to Soramane :> - // expressive curves => thanks end cutie ;) - readonly property list emphasized: [0.05, 0, 2 / 15, 0.06, 1 / 6, 0.4, 5 / 24, 0.82, 0.25, 1, 1, 1] - readonly property list emphasizedAccel: [0.3, 0, 0.8, 0.15, 1, 1] - readonly property int emphasizedAccelTime: 200 - readonly property list emphasizedDecel: [0.05, 0.7, 0.1, 1, 1, 1] - readonly property int emphasizedDecelTime: 400 - readonly property int emphasizedTime: 500 - readonly property list expressiveDefaultSpatial: [0.38, 1.21, 0.22, 1.00, 1, 1] - readonly property int expressiveDefaultSpatialTime: 500 - readonly property list expressiveEffects: [0.34, 0.80, 0.34, 1.00, 1, 1] - readonly property int expressiveEffectsTime: 200 - readonly property list expressiveFastSpatial: [0.42, 1.67, 0.21, 0.90, 1, 1] - readonly property int expressiveFastSpatialTime: 350 - readonly property list standard: [0.2, 0, 0, 1, 1, 1] - readonly property list standardAccel: [0.3, 0, 1, 1, 1, 1] - readonly property int standardAccelTime: 200 - readonly property list standardDecel: [0, 0, 0, 1, 1, 1] - readonly property int standardDecelTime: 250 - readonly property int standardTime: 300 -}