Implement #890 (Improvement to cover view)

This commit is contained in:
Kovid Goyal 2008-07-20 15:18:32 -07:00
parent d78296e8bd
commit 55f5523699
6 changed files with 32 additions and 11 deletions

View File

@ -12,7 +12,7 @@ import sys, os
from PyQt4.QtGui import QImage, QSizePolicy
from PyQt4.QtCore import Qt, QSize, SIGNAL, QObject
from calibre import pictureflow
from calibre import pictureflow, Settings
if pictureflow is not None:
class EmptyImageList(pictureflow.FlowImages):
@ -68,7 +68,8 @@ if pictureflow is not None:
class CoverFlow(pictureflow.PictureFlow):
def __init__(self, height=300, parent=None):
pictureflow.PictureFlow.__init__(self, parent)
pictureflow.PictureFlow.__init__(self, parent,
Settings().get('cover flow queue length', 6)+1)
self.setSlideSize(QSize(int(2/3. * height), height))
self.setMinimumSize(QSize(int(2.35*0.67*height), (5/3.)*height+25))
self.setFocusPolicy(Qt.WheelFocus)

View File

@ -66,6 +66,7 @@ class ConfigDialog(QDialog, Ui_Dialog):
single_format = settings.get('save to disk single format', 'lrf')
self.single_format.setCurrentIndex(BOOK_EXTENSIONS.index(single_format))
self.cover_browse.setValue(settings.get('cover flow queue length', 6))
def compact(self, toggled):
d = Vacuum(self, self.db)
@ -98,7 +99,7 @@ class ConfigDialog(QDialog, Ui_Dialog):
pattern = self.filename_pattern.commit()
settings.set('filename pattern', pattern)
settings.set('save to disk single format', BOOK_EXTENSIONS[self.single_format.currentIndex()])
settings.set('cover flow queue length', self.cover_browse.value())
if not path or not os.path.exists(path) or not os.path.isdir(path):
d = error_dialog(self, _('Invalid database location'), _('Invalid database location ')+path+_('<br>Must be a directory.'))

View File

@ -132,6 +132,23 @@
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout" >
<item>
<widget class="QLabel" name="label_6" >
<property name="text" >
<string>&amp;Number of covers to show in browse mode (after restart):</string>
</property>
<property name="buddy" >
<cstring>cover_browse</cstring>
</property>
</widget>
</item>
<item>
<widget class="QSpinBox" name="cover_browse" />
</item>
</layout>
</item>
<item>
<widget class="QCheckBox" name="new_version_notification" >
<property name="text" >

View File

@ -28,7 +28,7 @@ class PictureFlow : QWidget {
public :
PictureFlow(QWidget *parent /TransferThis/ = 0);
PictureFlow(QWidget *parent /TransferThis/ = 0, int queueLength = 3);
void setImages(FlowImages *images);

View File

@ -316,7 +316,7 @@ struct SlideInfo
class PictureFlowPrivate
{
public:
PictureFlowPrivate(PictureFlow* widget);
PictureFlowPrivate(PictureFlow* widget, int queueLength);
int slideCount() const;
void setSlideCount(int count);
@ -368,6 +368,7 @@ private:
int slideWidth;
int slideHeight;
int zoom;
int queueLength;
int centerIndex;
SlideInfo centerSlide;
@ -396,7 +397,7 @@ private:
void resetSlides();
};
PictureFlowPrivate::PictureFlowPrivate(PictureFlow* w)
PictureFlowPrivate::PictureFlowPrivate(PictureFlow* w, int queueLength_)
{
widget = w;
slideImages = new FlowImages();
@ -406,6 +407,7 @@ PictureFlowPrivate::PictureFlowPrivate(PictureFlow* w)
zoom = 100;
centerIndex = 0;
queueLength = queueLength_;
slideFrame = 0;
step = 0;
@ -553,7 +555,7 @@ void PictureFlowPrivate::resetSlides()
centerSlide.slideIndex = centerIndex;
leftSlides.clear();
leftSlides.resize(3);
leftSlides.resize(queueLength);
for(int i = 0; i < leftSlides.count(); i++)
{
SlideInfo& si = leftSlides[i];
@ -565,7 +567,7 @@ void PictureFlowPrivate::resetSlides()
}
rightSlides.clear();
rightSlides.resize(3);
rightSlides.resize(queueLength);
for(int i = 0; i < rightSlides.count(); i++)
{
SlideInfo& si = rightSlides[i];
@ -1104,9 +1106,9 @@ void PictureFlowPrivate::clearSurfaceCache()
// -----------------------------------------
PictureFlow::PictureFlow(QWidget* parent): QWidget(parent)
PictureFlow::PictureFlow(QWidget* parent, int queueLength): QWidget(parent)
{
d = new PictureFlowPrivate(this);
d = new PictureFlowPrivate(this, queueLength);
setAttribute(Qt::WA_StaticContents, true);
setAttribute(Qt::WA_OpaquePaintEvent, true);

View File

@ -98,7 +98,7 @@ public:
/*!
Creates a new PictureFlow widget.
*/
PictureFlow(QWidget* parent = 0);
PictureFlow(QWidget* parent = 0, int queueLength = 3);
/*!
Destroys the widget.