Add config option to start tabs minimized in system tray

Closes #14
This commit is contained in:
Alice Gaudon 2020-06-15 15:08:52 +02:00
parent a5394f3acd
commit 175b56d8f2
4 changed files with 38 additions and 13 deletions

View File

@ -27,8 +27,15 @@
<p id="current-version"></p> <p id="current-version"></p>
<p id="update-status">Loading...</p> <p id="update-status">Loading...</p>
<button id="download-button" type="button" class="hidden">Download</button> <button id="download-button" type="button" class="hidden">Download</button>
</div> </div>startMinimized
<section>
<h2 class="form-header">Startup</h2>
<label class="form-group"><input type="checkbox" name="start-minimized" id="start-minimized"> Start minimized in system tray</label>
</section>
<section>
<h2 class="form-header">History navigation buttons</h2> <h2 class="form-header">History navigation buttons</h2>
<label class="form-group"> <label class="form-group">
@ -41,6 +48,7 @@
<input type="checkbox" name="forward-button" id="forward-button"> Go forward button</label> <input type="checkbox" name="forward-button" id="forward-button"> Go forward button</label>
<label class="form-group"> <label class="form-group">
<input type="checkbox" name="refresh-button" id="refresh-button"> Refresh page button</label> <input type="checkbox" name="refresh-button" id="refresh-button"> Refresh page button</label>
</section>
</div> </div>
<div class="form-footer"> <div class="form-footer">

View File

@ -6,6 +6,8 @@ let updateInfo: any;
let updateButton: HTMLElement | null; let updateButton: HTMLElement | null;
let config: any; let config: any;
let startMinimizedField: HTMLInputElement | null;
let securityButtonField: HTMLInputElement | null, let securityButtonField: HTMLInputElement | null,
homeButtonField: HTMLInputElement | null, homeButtonField: HTMLInputElement | null,
backButtonField: HTMLInputElement | null, backButtonField: HTMLInputElement | null,
@ -18,6 +20,8 @@ ipcRenderer.on('current-version', (e, version) => {
ipcRenderer.on('config', (e, c) => { ipcRenderer.on('config', (e, c) => {
config = c; config = c;
if (startMinimizedField) startMinimizedField.checked = config.startMinimized;
if (securityButtonField) securityButtonField.checked = config.securityButton; if (securityButtonField) securityButtonField.checked = config.securityButton;
if (homeButtonField) homeButtonField.checked = config.homeButton; if (homeButtonField) homeButtonField.checked = config.homeButton;
if (backButtonField) backButtonField.checked = config.backButton; if (backButtonField) backButtonField.checked = config.backButton;
@ -41,6 +45,8 @@ function save() {
if (!form) return; if (!form) return;
const formData = new FormData(form); const formData = new FormData(form);
config.startMinimized = formData.get('start-minimized') === 'on';
config.securityButton = formData.get('security-button') === 'on'; config.securityButton = formData.get('security-button') === 'on';
config.homeButton = formData.get('home-button') === 'on'; config.homeButton = formData.get('home-button') === 'on';
config.backButton = formData.get('back-button') === 'on'; config.backButton = formData.get('back-button') === 'on';
@ -60,6 +66,8 @@ document.addEventListener('DOMContentLoaded', () => {
.catch(console.error); .catch(console.error);
}); });
startMinimizedField = <HTMLInputElement>document.getElementById('start-minimized');
securityButtonField = <HTMLInputElement>document.getElementById('security-button'); securityButtonField = <HTMLInputElement>document.getElementById('security-button');
homeButtonField = <HTMLInputElement>document.getElementById('home-button'); homeButtonField = <HTMLInputElement>document.getElementById('home-button');
backButtonField = <HTMLInputElement>document.getElementById('back-button'); backButtonField = <HTMLInputElement>document.getElementById('back-button');

View File

@ -10,7 +10,11 @@ const configFile = path.resolve(configDir, 'config.json');
export default class Config { export default class Config {
public services: Service[] = []; public services: Service[] = [];
public updateCheckSkip?: string; public updateCheckSkip?: string;
public startMinimized: boolean = false;
public securityButton: boolean = true; public securityButton: boolean = true;
public homeButton: boolean = false; public homeButton: boolean = false;
public backButton: boolean = true; public backButton: boolean = true;
@ -44,6 +48,8 @@ export default class Config {
this.defineProperty('updateCheckSkip', data); this.defineProperty('updateCheckSkip', data);
this.defineProperty('startMinimized', data);
this.defineProperty('securityButton', data); this.defineProperty('securityButton', data);
this.defineProperty('homeButton', data); this.defineProperty('homeButton', data);
this.defineProperty('backButton', data); this.defineProperty('backButton', data);

View File

@ -25,11 +25,14 @@ export default class MainWindow extends Window {
autoHideMenuBar: true, autoHideMenuBar: true,
icon: Meta.ICON_PATH, icon: Meta.ICON_PATH,
title: Meta.title, title: Meta.title,
show: !this.application.getConfig().startMinimized,
}); });
const window = this.getWindow(); const window = this.getWindow();
if (!this.application.getConfig().startMinimized) {
window.maximize(); window.maximize();
}
if (this.application.isDevMode()) { if (this.application.isDevMode()) {
window.webContents.openDevTools({ window.webContents.openDevTools({