mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
E-book viewer: Add the ability to rotate images to the popup image viewer. Fixes #1073513 ([enhancement] possibilty to rotate picture)
This commit is contained in:
parent
62422b2d79
commit
f8af6aacde
BIN
resources/images/rotate-right.png
Normal file
BIN
resources/images/rotate-right.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.0 KiB |
BIN
resources/images/view-image.png
Normal file
BIN
resources/images/view-image.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 24 KiB |
@ -485,7 +485,7 @@ class DocumentView(QWebView): # {{{
|
||||
self.dictionary_action.triggered.connect(self.lookup)
|
||||
self.addAction(self.dictionary_action)
|
||||
self.image_popup = ImagePopup(self)
|
||||
self.view_image_action = QAction(_('View &image...'), self)
|
||||
self.view_image_action = QAction(QIcon(I('view-image.png')), _('View &image...'), self)
|
||||
self.view_image_action.triggered.connect(self.image_popup)
|
||||
self.search_action = QAction(QIcon(I('dictionary.png')),
|
||||
_('&Search for next occurrence'), self)
|
||||
|
@ -8,7 +8,8 @@ __copyright__ = '2012, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
from PyQt4.Qt import (QDialog, QPixmap, QUrl, QScrollArea, QLabel, QSizePolicy,
|
||||
QDialogButtonBox, QVBoxLayout, QPalette, QApplication, QSize, QIcon, Qt)
|
||||
QDialogButtonBox, QVBoxLayout, QPalette, QApplication, QSize, QIcon,
|
||||
Qt, QTransform)
|
||||
|
||||
from calibre.gui2 import choose_save_file, gprefs
|
||||
|
||||
@ -37,12 +38,15 @@ class ImageView(QDialog):
|
||||
self.zi_button = zi = bb.addButton(_('Zoom &in'), bb.ActionRole)
|
||||
self.zo_button = zo = bb.addButton(_('Zoom &out'), bb.ActionRole)
|
||||
self.save_button = so = bb.addButton(_('&Save as'), bb.ActionRole)
|
||||
self.rotate_button = ro = bb.addButton(_('&Rotate'), bb.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')))
|
||||
zi.clicked.connect(self.zoom_in)
|
||||
zo.clicked.connect(self.zoom_out)
|
||||
so.clicked.connect(self.save_image)
|
||||
ro.clicked.connect(self.rotate_image)
|
||||
|
||||
self.l = l = QVBoxLayout()
|
||||
self.setLayout(l)
|
||||
@ -76,6 +80,14 @@ class ImageView(QDialog):
|
||||
self.scrollarea.verticalScrollBar()):
|
||||
sb.setValue(int(factor*sb.value()) + ((factor - 1) * sb.pageStep()/2))
|
||||
|
||||
def rotate_image(self):
|
||||
pm = self.label.pixmap()
|
||||
t = QTransform()
|
||||
t.rotate(90)
|
||||
pm = pm.transformed(t)
|
||||
self.label.setPixmap(pm)
|
||||
self.label.adjustSize()
|
||||
|
||||
def __call__(self):
|
||||
geom = self.avail_geom
|
||||
self.label.setPixmap(self.current_img)
|
||||
|
Loading…
x
Reference in New Issue
Block a user