aboutsummaryrefslogtreecommitdiff
path: root/ext/js
diff options
context:
space:
mode:
Diffstat (limited to 'ext/js')
-rw-r--r--ext/js/data/options-util.js17
-rw-r--r--ext/js/display/display.js22
-rw-r--r--ext/js/pages/settings/keyboard-shortcuts-controller.js2
3 files changed, 40 insertions, 1 deletions
diff --git a/ext/js/data/options-util.js b/ext/js/data/options-util.js
index 62b062aa..5319cfe4 100644
--- a/ext/js/data/options-util.js
+++ b/ext/js/data/options-util.js
@@ -537,7 +537,8 @@ export class OptionsUtil {
this._updateVersion28,
this._updateVersion29,
this._updateVersion30,
- this._updateVersion31
+ this._updateVersion31,
+ this._updateVersion32
];
/* eslint-enable @typescript-eslint/unbound-method */
if (typeof targetVersion === 'number' && targetVersion < result.length) {
@@ -1245,6 +1246,20 @@ export class OptionsUtil {
}
/**
+ * - Added profilePrevious and profileNext to hotkeys.
+ * @type {import('options-util').UpdateFunction}
+ */
+ async _updateVersion32(options) {
+ for (const profile of options.profiles) {
+ profile.options.inputs.hotkeys.push(
+ {action: 'profilePrevious', key: 'Minus', modifiers: ['alt'], scopes: ['popup', 'search'], enabled: true},
+ {action: 'profileNext', key: 'Equal', modifiers: ['alt'], scopes: ['popup', 'search'], enabled: true}
+ );
+ }
+ }
+
+
+ /**
* @param {string} url
* @returns {Promise<chrome.tabs.Tab>}
*/
diff --git a/ext/js/display/display.js b/ext/js/display/display.js
index 10c1545c..6b73f19b 100644
--- a/ext/js/display/display.js
+++ b/ext/js/display/display.js
@@ -196,6 +196,8 @@ export class Display extends EventDispatcher {
['firstEntry', () => { this._focusEntry(0, 0, true); }],
['historyBackward', () => { this._sourceTermView(); }],
['historyForward', () => { this._nextTermView(); }],
+ ['profilePrevious', async () => { await this._setProfile(-1); }],
+ ['profileNext', async () => { await this._setProfile(1); }],
['copyHostSelection', () => this._copyHostSelection()],
['nextEntryDifferentDictionary', () => { this._focusEntryWithDifferentDictionary(1, true); }],
['previousEntryDifferentDictionary', () => { this._focusEntryWithDifferentDictionary(-1, true); }]
@@ -1996,6 +1998,26 @@ export class Display extends EventDispatcher {
this._focusEntry(this._index + count * sign, 0, true);
}
+ /**
+ * @param {number} direction
+ */
+ async _setProfile(direction) {
+ const optionsFull = await this.application.api.optionsGetFull();
+
+ const profileCount = optionsFull.profiles.length;
+ const newProfile = (optionsFull.profileCurrent + direction + profileCount) % profileCount;
+
+ /** @type {import('settings-modifications').ScopedModificationSet} */
+ const modification = {
+ action: 'set',
+ path: 'profileCurrent',
+ value: newProfile,
+ scope: 'global',
+ optionsContext: null
+ };
+ await this.application.api.modifySettings([modification], 'search');
+ }
+
/** */
_closeAllPopupMenus() {
for (const popupMenu of PopupMenu.openMenus) {
diff --git a/ext/js/pages/settings/keyboard-shortcuts-controller.js b/ext/js/pages/settings/keyboard-shortcuts-controller.js
index b1ea6bb0..1e00d907 100644
--- a/ext/js/pages/settings/keyboard-shortcuts-controller.js
+++ b/ext/js/pages/settings/keyboard-shortcuts-controller.js
@@ -59,6 +59,8 @@ export class KeyboardShortcutController {
['previousEntryDifferentDictionary', {scopes: new Set(['popup', 'search'])}],
['historyBackward', {scopes: new Set(['popup', 'search'])}],
['historyForward', {scopes: new Set(['popup', 'search'])}],
+ ['profilePrevious', {scopes: new Set(['popup', 'search'])}],
+ ['profileNext', {scopes: new Set(['popup', 'search'])}],
['addNoteKanji', {scopes: new Set(['popup', 'search'])}],
['addNoteTermKanji', {scopes: new Set(['popup', 'search'])}],
['addNoteTermKana', {scopes: new Set(['popup', 'search'])}],