mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 18:24:30 -04:00
Make the book details pane animated
This commit is contained in:
parent
7cf81e7bff
commit
86dee77d36
@ -16,7 +16,7 @@ class DailyTelegraph(BasicNewsRecipe):
|
|||||||
language = 'en_AU'
|
language = 'en_AU'
|
||||||
|
|
||||||
oldest_article = 2
|
oldest_article = 2
|
||||||
max_articles_per_feed = 10
|
max_articles_per_feed = 20
|
||||||
remove_javascript = True
|
remove_javascript = True
|
||||||
no_stylesheets = True
|
no_stylesheets = True
|
||||||
encoding = 'utf8'
|
encoding = 'utf8'
|
||||||
|
@ -2,9 +2,10 @@ __license__ = 'GPL v3'
|
|||||||
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
__copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||||
import os, collections
|
import os, collections
|
||||||
|
|
||||||
from PyQt4.QtGui import QStatusBar, QLabel, QWidget, QHBoxLayout, QPixmap, \
|
from PyQt4.Qt import QStatusBar, QLabel, QWidget, QHBoxLayout, QPixmap, \
|
||||||
QSizePolicy, QScrollArea
|
QSizePolicy, QScrollArea, Qt, QSize, pyqtSignal, \
|
||||||
from PyQt4.QtCore import Qt, QSize, pyqtSignal
|
QPropertyAnimation, QEasingCurve
|
||||||
|
|
||||||
|
|
||||||
from calibre import fit_image, preferred_encoding, isosx
|
from calibre import fit_image, preferred_encoding, isosx
|
||||||
from calibre.gui2 import config
|
from calibre.gui2 import config
|
||||||
@ -50,6 +51,10 @@ class BookInfoDisplay(QWidget):
|
|||||||
|
|
||||||
def __init__(self, coverpath=I('book.svg')):
|
def __init__(self, coverpath=I('book.svg')):
|
||||||
QLabel.__init__(self)
|
QLabel.__init__(self)
|
||||||
|
self.animation = QPropertyAnimation(self, 'size', self)
|
||||||
|
self.animation.setEasingCurve(QEasingCurve(QEasingCurve.OutExpo))
|
||||||
|
self.animation.setDuration(1000)
|
||||||
|
self.animation.setStartValue(QSize(0, 0))
|
||||||
self.setMaximumWidth(81)
|
self.setMaximumWidth(81)
|
||||||
self.setMaximumHeight(108)
|
self.setMaximumHeight(108)
|
||||||
self.default_pixmap = QPixmap(coverpath)
|
self.default_pixmap = QPixmap(coverpath)
|
||||||
@ -58,6 +63,7 @@ class BookInfoDisplay(QWidget):
|
|||||||
self.setPixmap(self.default_pixmap)
|
self.setPixmap(self.default_pixmap)
|
||||||
|
|
||||||
def do_layout(self):
|
def do_layout(self):
|
||||||
|
self.animation.stop()
|
||||||
pixmap = self.pixmap()
|
pixmap = self.pixmap()
|
||||||
pwidth, pheight = pixmap.width(), pixmap.height()
|
pwidth, pheight = pixmap.width(), pixmap.height()
|
||||||
width, height = fit_image(pwidth, pheight,
|
width, height = fit_image(pwidth, pheight,
|
||||||
@ -68,11 +74,12 @@ class BookInfoDisplay(QWidget):
|
|||||||
except ZeroDivisionError:
|
except ZeroDivisionError:
|
||||||
aspect_ratio = 1
|
aspect_ratio = 1
|
||||||
self.setMaximumWidth(int(aspect_ratio*self.maximumHeight()))
|
self.setMaximumWidth(int(aspect_ratio*self.maximumHeight()))
|
||||||
|
self.animation.setEndValue(self.maximumSize())
|
||||||
|
|
||||||
def setPixmap(self, pixmap):
|
def setPixmap(self, pixmap):
|
||||||
QLabel.setPixmap(self, pixmap)
|
QLabel.setPixmap(self, pixmap)
|
||||||
self.do_layout()
|
self.do_layout()
|
||||||
|
self.animation.start()
|
||||||
|
|
||||||
def sizeHint(self):
|
def sizeHint(self):
|
||||||
return QSize(self.maximumWidth(), self.maximumHeight())
|
return QSize(self.maximumWidth(), self.maximumHeight())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user