mirror of
https://github.com/noctalia-dev/noctalia-shell.git
synced 2026-05-11 17:08:27 +08:00
Add airplane mode detection, improve NetworkService & add icons to notice toasts
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user