mirror of
https://github.com/zen-browser/components.git
synced 2025-07-07 22:09:59 +02:00
Refactor KeyShortcutModifiers to remove unnecessary parameter and improve consistency
This commit is contained in:
parent
cc4f1a3eb2
commit
f108074b81
1 changed files with 4 additions and 12 deletions
|
@ -116,14 +116,14 @@ class KeyShortcutModifiers {
|
|||
#meta = false;
|
||||
#accel = false;
|
||||
|
||||
constructor(ctrl, alt, shift, meta, accel, fromXHTML = false) {
|
||||
constructor(ctrl, alt, shift, meta, accel) {
|
||||
this.#control = ctrl;
|
||||
this.#alt = alt;
|
||||
this.#shift = shift;
|
||||
this.#meta = meta;
|
||||
this.#accel = accel;
|
||||
|
||||
if (AppConstants.platform != 'macosx' || !fromXHTML) {
|
||||
if (AppConstants.platform != 'macosx') {
|
||||
// Replace control with accel, to make it more consistent
|
||||
this.#accel = ctrl || accel;
|
||||
this.#control = false;
|
||||
|
@ -154,8 +154,7 @@ class KeyShortcutModifiers {
|
|||
modifiers.includes('alt'),
|
||||
modifiers.includes('shift'),
|
||||
modifiers.includes('meta'),
|
||||
modifiers.includes('accel'),
|
||||
true
|
||||
modifiers.includes('accel')
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -166,7 +165,7 @@ class KeyShortcutModifiers {
|
|||
|
||||
toUserString() {
|
||||
let str = '';
|
||||
if (this.#control && !this.#accel) {
|
||||
if (this.#control || this.#accel) {
|
||||
str += 'Ctrl+';
|
||||
}
|
||||
if (this.#alt) {
|
||||
|
@ -178,13 +177,6 @@ class KeyShortcutModifiers {
|
|||
if (this.#meta) {
|
||||
str += AppConstants.platform == 'macosx' ? 'Cmd+' : 'Win+';
|
||||
}
|
||||
if (this.#accel) {
|
||||
if (AppConstants.platform == 'macosx') {
|
||||
str += 'Meta+';
|
||||
} else {
|
||||
str += 'Ctrl+';
|
||||
}
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue