summaryrefslogtreecommitdiff
path: root/src/websnap.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/websnap.h')
-rw-r--r--src/websnap.h60
1 files changed, 44 insertions, 16 deletions
diff --git a/src/websnap.h b/src/websnap.h
index 9773b4cc..c77c0dc8 100644
--- a/src/websnap.h
+++ b/src/websnap.h
@@ -53,37 +53,65 @@
* 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)
+ *
+ * - TabBar class: to show a tab preview (given a page, you show AND save an image)
* - PreviewSelector class: to save new favorite selection (given a page, you show AND save an image)
*
+ * - NewTabPage class: to show the favorites page "preview" (given an url, you show AND save an image)
+ *
*/
class REKONQ_TESTS_EXPORT WebSnap : public QObject
{
Q_OBJECT
public:
- 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);
+ /**
+ * Creates a WebSnap object. It will load the url in one WebPage
+ * and snap an image from it.
+ *
+ * @param url the url to load
+ * @param parent the object parent
+ */
+ WebSnap(const KUrl &url, QObject *parent = 0);
+
+ /**
+ * Snaps a pixmap of size w * h from a page and save it to cache
+ *
+ * @param page the page to snap
+ * @param w the image width
+ * @param h the image height
+ *
+ * @return the pixmap snapped from the page
+ */
+ static QPixmap renderPreview(const QWebPage &page, int w = WIDTH, int h = HEIGHT);
+
+ /**
+ * Guess the local path where the image for the url provided
+ * should be
+ *
+ * @param url the url to guess snap path
+ *
+ * @return the local path of the url snap
+ */
+ static QString imagePathFromUrl(const KUrl &url);
- QString snapTitle();
+ /**
+ * Determines if a snap exists for that url
+ *
+ */
+ static bool existsImage(const KUrl &url);
+
private slots:
- void load();
void saveResult(bool ok = true);
+ void load();
+signals:
+ void snapDone(bool ok);
+
private:
QWebPage m_page;
-
- QUrl m_url;
- QString m_snapTitle;
-
- QWebFrame *m_frame;
- int m_previewIndex;
+ KUrl m_url;
};
#endif // WEB_SNAP_H