summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/data/home.html4
-rw-r--r--src/rekonqpage/newtabpage.cpp47
-rw-r--r--src/rekonqpage/newtabpage.h2
-rw-r--r--src/websnap.cpp27
-rw-r--r--src/websnap.h11
5 files changed, 52 insertions, 39 deletions
diff --git a/src/data/home.html b/src/data/home.html
index 103c559d..51b9ceec 100644
--- a/src/data/home.html
+++ b/src/data/home.html
@@ -66,7 +66,7 @@ color: black;
/* ------------------------------------------------------- */
/* page sections */
-#container {
+#rekonq-newtabpage {
width: 100%;
}
@@ -191,7 +191,7 @@ margin-bottom: 0.5em;
<body>
-<div id="container">
+<div id="rekonq-newtabpage">
<div id="navigation">
</div>
diff --git a/src/rekonqpage/newtabpage.cpp b/src/rekonqpage/newtabpage.cpp
index 49f4e837..19f1686f 100644
--- a/src/rekonqpage/newtabpage.cpp
+++ b/src/rekonqpage/newtabpage.cpp
@@ -76,7 +76,7 @@ NewTabPage::~NewTabPage()
void NewTabPage::generate(KUrl url)
-{
+{
if(KUrl("about:preview").isParentOf(url))
{
if(url.directory() == QString("preview/remove"))
@@ -140,10 +140,10 @@ void NewTabPage::generate(KUrl url)
void NewTabPage::favoritesPage()
{
+ m_root.addClass("favorites");
+
QStringList names = ReKonfig::previewNames();
QStringList urls = ReKonfig::previewUrls();
-
- m_root.addClass("favorites");
for(int i=0; i<8; ++i)
{
@@ -187,14 +187,12 @@ QWebElement NewTabPage::loadingPreview(int index, KUrl url)
prev.findFirst(".preview img").setAttribute("src" ,
QString("file:///") + KStandardDirs::locate("appdata", "pics/busywidget.gif"));
prev.findFirst("span").appendInside(i18n("Loading Preview..."));
+ prev.findFirst("a").setAttribute("href", url.toMimeDataString());
setupPreview(prev, index);
showControls(prev);
- WebSnap *snap = new WebSnap(url);
- bool test = connect(snap, SIGNAL(finished()), this, SLOT(snapFinished()));
- kDebug() << test;
- snap->SetData(QVariant(index));
+ new WebSnap(url, m_root.webFrame()->page(), index);
return prev;
}
@@ -244,12 +242,29 @@ 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()));
+void NewTabPage::snapFinished(int index, KUrl url, QString title)
+{
+ // do not try to modify the page if it isn't the newTabPage
+ if(m_root.document().findAll("#rekonq-newtabpage").count() == 0)
+ return;
+
+ QWebElement prev = m_root.findFirst("#preview" + QVariant(index).toString());
+ QWebElement newPrev = validPreview(index, url, title);
+
+ if(m_root.findAll(".closedTabs").count() != 0)
+ hideControls(newPrev);
+
+ prev.replace(newPrev);
+
+ // update title
+ if(m_root.findAll(".favorites").count() != 0)
+ {
+ QStringList names = ReKonfig::previewNames();
+ names.replace(index, title);
+ ReKonfig::setPreviewNames(names);
+
+ ReKonfig::self()->writeConfig();
+ }
}
@@ -319,6 +334,8 @@ void NewTabPage::browsingMenu(const KUrl &currentUrl)
void NewTabPage::historyPage()
{
+ m_root.addClass("history");
+
HistoryTreeModel *model = Application::historyManager()->historyTreeModel();
int i = 0;
@@ -349,6 +366,8 @@ void NewTabPage::historyPage()
void NewTabPage::bookmarksPage()
{
+ m_root.addClass("bookmarks");
+
KBookmarkGroup bookGroup = Application::bookmarkProvider()->rootGroup();
if (bookGroup.isNull())
{
@@ -395,6 +414,8 @@ void NewTabPage::createBookItem(const KBookmark &bookmark, QWebElement parent)
void NewTabPage::closedTabsPage()
{
+ m_root.addClass("closedTabs");
+
QList<HistoryItem> links = Application::instance()->mainWindow()->mainView()->recentlyClosedTabs();
for(int i=0; i < links.count(); ++i)
diff --git a/src/rekonqpage/newtabpage.h b/src/rekonqpage/newtabpage.h
index 1057c7cc..9d41946e 100644
--- a/src/rekonqpage/newtabpage.h
+++ b/src/rekonqpage/newtabpage.h
@@ -56,7 +56,7 @@ public:
void generate(KUrl url = KUrl("about:home"));
public slots:
- void snapFinished();
+ void snapFinished(int index, KUrl url, QString title);
void removePreview(int index);
protected: // these are the function to build the new tab page
diff --git a/src/websnap.cpp b/src/websnap.cpp
index 983da716..11b70e9e 100644
--- a/src/websnap.cpp
+++ b/src/websnap.cpp
@@ -29,6 +29,9 @@
#include "websnap.h"
#include "websnap.moc"
+// Local Includes
+#include "newtabpage.h"
+
// KDE Includes
#include <KDebug>
#include <KStandardDirs>
@@ -42,10 +45,12 @@
#include <QFile>
-WebSnap::WebSnap(const QUrl &url)
+WebSnap::WebSnap(const QUrl& url, QWebPage* originatingPage, int previewIndex)
: QObject()
{
m_url = url;
+ m_originatingPage = originatingPage;
+ m_previewIndex = previewIndex;
// this to not register websnap history
m_page.settings()->setAttribute(QWebSettings::PrivateBrowsingEnabled, true);
@@ -120,18 +125,6 @@ KUrl WebSnap::fileForUrl(KUrl url)
}
-void WebSnap::SetData(QVariant data)
-{
- m_data = data;
-}
-
-QVariant& WebSnap::data()
-{
- return m_data;
-}
-
-
-
QString WebSnap::guessNameFromUrl(QUrl url)
{
QString name = url.toString( QUrl::RemoveScheme | QUrl::RemoveUserInfo | QUrl::StripTrailingSlash );
@@ -163,12 +156,16 @@ void WebSnap::saveResult(bool ok)
else
{
m_image = renderPreview(m_page, WIDTH, HEIGHT);
+ m_snapTitle = m_page.mainFrame()->title();
}
QFile::remove(fileForUrl(m_url).toLocalFile());
m_image.save(fileForUrl(m_url).toLocalFile());
- kDebug() << "finished";
- emit finished();
+ //m_originatingPage->mainFrame()->load(KUrl("about:preview/replace/" + QVariant(m_previewIndex).toString()));
+ NewTabPage p(m_originatingPage->mainFrame());
+ p.snapFinished(m_previewIndex, m_url, m_snapTitle);
+
+ deleteLater();
}
diff --git a/src/websnap.h b/src/websnap.h
index b8ada30f..e15c2dcf 100644
--- a/src/websnap.h
+++ b/src/websnap.h
@@ -51,7 +51,7 @@ class WebSnap : public QObject
Q_OBJECT
public:
- WebSnap(const QUrl &url);
+ WebSnap(const QUrl &url, QWebPage *originatingPage, int previewIndex);
~WebSnap();
QPixmap previewImage(); // TODO : remove
@@ -66,12 +66,6 @@ public:
QString snapTitle();
QUrl snapUrl();
-
- void SetData(QVariant data);
- QVariant& data();
-
-signals:
- void finished();
private slots:
void load();
@@ -84,7 +78,8 @@ private:
QUrl m_url;
QString m_snapTitle;
- QVariant m_data;
+ QWebPage *m_originatingPage;
+ int m_previewIndex;
};
#endif // WEB_SNAP_H