Skip to content

Commit

Permalink
feat: Add the ability to cycle through panels (hidden configurable)
Browse files Browse the repository at this point in the history
  • Loading branch information
seppulcro committed Oct 10, 2024
1 parent d74c2f7 commit 7f302df
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 11 deletions.
3 changes: 3 additions & 0 deletions src/_locales/dict.browser.json
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@
"zh_TW": "切換到下一個面板",
"ja": "次のパネルに切り替え"
},
"KbLoopPanels": {
"en": "Loop trough all panels"
},
"KbPrevPanel": {
"en": "Switch to previous panel",
"de": "Zum vorherigen Panel wechseln",
Expand Down
7 changes: 5 additions & 2 deletions src/_locales/dict.setup-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1202,7 +1202,7 @@ export const setupPageTranslations: Translations = {
en: 'Required for:\n- Cleaning cookies\n- Proxy and URL rules of containers\n- Screenshots for the group page and windows selection panel\n- Changing the User-Agent per container',
de: 'Benötigt für:\n- Cookies löschen\n- Proxy- und URL-Regeln für Umgebungen\n- Bildschirmfotos für die Gruppenseite und das Fensterauswahlmenü\n- User-Agent per Umgebung ändern',
hu: 'A következő funkciókhoz szükséges:\n– Sütik törlése\n– A konténerek proxy- és URL-szabályainak beállítása\n– Képernyőképek a csoportoldalhoz és az ablakválasztóhoz\n– Konténerenkénti böngészőazonosító megadása',
pl: 'Wymagane dla:\n- Czyszczenia ciasteczek\n- Zasady proxy i URL dla kontenerów\n- Zrzuty ekranu dla grup stron i panelu zaznaczenia okna\n- Zmiana User-Agent\'a dla kontenera',
pl: "Wymagane dla:\n- Czyszczenia ciasteczek\n- Zasady proxy i URL dla kontenerów\n- Zrzuty ekranu dla grup stron i panelu zaznaczenia okna\n- Zmiana User-Agent'a dla kontenera",
ru: 'Необходимо для:\n- Удаления cookies\n- Прокси и url-правил контейнеров\n- Скриншотов на групповой странице и на панели выбора окна',
zh_CN:
'用于:\n- 清除 Cookie\n- 容器的代理和 URL 规则\n- 分组页面和窗口选择面板的缩略图\n- 更改每个容器的用户代理',
Expand Down Expand Up @@ -5383,7 +5383,7 @@ Przykłady: "*", "ctrl+$", "ctrl+alt+g"`,
%Y - Jahr; %M - Monat; %D - Tag; %h - Stunde; %m - Minute; %s - Sekunde`,
hu: `Megjegyzés: az elérési út a letöltések mappájához képest relatív.
%Y: év; %M: hónap; %D: nap; %h: óra; %m: perc; %s: másodperc`,
pl: `Info: Ścieżka jest relatywna do folderu pobrane i Firefox nie pozwala ustawić ścieżki poza nim.
pl: `Info: Ścieżka jest relatywna do folderu pobrane i Firefox nie pozwala ustawić ścieżki poza nim.
%Y - rok; %M - miesiąc; %D - dzień; %h - godzina; %m - minuta; %s - sekunda`,
ru: `Примечание: Путь указывается относительно папки загрузок и Firefox не позволяет устанавливать путь за ее пределами.
%Y - год; %M - месяц; %D - день; %h - час; %m - минута; %s - секунда`,
Expand Down Expand Up @@ -5980,6 +5980,9 @@ Przykłady: "*", "ctrl+$", "ctrl+alt+g"`,
zh_TW: '切換面板',
ja: 'パネル間の切り替え',
},
'settings.kb_switching_panel.ignore_hidden': {
en: 'Ignore hidden panels',
},
'settings.kb_scroll_active_panel': {
en: 'Scrolling the active panel',
de: 'Scrollen des aktiven Panels',
Expand Down
1 change: 1 addition & 0 deletions src/defaults/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ export const DEFAULT_SETTINGS: SettingsState = {

// Keybindings
selectActiveTabFirst: true,
ignoreHiddenPanelsSwitching: false,
}

// prettier-ignore
Expand Down
11 changes: 7 additions & 4 deletions src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@
},
"description": "__MSG_KbOpenSidebarPanel__"
},
"loop_panels": {
"suggested_key": {
"default": "Ctrl+Shift+Space",
"mac": "MacCtrl+Shift+Space"
},
"description": "__MSG_KbLoopPanels__"
},
"next_panel": {
"suggested_key": {
"default": "Alt+Period"
Expand All @@ -84,10 +91,6 @@
"description": "__MSG_KbOpenNewTabInCurrPanel__"
},
"new_tab_in_group": {
"suggested_key": {
"default": "Ctrl+Shift+Space",
"mac": "MacCtrl+Shift+Space"
},
"description": "__MSG_KbOpenNewTabAfter__"
},
"new_tab_as_first_child": {
Expand Down
8 changes: 7 additions & 1 deletion src/page.setup/components/keybindings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@
section
h2 {{translate('settings.kb_switching_panel')}}
span.header-shadow
KeybindingField.-no-separator(:keybinding="Keybindings.reactive.byName.next_panel")
KeybindingField.-no-separator(:keybinding="Keybindings.reactive.byName.loop_panels")
.sub-fields
ToggleField.-no-separator(
label="settings.kb_switching_panel.ignore_hidden"
v-model:value="Settings.state.ignoreHiddenPanelsSwitching"
@update:value="Settings.saveDebounced(150)")
KeybindingField(:keybinding="Keybindings.reactive.byName.next_panel")
KeybindingField(:keybinding="Keybindings.reactive.byName.prev_panel")
KeybindingField(:keybinding="Keybindings.reactive.byName.switch_to_panel_0")
KeybindingField(:keybinding="Keybindings.reactive.byName.switch_to_panel_1")
Expand Down
4 changes: 3 additions & 1 deletion src/services/keybindings.actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,9 @@ function onCmd(name: string): void {
if (!kb) kb = Keybindings.reactive.list.find(k => k.name === name)
if (!kb) return

if (name === 'next_panel') Sidebar.switchPanel(1, false, true)
if (name === 'loop_panels')
Sidebar.switchPanel(1, Settings.state.ignoreHiddenPanelsSwitching, true, undefined, true)
else if (name === 'next_panel') Sidebar.switchPanel(1, false, true)
else if (name === 'prev_panel') Sidebar.switchPanel(-1, false, true)
else if (name === 'new_tab_on_panel') onKeyNewTabInPanel()
else if (name === 'new_tab_in_group') onKeyNewTabAfter()
Expand Down
8 changes: 5 additions & 3 deletions src/services/sidebar.actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1264,7 +1264,8 @@ export function switchPanel(
dir: 1 | -1,
ignoreHidden?: boolean,
withoutTabCreation?: boolean,
restartDebouncer?: boolean
restartDebouncer?: boolean,
shouldLoop?: boolean
): void {
// Single panel switch
const delay = Settings.state.navSwitchPanelsDelay ?? 128
Expand All @@ -1285,7 +1286,6 @@ export function switchPanel(
Selection.resetSelection()

const activePanelId = Sidebar.activePanelId

// If current active panel is not exist
let activePanel = Sidebar.panelsById[activePanelId]
if (!activePanel) {
Expand Down Expand Up @@ -1350,6 +1350,7 @@ export function switchPanel(
else panel = hiddenPanels[hiddenPanels.length - 1]
newActIsHidden = true
}
if (shouldLoop && ignoreHidden) panel = visiblePanels[0]
break
}
if (!panel) break
Expand All @@ -1363,9 +1364,10 @@ export function switchPanel(
if (!panel) {
if (visiblePanels.length) {
panel = visiblePanels[dir > 0 ? hdnIndex : hdnIndex - 1]
if (!panel) break
if (!panel && !shouldLoop) break
if (hiddenPanelsPopupIsShown) Sidebar.reactive.hiddenPanelsPopup = false
newActIsHidden = false
if (shouldLoop) panel = visiblePanels[0]
}
break
}
Expand Down
1 change: 1 addition & 0 deletions src/types/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,4 +251,5 @@ export interface SettingsState {

// Keybindings
selectActiveTabFirst: boolean
ignoreHiddenPanelsSwitching: boolean
}

0 comments on commit 7f302df

Please sign in to comment.