Add label,description for Toast
This commit is contained in:
parent
8b3945b612
commit
40d6595f5d
5 changed files with 105 additions and 85 deletions
|
|
@ -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!")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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!")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue