Skip to content

Commit

Permalink
Add option to drag-select tabs with middle click to close (#754)
Browse files Browse the repository at this point in the history
* Add option to drag-select tabs with middle click to close

* Fixed typo
  • Loading branch information
emvaized authored Sep 16, 2022
1 parent 17558c5 commit 68ea790
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 4 deletions.
12 changes: 11 additions & 1 deletion src/_locales/dict.setup-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2338,6 +2338,16 @@ export const setupPageTranslations: Translations = {
ru: 'Только для несистемного контекстного меню',
de: 'Nur bei nicht-nativem Kontextmenü',
},
'settings.multiple_middle_close': {
en: 'Use multi-selection when closing tabs using middle-click',
ru: 'Использовать множественный выбор при закрытии вкладок средней кнопкой мыши',
de: 'Verwenden Sie die Mehrfachauswahl, wenn Sie Tabs mit einem Mittelklick schließen',
},
'settings.multiple_middle_close_note': {
en: 'Selected tabs will be closed on releasing the button',
ru: 'Выбранные вкладки будут закрыты при отпускании кнопки',
de: 'Ausgewählte Registerkarten werden beim Loslassen der Schaltfläche geschlossen',
},
'settings.long_click_delay': {
en: 'Long click delay (ms)',
ru: 'Задержка длительного нажатия (мс)',
Expand Down Expand Up @@ -3256,7 +3266,7 @@ export const setupPageTranslations: Translations = {
},
'styles.css_placeholder': {
en: 'Write custom CSS here...',
ru: 'Write custom CSS here...',
ru: 'Вводите правила CSS здесь...',
de: 'Eigenes CSS hier schreiben...',
zh_CN: '在此处编写自定义 CSS...',
},
Expand Down
1 change: 1 addition & 0 deletions src/defaults/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ export const DEFAULT_SETTINGS: SettingsState = {
scrollThroughTabsCyclic: false,
scrollThroughTabsScrollArea: 0,
autoMenuMultiSel: true,
multipleMiddleClose: false,
longClickDelay: 500,
wheelThreshold: false,
wheelThresholdX: 10,
Expand Down
7 changes: 6 additions & 1 deletion src/page.setup/components/settings.mouse.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ section(ref="el")
v-model:value="Settings.state.autoMenuMultiSel"
:note="translate('settings.auto_menu_multi_sel_note')"
@update:value="Settings.saveDebounced(150)")
ToggleField(
label="settings.multiple_middle_close"
v-model:value="Settings.state.multipleMiddleClose"
:note="translate('settings.multiple_middle_close_note')"
@update:value="Settings.saveDebounced(150)")
NumField.-inline(
label="settings.long_click_delay"
unitLabel="settings.long_click_delay_"
Expand Down Expand Up @@ -174,7 +179,7 @@ section(ref="el")
:opts="Settings.getOpts('tabsPanelMiddleClickAction')"
:folded="true"
@update:value="Settings.saveDebounced(150)")

.sub-title {{translate('settings.mouse.bookmarks_title')}}
SelectField(
label="settings.mouse.bookmarks.left_click_action"
Expand Down
22 changes: 20 additions & 2 deletions src/sidebar/components/tab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,14 @@ function onMouseDown(e: MouseEvent): void {
// Middle
else if (e.button === 1) {
e.preventDefault()
Tabs.removeTabs([props.tab.id])
Mouse.blockWheel()
Selection.resetSelection()
if (Settings.state.multipleMiddleClose) {
Selection.resetSelection()
Mouse.startMultiSelection(e, props.tab.id)
} else {
Tabs.removeTabs([props.tab.id])
Selection.resetSelection()
}
}
// Right
Expand Down Expand Up @@ -239,6 +244,19 @@ function onMouseUp(e: MouseEvent): void {
}
}
activating = false
} else if (e.button === 1) {
if (!Settings.state.multipleMiddleClose) return;
const inMultiSelectionMode = Mouse.multiSelectionMode
Mouse.stopMultiSelection()
if (inMultiSelectionMode && !Settings.state.autoMenuMultiSel && Selection.getLength() > 1) {
return
}
if (!Selection.isSet()) select()
Tabs.removeTabs(Selection.get())
} else if (e.button === 2) {
if (e.ctrlKey || e.shiftKey) return
Expand Down
1 change: 1 addition & 0 deletions src/types/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ export interface SettingsState {
scrollThroughTabsCyclic: boolean
scrollThroughTabsScrollArea: number
autoMenuMultiSel: boolean
multipleMiddleClose: boolean
longClickDelay: number
wheelThreshold: boolean
wheelThresholdX: number
Expand Down

0 comments on commit 68ea790

Please sign in to comment.