Add label,description for Toast

This commit is contained in:
Ly-sec 2025-08-19 14:33:36 +02:00
parent 8b3945b612
commit 40d6595f5d
5 changed files with 105 additions and 85 deletions

View file

@ -152,7 +152,7 @@ ColumnLayout {
matugenCheck.running = true matugenCheck.running = true
} else { } else {
Settings.data.colorSchemes.useWallpaperColors = false Settings.data.colorSchemes.useWallpaperColors = false
ToastService.showNotice("Matugen:\nDisabled") ToastService.showNotice("Matugen", "Disabled")
} }
} }
} }
@ -352,10 +352,10 @@ ColumnLayout {
// 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:\nEnabled!") ToastService.showNotice("Matugen", "Enabled!")
} else { } else {
// Matugen not found // Matugen not found
ToastService.showWarning("Matugen:\nNot installed!") ToastService.showWarning("Matugen", "Not installed!")
} }
} }

View file

@ -9,16 +9,15 @@ import qs.Widgets
ColumnLayout { ColumnLayout {
id: root id: root
spacing: 0 spacing: 0
ScrollView { ScrollView {
id: scrollView id: scrollView
Layout.fillWidth: true Layout.fillWidth: true
Layout.fillHeight: true Layout.fillHeight: true
padding: Style.marginM * scaling padding: Style.marginM * scaling
clip: true clip: true
ScrollBar.horizontal.policy: ScrollBar.AlwaysOff ScrollBar.horizontal.policy: ScrollBar.AlwaysOff
ScrollBar.vertical.policy: ScrollBar.AsNeeded ScrollBar.vertical.policy: ScrollBar.AsNeeded
@ -50,9 +49,9 @@ ColumnLayout {
Settings.data.network.wifiEnabled = checked Settings.data.network.wifiEnabled = checked
NetworkService.setWifiEnabled(checked) NetworkService.setWifiEnabled(checked)
if (checked) { if (checked) {
ToastService.showNotice("WiFi:\nEnabled") ToastService.showNotice("WiFi", "Enabled")
} else { } else {
ToastService.showNotice("WiFi:\nDisabled") ToastService.showNotice("WiFi", "Disabled")
} }
} }
} }
@ -65,9 +64,9 @@ ColumnLayout {
Settings.data.network.bluetoothEnabled = checked Settings.data.network.bluetoothEnabled = checked
BluetoothService.setBluetoothEnabled(checked) BluetoothService.setBluetoothEnabled(checked)
if (checked) { if (checked) {
ToastService.showNotice("Bluetooth:\nEnabled") ToastService.showNotice("Bluetooth", "Enabled")
} else { } else {
ToastService.showNotice("Bluetooth:\nDisabled") ToastService.showNotice("Bluetooth", "Disabled")
} }
} }
} }

View file

@ -153,7 +153,7 @@ ColumnLayout {
swwwCheck.running = true swwwCheck.running = true
} else { } else {
Settings.data.wallpaper.swww.enabled = false Settings.data.wallpaper.swww.enabled = false
ToastService.showNotice("SWWW:\nDisabled") ToastService.showNotice("SWWW", "Disabled")
} }
} }
} }
@ -354,10 +354,10 @@ ColumnLayout {
// 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:\nEnabled!") ToastService.showNotice("SWWW", "Enabled!")
} else { } else {
// SWWW not found // SWWW not found
ToastService.showWarning("SWWW:\nNot installed!") ToastService.showWarning("SWWW", "Not installed!")
} }
} }

View file

@ -15,12 +15,12 @@ QtObject {
property var currentToast: null property var currentToast: null
// Methods to show different types of messages // Methods to show different types of messages
function showNotice(message, persistent = false, duration = 3000) { function showNotice(label, description = "", persistent = false, duration = 3000) {
showToast(message, "notice", persistent, duration) showToast(label, description, "notice", persistent, duration)
} }
function showWarning(message, persistent = false, duration = 4000) { function showWarning(label, description = "", persistent = false, duration = 4000) {
showToast(message, "warning", persistent, duration) showToast(label, description, "warning", persistent, duration)
} }
// Utility function to check if a command exists and show appropriate toast // Utility function to check if a command exists and show appropriate toast
@ -139,9 +139,10 @@ QtObject {
} }
// Generic method to show a toast // 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 = { var toastData = {
message: message, label: label,
description: description,
type: type, type: type,
persistent: persistent, persistent: persistent,
duration: duration, duration: duration,
@ -177,7 +178,8 @@ QtObject {
// Configure and show toast // Configure and show toast
currentToast.message = toastData.message currentToast.label = toastData.label
currentToast.description = toastData.description
currentToast.type = toastData.type currentToast.type = toastData.type
currentToast.persistent = toastData.persistent currentToast.persistent = toastData.persistent
currentToast.duration = toastData.duration currentToast.duration = toastData.duration

View file

@ -8,7 +8,8 @@ import qs.Widgets
Item { Item {
id: root id: root
property string message: "" property string label: ""
property string description: ""
property string type: "notice" // "notice", "warning" property string type: "notice" // "notice", "warning"
property int duration: 5000 // Auto-hide after 5 seconds, 0 = no auto-hide property int duration: 5000 // Auto-hide after 5 seconds, 0 = no auto-hide
property bool persistent: false // If true, requires manual dismiss property bool persistent: false // If true, requires manual dismiss
@ -129,15 +130,33 @@ Item {
Layout.alignment: Qt.AlignVCenter Layout.alignment: Qt.AlignVCenter
} }
// Message text // Label and description
Column {
id: textColumn
spacing: Style.marginXXS * scaling
Layout.fillWidth: true
Layout.alignment: Qt.AlignVCenter
NText { NText {
id: messageText id: labelText
text: root.message 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 color: Color.mOnSurface
font.pointSize: Style.fontSize * scaling font.pointSize: Style.fontSize * scaling
wrapMode: Text.WordWrap wrapMode: Text.WordWrap
Layout.fillWidth: true width: parent.width
Layout.alignment: Qt.AlignVCenter visible: text.length > 0
}
} }
// Close button (only if persistent or manual dismiss needed) // Close button (only if persistent or manual dismiss needed)