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)

This commit is contained in:
Kovid Goyal 2019-11-20 07:21:49 +05:30
parent ba31bc20bc
commit 428957543c
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -2,6 +2,8 @@
# License: GPLv3 Copyright: 2008, Kovid Goyal <kovid at kovidgoyal.net>
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: