Settings rework...

This commit is contained in:
Ly-sec 2025-08-05 17:41:08 +02:00
parent 74b233798d
commit fb68300746
63 changed files with 7139 additions and 1026 deletions

View file

@ -22,18 +22,17 @@ Scope {
property var notificationHistoryWin: notificationHistoryWin
property bool pendingReload: false
// Helper function to round value to nearest step
// Round volume to nearest 5% increment for consistent control
function roundToStep(value, step) {
return Math.round(value / step) * step;
}
// Volume property reflecting current audio volume in 0-100
// Will be kept in sync dynamically below
// Current audio volume (0-100), synced with system
property int volume: (defaultAudioSink && defaultAudioSink.audio && !defaultAudioSink.audio.muted)
? Math.round(defaultAudioSink.audio.volume * 100)
: 0
// Function to update volume with clamping, stepping, and applying to audio sink
// Update volume with 5-step increments and apply to audio sink
function updateVolume(vol) {
var clamped = Math.max(0, Math.min(100, vol));
var stepped = roundToStep(clamped, 5);
@ -53,6 +52,15 @@ Scope {
property var notificationHistoryWin: notificationHistoryWin
}
// Create dock for each monitor (respects dockMonitors setting)
Variants {
model: Quickshell.screens
Dock {
property var modelData
}
}
Applauncher {
id: appLauncherPanel
visible: false
@ -77,9 +85,15 @@ Scope {
onNotification: function (notification) {
console.log("Notification received:", notification.appName);
notification.tracked = true;
if (notificationPopup.notificationsVisible) {
notificationPopup.addNotification(notification);
// Distribute notification to all visible notification popups
for (let i = 0; i < notificationPopupVariants.count; i++) {
let popup = notificationPopupVariants.objectAt(i);
if (popup && popup.notificationsVisible) {
popup.addNotification(notification);
}
}
if (notificationHistoryWin) {
notificationHistoryWin.addToHistory({
id: notification.id,
@ -93,9 +107,19 @@ Scope {
}
}
NotificationPopup {
id: notificationPopup
barVisible: bar.visible
// Create notification popups for each selected monitor
Variants {
id: notificationPopupVariants
model: Quickshell.screens
NotificationPopup {
property var modelData
barVisible: bar.visible
screen: modelData
visible: notificationsVisible && notificationModel.count > 0 &&
(Settings.settings.notificationMonitors.includes(modelData.name) ||
(Settings.settings.notificationMonitors.length === 0)) // Show on all if none selected
}
}
NotificationHistory {
@ -113,7 +137,7 @@ Scope {
appLauncherPanel: appLauncherPanel
lockScreen: lockScreen
idleInhibitor: idleInhibitor
notificationPopup: notificationPopup
notificationPopupVariants: notificationPopupVariants
}
Connections {
@ -130,11 +154,12 @@ Scope {
Timer {
id: reloadTimer
interval: 500 // ms
interval: 500
repeat: false
onTriggered: Quickshell.reload(true)
}
// Handle screen configuration changes (delay reload if locked)
Connections {
target: Quickshell
function onScreensChanged() {
@ -146,17 +171,15 @@ Scope {
}
}
// --- NEW: Keep volume property in sync with actual Pipewire audio sink volume ---
Connections {
target: defaultAudioSink.audio
onVolumeChanged: {
target: defaultAudioSink ? defaultAudioSink.audio : null
function onVolumeChanged() {
if (defaultAudioSink.audio && !defaultAudioSink.audio.muted) {
volume = Math.round(defaultAudioSink.audio.volume * 100);
console.log("Volume changed externally to:", volume);
}
}
onMutedChanged: {
function onMutedChanged() {
if (defaultAudioSink.audio) {
if (defaultAudioSink.audio.muted) {
volume = 0;