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,20 +27,28 @@
<p id="current-version"></p>
<p id="update-status">Loading...</p>
<button id="download-button" type="button" class="hidden">Download</button>
</div>
</div>startMinimized
<h2 class="form-header">History navigation buttons</h2>
<section>
<h2 class="form-header">Startup</h2>
<label class="form-group">
<input type="checkbox" name="security-button" id="security-button"> Security info (recommended)</label>
<label class="form-group">
<input type="checkbox" name="home-button" id="home-button"> Home button</label>
<label class="form-group">
<input type="checkbox" name="back-button" id="back-button"> Go back button</label>
<label class="form-group">
<input type="checkbox" name="forward-button" id="forward-button"> Go forward button</label>
<label class="form-group">
<input type="checkbox" name="refresh-button" id="refresh-button"> Refresh page button</label>
<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>
<label class="form-group">
<input type="checkbox" name="security-button" id="security-button"> Security info (recommended)</label>
<label class="form-group">
<input type="checkbox" name="home-button" id="home-button"> Home button</label>
<label class="form-group">
<input type="checkbox" name="back-button" id="back-button"> Go back button</label>
<label class="form-group">
<input type="checkbox" name="forward-button" id="forward-button"> Go forward button</label>
<label class="form-group">
<input type="checkbox" name="refresh-button" id="refresh-button"> Refresh page button</label>
</section>
</div>
<div class="form-footer">

View File

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

View File

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

View File

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