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
bar: JsonObject {
property string position: "top" // Possible values: "top", "bottom"
property string position: "top" // Possible values: "top", "bottom"
property bool showActiveWindow: true
property bool showSystemInfo: false
property bool showMedia: false

View file

@ -43,12 +43,10 @@ NLoader {
}
margins {
top: (Settings.data.bar.monitors.includes(modelData.name)
|| (Settings.data.bar.monitors.length === 0)) && Settings.data.bar.position === "top"
? Math.floor(Style.barHeight * scaling) : 0
bottom: (Settings.data.bar.monitors.includes(modelData.name)
|| (Settings.data.bar.monitors.length === 0)) && Settings.data.bar.position === "bottom"
? Math.floor(Style.barHeight * scaling) : 0
top: (Settings.data.bar.monitors.includes(modelData.name) || (Settings.data.bar.monitors.length === 0))
&& Settings.data.bar.position === "top" ? Math.floor(Style.barHeight * scaling) : 0
bottom: (Settings.data.bar.monitors.includes(modelData.name) || (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

View file

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

View file

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

View file

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

View file

@ -8,69 +8,69 @@ import qs.Services
import qs.Widgets
ColumnLayout {
id: root
spacing: 0
id: root
spacing: 0
ScrollView {
id: scrollView
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.fillHeight: true
padding: Style.marginM * scaling
clip: true
Layout.preferredHeight: 0
}
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
ScrollBar.vertical.policy: ScrollBar.AsNeeded
ColumnLayout {
spacing: Style.marginL * scaling
Layout.fillWidth: true
ColumnLayout {
width: scrollView.availableWidth
spacing: 0
Item {
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")
}
}
}
}
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")
}
}
}
}
}
}
}

View file

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

View file

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

View file

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

View file

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

View file

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