MCPcopy Create free account
hub / github.com/chieapp/chie / App

Class App

src/controller/app.ts:17–99  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15}
16
17export class App extends ConfigStoreItem {
18 firstTimeStart = true;
19 menuBar?: AppMenuBar;
20 tray?: AppTray;
21
22 shortcutId?: number;
23 dashboarShortcut?: string;
24
25 deserialize(data: AppData) {
26 if (typeof data != 'object') // accepts empty data
27 data = {};
28 if (!data.hideTrayIcon)
29 this.tray = new AppTray();
30 if (process.platform == 'darwin' && data.hideDockIcon)
31 this.setDockIconVisible(false);
32 if (data.notFirstTime)
33 this.firstTimeStart = false;
34 if (data.dashboarShortcut)
35 this.setDashboardShortcut(data.dashboarShortcut);
36 // There is no config for menuBar but we should only create it after config
37 // is read.
38 if (process.platform == 'darwin')
39 this.menuBar = new AppMenuBar();
40 }
41
42 serialize() {
43 const data: AppData = {notFirstTime: true};
44 if (!this.tray)
45 data.hideTrayIcon = true;
46 if (process.platform == 'darwin' && !this.isDockIconVisible())
47 data.hideDockIcon = true;
48 if (this.dashboarShortcut)
49 data.dashboarShortcut = this.dashboarShortcut;
50 return data;
51 }
52
53 hasDockOrTray() {
54 return this.isDockIconVisible() || this.tray || assistantManager.getAssistants().find(a => a.tray);
55 }
56
57 setDockIconVisible(visible: boolean) {
58 if (visible) {
59 gui.app.setActivationPolicy('regular');
60 } else {
61 gui.app.setActivationPolicy('accessory');
62 // Hidding dock icon would remove focus from app.
63 gui.app.activate(true);
64 }
65 this.saveConfig();
66 }
67
68 isDockIconVisible() {
69 if (process.platform != 'darwin')
70 return false;
71 return gui.app.getActivationPolicy() == 'regular';
72 }
73
74 setHasTray(has: boolean) {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected