aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLibravatar Vijay A <vraravam@users.noreply.github.com>2021-10-07 09:02:32 +0530
committerLibravatar Vijay Aravamudhan <vraravam@users.noreply.github.com>2021-10-07 12:56:36 +0530
commita94e6c69b5d409e219a0e5e62b045716f0f9c577 (patch)
tree14d8bc587ffbca64d609e6589dde7248cd40ce67 /src
parentrefactor: locale selection cleanup (#2031) (diff)
downloadferdium-app-a94e6c69b5d409e219a0e5e62b045716f0f9c577.tar.gz
ferdium-app-a94e6c69b5d409e219a0e5e62b045716f0f9c577.tar.zst
ferdium-app-a94e6c69b5d409e219a0e5e62b045716f0f9c577.zip
fix: Control the global shortcut (for hiding Ferdi) via a preference (default: off)
Diffstat (limited to 'src')
-rw-r--r--src/components/settings/settings/EditSettingsForm.js1
-rw-r--r--src/config.ts1
-rw-r--r--src/containers/settings/EditSettingsScreen.js10
-rw-r--r--src/i18n/locales/en-US.json1
-rw-r--r--src/index.js30
5 files changed, 29 insertions, 14 deletions
diff --git a/src/components/settings/settings/EditSettingsForm.js b/src/components/settings/settings/EditSettingsForm.js
index 063bf7b15..c04835a5f 100644
--- a/src/components/settings/settings/EditSettingsForm.js
+++ b/src/components/settings/settings/EditSettingsForm.js
@@ -673,6 +673,7 @@ class EditSettingsForm extends Component {
673 {this.state.activeSetttingsTab === 'advanced' && ( 673 {this.state.activeSetttingsTab === 'advanced' && (
674 <div> 674 <div>
675 <Toggle field={form.$('enableGPUAcceleration')} /> 675 <Toggle field={form.$('enableGPUAcceleration')} />
676 <Toggle field={form.$('enableGlobalHideShortcut')} />
676 <p className="settings__help indented__help"> 677 <p className="settings__help indented__help">
677 {intl.formatMessage(messages.appRestartRequired)} 678 {intl.formatMessage(messages.appRestartRequired)}
678 </p> 679 </p>
diff --git a/src/config.ts b/src/config.ts
index 82ce131f9..9aca70ba3 100644
--- a/src/config.ts
+++ b/src/config.ts
@@ -202,6 +202,7 @@ export const DEFAULT_APP_SETTINGS = {
202 beta: false, 202 beta: false,
203 isAppMuted: false, 203 isAppMuted: false,
204 enableGPUAcceleration: true, 204 enableGPUAcceleration: true,
205 enableGlobalHideShortcut: false,
205 206
206 // Ferdi specific options 207 // Ferdi specific options
207 server: LIVE_FERDI_API, 208 server: LIVE_FERDI_API,
diff --git a/src/containers/settings/EditSettingsScreen.js b/src/containers/settings/EditSettingsScreen.js
index 4b59442cb..8c37d2692 100644
--- a/src/containers/settings/EditSettingsScreen.js
+++ b/src/containers/settings/EditSettingsScreen.js
@@ -209,6 +209,10 @@ const messages = defineMessages({
209 id: 'settings.app.form.enableGPUAcceleration', 209 id: 'settings.app.form.enableGPUAcceleration',
210 defaultMessage: 'Enable GPU Acceleration', 210 defaultMessage: 'Enable GPU Acceleration',
211 }, 211 },
212 enableGlobalHideShortcut: {
213 id: 'settings.app.form.enableGlobalHideShortcut',
214 defaultMessage: 'Enable Global shortcut to hide Ferdi',
215 },
212 beta: { 216 beta: {
213 id: 'settings.app.form.beta', 217 id: 'settings.app.form.beta',
214 defaultMessage: 'Include beta versions', 218 defaultMessage: 'Include beta versions',
@@ -289,6 +293,7 @@ class EditSettingsScreen extends Component {
289 scheduledDNDStart: settingsData.scheduledDNDStart, 293 scheduledDNDStart: settingsData.scheduledDNDStart,
290 scheduledDNDEnd: settingsData.scheduledDNDEnd, 294 scheduledDNDEnd: settingsData.scheduledDNDEnd,
291 enableGPUAcceleration: Boolean(settingsData.enableGPUAcceleration), 295 enableGPUAcceleration: Boolean(settingsData.enableGPUAcceleration),
296 enableGlobalHideShortcut: Boolean(settingsData.enableGlobalHideShortcut),
292 showDisabledServices: Boolean(settingsData.showDisabledServices), 297 showDisabledServices: Boolean(settingsData.showDisabledServices),
293 darkMode: Boolean(settingsData.darkMode), 298 darkMode: Boolean(settingsData.darkMode),
294 adaptableDarkMode: Boolean(settingsData.adaptableDarkMode), 299 adaptableDarkMode: Boolean(settingsData.adaptableDarkMode),
@@ -623,6 +628,11 @@ class EditSettingsScreen extends Component {
623 value: settings.all.app.enableGPUAcceleration, 628 value: settings.all.app.enableGPUAcceleration,
624 default: DEFAULT_APP_SETTINGS.enableGPUAcceleration, 629 default: DEFAULT_APP_SETTINGS.enableGPUAcceleration,
625 }, 630 },
631 enableGlobalHideShortcut: {
632 label: intl.formatMessage(messages.enableGlobalHideShortcut),
633 value: settings.all.app.enableGlobalHideShortcut,
634 default: DEFAULT_APP_SETTINGS.enableGlobalHideShortcut,
635 },
626 locale: { 636 locale: {
627 label: intl.formatMessage(messages.language), 637 label: intl.formatMessage(messages.language),
628 value: app.locale, 638 value: app.locale,
diff --git a/src/i18n/locales/en-US.json b/src/i18n/locales/en-US.json
index 812ec8c4c..301a71818 100644
--- a/src/i18n/locales/en-US.json
+++ b/src/i18n/locales/en-US.json
@@ -210,6 +210,7 @@
210 "settings.app.form.customTodoServer": "Custom Todo Server", 210 "settings.app.form.customTodoServer": "Custom Todo Server",
211 "settings.app.form.darkMode": "Enable Dark Mode", 211 "settings.app.form.darkMode": "Enable Dark Mode",
212 "settings.app.form.enableGPUAcceleration": "Enable GPU Acceleration", 212 "settings.app.form.enableGPUAcceleration": "Enable GPU Acceleration",
213 "settings.app.form.enableGlobalHideShortcut": "Enable Global shortcut to hide Ferdi",
213 "settings.app.form.enableLock": "Enable Password Lock", 214 "settings.app.form.enableLock": "Enable Password Lock",
214 "settings.app.form.enableMenuBar": "Always show Ferdi in Menu Bar", 215 "settings.app.form.enableMenuBar": "Always show Ferdi in Menu Bar",
215 "settings.app.form.enableSpellchecking": "Enable spell checking", 216 "settings.app.form.enableSpellchecking": "Enable spell checking",
diff --git a/src/index.js b/src/index.js
index 9f384f5fa..933637688 100644
--- a/src/index.js
+++ b/src/index.js
@@ -76,10 +76,10 @@ if (isWindows) {
76const settings = new Settings('app', DEFAULT_APP_SETTINGS); 76const settings = new Settings('app', DEFAULT_APP_SETTINGS);
77const proxySettings = new Settings('proxy'); 77const proxySettings = new Settings('proxy');
78 78
79const retrieveSettingValue = (key, defaultValue = true) => 79const retrieveSettingValue = (key, defaultValue) =>
80 ifUndefinedBoolean(settings.get(key), defaultValue); 80 ifUndefinedBoolean(settings.get(key), defaultValue);
81 81
82if (retrieveSettingValue('sentry')) { 82if (retrieveSettingValue('sentry', DEFAULT_APP_SETTINGS.sentry)) {
83 // eslint-disable-next-line global-require 83 // eslint-disable-next-line global-require
84 require('./sentry'); 84 require('./sentry');
85} 85}
@@ -196,7 +196,7 @@ const createWindow = () => {
196 frame: isLinux, 196 frame: isLinux,
197 backgroundColor, 197 backgroundColor,
198 webPreferences: { 198 webPreferences: {
199 spellcheck: retrieveSettingValue('enableSpellchecking'), 199 spellcheck: retrieveSettingValue('enableSpellchecking', DEFAULT_APP_SETTINGS.enableSpellchecking),
200 nodeIntegration: true, 200 nodeIntegration: true,
201 contextIsolation: false, 201 contextIsolation: false,
202 webviewTag: true, 202 webviewTag: true,
@@ -270,13 +270,13 @@ const createWindow = () => {
270 // Dereference the window object, usually you would store windows 270 // Dereference the window object, usually you would store windows
271 // in an array if your app supports multi windows, this is the time 271 // in an array if your app supports multi windows, this is the time
272 // when you should delete the corresponding element. 272 // when you should delete the corresponding element.
273 if (!willQuitApp && retrieveSettingValue('runInBackground')) { 273 if (!willQuitApp && retrieveSettingValue('runInBackground', DEFAULT_APP_SETTINGS.runInBackground)) {
274 e.preventDefault(); 274 e.preventDefault();
275 if (isWindows) { 275 if (isWindows) {
276 debug('Window: minimize'); 276 debug('Window: minimize');
277 mainWindow.minimize(); 277 mainWindow.minimize();
278 278
279 if (retrieveSettingValue('closeToSystemTray')) { 279 if (retrieveSettingValue('closeToSystemTray', DEFAULT_APP_SETTINGS.closeToSystemTray)) {
280 debug('Skip taskbar: true'); 280 debug('Skip taskbar: true');
281 mainWindow.setSkipTaskbar(true); 281 mainWindow.setSkipTaskbar(true);
282 } 282 }
@@ -300,7 +300,7 @@ const createWindow = () => {
300 mainWindow.on('minimize', () => { 300 mainWindow.on('minimize', () => {
301 app.wasMaximized = app.isMaximized; 301 app.wasMaximized = app.isMaximized;
302 302
303 if (retrieveSettingValue('minimizeToSystemTray')) { 303 if (retrieveSettingValue('minimizeToSystemTray', DEFAULT_APP_SETTINGS.minimizeToSystemTray)) {
304 debug('Skip taskbar: true'); 304 debug('Skip taskbar: true');
305 mainWindow.setSkipTaskbar(true); 305 mainWindow.setSkipTaskbar(true);
306 trayIcon.show(); 306 trayIcon.show();
@@ -326,7 +326,7 @@ const createWindow = () => {
326 mainWindow.maximize(); 326 mainWindow.maximize();
327 } 327 }
328 328
329 if (!retrieveSettingValue('enableSystemTray')) { 329 if (!retrieveSettingValue('enableSystemTray', DEFAULT_APP_SETTINGS.enableSystemTray)) {
330 debug('Tray: hiding tray icon'); 330 debug('Tray: hiding tray icon');
331 trayIcon.hide(); 331 trayIcon.hide();
332 } 332 }
@@ -351,17 +351,19 @@ const createWindow = () => {
351 openExternalUrl(url); 351 openExternalUrl(url);
352 }); 352 });
353 353
354 if (retrieveSettingValue('startMinimized', false)) { 354 if (retrieveSettingValue('startMinimized', DEFAULT_APP_SETTINGS.startMinimized)) {
355 mainWindow.hide(); 355 mainWindow.hide();
356 } else { 356 } else {
357 mainWindow.show(); 357 mainWindow.show();
358 } 358 }
359 359
360 app.whenReady().then(() => { 360 app.whenReady().then(() => {
361 // Toggle the window on 'Alt+X' 361 if (retrieveSettingValue('enableGlobalHideShortcut', DEFAULT_APP_SETTINGS.enableGlobalHideShortcut)) {
362 globalShortcut.register(`${altKey()}+X`, () => { 362 // Toggle the window on 'Alt+X'
363 trayIcon.trayMenuTemplate[0].click(); 363 globalShortcut.register(`${altKey()}+X`, () => {
364 }); 364 trayIcon.trayMenuTemplate[0].click();
365 });
366 }
365 }); 367 });
366}; 368};
367 369
@@ -578,7 +580,7 @@ ipcMain.on('set-spellchecker-locales', (e, { locale, serviceId }) => {
578app.on('window-all-closed', () => { 580app.on('window-all-closed', () => {
579 // On OS X it is common for applications and their menu bar 581 // On OS X it is common for applications and their menu bar
580 // to stay active until the user quits explicitly with Cmd + Q 582 // to stay active until the user quits explicitly with Cmd + Q
581 if (retrieveSettingValue('runInBackground')) { 583 if (retrieveSettingValue('runInBackground', DEFAULT_APP_SETTINGS.runInBackground)) {
582 debug('Window: all windows closed, quit app'); 584 debug('Window: all windows closed, quit app');
583 app.quit(); 585 app.quit();
584 } else { 586 } else {
@@ -589,7 +591,7 @@ app.on('window-all-closed', () => {
589app.on('before-quit', event => { 591app.on('before-quit', event => {
590 const yesButtonIndex = 0; 592 const yesButtonIndex = 0;
591 let selection = yesButtonIndex; 593 let selection = yesButtonIndex;
592 if (retrieveSettingValue('confirmOnQuit')) { 594 if (retrieveSettingValue('confirmOnQuit', DEFAULT_APP_SETTINGS.confirmOnQuit)) {
593 selection = dialog.showMessageBoxSync(app.mainWindow, { 595 selection = dialog.showMessageBoxSync(app.mainWindow, {
594 type: 'question', 596 type: 'question',
595 message: 'Quit', 597 message: 'Quit',