summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormatgic78 <matgic78@gmail.com>2010-01-17 19:06:27 +0100
committermatgic78 <matgic78@gmail.com>2010-02-06 11:22:47 +0100
commit50d6ee1e340c35261b0445c1a2c793fb07da4854 (patch)
tree8c81a58e1ae521478cc7726433354d4068b6909b
parentA new approach for choosing previews : a bar appears, then you browse to the ... (diff)
downloadrekonq-50d6ee1e340c35261b0445c1a2c793fb07da4854.tar.xz
bugfixing...
-rw-r--r--src/rekonqpage/newtabpage.cpp56
-rw-r--r--src/rekonqpage/newtabpage.h14
-rw-r--r--src/rekonqpage/previewselectorbar.cpp22
-rw-r--r--src/websnap.cpp4
4 files changed, 31 insertions, 65 deletions
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<WebSnap*>(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 &currentUrl)
{
QList<QWebElement> 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 <KUrl>
// Qt Includes
-#include <QtCore/QObject>
-#include <QtCore/QString>
+#include <QObject>
+#include <QString>
#include <QWebElement>
// 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 &currentUrl);
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 <KIcon>
#include <KLocalizedString>
@@ -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();
}