mirror of
https://github.com/AvengeMedia/DankMaterialShell.git
synced 2025-12-11 07:52:50 -05:00
handle new ConfigReloaded event
This commit is contained in:
@@ -26,6 +26,10 @@ Singleton {
|
||||
// Overview state
|
||||
property bool inOverview: false
|
||||
|
||||
// Config validation
|
||||
property string configValidationOutput: ""
|
||||
property bool hasInitialConnection: false
|
||||
|
||||
signal windowOpenedOrChanged(var windowData)
|
||||
|
||||
// Feature availability
|
||||
@@ -97,6 +101,8 @@ Singleton {
|
||||
handleWindowOpenedOrChanged(event.WindowOpenedOrChanged)
|
||||
} else if (event.OverviewOpenedOrClosed) {
|
||||
handleOverviewChanged(event.OverviewOpenedOrClosed)
|
||||
} else if (event.ConfigLoaded) {
|
||||
handleConfigLoaded(event.ConfigLoaded)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -248,6 +254,48 @@ Singleton {
|
||||
inOverview = data.is_open
|
||||
}
|
||||
|
||||
function handleConfigLoaded(data) {
|
||||
if (data.failed) {
|
||||
validateProcess.running = true
|
||||
} else {
|
||||
configValidationOutput = ""
|
||||
if (ToastService.toastVisible && ToastService.currentLevel === ToastService.levelError) {
|
||||
ToastService.hideToast()
|
||||
}
|
||||
if (hasInitialConnection) {
|
||||
ToastService.showInfo("niri: config reloaded")
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasInitialConnection) {
|
||||
hasInitialConnection = true
|
||||
}
|
||||
}
|
||||
|
||||
Process {
|
||||
id: validateProcess
|
||||
command: ["niri", "validate"]
|
||||
running: false
|
||||
|
||||
stderr: StdioCollector {
|
||||
onStreamFinished: {
|
||||
const lines = text.split('\n')
|
||||
const trimmedLines = lines.map(line => line.replace(/\s+$/, ''))
|
||||
.filter(line => line.length > 0)
|
||||
configValidationOutput = trimmedLines.join('\n').trim()
|
||||
if (hasInitialConnection) {
|
||||
ToastService.showError("niri: failed to load config", configValidationOutput)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
onExited: exitCode => {
|
||||
if (exitCode === 0) {
|
||||
configValidationOutput = ""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function updateCurrentOutputWorkspaces() {
|
||||
if (!currentOutput) {
|
||||
currentOutputWorkspaces = allWorkspaces
|
||||
|
||||
@@ -15,34 +15,40 @@ Singleton {
|
||||
property int currentLevel: levelInfo
|
||||
property bool toastVisible: false
|
||||
property var toastQueue: []
|
||||
property string currentDetails: ""
|
||||
property bool hasDetails: false
|
||||
property string wallpaperErrorStatus: ""
|
||||
|
||||
function showToast(message, level = levelInfo) {
|
||||
function showToast(message, level = levelInfo, details = "") {
|
||||
toastQueue.push({
|
||||
"message": message,
|
||||
"level": level
|
||||
"level": level,
|
||||
"details": details
|
||||
})
|
||||
if (!toastVisible)
|
||||
processQueue()
|
||||
}
|
||||
|
||||
function showInfo(message) {
|
||||
showToast(message, levelInfo)
|
||||
function showInfo(message, details = "") {
|
||||
showToast(message, levelInfo, details)
|
||||
}
|
||||
|
||||
function showWarning(message) {
|
||||
showToast(message, levelWarn)
|
||||
function showWarning(message, details = "") {
|
||||
showToast(message, levelWarn, details)
|
||||
}
|
||||
|
||||
function showError(message) {
|
||||
showToast(message, levelError)
|
||||
function showError(message, details = "") {
|
||||
showToast(message, levelError, details)
|
||||
}
|
||||
|
||||
function hideToast() {
|
||||
toastVisible = false
|
||||
currentMessage = ""
|
||||
currentDetails = ""
|
||||
hasDetails = false
|
||||
currentLevel = levelInfo
|
||||
toastTimer.stop()
|
||||
resetToastState()
|
||||
if (toastQueue.length > 0)
|
||||
processQueue()
|
||||
}
|
||||
@@ -54,10 +60,31 @@ Singleton {
|
||||
const toast = toastQueue.shift()
|
||||
currentMessage = toast.message
|
||||
currentLevel = toast.level
|
||||
currentDetails = toast.details || ""
|
||||
hasDetails = currentDetails.length > 0
|
||||
toastVisible = true
|
||||
toastTimer.interval = toast.level
|
||||
=== levelError ? 5000 : toast.level === levelWarn ? 4000 : 3000
|
||||
toastTimer.start()
|
||||
resetToastState()
|
||||
|
||||
if (toast.level === levelError && hasDetails) {
|
||||
toastTimer.interval = 8000
|
||||
toastTimer.start()
|
||||
} else {
|
||||
toastTimer.interval = toast.level === levelError ? 5000 : toast.level === levelWarn ? 4000 : 3000
|
||||
toastTimer.start()
|
||||
}
|
||||
}
|
||||
|
||||
signal resetToastState
|
||||
|
||||
function stopTimer() {
|
||||
toastTimer.stop()
|
||||
}
|
||||
|
||||
function restartTimer() {
|
||||
if (hasDetails && currentLevel === levelError) {
|
||||
toastTimer.interval = 8000
|
||||
toastTimer.restart()
|
||||
}
|
||||
}
|
||||
|
||||
function clearWallpaperError() {
|
||||
|
||||
Reference in New Issue
Block a user