Merge pull request #631 from notiant/patch-10

Add airplane mode detection, improve NetworkService & add icons to notice toasts
This commit is contained in:
Lemmy
2025-10-31 18:45:07 -04:00
committed by GitHub
21 changed files with 198 additions and 47 deletions
+1 -1
View File
@@ -127,7 +127,7 @@ ColumnLayout {
cursorShape: Qt.PointingHandCursor
onClicked: {
Quickshell.execDetached(["xdg-open", "https://ko-fi.com/lysec"])
ToastService.showNotice(I18n.tr("settings.about.support"), I18n.tr("toast.kofi.opened"), 3000)
ToastService.showNotice(I18n.tr("settings.about.support"), I18n.tr("toast.kofi.opened"))
}
}
}
+2 -2
View File
@@ -111,7 +111,7 @@ ColumnLayout {
if (exitCode === 0) {
Settings.data.colorSchemes.useWallpaperColors = true
AppThemeService.generate()
ToastService.showNotice(I18n.tr("settings.color-scheme.color-source.use-wallpaper-colors.label"), I18n.tr("toast.wallpaper-colors.enabled"))
ToastService.showNotice(I18n.tr("settings.color-scheme.color-source.use-wallpaper-colors.label"), I18n.tr("toast.wallpaper-colors.enabled"), "settings-color-scheme")
} else {
ToastService.showWarning(I18n.tr("settings.color-scheme.color-source.use-wallpaper-colors.label"), I18n.tr("toast.wallpaper-colors.not-installed"))
}
@@ -248,7 +248,7 @@ ColumnLayout {
matugenCheck.running = true
} else {
Settings.data.colorSchemes.useWallpaperColors = false
ToastService.showNotice(I18n.tr("settings.color-scheme.color-source.use-wallpaper-colors.label"), I18n.tr("toast.wallpaper-colors.disabled"))
ToastService.showNotice(I18n.tr("settings.color-scheme.color-source.use-wallpaper-colors.label"), I18n.tr("toast.wallpaper-colors.disabled"), "settings-color-scheme")
if (Settings.data.colorSchemes.predefinedScheme) {
ColorSchemeService.applyScheme(Settings.data.colorSchemes.predefinedScheme)
+2 -2
View File
@@ -38,7 +38,7 @@ ColumnLayout {
if (exitCode === 0) {
Settings.data.nightLight.enabled = true
NightLightService.apply()
ToastService.showNotice(I18n.tr("settings.display.night-light.section.label"), I18n.tr("toast.night-light.enabled"))
ToastService.showNotice(I18n.tr("settings.display.night-light.section.label"), I18n.tr("toast.night-light.enabled"), "nightlight-on")
} else {
Settings.data.nightLight.enabled = false
ToastService.showWarning(I18n.tr("settings.display.night-light.section.label"), I18n.tr("toast.night-light.not-installed"))
@@ -194,7 +194,7 @@ ColumnLayout {
Settings.data.nightLight.enabled = false
Settings.data.nightLight.forced = false
NightLightService.apply()
ToastService.showNotice(I18n.tr("settings.display.night-light.section.label"), I18n.tr("toast.night-light.disabled"))
ToastService.showNotice(I18n.tr("settings.display.night-light.section.label"), I18n.tr("toast.night-light.disabled"), "nightlight-off")
}
}
}
+12 -11
View File
@@ -9,6 +9,7 @@ Rectangle {
property string message: ""
property string description: ""
property string icon: ""
property string type: "notice"
property int duration: 3000
readonly property real initialScale: 0.7
@@ -80,16 +81,15 @@ Rectangle {
// Icon
NIcon {
id: icon
icon: {
switch (type) {
case "warning":
return "toast-warning"
case "error":
return "toast-error"
default:
return "toast-notice"
}
}
icon: if (root.icon !== "") {
return root.icon
} else if (type === "warning") {
return "toast-warning"
} else if (type === "error") {
return "toast-error"
} else {
return "toast-notice"
}
color: {
switch (type) {
case "warning":
@@ -139,13 +139,14 @@ Rectangle {
cursorShape: Qt.PointingHandCursor
}
function show(msg, desc, msgType, msgDuration) {
function show(msg, desc, msgIcon, msgType, msgDuration) {
// Stop all timers first
hideTimer.stop()
hideAnimation.stop()
message = msg
description = desc || ""
icon = msgIcon || ""
type = msgType || "notice"
duration = msgDuration || 3000
+5 -4
View File
@@ -22,10 +22,11 @@ Item {
Connections {
target: ToastService
function onNotify(message, description, type, duration) {
function onNotify(message, description, icon, type, duration) {
root.enqueueToast({
"message": message,
"description": description,
"icon": icon,
"type": type,
"duration": duration,
"timestamp": Date.now()
@@ -122,7 +123,7 @@ Item {
onStatusChanged: {
// When loader becomes ready, show the pending toast
if (status === Loader.Ready && pendingToast !== null) {
item.showToast(pendingToast.message, pendingToast.description, pendingToast.type, pendingToast.duration)
item.showToast(pendingToast.message, pendingToast.description, pendingToast.icon, pendingToast.type, pendingToast.duration)
pendingToast = null
}
}
@@ -201,8 +202,8 @@ Item {
WlrLayershell.keyboardFocus: WlrKeyboardFocus.None
exclusionMode: PanelWindow.ExclusionMode.Ignore
function showToast(message, description, type, duration) {
toastItem.show(message, description, type, duration)
function showToast(message, description, icon, type, duration) {
toastItem.show(message, description, icon, type, duration)
}
function hideToast() {