summaryrefslogtreecommitdiff
path: root/src/rekonqpage/newtabpage.cpp
diff options
context:
space:
mode:
authormatgic78 <matgic78@gmail.com>2009-12-26 13:00:53 +0100
committermatgic78 <matgic78@gmail.com>2010-02-06 11:22:46 +0100
commit18b87086d1a0e472662f3883962b60dbe57e215f (patch)
tree05642e5ccafe858222463e2bfddaad850c05de95 /src/rekonqpage/newtabpage.cpp
parentVarious changes: (diff)
downloadrekonq-18b87086d1a0e472662f3883962b60dbe57e215f.tar.xz
First expermimental implementation of a new way of choosing a preview
Diffstat (limited to 'src/rekonqpage/newtabpage.cpp')
-rw-r--r--src/rekonqpage/newtabpage.cpp57
1 files changed, 45 insertions, 12 deletions
diff --git a/src/rekonqpage/newtabpage.cpp b/src/rekonqpage/newtabpage.cpp
index a587502c..c91af2dc 100644
--- a/src/rekonqpage/newtabpage.cpp
+++ b/src/rekonqpage/newtabpage.cpp
@@ -36,6 +36,7 @@
#include "application.h"
#include "mainwindow.h"
#include "mainview.h"
+#include "previewchooser.h"
// KDE Includes
#include <KStandardDirs>
@@ -43,6 +44,7 @@
#include <KDebug>
#include <KConfig>
#include <KConfigGroup>
+#include <KDialog>
// Qt Includes
#include <QFile>
@@ -82,6 +84,9 @@ void NewTabPage::generate(const KUrl &url)
}
if(url.directory() == QString("preview/modify"))
{
+ PreviewChooser *pc = new PreviewChooser(url.fileName().toInt());
+ connect(pc, SIGNAL(urlChoosed(int,KUrl)), SLOT(setPreview(int,KUrl)));
+ pc->show();
return;
}
}
@@ -139,7 +144,8 @@ void NewTabPage::favoritesPage()
else
prev = validPreview(i, url, names.at(i));
- prev.setAttribute("id", "preview" + QVariant(i).toString());
+ setupPreview(prev, i);
+
m_root.appendInside(prev);
}
}
@@ -152,7 +158,9 @@ QWebElement NewTabPage::emptyPreview(int index)
prev.findFirst(".preview img").setAttribute("src" , QString("file:///") +
KIconLoader::global()->iconPath("insert-image", KIconLoader::Desktop));
prev.findFirst("span").appendInside(i18n("Set a Preview..."));
- prev.findFirst("a").setAttribute("href", QString("about:/preview/modify/" + QVariant(index).toString()));
+ prev.findFirst("a").setAttribute("href", QString("about:preview/modify/" + QVariant(index).toString()));
+
+ setupPreview(prev, index);
hideControls(prev);
return prev;
@@ -166,6 +174,8 @@ 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..."));
+
+ setupPreview(prev, index);
showControls(prev);
WebSnap *snap = new WebSnap(url);
@@ -184,19 +194,11 @@ QWebElement NewTabPage::validPreview(int index, KUrl url, QString title)
prev.findFirst(".preview img").setAttribute("src" , previewPath.toMimeDataString());
prev.findFirst("a").setAttribute("href", url.toMimeDataString());
prev.findFirst("span a").setAttribute("href", url.toMimeDataString());
- prev.findFirst("span").appendInside(checkTitle(title));
-
- prev.findFirst(".modify img").setAttribute("src", QString("file:///") +
- KIconLoader::global()->iconPath("insert-image", KIconLoader::DefaultState));
- prev.findFirst(".modify").setAttribute("href", QString("about:preview/modify/" + iString ));
-
- prev.findFirst(".remove img").setAttribute("src", QString("file:///") +
- KIconLoader::global()->iconPath("edit-delete", KIconLoader::DefaultState));
- prev.findFirst(".remove").setAttribute("href", QString("about:preview/remove/" + iString ));
+ prev.findFirst("span").setPlainText(checkTitle(title));
+ setupPreview(prev, index);
showControls(prev);
-
return prev;
}
@@ -212,6 +214,19 @@ void NewTabPage::showControls(QWebElement e)
e.findFirst(".modify").setStyleProperty("visibility", "visible");
}
+void NewTabPage::setupPreview(QWebElement e, int index)
+{
+ e.findFirst(".remove img").setAttribute("src", QString("file:///") +
+ KIconLoader::global()->iconPath("edit-delete", KIconLoader::DefaultState));
+ e.findFirst(".modify img").setAttribute("src", QString("file:///") +
+ KIconLoader::global()->iconPath("insert-image", KIconLoader::DefaultState));
+
+ e.findFirst(".modify").setAttribute("href", QString("about:preview/modify/" + QVariant(index).toString()));
+ e.findFirst(".remove").setAttribute("href", QString("about:preview/remove/" + QVariant(index).toString()));
+
+ e.setAttribute("id", "preview" + QVariant(index).toString());
+}
+
void NewTabPage::snapFinished()
{
@@ -255,6 +270,24 @@ 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());
+
+ QStringList urls = ReKonfig::previewUrls();
+ urls.replace(index, url.toMimeDataString());
+ ReKonfig::setPreviewUrls(urls);
+ ReKonfig::self()->writeConfig();
+
+ prev.replace(loadingPreview(index, url));
+
+
+}
+
+
void NewTabPage::browsingMenu(const KUrl &currentUrl)
{
QList<QWebElement> navItems;