mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 11:37:58 +02:00
Make tray icon light map to notification status of various menus
This commit is contained in:
parent
308deeaa8d
commit
dde106e42e
1 changed files with 24 additions and 17 deletions
|
@ -60,7 +60,10 @@ const HOME_CONTENT_URL = "http://cdn.highfidelity.com/content-sets/home-tutorial
|
||||||
|
|
||||||
const buildInfo = GetBuildInfo();
|
const buildInfo = GetBuildInfo();
|
||||||
|
|
||||||
|
const NotificationState = {
|
||||||
|
UNNOTIFIED: 'unnotified',
|
||||||
|
NOTIFIED: 'notified'
|
||||||
|
};
|
||||||
|
|
||||||
// Update lock filepath
|
// Update lock filepath
|
||||||
const UPDATER_LOCK_FILENAME = ".updating";
|
const UPDATER_LOCK_FILENAME = ".updating";
|
||||||
|
@ -324,12 +327,21 @@ const HifiNotifications = hfNotifications.HifiNotifications;
|
||||||
const HifiNotificationType = hfNotifications.NotificationType;
|
const HifiNotificationType = hfNotifications.NotificationType;
|
||||||
|
|
||||||
var pendingNotifications = {}
|
var pendingNotifications = {}
|
||||||
function notificationCallback(notificationType, pending = true) {
|
var notificationState = NotificationState.UNNOTIFIED;
|
||||||
|
|
||||||
|
function setNotificationState(notificationType, pending = true) {
|
||||||
pendingNotifications[notificationType] = pending;
|
pendingNotifications[notificationType] = pending;
|
||||||
|
notificationState = NotificationState.UNNOTIFIED;
|
||||||
|
for (var key in pendingNotifications) {
|
||||||
|
if (pendingNotifications[key]) {
|
||||||
|
notificationState = NotificationState.NOTIFIED;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
updateTrayMenu(homeServer ? homeServer.state : ProcessGroupStates.STOPPED);
|
updateTrayMenu(homeServer ? homeServer.state : ProcessGroupStates.STOPPED);
|
||||||
}
|
}
|
||||||
|
|
||||||
var trayNotifications = new HifiNotifications(userConfig, notificationCallback);
|
var trayNotifications = new HifiNotifications(userConfig, setNotificationState);
|
||||||
|
|
||||||
var LogWindow = function(ac, ds) {
|
var LogWindow = function(ac, ds) {
|
||||||
this.ac = ac;
|
this.ac = ac;
|
||||||
|
@ -389,7 +401,7 @@ var labels = {
|
||||||
type: 'checkbox',
|
type: 'checkbox',
|
||||||
checked: true,
|
checked: true,
|
||||||
click: function () {
|
click: function () {
|
||||||
trayNotifications.enable(!trayNotifications.enabled(), notificationCallback);
|
trayNotifications.enable(!trayNotifications.enabled(), setNotificationState);
|
||||||
userConfig.save(configPath);
|
userConfig.save(configPath);
|
||||||
updateTrayMenu(homeServer ? homeServer.state : ProcessGroupStates.STOPPED);
|
updateTrayMenu(homeServer ? homeServer.state : ProcessGroupStates.STOPPED);
|
||||||
}
|
}
|
||||||
|
@ -398,32 +410,28 @@ var labels = {
|
||||||
label: 'GoTo',
|
label: 'GoTo',
|
||||||
click: function () {
|
click: function () {
|
||||||
StartInterface("hifiapp:GOTO");
|
StartInterface("hifiapp:GOTO");
|
||||||
pendingNotifications[HifiNotificationType.GOTO] = false;
|
setNotificationState(HifiNotificationType.GOTO, false);
|
||||||
updateTrayMenu(homeServer ? homeServer.state : ProcessGroupStates.STOPPED);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
people: {
|
people: {
|
||||||
label: 'People',
|
label: 'People',
|
||||||
click: function () {
|
click: function () {
|
||||||
StartInterface("hifiapp:PEOPLE");
|
StartInterface("hifiapp:PEOPLE");
|
||||||
pendingNotifications[HifiNotificationType.PEOPLE] = false;
|
setNotificationState(HifiNotificationType.PEOPLE, false);
|
||||||
updateTrayMenu(homeServer ? homeServer.state : ProcessGroupStates.STOPPED);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
wallet: {
|
wallet: {
|
||||||
label: 'Wallet',
|
label: 'Wallet',
|
||||||
click: function () {
|
click: function () {
|
||||||
StartInterface("hifiapp:WALLET");
|
StartInterface("hifiapp:WALLET");
|
||||||
pendingNotifications[HifiNotificationType.WALLET] = false;
|
setNotificationState(HifiNotificationType.WALLET, false);
|
||||||
updateTrayMenu(homeServer ? homeServer.state : ProcessGroupStates.STOPPED);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
marketplace: {
|
marketplace: {
|
||||||
label: 'Market',
|
label: 'Market',
|
||||||
click: function () {
|
click: function () {
|
||||||
StartInterface("hifiapp:MARKET");
|
StartInterface("hifiapp:MARKET");
|
||||||
pendingNotifications[HifiNotificationType.MARKETPLACE] = false;
|
setNotificationState(HifiNotificationType.MARKETPLACE, false);
|
||||||
updateTrayMenu(homeServer ? homeServer.state : ProcessGroupStates.STOPPED);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
restart: {
|
restart: {
|
||||||
|
@ -557,7 +565,7 @@ function updateLabels(serverState) {
|
||||||
function updateTrayMenu(serverState) {
|
function updateTrayMenu(serverState) {
|
||||||
if (tray) {
|
if (tray) {
|
||||||
var menuArray = buildMenuArray(isShuttingDown ? null : serverState);
|
var menuArray = buildMenuArray(isShuttingDown ? null : serverState);
|
||||||
tray.setImage(trayIcons[serverState]);
|
tray.setImage(trayIcons[notificationState]);
|
||||||
tray.setContextMenu(Menu.buildFromTemplate(menuArray));
|
tray.setContextMenu(Menu.buildFromTemplate(menuArray));
|
||||||
if (isShuttingDown) {
|
if (isShuttingDown) {
|
||||||
tray.setToolTip('High Fidelity - Shutting Down');
|
tray.setToolTip('High Fidelity - Shutting Down');
|
||||||
|
@ -777,9 +785,8 @@ function maybeShowSplash() {
|
||||||
|
|
||||||
const trayIconOS = (osType == "Darwin") ? "osx" : "win";
|
const trayIconOS = (osType == "Darwin") ? "osx" : "win";
|
||||||
var trayIcons = {};
|
var trayIcons = {};
|
||||||
trayIcons[ProcessGroupStates.STARTED] = "console-tray-" + trayIconOS + ".png";
|
trayIcons[NotificationState.UNNOTIFIED] = "console-tray-" + trayIconOS + ".png";
|
||||||
trayIcons[ProcessGroupStates.STOPPED] = "console-tray-" + trayIconOS + "-stopped.png";
|
trayIcons[NotificationState.NOTIFIED] = "console-tray-" + trayIconOS + "-stopped.png";
|
||||||
trayIcons[ProcessGroupStates.STOPPING] = "console-tray-" + trayIconOS + "-stopping.png";
|
|
||||||
for (var key in trayIcons) {
|
for (var key in trayIcons) {
|
||||||
var fullPath = path.join(__dirname, '../resources/' + trayIcons[key]);
|
var fullPath = path.join(__dirname, '../resources/' + trayIcons[key]);
|
||||||
var img = nativeImage.createFromPath(fullPath);
|
var img = nativeImage.createFromPath(fullPath);
|
||||||
|
@ -892,7 +899,7 @@ app.on('ready', function() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create tray icon
|
// Create tray icon
|
||||||
tray = new Tray(trayIcons[ProcessGroupStates.STOPPED]);
|
tray = new Tray(trayIcons[NotificationState.UNNOTIFIED]);
|
||||||
tray.setToolTip('High Fidelity');
|
tray.setToolTip('High Fidelity');
|
||||||
|
|
||||||
tray.on('click', function() {
|
tray.on('click', function() {
|
||||||
|
|
Loading…
Reference in a new issue