Launch and minimize to tray icon
This commit is contained in:
parent
17069261ed
commit
16d804611e
@ -4,24 +4,49 @@
|
|||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
var gui = require('nw.gui');
|
||||||
var linewidth = 48;
|
var linewidth = 48;
|
||||||
var devtype = "epson";
|
var devtype = "epson";
|
||||||
var device = "/dev/usb/lp0";
|
var device = "/dev/usb/lp0";
|
||||||
|
var settingsValid = true;
|
||||||
|
var win = gui.Window.get();
|
||||||
|
var tray = new nw.Tray({
|
||||||
|
title: 'NickelBridge',
|
||||||
|
tooltip: 'Open NickelBridge configuration',
|
||||||
|
icon: 'public/assets/img/logo_64.png'
|
||||||
|
});
|
||||||
|
|
||||||
function loadSettings() {
|
function loadSettings() {
|
||||||
if (localStorage.getItem("linewidth") !== null && Number.parseInt(localStorage.getItem("linewidth")) != Number.NaN) {
|
if (localStorage.getItem("linewidth") !== null && Number.parseInt(localStorage.getItem("linewidth")) != Number.NaN) {
|
||||||
linewidth = Number.parseInt(localStorage.getItem("linewidth"));
|
linewidth = Number.parseInt(localStorage.getItem("linewidth"));
|
||||||
|
} else {
|
||||||
|
settingsValid = false;
|
||||||
}
|
}
|
||||||
if (localStorage.getItem("devtype") !== null) {
|
if (localStorage.getItem("devtype") !== null) {
|
||||||
devtype = localStorage.getItem("devtype");
|
devtype = localStorage.getItem("devtype");
|
||||||
if (devtype != "epson" && devtype != "star") {
|
if (devtype != "epson" && devtype != "star") {
|
||||||
devtype = "epson";
|
devtype = "epson";
|
||||||
|
settingsValid = false;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
settingsValid = false;
|
||||||
}
|
}
|
||||||
if (localStorage.getItem("device") !== null) {
|
if (localStorage.getItem("device") !== null && localStorage.getItem("device") != "") {
|
||||||
device = localStorage.getItem("device");
|
device = localStorage.getItem("device");
|
||||||
|
} else {
|
||||||
|
settingsValid = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
loadSettings();
|
loadSettings();
|
||||||
|
|
||||||
|
win.on('minimize', function () {
|
||||||
|
win.hide();
|
||||||
|
});
|
||||||
|
tray.on('click', function () {
|
||||||
|
win.show();
|
||||||
|
});
|
||||||
|
|
||||||
|
if (settingsValid === true) {
|
||||||
|
win.hide();
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user