import Quickshell
import Quickshell.Io
import QtQuick

import qs.config

ShellRoot {
    IpcHandler {
        target: "home-pref-test"

        function initialize(idsJson: string): void { HomePreferences.initialize(JSON.parse(idsJson)); }
        function add(id: string): void { HomePreferences.add(id); }
        function alias(id: string, value: string): void { HomePreferences.setAlias(id, value); }
        function move(id: string, index: int): void { HomePreferences.move(id, index); }
        function remove(id: string): void { HomePreferences.remove(id); }
        function reset(): void { HomePreferences.resetHomeDefaults(); }
        function status(): string {
            return JSON.stringify({
                initialized: HomePreferences.initialized,
                favorites: HomePreferences.favorites,
                saveError: HomePreferences.saveError,
                stateDir: Quickshell.stateDir
            });
        }
    }
}
