Skip to content

Commit

Permalink
make F12 controls bar hiding hotkey disablable
Browse files Browse the repository at this point in the history
* hotkey disabled by default
* #235, #208, #128
  • Loading branch information
vladimiry committed Jan 24, 2020
1 parent 9104407 commit c752a8b
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 14 deletions.
7 changes: 7 additions & 0 deletions src/electron-main/storage-upgrade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,13 @@ const CONFIG_UPGRADES: Record<string, (config: Config) => void> = {
config[key] = INITIAL_STORES.config()[key];
}
})();

(() => {
const key = "enableHideControlsHotkey";
if (typeof config[key] === "undefined") {
config[key] = INITIAL_STORES.config()[key];
}
})();
},
};

Expand Down
8 changes: 6 additions & 2 deletions src/electron-preload/lib/events-handling/handle-keydown.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,12 @@ export function registerDocumentKeyDownEventListener<E extends ObservableElement
"keydown",
async (event: Readonly<KeyboardEvent>) => {
if (event.keyCode === keyCodes.F12) {
await apiClient("toggleControls")();
return;
const {enableHideControlsHotkey} = await apiClient("readConfig")();

if (enableHideControlsHotkey) {
await apiClient("toggleControls")();
return;
}
}

const el: Element | null = (event.target as any);
Expand Down
2 changes: 2 additions & 0 deletions src/shared/model/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export interface Config extends BaseConfig, Partial<StoreModel.StoreEntity> {
customUnreadBgColor: string;
customUnreadTextColor: string;
disableSpamNotifications: boolean;
enableHideControlsHotkey: boolean;
findInPage: boolean;
fullTextSearch: boolean;
hideControls: boolean;
Expand All @@ -63,6 +64,7 @@ export type BaseConfig = Pick<Config,
| "customUnreadBgColor"
| "customUnreadTextColor"
| "disableSpamNotifications"
| "enableHideControlsHotkey"
| "findInPage"
| "fullTextSearch"
| "hideControls"
Expand Down
3 changes: 3 additions & 0 deletions src/shared/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export function initialConfig(): Config {
customUnreadBgColor: "",
customUnreadTextColor: "",
disableSpamNotifications: true,
enableHideControlsHotkey: false,
findInPage: true,
fullTextSearch: true,
hideControls: false,
Expand All @@ -88,6 +89,7 @@ export function pickBaseConfigProperties(
customUnreadBgColor,
customUnreadTextColor,
disableSpamNotifications,
enableHideControlsHotkey,
findInPage,
fullTextSearch,
hideControls,
Expand All @@ -106,6 +108,7 @@ export function pickBaseConfigProperties(
customUnreadBgColor,
customUnreadTextColor,
disableSpamNotifications,
enableHideControlsHotkey,
findInPage,
fullTextSearch,
hideControls,
Expand Down
36 changes: 24 additions & 12 deletions src/web/browser-window/app/_options/base-settings.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -101,17 +101,6 @@
Start minimized to tray
</label>
</div>
<div class="custom-control custom-switch">
<input
class="custom-control-input"
formControlName="hideControls"
id="hideControlsCheckbox"
type="checkbox"
>
<label class="custom-control-label" for="hideControlsCheckbox">
Hide controls bar (F12)
</label>
</div>
<div class="custom-control custom-switch">
<input
class="custom-control-input"
Expand Down Expand Up @@ -168,6 +157,29 @@
</label>
</div>
<hr>
<div class="custom-control custom-switch">
<input
class="custom-control-input"
formControlName="hideControls"
id="hideControlsCheckbox"
type="checkbox"
>
<label class="custom-control-label" for="hideControlsCheckbox">
Hide controls bar
</label>
</div>
<div class="custom-control custom-switch">
<input
class="custom-control-input"
formControlName="enableHideControlsHotkey"
id="enableHideControlsHotkeyCheckbox"
type="checkbox"
>
<label class="custom-control-label" for="enableHideControlsHotkeyCheckbox">
Enable F12 hotkey for hiding controls bar
</label>
</div>
<hr>
<div class="text-muted mb-2">
Switches of this block only make sense and take effect if the
<a href="https://github.com/vladimiry/ElectronMail/wiki/FAQ">local store</a> feature is enabled for at least
Expand Down Expand Up @@ -212,7 +224,7 @@
</div>
</div>
<label class="d-block mb-2">
Page Zoom
Page zoom
</label>
<div class="row mb-2">
<div class="col-sm-6">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export class BaseSettingsComponent implements OnInit, OnDestroy {
customUnreadBgColor: new FormControl(),
customUnreadTextColor: new FormControl(),
disableSpamNotifications: new FormControl(),
enableHideControlsHotkey: new FormControl(),
findInPage: new FormControl(),
fullTextSearch: new FormControl(),
hideControls: new FormControl(),
Expand Down

0 comments on commit c752a8b

Please sign in to comment.