From 428957543c3b9d9cf869ad63896d1e37a4db8cdb Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 20 Nov 2019 07:21:49 +0530 Subject: [PATCH] Book details window: Show path to book in cover tooltip. Fixes #1853184 [[Enhancement] Show path to cover image when hovering](https://bugs.launchpad.net/calibre/+bug/1853184) --- src/calibre/gui2/dialogs/book_info.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/calibre/gui2/dialogs/book_info.py b/src/calibre/gui2/dialogs/book_info.py index d5f7313efc..b08395f698 100644 --- a/src/calibre/gui2/dialogs/book_info.py +++ b/src/calibre/gui2/dialogs/book_info.py @@ -2,6 +2,8 @@ # License: GPLv3 Copyright: 2008, Kovid Goyal from __future__ import absolute_import, division, print_function, unicode_literals +import textwrap + from PyQt5.Qt import ( QBrush, QCheckBox, QCoreApplication, QDialog, QGridLayout, QHBoxLayout, QIcon, QKeySequence, QLabel, QListView, QModelIndex, QPalette, QPixmap, QPushButton, @@ -169,6 +171,7 @@ class BookInfo(QDialog): l2.addWidget(self.next_button, l2.rowCount() - 1, 1) self.view = view + self.path_to_book = None self.current_row = None self.refresh(row) self.view.model().new_bookdisplay_data.connect(self.slave) @@ -275,9 +278,14 @@ class BookInfo(QDialog): def update_cover_tooltip(self): tt = '' if self.marked: - tt = _('This book is marked') if self.marked in {True, 'true'} else _( + tt += _('This book is marked') if self.marked in {True, 'true'} else _( 'This book is marked as: %s') % self.marked tt += '\n\n' + + if self.path_to_book is not None: + tt += textwrap.fill(_('Path: {}').format(self.path_to_book)) + tt += '\n\n' + if self.cover_pixmap is not None: sz = self.cover_pixmap.size() tt += _('Cover size: %(width)d x %(height)d pixels')%dict(width=sz.width(), height=sz.height()) @@ -300,6 +308,7 @@ class BookInfo(QDialog): self.current_row = row self.setWindowTitle(mi.title) self.cover_pixmap = QPixmap.fromImage(mi.cover_data[1]) + self.path_to_book = getattr(mi, 'path', None) try: dpr = self.devicePixelRatioF() except AttributeError: