diff options
author | Andrea Diamantini <adjam7@gmail.com> | 2010-04-22 01:42:58 +0200 |
---|---|---|
committer | Andrea Diamantini <adjam7@gmail.com> | 2010-04-22 01:42:58 +0200 |
commit | 1d2e4946e7650466a21acc6d2abb19740a63d431 (patch) | |
tree | 411406e7a02e77492a215904316b64f3fa55b73a /src/websnap.h | |
parent | Fix embed kpart bahevior. Try embedding just when there is a ReadOnlyPart (diff) | |
download | rekonq-1d2e4946e7650466a21acc6d2abb19740a63d431.tar.xz |
Fix, improve and clean WebSnap API.
This led me to a little polish in the classes using
the WebSnap facilities and to change the mechanism
the NewTabPage retrieves images from the "cache"
Diffstat (limited to 'src/websnap.h')
-rw-r--r-- | src/websnap.h | 60 |
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 |