From 50d6ee1e340c35261b0445c1a2c793fb07da4854 Mon Sep 17 00:00:00 2001 From: matgic78 Date: Sun, 17 Jan 2010 19:06:27 +0100 Subject: bugfixing... --- src/rekonqpage/newtabpage.cpp | 56 ++++------------------------------- src/rekonqpage/newtabpage.h | 14 ++------- src/rekonqpage/previewselectorbar.cpp | 22 +++++++++++++- src/websnap.cpp | 4 ++- 4 files changed, 31 insertions(+), 65 deletions(-) (limited to 'src') diff --git a/src/rekonqpage/newtabpage.cpp b/src/rekonqpage/newtabpage.cpp index b075c186..f2609c19 100644 --- a/src/rekonqpage/newtabpage.cpp +++ b/src/rekonqpage/newtabpage.cpp @@ -26,6 +26,7 @@ // Self Includes #include "newtabpage.h" +#include "newtabpage.moc" // Auto Includes #include "rekonq.h" @@ -183,8 +184,9 @@ QWebElement NewTabPage::loadingPreview(int index, KUrl url) showControls(prev); WebSnap *snap = new WebSnap(url); + bool test = connect(snap, SIGNAL(finished()), this, SLOT(snapFinished())); + kDebug() << test; snap->SetData(QVariant(index)); - connect(snap, SIGNAL(finished()), SLOT(snapFinished())); return prev; } @@ -233,26 +235,11 @@ void NewTabPage::setupPreview(QWebElement e, int index) void NewTabPage::snapFinished() -{ +{ + kDebug() << "called"; WebSnap *snap = qobject_cast(sender()); QWebElement prev = m_root.findFirst("#preview" + snap->data().toString()); prev.replace(validPreview(snap->data().toInt(), snap->snapUrl(), snap->snapTitle())); - - if(m_url != KUrl("about:favorites")) - return; - - // Save the new config - QStringList names = ReKonfig::previewNames(); - QStringList urls = ReKonfig::previewUrls(); - - // stripTrailingSlash to be sure to get the same string for same address - urls.replace(snap->data().toInt(), snap->snapUrl().toString(QUrl::StripTrailingSlash)); - names.replace(snap->data().toInt() , snap->snapTitle()); - - ReKonfig::setPreviewNames(names); - ReKonfig::setPreviewUrls(urls); - - ReKonfig::self()->writeConfig(); } @@ -274,39 +261,6 @@ void NewTabPage::removePreview(int index) } -void NewTabPage::setPreview(int index, KUrl url) -{ - if(url.isEmpty()) - return; - - QWebElement prev = m_root.findFirst("#preview" + QVariant(index).toString()); - prev.replace(loadingPreview(index, url)); - -} - - -void NewTabPage::setPreview(int index, WebPage* page) -{ - KUrl url = page->mainFrame()->url(); - - WebSnap::savePreview(WebSnap::renderPreview(*page), url); - - QStringList names = ReKonfig::previewNames(); - QStringList urls = ReKonfig::previewUrls(); - - urls.replace(index, url.toMimeDataString()); - names.replace(index, page->mainFrame()->title()); - - ReKonfig::setPreviewNames(names); - ReKonfig::setPreviewUrls(urls); - - ReKonfig::self()->writeConfig(); - - setPreview(index, url); -} - - - void NewTabPage::browsingMenu(const KUrl ¤tUrl) { QList navItems; diff --git a/src/rekonqpage/newtabpage.h b/src/rekonqpage/newtabpage.h index 742d9209..1057c7cc 100644 --- a/src/rekonqpage/newtabpage.h +++ b/src/rekonqpage/newtabpage.h @@ -32,8 +32,8 @@ #include // Qt Includes -#include -#include +#include +#include #include // Forward Includes @@ -58,16 +58,6 @@ public: public slots: void snapFinished(); void removePreview(int index); - - /** - Used for recently closed tabs - */ - void setPreview(int index, KUrl url); - - /** - Used for favorites - */ - void setPreview(int index, WebPage *page); protected: // these are the function to build the new tab page void browsingMenu(const KUrl ¤tUrl); diff --git a/src/rekonqpage/previewselectorbar.cpp b/src/rekonqpage/previewselectorbar.cpp index 04e7f0ac..bbdce9d4 100644 --- a/src/rekonqpage/previewselectorbar.cpp +++ b/src/rekonqpage/previewselectorbar.cpp @@ -21,6 +21,10 @@ // Auto Includes #include "previewselectorbar.h" +// Local Include +#include "rekonq.h" +#include "websnap.h" + // KDE Includes #include #include @@ -130,8 +134,24 @@ void PreviewSelectorBar::loadFinished() void PreviewSelectorBar::clicked() { - m_page->newTabPage()->setPreview(m_previewIndex, m_page); + KUrl url = m_page->mainFrame()->url(); + + WebSnap::savePreview(WebSnap::renderPreview(*m_page), url); + + QStringList names = ReKonfig::previewNames(); + QStringList urls = ReKonfig::previewUrls(); + + urls.replace(m_previewIndex, url.toMimeDataString()); + names.replace(m_previewIndex, m_page->mainFrame()->title()); + + ReKonfig::setPreviewNames(names); + ReKonfig::setPreviewUrls(urls); + + ReKonfig::self()->writeConfig(); + + m_page->mainFrame()->load(KUrl("about:favorites")); + hide(); } diff --git a/src/websnap.cpp b/src/websnap.cpp index ff4746ca..fde7bd94 100644 --- a/src/websnap.cpp +++ b/src/websnap.cpp @@ -108,6 +108,8 @@ QPixmap WebSnap::renderPreview(const QWebPage &page,int w, int h) page.mainFrame()->setScrollBarPolicy(Qt::Vertical, Qt::ScrollBarAsNeeded); return QPixmap::fromImage(pageImage); + + kDebug() << w << h; } @@ -172,8 +174,8 @@ void WebSnap::saveResult(bool ok) } QFile::remove(fileForUrl(m_url).toLocalFile()); m_image.save(fileForUrl(m_url).toLocalFile()); - kDebug() << "finished"; + kDebug() << "finished"; emit finished(); } -- cgit v1.2.1