feat: Add warning for changing the languages requested

This commit is contained in:
rooki
2024-08-13 08:46:53 +02:00
parent f85794b47d
commit db4a9b41cc
2 changed files with 39 additions and 16 deletions

View File

@@ -48,12 +48,28 @@ var gZenLooksAndFeel = {
}, },
_getInitialAccentColor() { _getInitialAccentColor() {
return Services.prefs.getStringPref("zen.theme.accent-color", kZenColors[0]); return Services.prefs.getStringPref(
"zen.theme.accent-color",
kZenColors[0]
);
}, },
}; };
var gZenWorkspacesSettings = { var gZenWorkspacesSettings = {
init() { init() {
this.addLanguageWarning();
},
addLanguageWarning() {
let chooseLanguage = document.getElementById("languagesBox");
let fragment = window.MozXULElement.parseXULToFragment(`
<hbox class="zenLanguageWarning">
<label class="zenLanguageWarning-label"><html:b data-l10n-id="zen-warning-language"/></label>
</hbox>
`);
chooseLanguage.after(fragment);
}, },
}; };
@@ -66,18 +82,18 @@ var gZenCKSSettings = {
}, },
_addPrefObservers() { _addPrefObservers() {
Services.prefs.addObserver("zen.keyboard.shortcuts.disable-firefox", this.onDisableFirefoxShortcutsChange.bind(this)); Services.prefs.addObserver(
"zen.keyboard.shortcuts.disable-firefox",
this.onDisableFirefoxShortcutsChange.bind(this)
);
}, },
async onDisableFirefoxShortcutsChange(event) { async onDisableFirefoxShortcutsChange(event) {
let checked = Services.prefs.getBoolPref("zen.keyboard.shortcuts.disable-firefox"); let checked = Services.prefs.getBoolPref(
if (checked) return; "zen.keyboard.shortcuts.disable-firefox"
let buttonIndex = await confirmRestartPrompt(
true,
1,
true,
false
); );
if (checked) return;
let buttonIndex = await confirmRestartPrompt(true, 1, true, false);
if (buttonIndex == CONFIRM_RESTART_PROMPT_RESTART_NOW) { if (buttonIndex == CONFIRM_RESTART_PROMPT_RESTART_NOW) {
Services.startup.quit( Services.startup.quit(
Ci.nsIAppStartup.eAttemptQuit | Ci.nsIAppStartup.eRestart Ci.nsIAppStartup.eAttemptQuit | Ci.nsIAppStartup.eRestart
@@ -113,7 +129,10 @@ var gZenCKSSettings = {
<html:input readonly="1" class="zenCKSOption-input"/> <html:input readonly="1" class="zenCKSOption-input"/>
</hbox> </hbox>
`); `);
document.l10n.setAttributes(fragment.querySelector(".zenCKSOption-label"), l10nId); document.l10n.setAttributes(
fragment.querySelector(".zenCKSOption-label"),
l10nId
);
let input = fragment.querySelector(".zenCKSOption-input"); let input = fragment.querySelector(".zenCKSOption-input");
let shortcut = gZenKeyboardShortcuts.getShortcut(key); let shortcut = gZenKeyboardShortcuts.getShortcut(key);
@@ -156,15 +175,18 @@ var gZenCKSSettings = {
return; return;
} }
let input = document.querySelector(`.zenCKSOption-input[data-key="${this._currentAction}"]`); let input = document.querySelector(
`.zenCKSOption-input[data-key="${this._currentAction}"]`
);
let shortcut = { let shortcut = {
ctrl: event.ctrlKey, ctrl: event.ctrlKey,
alt: event.altKey, alt: event.altKey,
shift: event.shiftKey, shift: event.shiftKey,
meta: event.metaKey meta: event.metaKey,
}; };
const shortcutWithoutModifiers = !shortcut.ctrl && !shortcut.alt && !shortcut.shift && !shortcut.meta; const shortcutWithoutModifiers =
!shortcut.ctrl && !shortcut.alt && !shortcut.shift && !shortcut.meta;
if (event.key === "Tab" && shortcutWithoutModifiers) { if (event.key === "Tab" && shortcutWithoutModifiers) {
return; return;
@@ -182,7 +204,7 @@ var gZenCKSSettings = {
return; // No modifiers, ignore. return; // No modifiers, ignore.
} }
if (!(["Control", "Alt", "Meta", "Shift"].includes(event.key))) { if (!["Control", "Alt", "Meta", "Shift"].includes(event.key)) {
if (event.keycode) { if (event.keycode) {
shortcut.keycode = event.keycode; shortcut.keycode = event.keycode;
} else { } else {
@@ -259,5 +281,5 @@ Preferences.addAll([
id: "zen.keyboard.shortcuts.disable-firefox", id: "zen.keyboard.shortcuts.disable-firefox",
type: "bool", type: "bool",
default: false, default: false,
} },
]); ]);

View File

@@ -3,6 +3,7 @@ pane-zen-looks-title = Look And Feel
category-zen-looks = category-zen-looks =
.tooltiptext = { pane-zen-looks-title } .tooltiptext = { pane-zen-looks-title }
zen-warning-language = Changing the default language could make it easier for Websites to track you.
zen-look-and-feel-colors-header = Pick a theme colour zen-look-and-feel-colors-header = Pick a theme colour
zen-look-and-feel-colors-description = Make { -brand-short-name } look and feel the way you like zen-look-and-feel-colors-description = Make { -brand-short-name } look and feel the way you like
@@ -152,4 +153,4 @@ zen-change-workspace = Cycle Workspaces
zen-split-view-grid = Split View Grid zen-split-view-grid = Split View Grid
zen-split-view-vertical = Split View Vertical zen-split-view-vertical = Split View Vertical
zen-split-view-horizontal = Split View Horizontal zen-split-view-horizontal = Split View Horizontal
zen-split-view-close = Close Split View zen-split-view-close = Close Split View