Added option to quit on closing the window.

This adds a configuration option to quit the app (rather than going to
the tray) when the "close" button is clicked.
This commit is contained in:
Ross Brunton
2019-10-13 20:35:18 +01:00
committed by Akash Nimare
parent 1da6e5d51d
commit eb1be7106b
4 changed files with 25 additions and 2 deletions

View File

@@ -94,6 +94,9 @@ function createMainWindow(): Electron.BrowserWindow {
// Keep the app running in background on close event // Keep the app running in background on close event
win.on('close', e => { win.on('close', e => {
if (ConfigUtil.getConfigItem("quitOnClose")) {
app.quit();
}
if (!isQuitting) { if (!isQuitting) {
e.preventDefault(); e.preventDefault();

View File

@@ -58,6 +58,7 @@ interface SettingsOptions {
}; };
downloadsPath: string; downloadsPath: string;
showDownloadFolder: boolean; showDownloadFolder: boolean;
quitOnClose: boolean;
flashTaskbarOnMessage?: boolean; flashTaskbarOnMessage?: boolean;
dockBouncing?: boolean; dockBouncing?: boolean;
loading?: AnyObject; loading?: AnyObject;
@@ -206,7 +207,8 @@ class ServerManagerView {
silent: false silent: false
}, },
downloadsPath: `${app.getPath('downloads')}`, downloadsPath: `${app.getPath('downloads')}`,
showDownloadFolder: false showDownloadFolder: false,
quitOnClose: false
}; };
// Platform specific settings // Platform specific settings

View File

@@ -82,6 +82,10 @@ class GeneralSection extends BaseSection {
<div class="setting-description">${t.__('Always start minimized')}</div> <div class="setting-description">${t.__('Always start minimized')}</div>
<div class="setting-control"></div> <div class="setting-control"></div>
</div> </div>
<div class="setting-row" id="quitOnClose-option">
<div class="setting-description">${t.__('Quit when the window is closed')}</div>
<div class="setting-control"></div>
</div>
<div class="setting-row" id="enable-spellchecker-option"> <div class="setting-row" id="enable-spellchecker-option">
<div class="setting-description">${t.__('Enable spellchecker (requires restart)')}</div> <div class="setting-description">${t.__('Enable spellchecker (requires restart)')}</div>
<div class="setting-control"></div> <div class="setting-control"></div>
@@ -155,6 +159,7 @@ class GeneralSection extends BaseSection {
this.removeCustomCSS(); this.removeCustomCSS();
this.downloadFolder(); this.downloadFolder();
this.showDownloadFolder(); this.showDownloadFolder();
this.updateQuitOnCloseOption();
this.enableErrorReporting(); this.enableErrorReporting();
// Platform specific settings // Platform specific settings
@@ -321,6 +326,18 @@ class GeneralSection extends BaseSection {
}); });
} }
updateQuitOnCloseOption(): void {
this.generateSettingOption({
$element: document.querySelector('#quitOnClose-option .setting-control'),
value: ConfigUtil.getConfigItem('quitOnClose', false),
clickHandler: () => {
const newValue = !ConfigUtil.getConfigItem('quitOnClose');
ConfigUtil.setConfigItem('quitOnClose', newValue);
this.updateQuitOnCloseOption();
}
});
}
enableSpellchecker(): void { enableSpellchecker(): void {
this.generateSettingOption({ this.generateSettingOption({
$element: document.querySelector('#enable-spellchecker-option .setting-control'), $element: document.querySelector('#enable-spellchecker-option .setting-control'),

View File

@@ -113,5 +113,6 @@
"Zoom Out": "Zoom Out", "Zoom Out": "Zoom Out",
"Zulip Help": "Zulip Help", "Zulip Help": "Zulip Help",
"keyboard shortcuts": "keyboard shortcuts", "keyboard shortcuts": "keyboard shortcuts",
"script": "script" "script": "script",
"Quit when the window is closed": "Quit when the window is closed"
} }