summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2009-09-18 19:22:51 +0200
committerAndrea Diamantini <adjam7@gmail.com>2009-09-18 19:22:51 +0200
commite2f57546558b2d90147cced3beee541e7e1cae9e (patch)
treeed1f7b355450f2ca45d116e036a02a82e42f3a44 /src
parentFixed options show recently closed tabs / show recent history (diff)
downloadrekonq-e2f57546558b2d90147cced3beee541e7e1cae9e.tar.xz
Faster loading..
Diffstat (limited to 'src')
-rw-r--r--src/homepage.cpp3
-rw-r--r--src/previewimage.cpp27
-rw-r--r--src/previewimage.h2
-rw-r--r--src/webpluginfactory.cpp10
-rw-r--r--src/websnap.cpp12
-rw-r--r--src/websnap.h7
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 += "<div class=\"thumbnail\">";
speed += "<a href=\"" + urls.at(i) + "\">";
speed += "<object type=\"application/image-preview\" width=\"200\">";
- speed += "<param name=\"url\" value=\"" + urls.at(i) + "\">";
+ speed += "<param name=\"url\" value=\"" + urls.at(i) + "\">";
+ speed += "<param name=\"position\" value=\"" + QString::number(i) + "\">";
speed += "</object>";
speed += "<br />";
speed += names.at(i) + "</a></div>";
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 <QFile>
+
#include <KUrl>
#include <KStandardDirs>
#include <KDebug>
-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<argumentNames.count(); ++i)
{
if(argumentNames.at(i) == QString("url"))
{
- return new PreviewImage( argumentValues.at(i) );
+ url = argumentValues.at(i);
+ }
+ if(argumentNames.at(i) == QString("position"))
+ {
+ pos = argumentValues.at(i);
}
}
+ return new PreviewImage(url, pos);
}
kDebug() << "No plugins found for" << mimeType;
diff --git a/src/websnap.cpp b/src/websnap.cpp
index 349f2329..ec537b32 100644
--- a/src/websnap.cpp
+++ b/src/websnap.cpp
@@ -36,19 +36,21 @@
#include <QWebSettings>
#include <QPainter>
#include <QTimer>
+#include <QFile>
#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