Edit book: Show full path to book being edited in the status bar

This commit is contained in:
Kovid Goyal 2023-10-01 09:04:26 +05:30
parent e841b4c94d
commit f45bda394b
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 12 additions and 1 deletions

View File

@ -356,6 +356,7 @@ class Boss(QObject):
self._edit_file_on_open = self._search_text_on_open = None self._edit_file_on_open = self._search_text_on_open = None
if job.traceback is not None: if job.traceback is not None:
self.gui.update_status_bar_default_message()
if 'DRMError:' in job.traceback: if 'DRMError:' in job.traceback:
from calibre.gui2.dialogs.drm_error import DRMErrorMessage from calibre.gui2.dialogs.drm_error import DRMErrorMessage
return DRMErrorMessage(self.gui).exec() return DRMErrorMessage(self.gui).exec()
@ -390,6 +391,7 @@ class Boss(QObject):
path = os.path.abspath(container.path_to_ebook) path = os.path.abspath(container.path_to_ebook)
if path in recent_books: if path in recent_books:
recent_books.remove(path) recent_books.remove(path)
self.gui.update_status_bar_default_message(path)
recent_books.insert(0, path) recent_books.insert(0, path)
tprefs['recent-books'] = recent_books[:10] tprefs['recent-books'] = recent_books[:10]
self.gui.update_recent_books() self.gui.update_recent_books()

View File

@ -305,8 +305,10 @@ class Main(MainWindow):
self.status_bar.addPermanentWidget(self.boss.save_manager.status_widget) self.status_bar.addPermanentWidget(self.boss.save_manager.status_widget)
self.cursor_position_widget = CursorPositionWidget(self) self.cursor_position_widget = CursorPositionWidget(self)
self.status_bar.addPermanentWidget(self.cursor_position_widget) self.status_bar.addPermanentWidget(self.cursor_position_widget)
self.status_bar_default_msg = la = QLabel(' ' + _('{0} {1} created by {2}').format(__appname__, get_version(), 'Kovid Goyal')) v = get_version()
self.status_bar_default_msg = la = QLabel(' ' + _('{0} {1} created by {2}').format(__appname__, v, 'Kovid Goyal'))
la.base_template = str(la.text()) la.base_template = str(la.text())
la.editing_template = _('{appname} {version} editing: {{path}}').format(appname=__appname__, version=v)
self.status_bar.addWidget(la) self.status_bar.addWidget(la)
self.boss(self) self.boss(self)
@ -332,6 +334,13 @@ class Main(MainWindow):
def show_status_message(self, msg, timeout=5): def show_status_message(self, msg, timeout=5):
self.status_bar.showMessage(msg, int(timeout*1000)) self.status_bar.showMessage(msg, int(timeout*1000))
def update_status_bar_default_message(self, path=''):
m = self.status_bar_default_msg
if path:
m.setText(m.editing_template.format(path=path))
else:
m.setText(m.base_template)
def elided_text(self, text, width=300): def elided_text(self, text, width=300):
return elided_text(text, font=self.font(), width=width) return elided_text(text, font=self.font(), width=width)