Update main window title with service navigation
This commit is contained in:
parent
f1c66b1db1
commit
d723dc2511
@ -8,6 +8,7 @@ const {
|
||||
dialog,
|
||||
} = remote;
|
||||
|
||||
const appInfo = {};
|
||||
const icons = [];
|
||||
|
||||
let services = [];
|
||||
@ -68,7 +69,11 @@ function openServiceContextMenu(event, serviceId) {
|
||||
}
|
||||
|
||||
|
||||
ipcRenderer.on('data', (event, brandIcons, solidIcons, actualServices, actualSelectedService) => {
|
||||
ipcRenderer.on('data', (event, appData, brandIcons, solidIcons, actualServices, actualSelectedService) => {
|
||||
// App info
|
||||
appInfo.title = appData.title;
|
||||
|
||||
// Icons
|
||||
for (const icon of brandIcons) {
|
||||
icons.push(icon);
|
||||
}
|
||||
@ -332,6 +337,16 @@ function updateNavigation() {
|
||||
if (view && view.canGoBack()) backButton.classList.remove('disabled');
|
||||
else backButton.classList.add('disabled');
|
||||
}
|
||||
|
||||
updateWindowTitle();
|
||||
}
|
||||
|
||||
function updateWindowTitle() {
|
||||
if (selectedService === null) {
|
||||
ipcRenderer.send('updateWindowTitle', null);
|
||||
} else {
|
||||
ipcRenderer.send('updateWindowTitle', selectedService, services[selectedService].view.getWebContents().getTitle());
|
||||
}
|
||||
}
|
||||
|
||||
function goForward() {
|
||||
|
19
src/Meta.js
19
src/Meta.js
@ -1,12 +1,29 @@
|
||||
export default class Meta {
|
||||
static #title = 'Tabs';
|
||||
static #devMode = null;
|
||||
|
||||
static get title() {
|
||||
return this.#title;
|
||||
}
|
||||
|
||||
static isDevMode() {
|
||||
if(this.#devMode === null) {
|
||||
if (this.#devMode === null) {
|
||||
this.#devMode = process.argv.length > 2 && process.argv[2] === '--dev';
|
||||
console.debug('Dev mode:', this.#devMode);
|
||||
}
|
||||
|
||||
return this.#devMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param service {Service}
|
||||
* @param viewTitle {string}
|
||||
*/
|
||||
static getTitleForService(service, viewTitle) {
|
||||
let suffix = '';
|
||||
if (typeof viewTitle === 'string' && viewTitle.length > 0) {
|
||||
suffix = ' - ' + viewTitle;
|
||||
}
|
||||
return this.title + ' - ' + service.name + suffix;
|
||||
}
|
||||
}
|
12
src/main.js
12
src/main.js
@ -58,6 +58,7 @@ function createWindow() {
|
||||
},
|
||||
autoHideMenuBar: true,
|
||||
icon: iconPath,
|
||||
title: Meta.title,
|
||||
});
|
||||
window.maximize();
|
||||
window.on('closed', () => {
|
||||
@ -157,12 +158,21 @@ function createWindow() {
|
||||
window.webContents.send('deleteService', id);
|
||||
});
|
||||
|
||||
ipcMain.on('updateWindowTitle', (event, serviceId, viewTitle) => {
|
||||
if (serviceId === null) {
|
||||
window.setTitle(Meta.title);
|
||||
} else {
|
||||
const service = config.services[serviceId];
|
||||
window.setTitle(Meta.getTitleForService(service, viewTitle));
|
||||
}
|
||||
});
|
||||
|
||||
console.log('> App started');
|
||||
}
|
||||
|
||||
function sendData() {
|
||||
console.log('Syncing data');
|
||||
window.webContents.send('data', brandIcons, solidIcons, config.services, selectedService);
|
||||
window.webContents.send('data', Meta.title, brandIcons, solidIcons, config.services, selectedService);
|
||||
}
|
||||
|
||||
function setActiveService(index) {
|
||||
|
Loading…
Reference in New Issue
Block a user