mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
...
This commit is contained in:
parent
a6bebd5d75
commit
6a6b2a6f58
@ -468,7 +468,6 @@ class DocumentView(QWebView):
|
||||
QWebView.__init__(self, *args)
|
||||
self.flipper = SlideFlip(self)
|
||||
self.is_auto_repeat_event = False
|
||||
self.load_flip_direction = None
|
||||
self.debug_javascript = False
|
||||
self.shortcuts = Shortcuts(SHORTCUTS, 'shortcuts/viewer')
|
||||
self.self_closing_pat = re.compile(r'<([a-z1-6]+)\s+([^>]+)/>',
|
||||
@ -647,10 +646,6 @@ class DocumentView(QWebView):
|
||||
return '<%s %s></%s>'%(match.group(1), match.group(2), match.group(1))
|
||||
|
||||
def load_path(self, path, pos=0.0):
|
||||
if self.load_flip_direction is not None:
|
||||
self.flipper.initialize(self.current_page_image(),
|
||||
self.load_flip_direction=='next')
|
||||
self.load_flip_direction = None
|
||||
self.initial_pos = pos
|
||||
mt = getattr(path, 'mime_type', None)
|
||||
if mt is None:
|
||||
@ -763,11 +758,9 @@ class DocumentView(QWebView):
|
||||
if self.document.at_top:
|
||||
if self.manager is not None:
|
||||
self.to_bottom = True
|
||||
self.load_flip_direction = 'previous' if epf else None
|
||||
try:
|
||||
if epf:
|
||||
self.flipper.initialize(self.current_page_image(), False)
|
||||
self.manager.previous_document()
|
||||
finally:
|
||||
self.load_flip_direction = None
|
||||
else:
|
||||
opos = self.document.ypos
|
||||
upper_limit = opos - delta_y
|
||||
@ -800,11 +793,9 @@ class DocumentView(QWebView):
|
||||
delta_y = window_height - 25
|
||||
if self.document.at_bottom or ddelta <= 0:
|
||||
if self.manager is not None:
|
||||
self.load_flip_direction = 'next' if epf else None
|
||||
try:
|
||||
self.manager.next_document()
|
||||
finally:
|
||||
self.load_flip_direction = None
|
||||
if epf:
|
||||
self.flipper.initialize(self.current_page_image())
|
||||
self.manager.next_document()
|
||||
elif ddelta < 25:
|
||||
self.scroll_by(y=ddelta)
|
||||
return
|
||||
@ -816,11 +807,9 @@ class DocumentView(QWebView):
|
||||
#print 'After set padding=0:', self.document.ypos
|
||||
if opos < oopos:
|
||||
if self.manager is not None:
|
||||
self.load_flip_direction = 'next' if epf else None
|
||||
try:
|
||||
self.manager.next_document()
|
||||
finally:
|
||||
self.load_flip_direction = None
|
||||
if epf:
|
||||
self.flipper.initialize(self.current_page_image())
|
||||
self.manager.next_document()
|
||||
return
|
||||
lower_limit = opos + delta_y # Max value of top y co-ord after scrolling
|
||||
max_y = self.document.height - window_height # The maximum possible top y co-ord
|
||||
@ -828,11 +817,9 @@ class DocumentView(QWebView):
|
||||
padding = lower_limit - max_y
|
||||
if padding == window_height:
|
||||
if self.manager is not None:
|
||||
self.load_flip_direction = 'next' if epf else None
|
||||
try:
|
||||
self.manager.next_document()
|
||||
finally:
|
||||
self.load_flip_direction = 'next'
|
||||
if epf:
|
||||
self.flipper.initialize(self.current_page_image())
|
||||
self.manager.next_document()
|
||||
return
|
||||
#print 'Setting padding to:', lower_limit - max_y
|
||||
self.document.set_bottom_padding(lower_limit - max_y)
|
||||
|
@ -12,6 +12,8 @@ class SlideFlip(QWidget):
|
||||
|
||||
# API {{{
|
||||
|
||||
# In addition the isVisible() and setVisible() methods must be present
|
||||
|
||||
def __init__(self, parent):
|
||||
QWidget.__init__(self, parent)
|
||||
|
||||
@ -27,9 +29,19 @@ class SlideFlip(QWidget):
|
||||
|
||||
@property
|
||||
def running(self):
|
||||
'True iff animation is currently running'
|
||||
return self.animation.state() == self.animation.Running
|
||||
|
||||
def initialize(self, image, forwards=True):
|
||||
'''
|
||||
Initialize the flipper, causes the flipper to show itself displaying
|
||||
the full `image`.
|
||||
|
||||
:param image: The image to display as background
|
||||
:param forwards: If True flipper will flip forwards, otherwise
|
||||
backwards
|
||||
|
||||
'''
|
||||
self.flip_forwards = forwards
|
||||
self.before_image = QPixmap.fromImage(image)
|
||||
self.after_image = None
|
||||
@ -37,6 +49,12 @@ class SlideFlip(QWidget):
|
||||
self.setVisible(True)
|
||||
|
||||
def __call__(self, image, duration=0.5):
|
||||
'''
|
||||
Start the animation. You must have called :meth:`initialize` first.
|
||||
|
||||
:param duration: Animation duration in seconds.
|
||||
|
||||
'''
|
||||
if self.running:
|
||||
return
|
||||
self.after_image = QPixmap.fromImage(image)
|
||||
|
Loading…
x
Reference in New Issue
Block a user