From 40d6595f5d409dbe46c8bb16fb009192e4b2e12c Mon Sep 17 00:00:00 2001 From: Ly-sec Date: Tue, 19 Aug 2025 14:33:36 +0200 Subject: [PATCH] Add label,description for Toast --- Modules/SettingsPanel/Tabs/ColorSchemeTab.qml | 10 +- Modules/SettingsPanel/Tabs/NetworkTab.qml | 119 +++++++++--------- Modules/SettingsPanel/Tabs/WallpaperTab.qml | 10 +- Services/ToastService.qml | 16 +-- Widgets/NToast.qml | 35 ++++-- 5 files changed, 105 insertions(+), 85 deletions(-) diff --git a/Modules/SettingsPanel/Tabs/ColorSchemeTab.qml b/Modules/SettingsPanel/Tabs/ColorSchemeTab.qml index d8ceb66..02a8306 100644 --- a/Modules/SettingsPanel/Tabs/ColorSchemeTab.qml +++ b/Modules/SettingsPanel/Tabs/ColorSchemeTab.qml @@ -152,7 +152,7 @@ ColumnLayout { matugenCheck.running = true } else { Settings.data.colorSchemes.useWallpaperColors = false - ToastService.showNotice("Matugen:\nDisabled") + ToastService.showNotice("Matugen", "Disabled") } } } @@ -352,10 +352,10 @@ ColumnLayout { // Matugen exists, enable it Settings.data.colorSchemes.useWallpaperColors = true ColorSchemeService.changedWallpaper() - ToastService.showNotice("Matugen:\nEnabled!") - } else { - // Matugen not found - ToastService.showWarning("Matugen:\nNot installed!") + ToastService.showNotice("Matugen", "Enabled!") + } else { + // Matugen not found + ToastService.showWarning("Matugen", "Not installed!") } } diff --git a/Modules/SettingsPanel/Tabs/NetworkTab.qml b/Modules/SettingsPanel/Tabs/NetworkTab.qml index 783556b..031b33d 100644 --- a/Modules/SettingsPanel/Tabs/NetworkTab.qml +++ b/Modules/SettingsPanel/Tabs/NetworkTab.qml @@ -8,70 +8,69 @@ import qs.Services import qs.Widgets ColumnLayout { - id: root + id: root + spacing: 0 - spacing: 0 - - 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 { + ScrollView { + id: scrollView Layout.fillWidth: true - Layout.preferredHeight: 0 - } + Layout.fillHeight: true + padding: Style.marginM * scaling + clip: true - ColumnLayout { - spacing: Style.marginL * scaling - Layout.fillWidth: true + ScrollBar.horizontal.policy: ScrollBar.AlwaysOff + ScrollBar.vertical.policy: ScrollBar.AsNeeded - NText { - text: "Interfaces" - font.pointSize: Style.fontSizeXXL * scaling - font.weight: Style.fontWeightBold - color: Color.mOnSurface + 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") + } + } + } + } } - - 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:\nEnabled") - } else { - ToastService.showNotice("WiFi:\nDisabled") - } - } - } - - 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:\nEnabled") - } else { - ToastService.showNotice("Bluetooth:\nDisabled") - } - } - } - } } - } } diff --git a/Modules/SettingsPanel/Tabs/WallpaperTab.qml b/Modules/SettingsPanel/Tabs/WallpaperTab.qml index 7fc4787..a87b421 100644 --- a/Modules/SettingsPanel/Tabs/WallpaperTab.qml +++ b/Modules/SettingsPanel/Tabs/WallpaperTab.qml @@ -153,7 +153,7 @@ ColumnLayout { swwwCheck.running = true } else { Settings.data.wallpaper.swww.enabled = false - ToastService.showNotice("SWWW:\nDisabled") + ToastService.showNotice("SWWW", "Disabled") } } } @@ -354,10 +354,10 @@ ColumnLayout { // SWWW exists, enable it Settings.data.wallpaper.swww.enabled = true WallpaperService.startSWWWDaemon() - ToastService.showNotice("SWWW:\nEnabled!") - } else { - // SWWW not found - ToastService.showWarning("SWWW:\nNot installed!") + ToastService.showNotice("SWWW", "Enabled!") + } else { + // SWWW not found + ToastService.showWarning("SWWW", "Not installed!") } } diff --git a/Services/ToastService.qml b/Services/ToastService.qml index 674ce8e..5553986 100644 --- a/Services/ToastService.qml +++ b/Services/ToastService.qml @@ -15,12 +15,12 @@ QtObject { property var currentToast: null // Methods to show different types of messages - function showNotice(message, persistent = false, duration = 3000) { - showToast(message, "notice", persistent, duration) + function showNotice(label, description = "", persistent = false, duration = 3000) { + showToast(label, description, "notice", persistent, duration) } - function showWarning(message, persistent = false, duration = 4000) { - showToast(message, "warning", persistent, duration) + function showWarning(label, description = "", persistent = false, duration = 4000) { + showToast(label, description, "warning", persistent, duration) } // Utility function to check if a command exists and show appropriate toast @@ -139,9 +139,10 @@ QtObject { } // Generic method to show a toast - function showToast(message, type = "notice", persistent = false, duration = 3000) { + function showToast(label, description = "", type = "notice", persistent = false, duration = 3000) { var toastData = { - message: message, + label: label, + description: description, type: type, persistent: persistent, duration: duration, @@ -177,7 +178,8 @@ QtObject { // Configure and show toast - currentToast.message = toastData.message + currentToast.label = toastData.label + currentToast.description = toastData.description currentToast.type = toastData.type currentToast.persistent = toastData.persistent currentToast.duration = toastData.duration diff --git a/Widgets/NToast.qml b/Widgets/NToast.qml index 2a394a0..227966b 100644 --- a/Widgets/NToast.qml +++ b/Widgets/NToast.qml @@ -8,7 +8,8 @@ import qs.Widgets Item { id: root - property string message: "" + property string label: "" + property string description: "" property string type: "notice" // "notice", "warning" property int duration: 5000 // Auto-hide after 5 seconds, 0 = no auto-hide property bool persistent: false // If true, requires manual dismiss @@ -129,15 +130,33 @@ Item { Layout.alignment: Qt.AlignVCenter } - // Message text - NText { - id: messageText - text: root.message - color: Color.mOnSurface - font.pointSize: Style.fontSize * scaling - wrapMode: Text.WordWrap + // Label and description + Column { + id: textColumn + spacing: Style.marginXXS * scaling Layout.fillWidth: true Layout.alignment: Qt.AlignVCenter + + NText { + id: labelText + text: root.label + color: Color.mOnSurface + font.pointSize: Style.fontSize * scaling + font.weight: Style.fontWeightBold + wrapMode: Text.WordWrap + width: parent.width + visible: text.length > 0 + } + + NText { + id: descriptionText + text: root.description + color: Color.mOnSurface + font.pointSize: Style.fontSize * scaling + wrapMode: Text.WordWrap + width: parent.width + visible: text.length > 0 + } } // Close button (only if persistent or manual dismiss needed)