summaryrefslogtreecommitdiff
path: root/shell.qml
blob: 1bb5c7a8517908be9758ec016dd9d53c497d5ba3 (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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
//@ pragma UseQApplication

import Quickshell
import Quickshell.Io
import "bar"
import "popups/launcher"

import QtQuick

import core

import qs.services

Scope {
	id: root

	property var standaloneObj: ({})

	Bar {}

	PersistentProperties {
		id: loaderProp
		reloadableId: "launcherLoaderProp"

		property bool active: false
	}
	// TODO: cache/don't destory when closed(active=false)
	LazyLoader {
		id: launcherLoader

		active: loaderProp.active

		component: Launcher {
			parentLoader: loaderProp
		}
	}

	IpcHandler {
		target: "qs"

		function reload(hard: bool): void {
			Quickshell.reload(hard);
		}
	}
	IpcHandler {
		target: "launcher"

		function toggle() {
			loaderProp.active = !loaderProp.active;
		}

		function standalone(component: string): void {
			if (root.standaloneObj.name === component) {
				root.standaloneObj.obj.active = !root.standaloneObj.obj.active;
				return;
			}
			root.standaloneObj.obj = Qt.createComponent("popups/launcher/StandaloneLauncher.qml", Component.PreferSynchronous, root).createObject(root, {
				componentName: component
			});
			root.standaloneObj.name = component;
		}
	}

	Connections {
		target: Quickshell
		function onReloadCompleted() {
			Quickshell.inhibitReloadPopup();
		}
		// function onReloadFailed() {
		//     Quickshell.inhibitReloadPopup();
		// }
	}
}