summaryrefslogtreecommitdiff
path: root/src/websnap.h
diff options
context:
space:
mode:
authorPanagiotis Papadopoulos <pano_90@gmx.net>2010-04-21 13:34:20 +0200
committerPanagiotis Papadopoulos <pano_90@gmx.net>2010-04-21 13:34:20 +0200
commitf9153663cb8210ac4d6e7055838344839b4e19b6 (patch)
treeb70233b32eadfbebff062c0000f007ca2f99d732 /src/websnap.h
parentMerge branch 'master' of git://gitorious.org/rekonq/mainline into i18n (diff)
parentNebulon's patch. (diff)
downloadrekonq-f9153663cb8210ac4d6e7055838344839b4e19b6.tar.xz
Merge branch 'master' of git://gitorious.org/rekonq/mainline into i18n
Diffstat (limited to 'src/websnap.h')
-rw-r--r--src/websnap.h44
1 files changed, 29 insertions, 15 deletions
diff --git a/src/websnap.h b/src/websnap.h
index 6c5b4af9..9773b4cc 100644
--- a/src/websnap.h
+++ b/src/websnap.h
@@ -3,7 +3,8 @@
* This file is a part of the rekonq project
*
* Copyright (C) 2009 Nokia Corporation <qt-info@nokia.com>
-* Copyright (C) 2009 by Andrea Diamantini <adjam7 at gmail dot com>
+* Copyright (C) 2009-2010 by Andrea Diamantini <adjam7 at gmail dot com>
+* Copyright (C) 2010 by Matthieu Gicquel <matgic78 at gmail dot com>
*
*
* This program is free software; you can redistribute it and/or
@@ -28,6 +29,9 @@
#ifndef WEB_SNAP_H
#define WEB_SNAP_H
+// Local Includes
+#include "rekonqprivate_export.h"
+
// KDE Includes
#include <KUrl>
@@ -37,39 +41,49 @@
#include <QImage>
#include <QWebPage>
+#define WIDTH 200
+#define HEIGHT 150
+
/**
- * This class renders a site producing an image based
- * on that.
+ * This class is used in many classes of rekonq to produce an image
+ * based on the site corresponding to the url passed as argument.
+ * It also cached the images to not retrieve them every time :)
+ *
* Heavily based on Graphics-Dojo WebSnap example (thanks!)
+ *
+ * We use this in the following rekonq classes:
+ * - TabBar class: to show a tab preview (given a page, you show WITHOUT saving an image)
+ * - NewTabPage class: to show the favorites page "preview" (given an url, you show AND save an image)
+ * - PreviewSelector class: to save new favorite selection (given a page, you show AND save an image)
+ *
*/
-class WebSnap : public QObject
+class REKONQ_TESTS_EXPORT WebSnap : public QObject
{
Q_OBJECT
public:
- WebSnap(const QUrl &url);
- ~WebSnap();
-
- QPixmap previewImage();
- static QPixmap renderPreview(const QWebPage &page, int w, int h);
+ WebSnap(const QUrl &url, QWebFrame *frame, int index);
+
+ static QPixmap renderPreview(const QWebPage &page, int w = WIDTH, int h = HEIGHT, bool save = true);
+
+ static KUrl fileForUrl(KUrl url);
+ static QString guessNameFromUrl(QUrl url);
QString snapTitle();
- QUrl snapUrl();
-
-signals:
- void finished();
private slots:
void load();
- void saveResult(bool ok);
+ void saveResult(bool ok = true);
private:
QWebPage m_page;
- QPixmap m_image;
QUrl m_url;
QString m_snapTitle;
+
+ QWebFrame *m_frame;
+ int m_previewIndex;
};
#endif // WEB_SNAP_H