Skip to content

Commit c752a8b

Browse files
committed
make F12 controls bar hiding hotkey disablable
* hotkey disabled by default * #235, #208, #128
1 parent 9104407 commit c752a8b

File tree

6 files changed

+43
-14
lines changed

6 files changed

+43
-14
lines changed

src/electron-main/storage-upgrade.ts

+7
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,13 @@ const CONFIG_UPGRADES: Record<string, (config: Config) => void> = {
219219
config[key] = INITIAL_STORES.config()[key];
220220
}
221221
})();
222+
223+
(() => {
224+
const key = "enableHideControlsHotkey";
225+
if (typeof config[key] === "undefined") {
226+
config[key] = INITIAL_STORES.config()[key];
227+
}
228+
})();
222229
},
223230
};
224231

src/electron-preload/lib/events-handling/handle-keydown.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,12 @@ export function registerDocumentKeyDownEventListener<E extends ObservableElement
3232
"keydown",
3333
async (event: Readonly<KeyboardEvent>) => {
3434
if (event.keyCode === keyCodes.F12) {
35-
await apiClient("toggleControls")();
36-
return;
35+
const {enableHideControlsHotkey} = await apiClient("readConfig")();
36+
37+
if (enableHideControlsHotkey) {
38+
await apiClient("toggleControls")();
39+
return;
40+
}
3741
}
3842

3943
const el: Element | null = (event.target as any);

src/shared/model/options.ts

+2
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ export interface Config extends BaseConfig, Partial<StoreModel.StoreEntity> {
4545
customUnreadBgColor: string;
4646
customUnreadTextColor: string;
4747
disableSpamNotifications: boolean;
48+
enableHideControlsHotkey: boolean;
4849
findInPage: boolean;
4950
fullTextSearch: boolean;
5051
hideControls: boolean;
@@ -63,6 +64,7 @@ export type BaseConfig = Pick<Config,
6364
| "customUnreadBgColor"
6465
| "customUnreadTextColor"
6566
| "disableSpamNotifications"
67+
| "enableHideControlsHotkey"
6668
| "findInPage"
6769
| "fullTextSearch"
6870
| "hideControls"

src/shared/util.ts

+3
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ export function initialConfig(): Config {
6767
customUnreadBgColor: "",
6868
customUnreadTextColor: "",
6969
disableSpamNotifications: true,
70+
enableHideControlsHotkey: false,
7071
findInPage: true,
7172
fullTextSearch: true,
7273
hideControls: false,
@@ -88,6 +89,7 @@ export function pickBaseConfigProperties(
8889
customUnreadBgColor,
8990
customUnreadTextColor,
9091
disableSpamNotifications,
92+
enableHideControlsHotkey,
9193
findInPage,
9294
fullTextSearch,
9395
hideControls,
@@ -106,6 +108,7 @@ export function pickBaseConfigProperties(
106108
customUnreadBgColor,
107109
customUnreadTextColor,
108110
disableSpamNotifications,
111+
enableHideControlsHotkey,
109112
findInPage,
110113
fullTextSearch,
111114
hideControls,

src/web/browser-window/app/_options/base-settings.component.html

+24-12
Original file line numberDiff line numberDiff line change
@@ -101,17 +101,6 @@
101101
Start minimized to tray
102102
</label>
103103
</div>
104-
<div class="custom-control custom-switch">
105-
<input
106-
class="custom-control-input"
107-
formControlName="hideControls"
108-
id="hideControlsCheckbox"
109-
type="checkbox"
110-
>
111-
<label class="custom-control-label" for="hideControlsCheckbox">
112-
Hide controls bar (F12)
113-
</label>
114-
</div>
115104
<div class="custom-control custom-switch">
116105
<input
117106
class="custom-control-input"
@@ -168,6 +157,29 @@
168157
</label>
169158
</div>
170159
<hr>
160+
<div class="custom-control custom-switch">
161+
<input
162+
class="custom-control-input"
163+
formControlName="hideControls"
164+
id="hideControlsCheckbox"
165+
type="checkbox"
166+
>
167+
<label class="custom-control-label" for="hideControlsCheckbox">
168+
Hide controls bar
169+
</label>
170+
</div>
171+
<div class="custom-control custom-switch">
172+
<input
173+
class="custom-control-input"
174+
formControlName="enableHideControlsHotkey"
175+
id="enableHideControlsHotkeyCheckbox"
176+
type="checkbox"
177+
>
178+
<label class="custom-control-label" for="enableHideControlsHotkeyCheckbox">
179+
Enable F12 hotkey for hiding controls bar
180+
</label>
181+
</div>
182+
<hr>
171183
<div class="text-muted mb-2">
172184
Switches of this block only make sense and take effect if the
173185
<a href="https://github.com/vladimiry/ElectronMail/wiki/FAQ">local store</a> feature is enabled for at least
@@ -212,7 +224,7 @@
212224
</div>
213225
</div>
214226
<label class="d-block mb-2">
215-
Page Zoom
227+
Page zoom
216228
</label>
217229
<div class="row mb-2">
218230
<div class="col-sm-6">

src/web/browser-window/app/_options/base-settings.component.ts

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ export class BaseSettingsComponent implements OnInit, OnDestroy {
4848
customUnreadBgColor: new FormControl(),
4949
customUnreadTextColor: new FormControl(),
5050
disableSpamNotifications: new FormControl(),
51+
enableHideControlsHotkey: new FormControl(),
5152
findInPage: new FormControl(),
5253
fullTextSearch: new FormControl(),
5354
hideControls: new FormControl(),

0 commit comments

Comments
 (0)