Formatting

This commit is contained in:
quadbyte 2025-08-19 13:31:13 -04:00
parent dd79920d92
commit 1d7b47ee4c
14 changed files with 267 additions and 254 deletions

View file

@ -109,7 +109,7 @@ Singleton {
property JsonObject bar property JsonObject bar
bar: JsonObject { bar: JsonObject {
property string position: "top" // Possible values: "top", "bottom" property string position: "top" // Possible values: "top", "bottom"
property bool showActiveWindow: true property bool showActiveWindow: true
property bool showSystemInfo: false property bool showSystemInfo: false
property bool showMedia: false property bool showMedia: false

View file

@ -43,12 +43,10 @@ NLoader {
} }
margins { margins {
top: (Settings.data.bar.monitors.includes(modelData.name) top: (Settings.data.bar.monitors.includes(modelData.name) || (Settings.data.bar.monitors.length === 0))
|| (Settings.data.bar.monitors.length === 0)) && Settings.data.bar.position === "top" && Settings.data.bar.position === "top" ? Math.floor(Style.barHeight * scaling) : 0
? Math.floor(Style.barHeight * scaling) : 0 bottom: (Settings.data.bar.monitors.includes(modelData.name) || (Settings.data.bar.monitors.length === 0))
bottom: (Settings.data.bar.monitors.includes(modelData.name) && Settings.data.bar.position === "bottom" ? Math.floor(Style.barHeight * scaling) : 0
|| (Settings.data.bar.monitors.length === 0)) && Settings.data.bar.position === "bottom"
? Math.floor(Style.barHeight * scaling) : 0
} }
// Source we want to show only as a ring // Source we want to show only as a ring

View file

@ -76,10 +76,10 @@ NLoader {
anchors { anchors {
right: parent.right right: parent.right
rightMargin: Style.marginXS * scaling rightMargin: Style.marginXS * scaling
top: Settings.data.bar.position === "top" ? parent.top : undefined top: Settings.data.bar.position === "top" ? parent.top : undefined
bottom: Settings.data.bar.position === "bottom" ? parent.bottom : undefined bottom: Settings.data.bar.position === "bottom" ? parent.bottom : undefined
topMargin: Settings.data.bar.position === "top" ? Style.marginXS * scaling : undefined topMargin: Settings.data.bar.position === "top" ? Style.marginXS * scaling : undefined
bottomMargin: Settings.data.bar.position === "bottom" ? Style.barHeight * scaling + Style.marginXS * scaling : undefined bottomMargin: Settings.data.bar.position === "bottom" ? Style.barHeight * scaling + Style.marginXS * scaling : undefined
} }
// Animation properties // Animation properties

View file

@ -91,10 +91,10 @@ NLoader {
anchors { anchors {
right: parent.right right: parent.right
rightMargin: Style.marginXS * scaling rightMargin: Style.marginXS * scaling
top: Settings.data.bar.position === "top" ? parent.top : undefined top: Settings.data.bar.position === "top" ? parent.top : undefined
bottom: Settings.data.bar.position === "bottom" ? parent.bottom : undefined bottom: Settings.data.bar.position === "bottom" ? parent.bottom : undefined
topMargin: Settings.data.bar.position === "top" ? Style.marginXS * scaling : undefined topMargin: Settings.data.bar.position === "top" ? Style.marginXS * scaling : undefined
bottomMargin: Settings.data.bar.position === "bottom" ? Style.barHeight * scaling + Style.marginXS * scaling : undefined bottomMargin: Settings.data.bar.position === "bottom" ? Style.barHeight * scaling + Style.marginXS * scaling : undefined
} }
// Animation properties // Animation properties

View file

@ -347,15 +347,15 @@ ColumnLayout {
command: ["which", "matugen"] command: ["which", "matugen"]
running: false running: false
onExited: function(exitCode) { onExited: function (exitCode) {
if (exitCode === 0) { if (exitCode === 0) {
// Matugen exists, enable it // Matugen exists, enable it
Settings.data.colorSchemes.useWallpaperColors = true Settings.data.colorSchemes.useWallpaperColors = true
ColorSchemeService.changedWallpaper() ColorSchemeService.changedWallpaper()
ToastService.showNotice("Matugen", "Enabled!") ToastService.showNotice("Matugen", "Enabled!")
} else { } else {
// Matugen not found // Matugen not found
ToastService.showWarning("Matugen", "Not installed!") ToastService.showWarning("Matugen", "Not installed!")
} }
} }

View file

@ -8,69 +8,69 @@ import qs.Services
import qs.Widgets import qs.Widgets
ColumnLayout { ColumnLayout {
id: root id: root
spacing: 0 spacing: 0
ScrollView { ScrollView {
id: scrollView id: scrollView
Layout.fillWidth: true
Layout.fillHeight: true
padding: Style.marginM * scaling
clip: true
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
ScrollBar.vertical.policy: ScrollBar.AsNeeded
ColumnLayout {
width: scrollView.availableWidth
spacing: 0
Item {
Layout.fillWidth: true Layout.fillWidth: true
Layout.fillHeight: true Layout.preferredHeight: 0
padding: Style.marginM * scaling }
clip: true
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff ColumnLayout {
ScrollBar.vertical.policy: ScrollBar.AsNeeded spacing: Style.marginL * scaling
Layout.fillWidth: true
ColumnLayout { NText {
width: scrollView.availableWidth text: "Interfaces"
spacing: 0 font.pointSize: Style.fontSizeXXL * scaling
font.weight: Style.fontWeightBold
Item { color: Color.mOnSurface
Layout.fillWidth: true
Layout.preferredHeight: 0
}
ColumnLayout {
spacing: Style.marginL * scaling
Layout.fillWidth: true
NText {
text: "Interfaces"
font.pointSize: Style.fontSizeXXL * scaling
font.weight: Style.fontWeightBold
color: Color.mOnSurface
}
NToggle {
label: "WiFi Enabled"
description: "Enable WiFi connectivity."
checked: Settings.data.network.wifiEnabled
onToggled: checked => {
Settings.data.network.wifiEnabled = checked
NetworkService.setWifiEnabled(checked)
if (checked) {
ToastService.showNotice("WiFi", "Enabled")
} else {
ToastService.showNotice("WiFi", "Disabled")
}
}
}
NToggle {
label: "Bluetooth Enabled"
description: "Enable Bluetooth connectivity."
checked: Settings.data.network.bluetoothEnabled
onToggled: checked => {
Settings.data.network.bluetoothEnabled = checked
BluetoothService.setBluetoothEnabled(checked)
if (checked) {
ToastService.showNotice("Bluetooth", "Enabled")
} else {
ToastService.showNotice("Bluetooth", "Disabled")
}
}
}
}
} }
NToggle {
label: "WiFi Enabled"
description: "Enable WiFi connectivity."
checked: Settings.data.network.wifiEnabled
onToggled: checked => {
Settings.data.network.wifiEnabled = checked
NetworkService.setWifiEnabled(checked)
if (checked) {
ToastService.showNotice("WiFi", "Enabled")
} else {
ToastService.showNotice("WiFi", "Disabled")
}
}
}
NToggle {
label: "Bluetooth Enabled"
description: "Enable Bluetooth connectivity."
checked: Settings.data.network.bluetoothEnabled
onToggled: checked => {
Settings.data.network.bluetoothEnabled = checked
BluetoothService.setBluetoothEnabled(checked)
if (checked) {
ToastService.showNotice("Bluetooth", "Enabled")
} else {
ToastService.showNotice("Bluetooth", "Disabled")
}
}
}
}
} }
}
} }

View file

@ -349,15 +349,15 @@ ColumnLayout {
command: ["which", "swww"] command: ["which", "swww"]
running: false running: false
onExited: function(exitCode) { onExited: function (exitCode) {
if (exitCode === 0) { if (exitCode === 0) {
// SWWW exists, enable it // SWWW exists, enable it
Settings.data.wallpaper.swww.enabled = true Settings.data.wallpaper.swww.enabled = true
WallpaperService.startSWWWDaemon() WallpaperService.startSWWWDaemon()
ToastService.showNotice("SWWW", "Enabled!") ToastService.showNotice("SWWW", "Enabled!")
} else { } else {
// SWWW not found // SWWW not found
ToastService.showWarning("SWWW", "Not installed!") ToastService.showWarning("SWWW", "Not installed!")
} }
} }

View file

@ -48,9 +48,7 @@ Variants {
targetY: Style.marginS * scaling targetY: Style.marginS * scaling
// Hidden position based on bar location // Hidden position based on bar location
hiddenY: Settings.data.bar.position === "top" hiddenY: Settings.data.bar.position === "top" ? -toast.height - 20 : toast.height + 20
? -toast.height - 20
: toast.height + 20
Component.onCompleted: { Component.onCompleted: {
// Register this toast with the service // Register this toast with the service

View file

@ -20,6 +20,7 @@ Singleton {
} }
} }
} catch (e) { } catch (e) {
//Logger.warn(e) //Logger.warn(e)
} }

View file

@ -26,48 +26,59 @@ QtObject {
// Utility function to check if a command exists and show appropriate toast // Utility function to check if a command exists and show appropriate toast
function checkCommandAndToast(command, successMessage, failMessage, onSuccess = null) { function checkCommandAndToast(command, successMessage, failMessage, onSuccess = null) {
var checkProcess = Qt.createQmlObject(` var checkProcess = Qt.createQmlObject(`
import QtQuick import QtQuick
import Quickshell.Io import Quickshell.Io
Process { Process {
id: checkProc id: checkProc
command: ["which", "${command}"] command: ["which", "${command}"]
running: true running: true
property var onSuccessCallback: null property var onSuccessCallback: null
property bool hasFinished: false property bool hasFinished: false
onExited: { onExited: {
if (!hasFinished) { if (!hasFinished) {
hasFinished = true hasFinished = true
if (exitCode === 0) { if (exitCode === 0) {
ToastService.showNotice("${successMessage}") ToastService.showNotice("${successMessage}")
if (onSuccessCallback) onSuccessCallback() if (onSuccessCallback) onSuccessCallback()
} else { } else {
ToastService.showWarning("${failMessage}") ToastService.showWarning("${failMessage}")
} }
checkProc.destroy() checkProc.destroy()
} }
} }
// Fallback collectors to prevent issues // Fallback collectors to prevent issues
stdout: StdioCollector {} stdout: StdioCollector {}
stderr: StdioCollector {} stderr: StdioCollector {}
} }
`, root) `, root)
checkProcess.onSuccessCallback = onSuccess checkProcess.onSuccessCallback = onSuccess
} }
// Simple function to show a random toast (useful for testing or fun messages) // Simple function to show a random toast (useful for testing or fun messages)
function showRandomToast() { function showRandomToast() {
var messages = [ var messages = [{
{ type: "notice", text: "Everything is working smoothly!" }, "type": "notice",
{ type: "notice", text: "Noctalia is looking great today!" }, "text": "Everything is working smoothly!"
{ type: "notice", text: "Your desktop setup is amazing!" }, }, {
{ type: "warning", text: "Don't forget to take a break!" }, "type": "notice",
{ type: "notice", text: "Configuration saved successfully!" }, "text": "Noctalia is looking great today!"
{ type: "warning", text: "Remember to backup your settings!" } }, {
] "type": "notice",
"text": "Your desktop setup is amazing!"
}, {
"type": "warning",
"text": "Don't forget to take a break!"
}, {
"type": "notice",
"text": "Configuration saved successfully!"
}, {
"type": "warning",
"text": "Remember to backup your settings!"
}]
var randomMessage = messages[Math.floor(Math.random() * messages.length)] var randomMessage = messages[Math.floor(Math.random() * messages.length)]
showToast(randomMessage.text, randomMessage.type) showToast(randomMessage.text, randomMessage.type)
@ -86,33 +97,33 @@ QtObject {
function runCommandWithToast(command, args, successMessage, failMessage, onSuccess = null) { function runCommandWithToast(command, args, successMessage, failMessage, onSuccess = null) {
var fullCommand = [command].concat(args || []) var fullCommand = [command].concat(args || [])
var runProcess = Qt.createQmlObject(` var runProcess = Qt.createQmlObject(`
import QtQuick import QtQuick
import Quickshell.Io import Quickshell.Io
Process { Process {
id: runProc id: runProc
command: ${JSON.stringify(fullCommand)} command: ${JSON.stringify(fullCommand)}
running: true running: true
property var onSuccessCallback: null property var onSuccessCallback: null
property bool hasFinished: false property bool hasFinished: false
onExited: { onExited: {
if (!hasFinished) { if (!hasFinished) {
hasFinished = true hasFinished = true
if (exitCode === 0) { if (exitCode === 0) {
ToastService.showNotice("${successMessage}") ToastService.showNotice("${successMessage}")
if (onSuccessCallback) onSuccessCallback() if (onSuccessCallback) onSuccessCallback()
} else { } else {
ToastService.showWarning("${failMessage}") ToastService.showWarning("${failMessage}")
} }
runProc.destroy() runProc.destroy()
} }
} }
stdout: StdioCollector {} stdout: StdioCollector {}
stderr: StdioCollector {} stderr: StdioCollector {}
} }
`, root) `, root)
runProcess.onSuccessCallback = onSuccess runProcess.onSuccessCallback = onSuccess
} }
@ -125,32 +136,30 @@ QtObject {
// Show toast after a delay (useful for delayed feedback) // Show toast after a delay (useful for delayed feedback)
function delayedToast(message, type = "notice", delayMs = 1000) { function delayedToast(message, type = "notice", delayMs = 1000) {
var timer = Qt.createQmlObject(` var timer = Qt.createQmlObject(`
import QtQuick import QtQuick
Timer { Timer {
interval: ${delayMs} interval: ${delayMs}
repeat: false repeat: false
running: true running: true
onTriggered: { onTriggered: {
ToastService.showToast("${message}", "${type}") ToastService.showToast("${message}", "${type}")
destroy() destroy()
} }
} }
`, root) `, root)
} }
// Generic method to show a toast // Generic method to show a toast
function showToast(label, description = "", type = "notice", persistent = false, duration = 3000) { function showToast(label, description = "", type = "notice", persistent = false, duration = 3000) {
var toastData = { var toastData = {
label: label, "label": label,
description: description, "description": description,
type: type, "type": type,
persistent: persistent, "persistent": persistent,
duration: duration, "duration": duration,
timestamp: Date.now() "timestamp": Date.now()
} }
// Add to queue // Add to queue
messageQueue.push(toastData) messageQueue.push(toastData)
@ -175,8 +184,6 @@ QtObject {
var toastData = messageQueue.shift() var toastData = messageQueue.shift()
isShowingToast = true isShowingToast = true
// Configure and show toast // Configure and show toast
currentToast.label = toastData.label currentToast.label = toastData.label
currentToast.description = toastData.description currentToast.description = toastData.description
@ -192,7 +199,7 @@ QtObject {
isShowingToast = false isShowingToast = false
// Small delay before showing next toast // Small delay before showing next toast
Qt.callLater(function() { Qt.callLater(function () {
processQueue() processQueue()
}) })
} }

View file

@ -20,7 +20,7 @@ Item {
property real targetY: 0 property real targetY: 0
property real hiddenY: -height - 20 property real hiddenY: -height - 20
signal dismissed() signal dismissed
width: Math.min(500 * scaling, parent.width * 0.8) width: Math.min(500 * scaling, parent.width * 0.8)
height: Math.max(60 * scaling, contentLayout.implicitHeight + Style.marginL * 2 * scaling) height: Math.max(60 * scaling, contentLayout.implicitHeight + Style.marginL * 2 * scaling)
@ -85,9 +85,12 @@ Item {
// Simple colored border all around // Simple colored border all around
border.color: { border.color: {
switch (root.type) { switch (root.type) {
case "warning": return Color.mError case "warning":
case "notice": return Color.mPrimary return Color.mError
default: return Color.mOutline case "notice":
return Color.mPrimary
default:
return Color.mOutline
} }
} }
border.width: Math.max(2, Style.borderM * scaling) border.width: Math.max(2, Style.borderM * scaling)
@ -112,17 +115,23 @@ Item {
id: icon id: icon
text: { text: {
switch (root.type) { switch (root.type) {
case "warning": return "warning" case "warning":
case "notice": return "info" return "warning"
default: return "info" case "notice":
return "info"
default:
return "info"
} }
} }
color: { color: {
switch (root.type) { switch (root.type) {
case "warning": return Color.mError case "warning":
case "notice": return Color.mPrimary return Color.mError
default: return Color.mPrimary case "notice":
return Color.mPrimary
default:
return Color.mPrimary
} }
} }