config: add toasts for events
Loaded, load parse error, load failed, save failed Also increase toast icon size
This commit is contained in:
parent
8e4c29b9de
commit
38b9b86595
2 changed files with 24 additions and 3 deletions
|
|
@ -1,6 +1,7 @@
|
|||
pragma Singleton
|
||||
|
||||
import qs.utils
|
||||
import Caelestia
|
||||
import Quickshell
|
||||
import Quickshell.Io
|
||||
|
||||
|
|
@ -25,10 +26,30 @@ Singleton {
|
|||
property alias services: adapter.services
|
||||
property alias paths: adapter.paths
|
||||
|
||||
ElapsedTimer {
|
||||
id: timer
|
||||
}
|
||||
|
||||
FileView {
|
||||
path: `${Paths.config}/shell.json`
|
||||
watchChanges: true
|
||||
onFileChanged: reload()
|
||||
onFileChanged: {
|
||||
timer.restart();
|
||||
reload();
|
||||
}
|
||||
onLoaded: {
|
||||
try {
|
||||
JSON.parse(text());
|
||||
Toaster.toast(qsTr("Config loaded"), qsTr("Config loaded in %1ms").arg(timer.elapsedMs()), "rule_settings");
|
||||
} catch (e) {
|
||||
Toaster.toast(qsTr("Failed to load config"), e.message, "settings_alert", Toast.Error);
|
||||
}
|
||||
}
|
||||
onLoadFailed: err => {
|
||||
if (err !== FileViewError.FileNotFound)
|
||||
Toaster.toast(qsTr("Failed to read config file"), FileViewError.toString(err), "settings_alert", Toast.Warning);
|
||||
}
|
||||
onSaveFailed: err => Toaster.toast(qsTr("Failed to save config"), FileViewError.toString(err), "settings_alert", Toast.Error)
|
||||
|
||||
JsonAdapter {
|
||||
id: adapter
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ StyledRect {
|
|||
}
|
||||
|
||||
implicitWidth: implicitHeight
|
||||
implicitHeight: icon.implicitHeight + Appearance.padding.normal * 2
|
||||
implicitHeight: icon.implicitHeight + Appearance.padding.smaller * 2
|
||||
|
||||
MaterialIcon {
|
||||
id: icon
|
||||
|
|
@ -84,7 +84,7 @@ StyledRect {
|
|||
return Colours.palette.m3onError;
|
||||
return Colours.palette.m3onSurfaceVariant;
|
||||
}
|
||||
font.pointSize: Appearance.font.size.large
|
||||
font.pointSize: Math.round(Appearance.font.size.large * 1.2)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue