summaryrefslogtreecommitdiff
path: root/services/Persistent.qml
blob: 3a911bff403127b590c3e50b8679fc02066068ae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import QtQuick
import Quickshell
import Quickshell.Io
import qs.utils

Scope {
    id: root
    property alias adapter: fileView.adapter
    property alias fileView: fileView
    property string fileDir: Directories.state
    property string fileName: "states.json"
    property string filePath: `${root.fileDir}/${root.fileName}`

    FileView {
        id: fileView
        path: root.filePath
        watchChanges: true
        onFileChanged: reload()
        onAdapterUpdated: writeAdapter()
        onLoadFailed: error => {
            console.log("Failed to load persistent states file:", error);
            if (error == FileViewError.FileNotFound) {
                writeAdapter();
            }
        }
    }
}