mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Edit book: Add an action to the right click menu for tabs to close tabs to the right of the current tab. Fixes #1902518 [feature request: Lock tabs in editor so that they don't close in close all other tabs action](https://bugs.launchpad.net/calibre/+bug/1902518)
This commit is contained in:
parent
0ac67b2167
commit
786f3e963e
@ -149,6 +149,9 @@ class Central(QStackedWidget): # {{{
|
||||
def close_all_but_current_editor(self):
|
||||
self.close_all_but(self.current_editor)
|
||||
|
||||
def close_to_right_of_current_editor(self):
|
||||
self.close_to_right(self.current_editor)
|
||||
|
||||
def close_all_but(self, ed):
|
||||
close = []
|
||||
if ed is not None:
|
||||
@ -159,6 +162,19 @@ class Central(QStackedWidget): # {{{
|
||||
for q in close:
|
||||
self.close_requested.emit(q)
|
||||
|
||||
def close_to_right(self, ed):
|
||||
close = []
|
||||
if ed is not None:
|
||||
found = False
|
||||
for i in range(self.editor_tabs.count()):
|
||||
q = self.editor_tabs.widget(i)
|
||||
if found:
|
||||
close.append(q)
|
||||
elif q is ed:
|
||||
found = True
|
||||
for q in close:
|
||||
self.close_requested.emit(q)
|
||||
|
||||
@property
|
||||
def current_editor(self):
|
||||
return self.editor_tabs.currentWidget()
|
||||
@ -196,6 +212,7 @@ class Central(QStackedWidget): # {{{
|
||||
menu.addAction(actions['close-current-tab'].icon(), _('Close tab'), partial(self.close_requested.emit, ed))
|
||||
menu.addSeparator()
|
||||
menu.addAction(actions['close-all-but-current-tab'].icon(), _('Close other tabs'), partial(self.close_all_but, ed))
|
||||
menu.addAction(actions['close-tabs-to-right-of'].icon(), _('Close tabs to right of this tab'), partial(self.close_to_right, ed))
|
||||
menu.exec_(self.editor_tabs.tabBar().mapToGlobal(event.pos()))
|
||||
|
||||
return True
|
||||
@ -510,6 +527,9 @@ class Main(MainWindow):
|
||||
self.action_close_all_but_current_tab = reg(
|
||||
'edit-clear.png', _('C&lose other tabs'), self.central.close_all_but_current_editor, 'close-all-but-current-tab', 'Ctrl+Alt+W', _(
|
||||
'Close all tabs except the current tab'))
|
||||
self.action_close_to_right = reg(
|
||||
'edit-clear.png', _('Close tabs to the &right'), self.central.close_to_right_of_current_editor, 'close-tabs-to-right-of', 'Ctrl+Shift+W', _(
|
||||
'Close tabs to the right of the current tab'))
|
||||
self.action_help = treg(
|
||||
'help.png', _('User &Manual'), lambda : open_url(QUrl(localize_user_manual_link(
|
||||
'https://manual.calibre-ebook.com/edit.html'))), 'user-manual', 'F1', _(
|
||||
|
Loading…
x
Reference in New Issue
Block a user