Commit 5d3a315a authored by Albert Astals Cid's avatar Albert Astals Cid
Browse files

Enrico code is probably better but until we merge the experiments branch this...

Enrico code is probably better but until we merge the experiments branch this is a little more thing that can be done in the thread so GUI is even smaller

svn path=/trunk/kdegraphics/kpdf/; revision=346789
parent df338999
......@@ -402,6 +402,7 @@ Part::openFile()
{
// TODO use a qvaluelist<int> to pass aspect ratio?
// TODO move it to inside pdfpartview or even the thumbnail list itself?
// TODO take page rotation into acount for calculating aspect ratio
pdfpartview->setPages(m_doc->getNumPages(), m_doc->getPageHeight(1)/m_doc->getPageWidth(1));
pdfpartview->generateThumbnails(m_doc);
......
......@@ -26,8 +26,9 @@ Thumbnail::Thumbnail(QWidget *parent, const QString &text, const QColor &color,
void Thumbnail::setImage(const QImage *thumbnail)
{
// TODO i am almost sure this can be done inside the thumbnailgenerator thread
m_original = thumbnail->smoothScale(m_thumbnailW->size());
// Happens for the very first thumbnail on scrollbar appear
if (thumbnail->size() != m_thumbnailW->size()) m_original = thumbnail->smoothScale(m_thumbnailW->size());
else m_original = *thumbnail;
m_thumbnailW->setPaletteBackgroundPixmap(m_original);
}
......
......@@ -11,12 +11,12 @@
#include <qevent.h>
#include <qimage.h>
#include <qmutex.h>
#include "PDFDoc.h"
#include "thumbnailgenerator.h"
ThumbnailGenerator::ThumbnailGenerator(PDFDoc *doc, QMutex *docMutex, int page, double ppp, QObject *o) : m_doc(doc), m_docMutex(docMutex), m_page(page), m_o(o), m_ppp(ppp)
ThumbnailGenerator::ThumbnailGenerator(PDFDoc *doc, QMutex *docMutex, int page, double ppp, QObject *o, const QSize &size) : m_doc(doc), m_docMutex(docMutex), m_page(page), m_o(o), m_ppp(ppp), m_size(size)
{
}
......@@ -29,7 +29,7 @@ void ThumbnailGenerator::run()
{
QCustomEvent *ce;
QImage *i;
SplashColor paperColor;
paperColor.rgb8 = splashMakeRGB8(0xff, 0xff, 0xff);
QOutputDevPixmap odev(paperColor);
......@@ -38,7 +38,7 @@ void ThumbnailGenerator::run()
m_doc -> displayPage(&odev, m_page, m_ppp, m_ppp, 0, true, false);
m_docMutex->unlock();
ce = new QCustomEvent(65432);
i = new QImage(odev.getImage());
i = new QImage(odev.getImage().smoothScale(m_size));
i -> detach();
ce -> setData(i);
QApplication::postEvent(m_o, ce);
......
......@@ -10,7 +10,7 @@
#ifndef THUMBNAILGENERATOR_H
#define THUMBNAILGENERATOR_H
#include <qthread.h>
#include <qthread.h>
#include "QOutputDevPixmap.h"
......@@ -21,19 +21,20 @@ class PDFDoc;
class ThumbnailGenerator : public QThread
{
public:
ThumbnailGenerator(PDFDoc *doc, QMutex *docMutex, int page, double ppp, QObject *o);
ThumbnailGenerator(PDFDoc *doc, QMutex *docMutex, int page, double ppp, QObject *o, const QSize &size);
int getPage() const;
protected:
void run();
private:
PDFDoc *m_doc;
QMutex *m_docMutex;
int m_page;
QObject *m_o;
double m_ppp;
QSize m_size;
};
#endif
......@@ -68,7 +68,7 @@ void ThumbnailList::generateNextThumbnail()
m_tg->wait();
delete m_tg;
}
m_tg = new ThumbnailGenerator(m_doc, m_docMutex, m_nextThumbnail, QPaintDevice::x11AppDpiX(), this);
m_tg = new ThumbnailGenerator(m_doc, m_docMutex, m_nextThumbnail, QPaintDevice::x11AppDpiX(), this, QSize(visibleWidth(), (int)(visibleWidth()*m_ar)));
m_tg->start();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment