This repository has been archived by the owner on Nov 15, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 21
/
Copy pathsettings.js
181 lines (159 loc) · 3.44 KB
/
settings.js
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
const settings = require('electron-settings')
/**
* Modul for loading and storing user preferences and logins
*/
class Settings {
/**
* @returns true if settings contain an url
*/
hasUrl () {
return settings.has('url')
}
/**
* @returns url
*/
url () {
return settings.get('url')
}
/**
* @returns password
*/
password () {
return settings.get('password')
}
/**
* @returns true if tray-menu should be shown
*/
tray () {
return settings.get('tray', true)
}
/**
* @return true if notifications should be shown
*/
notifications () {
return settings.get('notifications')
}
/**
* @return true if window dimensions are saved in the settings
*/
hasDimensions () {
return settings.has('width') && settings.has('height')
}
/**
* @returns width
*/
width () {
return settings.get('width')
}
/**
* @returns tray icon
*/
icon () {
return settings.get('icon', 'Black')
}
/**
* @returns height
*/
height () {
return settings.get('height')
}
/**
* @returns true if toolbar should not be hidden
*/
toolbar () {
return settings.get('toolbar_always', true)
}
/**
* Set credentials for the Configurator panel
* @param {*} username
* @param {*} password
*/
setConfiguratorCredentials (username, password) {
settings.set('c_user', username)
settings.set('c_password', password)
}
/**
* @return Credentials for the Configurator panel
*/
configuratorCredentials () {
return {
username: settings.get('c_user', ''),
password: settings.get('c_password', '')
}
}
/**
* @returns true if the app should start in kiosk-mode
*/
kiosk () {
return settings.get('kiosk')
}
/**
* @returns true if window postitions are saved in the settings
*/
hasPosition () {
return settings.has('xpos') && settings.has('ypos')
}
/**
* @returns window x-position
*/
xpos () {
return settings.get('xpos')
}
/**
* @returns window y-position
*/
ypos () {
return settings.get('ypos')
}
/**
* @returns last window color
*/
color () {
return settings.get('color', '#03A9F4')
}
/**
* Save url and password
* @param {*} url
* @param {*} password
*/
setUrlAndPassword (url, password) {
settings.set('url', url)
settings.set('password', password)
}
/**
* Save user preferences
* @param {*} notifications
* @param {*} tray
* @param {*} kiosk
* @param {*} toolbar
*/
setSettings (notifications, tray, kiosk, toolbar, icon, c_user, c_password) {
settings.set('notifications', notifications)
settings.set('tray', tray)
settings.set('kiosk', kiosk)
settings.set('toolbar_always', toolbar)
settings.set('icon', icon)
settings.set('c_user', c_user)
settings.set('c_password', c_password)
}
/**
* Save window position
* @param {*} x
* @param {*} y
* @param {*} w
* @param {*} h
*/
saveWindowBounds (x, y, w, h) {
settings.set('xpos', x)
settings.set('ypos', y)
settings.set('width', w)
settings.set('height', h)
}
/**
* Deletes ALL settings
*/
deleteAll () {
settings.deleteAll()
}
}
module.exports = new Settings()