From e2f57546558b2d90147cced3beee541e7e1cae9e Mon Sep 17 00:00:00 2001 From: Andrea Diamantini Date: Fri, 18 Sep 2009 19:22:51 +0200 Subject: Faster loading.. --- src/homepage.cpp | 3 ++- src/previewimage.cpp | 27 ++++++++++++++++++++------- src/previewimage.h | 2 +- src/webpluginfactory.cpp | 10 ++++++++-- src/websnap.cpp | 12 +++++++----- src/websnap.h | 7 ++++--- 6 files changed, 42 insertions(+), 19 deletions(-) diff --git a/src/homepage.cpp b/src/homepage.cpp index 1f056a92..14db5806 100644 --- a/src/homepage.cpp +++ b/src/homepage.cpp @@ -97,7 +97,8 @@ QString HomePage::speedDial() speed += "
"; speed += ""; speed += ""; - speed += ""; + speed += ""; + speed += ""; speed += ""; speed += "
"; speed += names.at(i) + "
"; diff --git a/src/previewimage.cpp b/src/previewimage.cpp index 2d963171..d027bfd1 100644 --- a/src/previewimage.cpp +++ b/src/previewimage.cpp @@ -26,19 +26,32 @@ #include "previewimage.h" #include "previewimage.moc" +#include + #include #include #include -PreviewImage::PreviewImage(const QString &url) +PreviewImage::PreviewImage(const QString &url, const QString &pos) : QLabel() , ws(0) -{ - QString path = KStandardDirs::locate("appdata", "pics/loading.mng"); //QString("thumbs/") + m_fileName, true); - setPixmap( QPixmap(path) ); - kDebug() << url; - ws = new WebSnap( KUrl(url) ); - connect(ws, SIGNAL(finished()), this, SLOT(setSiteImage())); +{ + QString path = KStandardDirs::locateLocal("cache", QString("thumbs/rek") + pos + ".png", true); + + if(QFile::exists(path)) + { + kDebug() << "exists! Loading it..."; + m_pixmap.load(path); + setPixmap( m_pixmap ); + } + else + { + QString path = KStandardDirs::locate("appdata", "pics/loading.mng"); + setPixmap( QPixmap(path) ); + + ws = new WebSnap( url, pos ); + connect(ws, SIGNAL(finished()), this, SLOT(setSiteImage())); + } } diff --git a/src/previewimage.h b/src/previewimage.h index 7cb6c00b..612d98c6 100644 --- a/src/previewimage.h +++ b/src/previewimage.h @@ -39,7 +39,7 @@ class PreviewImage : public QLabel Q_OBJECT public: - PreviewImage(const QString &url); + PreviewImage(const QString &url, const QString &pos); ~PreviewImage(); diff --git a/src/webpluginfactory.cpp b/src/webpluginfactory.cpp index 9d7755c5..1e599327 100644 --- a/src/webpluginfactory.cpp +++ b/src/webpluginfactory.cpp @@ -53,14 +53,20 @@ QObject *WebPluginFactory::create(const QString &mimeType, kDebug() << "loading mimeType: " << mimeType; if(mimeType == QString("application/image-preview") ) - { + { + QString url, pos; for(int i = 0; i #include #include +#include #define WIDTH 200 #define HEIGHT 150 -WebSnap::WebSnap(const KUrl &url) +WebSnap::WebSnap(const QString &url, const QString &pos) : QObject() - , m_url(url) { + m_url = url; + m_pos = pos; + // this to not register websnap history m_page.settings()->setAttribute(QWebSettings::PrivateBrowsingEnabled, true); - connect(&m_page, SIGNAL(loadFinished(bool)), this, SLOT(saveResult(bool))); QTimer::singleShot(0, this, SLOT(load())); } @@ -57,7 +59,7 @@ WebSnap::WebSnap(const KUrl &url) void WebSnap::load() { kDebug() << "loading.."; - m_page.mainFrame()->load(m_url); + m_page.mainFrame()->load( QUrl(m_url) ); } @@ -86,7 +88,7 @@ void WebSnap::saveResult(bool ok) m_image = m_image.scaled(WIDTH, HEIGHT, Qt::KeepAspectRatioByExpanding); - QString path = KStandardDirs::locateLocal("cache", QString("thumbs/uno.png"), true); + QString path = KStandardDirs::locateLocal("cache", QString("thumbs/rek") + m_pos + ".png", true); if( m_image.save(path) ) { kDebug() << "finished"; diff --git a/src/websnap.h b/src/websnap.h index 7e77da49..2bcdfef8 100644 --- a/src/websnap.h +++ b/src/websnap.h @@ -45,7 +45,7 @@ class WebSnap : public QObject Q_OBJECT public: - WebSnap(const KUrl &url); + WebSnap(const QString &url, const QString &pos); QPixmap previewImage(); @@ -58,9 +58,10 @@ private slots: private: QWebPage m_page; - KUrl m_url; QPixmap m_image; - QString m_fileName; + + QString m_url; + QString m_pos; }; #endif // WEB_SNAP_H -- cgit v1.2.1