E-book viewer: Allow fullscreening the image popup. Fixes #1928596 [[Enhancement - Viewer] View image in full screen](https://bugs.launchpad.net/calibre/+bug/1928596)

This commit is contained in:
Kovid Goyal 2021-05-17 11:31:53 +05:30
parent 59fa3f9402
commit 0c83360ed9
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -94,6 +94,7 @@ class ImageView(QDialog):
def __init__(self, parent, current_img, current_url, geom_name='viewer_image_popup_geometry'):
QDialog.__init__(self)
self.current_image_name = ''
self.maximized_at_last_fullscreen = False
self.setWindowFlag(Qt.WindowType.WindowMinimizeButtonHint)
self.setWindowFlag(Qt.WindowType.WindowMaximizeButtonHint)
dw = QApplication.instance().desktop()
@ -117,14 +118,18 @@ class ImageView(QDialog):
self.zo_button = zo = bb.addButton(_('Zoom &out'), QDialogButtonBox.ButtonRole.ActionRole)
self.save_button = so = bb.addButton(_('&Save as'), QDialogButtonBox.ButtonRole.ActionRole)
self.rotate_button = ro = bb.addButton(_('&Rotate'), QDialogButtonBox.ButtonRole.ActionRole)
self.fullscreen_buton = fo = bb.addButton(_('&Fullscreen'), QDialogButtonBox.ButtonRole.ActionRole)
zi.setIcon(QIcon(I('plus.png')))
zo.setIcon(QIcon(I('minus.png')))
so.setIcon(QIcon(I('save.png')))
ro.setIcon(QIcon(I('rotate-right.png')))
fo.setIcon(QIcon(I('page.png')))
zi.clicked.connect(self.zoom_in)
zo.clicked.connect(self.zoom_out)
so.clicked.connect(self.save_image)
ro.clicked.connect(self.rotate_image)
fo.setCheckable(True)
fo.toggled.connect(self.toggle_fullscreen)
self.l = l = QVBoxLayout(self)
l.addWidget(sa)
@ -251,6 +256,17 @@ class ImageView(QDialog):
gprefs[self.geom_name] = bytearray(self.saveGeometry())
return QDialog.done(self, e)
def toggle_fullscreen(self):
on = not self.isFullScreen()
if on:
self.maximized_at_last_fullscreen = self.isMaximized()
self.showFullScreen()
else:
if self.maximized_at_last_fullscreen:
self.showMaximized()
else:
self.showNormal()
def wheelEvent(self, event):
d = event.angleDelta().y()
if abs(d) > 0 and not self.scrollarea.verticalScrollBar().isVisible():