Settings window #20

Merged
Zacharias-Brohn merged 83 commits from settingsWindow into main 2026-03-06 23:27:24 +01:00
11 changed files with 311 additions and 237 deletions
Showing only changes of commit afb736102d - Show all commits
+24 -4
View File
@@ -4,6 +4,7 @@ import qs.Config
Item { Item {
id: root id: root
property bool animate: false
property color color: DynamicColors.palette.m3onSurface property color color: DynamicColors.palette.m3onSurface
property int fadeStrengthAnimMs: 180 property int fadeStrengthAnimMs: 180
property real fadeStrengthIdle: 0.0 property real fadeStrengthIdle: 0.0
@@ -27,6 +28,19 @@ Item {
return Math.max(1, Math.round(Math.abs(px) / root.pixelsPerSecond * 1000)); return Math.max(1, Math.round(Math.abs(px) / root.pixelsPerSecond * 1000));
} }
function resetMarquee() {
// stop + reset all state immediately
marqueeAnim.stop();
strip.x = 0;
root.sliding = false;
root.leftFadeEnabled = false;
// restart after bindings/layout settle
if (root.marqueeEnabled && root.overflowing && root.visible) {
marqueeAnim.restart();
}
}
clip: true clip: true
implicitHeight: elideText.implicitHeight implicitHeight: elideText.implicitHeight
@@ -39,10 +53,10 @@ Item {
} }
} }
onTextChanged: strip.x = 0 onTextChanged: resetMarquee()
onVisibleChanged: if (!visible) onVisibleChanged: if (!visible)
strip.x = 0 resetMarquee()
onWidthChanged: strip.x = 0 onWidthChanged: resetMarquee()
TextMetrics { TextMetrics {
id: metrics id: metrics
@@ -55,8 +69,10 @@ Item {
id: elideText id: elideText
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
animate: root.animate
animateProp: "scale,opacity"
color: root.color color: root.color
elide: Text.ElideRight elide: Text.ElideNone
visible: !root.overflowing visible: !root.overflowing
width: root.width width: root.width
} }
@@ -84,6 +100,8 @@ Item {
CustomText { CustomText {
id: t1 id: t1
animate: root.animate
animateProp: "opacity"
color: root.color color: root.color
text: elideText.text text: elideText.text
} }
@@ -91,6 +109,8 @@ Item {
CustomText { CustomText {
id: t2 id: t2
animate: root.animate
animateProp: "opacity"
color: root.color color: root.color
text: t1.text text: t1.text
x: t1.width + root.gap x: t1.width + root.gap
+4
View File
@@ -11,6 +11,10 @@ JsonObject {
id: "audio", id: "audio",
enabled: true enabled: true
}, },
{
id: "media",
enabled: true
},
{ {
id: "resources", id: "resources",
enabled: true enabled: true
+50 -76
View File
@@ -24,101 +24,75 @@ Item {
} }
} }
Rectangle { CustomRect {
anchors.left: parent.left anchors.left: parent.left
anchors.right: parent.right anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter anchors.verticalCenter: parent.verticalCenter
color: DynamicColors.tPalette.m3surfaceContainer color: DynamicColors.tPalette.m3surfaceContainer
height: 22 height: 22
radius: height / 2 radius: height / 2
}
Behavior on color { RowLayout {
CAnim { id: layout
}
anchors.fill: parent
anchors.leftMargin: Appearance.padding.small
anchors.rightMargin: Appearance.padding.small * 2
anchors.verticalCenter: parent.verticalCenter
MaterialIcon {
Layout.alignment: Qt.AlignVCenter
color: Audio.muted ? DynamicColors.palette.m3error : root.textColor
font.pointSize: 14
text: Audio.muted ? "volume_off" : "volume_up"
} }
Rectangle { CustomRect {
anchors.centerIn: parent Layout.fillWidth: true
border.color: "#30ffffff" color: "#50ffffff"
border.width: 0 implicitHeight: 4
color: "transparent" radius: 20
height: parent.height
radius: width / 2
width: parent.width
}
RowLayout { CustomRect {
id: layout id: sinkVolumeBar
anchors.left: parent.left color: Audio.muted ? DynamicColors.palette.m3error : root.barColor
anchors.leftMargin: Appearance.padding.small implicitWidth: parent.width * (Audio.volume ?? 0)
anchors.right: parent.right radius: parent.radius
anchors.rightMargin: Appearance.padding.small * 2
anchors.verticalCenter: parent.verticalCenter
MaterialIcon { anchors {
Layout.alignment: Qt.AlignVCenter bottom: parent.bottom
color: Audio.muted ? DynamicColors.palette.m3error : root.textColor left: parent.left
font.pointSize: 14 top: parent.top
text: Audio.muted ? "volume_off" : "volume_up"
}
Rectangle {
Layout.fillWidth: true
color: "#50ffffff"
implicitHeight: 4
radius: 20
Rectangle {
id: sinkVolumeBar
color: Audio.muted ? DynamicColors.palette.m3error : root.barColor
implicitWidth: parent.width * (Audio.volume ?? 0)
radius: parent.radius
Behavior on color {
CAnim {
}
}
anchors {
bottom: parent.bottom
left: parent.left
top: parent.top
}
} }
} }
}
MaterialIcon { MaterialIcon {
Layout.alignment: Qt.AlignVCenter Layout.alignment: Qt.AlignVCenter
color: (Audio.sourceMuted ?? false) ? DynamicColors.palette.m3error : root.textColor color: (Audio.sourceMuted ?? false) ? DynamicColors.palette.m3error : root.textColor
font.pointSize: 14 font.pointSize: 14
text: Audio.sourceMuted ? "mic_off" : "mic" text: Audio.sourceMuted ? "mic_off" : "mic"
} }
Rectangle { CustomRect {
Layout.fillWidth: true Layout.fillWidth: true
color: "#50ffffff" color: "#50ffffff"
implicitHeight: 4 implicitHeight: 4
radius: 20 radius: 20
Rectangle { CustomRect {
id: sourceVolumeBar id: sourceVolumeBar
color: (Audio.sourceMuted ?? false) ? DynamicColors.palette.m3error : root.barColor color: (Audio.sourceMuted ?? false) ? DynamicColors.palette.m3error : root.barColor
implicitWidth: parent.width * (Audio.sourceVolume ?? 0) implicitWidth: parent.width * (Audio.sourceVolume ?? 0)
radius: parent.radius radius: parent.radius
Behavior on color { anchors {
CAnim { bottom: parent.bottom
} left: parent.left
} top: parent.top
anchors {
bottom: parent.bottom
left: parent.left
top: parent.top
}
} }
} }
} }
+9 -8
View File
@@ -206,14 +206,15 @@ RowLayout {
} }
} }
} }
// DelegateChoice {
// roleValue: "dash" DelegateChoice {
// delegate: WrappedLoader { roleValue: "media"
// sourceComponent: DashWidget {
// visibilities: root.visibilities delegate: WrappedLoader {
// } sourceComponent: MediaWidget {
// } }
// } }
}
} }
} }
+32 -3
View File
@@ -217,7 +217,7 @@ Item {
width: parent.width - Appearance.padding.large * 4 width: parent.width - Appearance.padding.large * 4
} }
Row { RowLayout {
id: controls id: controls
anchors.horizontalCenter: parent.horizontalCenter anchors.horizontalCenter: parent.horizontalCenter
@@ -260,20 +260,48 @@ Item {
required property bool canUse required property bool canUse
required property string icon required property string icon
property int level: 1
property string set_color: "Secondary"
function onClicked(): void { function onClicked(): void {
} }
Layout.preferredWidth: implicitWidth + (controlState.pressed ? Appearance.padding.normal * 2 : 0)
color: canUse ? DynamicColors.palette[`m3${set_color.toLowerCase()}`] : DynamicColors.palette[`m3${set_color.toLowerCase()}Container`]
implicitHeight: implicitWidth implicitHeight: implicitWidth
implicitWidth: Math.max(icon.implicitHeight, icon.implicitHeight) + Appearance.padding.small implicitWidth: Math.max(icon.implicitHeight, icon.implicitHeight) + Appearance.padding.small
radius: Appearance.rounding.full
Behavior on Layout.preferredWidth {
Anim {
duration: Appearance.anim.durations.expressiveFastSpatial
easing.bezierCurve: Appearance.anim.curves.expressiveFastSpatial
}
}
Behavior on radius {
Anim {
duration: Appearance.anim.durations.expressiveFastSpatial
easing.bezierCurve: Appearance.anim.curves.expressiveFastSpatial
}
}
Elevation {
anchors.fill: parent
level: controlState.containsMouse && !controlState.pressed ? control.level + 1 : control.level
radius: parent.radius
z: -1
}
StateLayer { StateLayer {
id: controlState
function onClicked(): void { function onClicked(): void {
control.onClicked(); control.onClicked();
} }
color: control.canUse ? DynamicColors.palette[`m3on${control.set_color}`] : DynamicColors.palette[`m3on${control.set_color}Container`]
disabled: !control.canUse disabled: !control.canUse
radius: Appearance.rounding.full // radius: Appearance.rounding.full
} }
MaterialIcon { MaterialIcon {
@@ -282,7 +310,8 @@ Item {
anchors.centerIn: parent anchors.centerIn: parent
anchors.verticalCenterOffset: font.pointSize * 0.05 anchors.verticalCenterOffset: font.pointSize * 0.05
animate: true animate: true
color: control.canUse ? DynamicColors.palette.m3onSurface : DynamicColors.palette.m3outline color: control.canUse ? DynamicColors.palette[`m3on${control.set_color}`] : DynamicColors.palette[`m3on${control.set_color}Container`]
fill: control.canUse ? 1 : 0
font.pointSize: Appearance.font.size.large font.pointSize: Appearance.font.size.large
text: control.icon text: control.icon
} }
+3 -3
View File
@@ -121,9 +121,9 @@ Item {
active: Players.active?.isPlaying ?? false active: Players.active?.isPlaying ?? false
animate: true animate: true
colour: "Primary"
icon: active ? "pause" : "play_arrow" icon: active ? "pause" : "play_arrow"
level: active ? 2 : 1 level: active ? 2 : 1
set_color: "Primary"
} }
PlayerControl { PlayerControl {
@@ -142,15 +142,15 @@ Item {
property bool active property bool active
property alias animate: controlIcon.animate property alias animate: controlIcon.animate
property string colour: "Secondary"
property alias icon: controlIcon.text property alias icon: controlIcon.text
property int level: 1 property int level: 1
property string set_color: "Secondary"
function onClicked(): void { function onClicked(): void {
} }
Layout.preferredWidth: implicitWidth + (controlState.pressed ? Appearance.padding.normal * 2 : active ? Appearance.padding.small * 2 : 0) Layout.preferredWidth: implicitWidth + (controlState.pressed ? Appearance.padding.normal * 2 : active ? Appearance.padding.small * 2 : 0)
color: active ? DynamicColors.palette[`m3${colour.toLowerCase()}`] : DynamicColors.palette[`m3${colour.toLowerCase()}Container`] color: active ? DynamicColors.palette[`m3${set_color.toLowerCase()}`] : DynamicColors.palette[`m3${set_color.toLowerCase()}Container`]
implicitHeight: controlIcon.implicitHeight + Appearance.padding.normal * 2 implicitHeight: controlIcon.implicitHeight + Appearance.padding.normal * 2
implicitWidth: controlIcon.implicitWidth + Appearance.padding.large * 2 implicitWidth: controlIcon.implicitWidth + Appearance.padding.large * 2
radius: active || controlState.pressed ? Appearance.rounding.small : Appearance.rounding.normal radius: active || controlState.pressed ? Appearance.rounding.small : Appearance.rounding.normal
+73
View File
@@ -0,0 +1,73 @@
import QtQuick
import QtQuick.Layouts
import qs.Components
import qs.Daemons
import qs.Config
import qs.Helpers
Item {
id: root
readonly property string currentMedia: (Players.active?.trackTitle ?? qsTr("No media")) || qsTr("Unknown title")
readonly property int textWidth: Math.min(metrics.width, 200)
anchors.bottom: parent.bottom
anchors.top: parent.top
implicitWidth: layout.implicitWidth + Appearance.padding.normal * 2
Behavior on implicitWidth {
Anim {
}
}
CustomRect {
anchors.left: parent.left
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
color: DynamicColors.tPalette.m3surfaceContainer
implicitHeight: 22
radius: Appearance.rounding.full
}
TextMetrics {
id: metrics
font: mediatext.font
text: mediatext.text
}
RowLayout {
id: layout
anchors.bottom: parent.bottom
anchors.horizontalCenter: parent.horizontalCenter
anchors.left: parent.left
anchors.leftMargin: Appearance.padding.normal
anchors.top: parent.top
Behavior on implicitWidth {
Anim {
}
}
MaterialIcon {
animate: true
color: Players.active?.isPlaying ? DynamicColors.palette.m3primary : DynamicColors.palette.m3onSurface
font.pointSize: 14
text: Players.active?.isPlaying ? "music_note" : "music_off"
}
MarqueeText {
id: mediatext
Layout.preferredWidth: root.textWidth
animate: true
color: Players.active?.isPlaying ? DynamicColors.palette.m3primary : DynamicColors.palette.m3onSurface
font.pointSize: Appearance.font.size.normal
horizontalAlignment: Text.AlignHCenter
pauseMs: 4000
text: root.currentMedia
width: root.textWidth
}
}
}
+48 -53
View File
@@ -16,80 +16,75 @@ Item {
implicitHeight: 34 implicitHeight: 34
implicitWidth: rowLayout.implicitWidth + Appearance.padding.small * 2 implicitWidth: rowLayout.implicitWidth + Appearance.padding.small * 2
Rectangle { CustomRect {
id: backgroundRect id: backgroundRect
color: DynamicColors.tPalette.m3surfaceContainer color: DynamicColors.tPalette.m3surfaceContainer
implicitHeight: 22 implicitHeight: 22
radius: height / 2 radius: height / 2
Behavior on color {
CAnim {
}
}
anchors { anchors {
left: parent.left left: parent.left
right: parent.right right: parent.right
verticalCenter: parent.verticalCenter verticalCenter: parent.verticalCenter
} }
}
RowLayout { RowLayout {
id: rowLayout id: rowLayout
anchors.centerIn: parent anchors.centerIn: parent
spacing: 6 spacing: 6
MaterialIcon { MaterialIcon {
Layout.alignment: Qt.AlignVCenter Layout.alignment: Qt.AlignVCenter
color: DynamicColors.palette.m3onSurface color: DynamicColors.palette.m3onSurface
font.pointSize: 14 font.pointSize: 14
text: "memory_alt" text: "memory_alt"
} }
Resource { Resource {
Layout.alignment: Qt.AlignVCenter Layout.alignment: Qt.AlignVCenter
mainColor: DynamicColors.palette.m3primary mainColor: DynamicColors.palette.m3primary
percentage: ResourceUsage.memoryUsedPercentage percentage: ResourceUsage.memoryUsedPercentage
warningThreshold: 95 warningThreshold: 95
} }
MaterialIcon { MaterialIcon {
Layout.alignment: Qt.AlignVCenter Layout.alignment: Qt.AlignVCenter
color: DynamicColors.palette.m3onSurface color: DynamicColors.palette.m3onSurface
font.pointSize: 14 font.pointSize: 14
text: "memory" text: "memory"
} }
Resource { Resource {
mainColor: DynamicColors.palette.m3secondary mainColor: DynamicColors.palette.m3secondary
percentage: ResourceUsage.cpuUsage percentage: ResourceUsage.cpuUsage
warningThreshold: 80 warningThreshold: 80
} }
MaterialIcon { MaterialIcon {
Layout.alignment: Qt.AlignVCenter Layout.alignment: Qt.AlignVCenter
color: DynamicColors.palette.m3onSurface color: DynamicColors.palette.m3onSurface
font.pointSize: 14 font.pointSize: 14
text: "gamepad" text: "gamepad"
} }
Resource { Resource {
mainColor: DynamicColors.palette.m3tertiary mainColor: DynamicColors.palette.m3tertiary
percentage: ResourceUsage.gpuUsage percentage: ResourceUsage.gpuUsage
} }
MaterialIcon { MaterialIcon {
Layout.alignment: Qt.AlignVCenter Layout.alignment: Qt.AlignVCenter
color: DynamicColors.palette.m3onSurface color: DynamicColors.palette.m3onSurface
font.pointSize: 14 font.pointSize: 14
text: "developer_board" text: "developer_board"
} }
Resource { Resource {
mainColor: DynamicColors.palette.m3primary mainColor: DynamicColors.palette.m3primary
percentage: ResourceUsage.gpuMemUsage percentage: ResourceUsage.gpuMemUsage
}
} }
} }
} }
+1 -9
View File
@@ -27,25 +27,17 @@ Item {
id: contentRow id: contentRow
anchors.centerIn: parent anchors.centerIn: parent
implicitHeight: 22
spacing: Appearance.spacing.small spacing: Appearance.spacing.small
MaterialIcon { MaterialIcon {
Layout.alignment: Qt.AlignVCenter
font.pointSize: 14 font.pointSize: 14
text: "package_2" text: "package_2"
} }
TextMetrics {
id: textMetrics
text: root.countUpdates
}
CustomText { CustomText {
color: root.textColor color: root.textColor
font.pointSize: 12 font.pointSize: 12
text: textMetrics.text text: root.countUpdates
} }
} }
} }
+12 -29
View File
@@ -4,7 +4,6 @@
#include "audioprovider.hpp" #include "audioprovider.hpp"
#include <algorithm> #include <algorithm>
#include <cava/cavacore.h> #include <cava/cavacore.h>
#include <cmath>
#include <cstddef> #include <cstddef>
#include <qdebug.h> #include <qdebug.h>
@@ -40,35 +39,19 @@ void CavaProcessor::process() {
values[i] = std::clamp(m_out[i], 0.0, 1.0); values[i] = std::clamp(m_out[i], 0.0, 1.0);
} }
// --- spectral contrast (removes the "everything rises together" effect) // Left to right pass
// QVector<double> tmp = values; // const double inv = 1.0 / 1.5;
// auto* b = tmp.data(); // double carry = 0.0;
// auto* e = b + tmp.size();
//
// auto pct = [&](double p) -> double {
// const qsizetype n = tmp.size();
// if (n <= 0) return 0.0;
//
// // p in [0,1] -> index in [0, n-1]
// const double pos = p * double(n - 1);
// qsizetype k = static_cast<qsizetype>(std::llround(pos));
// k = std::clamp<qsizetype>(k, 0, n - 1);
//
// auto first = tmp.begin();
// auto nth = first + k;
// std::nth_element(first, nth, tmp.end());
// return *nth;
// };
//
// const double floor = pct(0.25);
// const double ceil = pct(0.95);
// const double range = std::max(1e-6, ceil - floor);
//
// const double gamma = 1.6; // 1.3..2.2 range; higher = more contrast
// for (int i = 0; i < m_bars; ++i) { // for (int i = 0; i < m_bars; ++i) {
// double x = (values[i] - floor) / range; // carry = std::max(m_out[i], carry * inv);
// x = std::clamp(x, 0.0, 1.0); // values[i] = carry;
// values[i] = std::pow(x, gamma); // }
//
// // Right to left pass and combine
// carry = 0.0;
// for (int i = m_bars - 1; i >= 0; --i) {
// carry = std::max(m_out[i], carry * inv);
// values[i] = std::max(values[i], carry);
// } // }
// Update values // Update values
+55 -52
View File
@@ -1,4 +1,6 @@
{ {
fftw,
libcava,
rev, rev,
lib, lib,
stdenv, stdenv,
@@ -23,7 +25,8 @@
pkg-config, pkg-config,
pythonEnv, pythonEnv,
zshell-cli, zshell-cli,
}: let }:
let
version = "1.0.0"; version = "1.0.0";
runtimeDeps = [ runtimeDeps = [
@@ -74,66 +77,66 @@
libqalculate libqalculate
pipewire pipewire
aubio aubio
libcava
fftw
]; ];
dontWrapQtApps = true; dontWrapQtApps = true;
cmakeFlags = cmakeFlags = [
[ (lib.cmakeFeature "ENABLE_MODULES" "plugin")
(lib.cmakeFeature "ENABLE_MODULES" "plugin") (lib.cmakeFeature "INSTALL_QMLDIR" qt6.qtbase.qtQmlPrefix)
(lib.cmakeFeature "INSTALL_QMLDIR" qt6.qtbase.qtQmlPrefix) ]
] ++ cmakeVersionFlags;
++ cmakeVersionFlags;
}; };
in in
stdenv.mkDerivation { stdenv.mkDerivation {
inherit version cmakeBuildType; inherit version cmakeBuildType;
pname = "zshell"; pname = "zshell";
src = ./..; src = ./..;
nativeBuildInputs = [ nativeBuildInputs = [
cmake cmake
ninja ninja
makeWrapper makeWrapper
qt6.wrapQtAppsHook qt6.wrapQtAppsHook
]; ];
buildInputs = [ buildInputs = [
quickshell quickshell
plugin plugin
qt6.qtbase qt6.qtbase
qt6.qtwayland qt6.qtwayland
]; ];
propagatedBuildInputs = runtimeDeps; propagatedBuildInputs = runtimeDeps;
cmakeFlags = cmakeFlags = [
[ (lib.cmakeFeature "ENABLE_MODULES" "shell")
(lib.cmakeFeature "ENABLE_MODULES" "shell") (lib.cmakeFeature "INSTALL_QSCONFDIR" "${placeholder "out"}/share/ZShell")
(lib.cmakeFeature "INSTALL_QSCONFDIR" "${placeholder "out"}/share/ZShell") ]
] ++ cmakeVersionFlags;
++ cmakeVersionFlags;
prePatch = '' prePatch = ''
substituteInPlace shell.qml \ substituteInPlace shell.qml \
--replace-fail 'ShellRoot {' 'ShellRoot { settings.watchFiles: false' --replace-fail 'ShellRoot {' 'ShellRoot { settings.watchFiles: false'
''; '';
postInstall = '' postInstall = ''
makeWrapper ${quickshell}/bin/qs $out/bin/zshell \ makeWrapper ${quickshell}/bin/qs $out/bin/zshell \
--prefix PATH : "${lib.makeBinPath runtimeDeps}" \ --prefix PATH : "${lib.makeBinPath runtimeDeps}" \
--set FONTCONFIG_FILE "${fontconfig}" \ --set FONTCONFIG_FILE "${fontconfig}" \
--add-flags "-p $out/share/ZShell" --add-flags "-p $out/share/ZShell"
echo "$out" echo "$out"
mkdir -p $out/lib mkdir -p $out/lib
''; '';
passthru = { passthru = {
inherit plugin; inherit plugin;
}; };
meta = { meta = {
description = "A very segsy desktop shell"; description = "A very segsy desktop shell";
homepage = "https://github.com/Zacharias-Brohn/z-bar-qt"; homepage = "https://github.com/Zacharias-Brohn/z-bar-qt";
license = lib.licenses.gpl3Only; license = lib.licenses.gpl3Only;
mainProgram = "zshell"; mainProgram = "zshell";
}; };
} }