summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormatgic78 <matgic78@gmail.com>2009-12-18 15:58:48 +0100
committermatgic78 <matgic78@gmail.com>2010-02-06 11:22:46 +0100
commitf1f7e2011c3f245cd1987b0f09b72c2f7dea283f (patch)
tree6cad61cbf826363713d54d06681ae91b0009bfa4 /src
parentRe-implemented previews in homepage without using plugins. Not finished yet : (diff)
downloadrekonq-f1f7e2011c3f245cd1987b0f09b72c2f7dea283f.tar.xz
Various changes:
- improve appearance of empty/loading previews - port closedTabs to new system - remove PreviewImage files TODO : dialog to choose preview
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt1
-rw-r--r--src/data/home.html22
-rw-r--r--src/previewimage.cpp430
-rw-r--r--src/previewimage.h101
-rw-r--r--src/rekonqpage/newtabpage.cpp84
-rw-r--r--src/rekonqpage/newtabpage.h9
-rw-r--r--src/webpluginfactory.cpp28
7 files changed, 79 insertions, 596 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index b0a3fbd8..2295e9e0 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -11,7 +11,6 @@ SET( rekonq_KDEINIT_SRCS
findbar.cpp
mainview.cpp
mainwindow.cpp
- previewimage.cpp
sessionmanager.cpp
tabbar.cpp
webpage.cpp
diff --git a/src/data/home.html b/src/data/home.html
index 8db3d894..103c559d 100644
--- a/src/data/home.html
+++ b/src/data/home.html
@@ -127,10 +127,12 @@ width:25%; margin-top: 7%;
min-width:250px; min-height:192px;
}
+.preview img {
+}
.preview {
-display: block;
-width: 200px;
-height: 150px;
+display: table-cell;
+vertical-align: middle;
+width: 200px; height: 150px;
padding: 14px 16px;
background: url(%2/bg.png) no-repeat;
-webkit-background-size: 100% 100%;
@@ -154,10 +156,10 @@ opacity: 0;
}
.remove {
- float: right;
+float: right;
}
.modify {
- float: left;
+float: left;
}
.title {
@@ -171,14 +173,10 @@ text-align: center;
.thumbnail a {
text-align:center;
}
-.thumbnail a:hover {
+.thumbnail a:hover, span {
color:#3F7AB7;
}
-.thumbnail span {
-
-}
-
/* -------------------------------------------------------- */
/* Bookmarks page*/
@@ -210,7 +208,9 @@ margin-bottom: 0.5em;
</div>
<div class="thumbnail">
<a>
- <img class="preview"></img>
+ <div class ="preview">
+ <img />
+ </div>
<div class="title">
<a class="button modify"><img /></a>
<span><a></a></span>
diff --git a/src/previewimage.cpp b/src/previewimage.cpp
deleted file mode 100644
index 9c8bb194..00000000
--- a/src/previewimage.cpp
+++ /dev/null
@@ -1,430 +0,0 @@
-/* ============================================================
-*
-* This file is a part of the rekonq project
-*
-* Copyright (C) 2009 by Andrea Diamantini <adjam7 at gmail dot com>
-*
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License as
-* published by the Free Software Foundation; either version 2 of
-* the License or (at your option) version 3 or any later version
-* accepted by the membership of KDE e.V. (or its successor approved
-* by the membership of KDE e.V.), which shall act as a proxy
-* defined in Section 14 of version 3 of the license.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see <http://www.gnu.org/licenses/>.
-*
-* ============================================================ */
-
-
-// Self Includes
-#include "previewimage.h"
-#include "previewimage.moc"
-
-// Local Includes
-#include "historymanager.h"
-#include "rekonq.h"
-#include "mainwindow.h"
-#include "mainview.h"
-
-// KDE Includes
-#include <KUrl>
-#include <KStandardDirs>
-#include <KDebug>
-#include <KMenu>
-#include <KAction>
-#include <KLocale>
-
-// Qt Includes
-#include <QFile>
-#include <QMovie>
-#include <QMouseEvent>
-#include <QHBoxLayout>
-#include <QVBoxLayout>
-#include <QPainter>
-
-
-PreviewImage::PreviewImage(const QUrl &url, const QString &title, int index, bool isFavorite)
- : QWidget()
- , ws(0)
- , loadingSnapshot(false)
- , m_url(url)
- , m_title(title)
- , m_isFavorite(isFavorite)
- , m_index(index)
- , m_button(0)
- , m_imageLabel(new QLabel)
- , m_textLabel(new QLabel)
- , m_backgroundLabel(new QLabel)
- , m_previewLabel(new QLabel)
-{
-
- int borderTop = 14;
- int borderRight = 16;
- int borderBottom = 14;
- int borderLeft = 16;
-
- int previewWidth = 200;
- int previewHeight = 150;
-
- int urlHeight = 18;
-
- m_size = QSize(borderLeft+previewWidth+borderRight, borderTop+previewHeight+borderBottom+urlHeight);
-
- setFixedSize(m_size);
- m_previewLabel->setFixedSize(m_size);
-
- m_backgroundLabel->setPixmap(renderBackground(previewWidth,previewHeight, borderTop, borderBottom, borderLeft, borderRight));
-
- m_previewLabel->setAlignment(Qt::AlignCenter);
- m_backgroundLabel->setAlignment(Qt::AlignCenter);
- m_imageLabel->setAlignment(Qt::AlignCenter);
- m_textLabel->setAlignment(Qt::AlignCenter);
-
- m_previewLabel->setLayout(new QVBoxLayout);
- m_previewLabel->layout()->setMargin(0);
- m_previewLabel->layout()->addWidget(m_backgroundLabel);
- m_previewLabel->layout()->addWidget(m_textLabel);
- m_previewLabel->setCursor(Qt::PointingHandCursor);
-
- m_backgroundLabel->setLayout(new QVBoxLayout);
- m_backgroundLabel->layout()->addWidget(m_imageLabel);
-
- setLayout(new QHBoxLayout);
- layout()->setMargin(0);
- layout()->setAlignment(Qt::AlignCenter);
- layout()->addWidget(m_previewLabel);
-
- connect(this, SIGNAL(loadUrl(const KUrl &, const Rekonq::OpenType &)),
- Application::instance(), SLOT(loadUrl(const KUrl &, const Rekonq::OpenType &)));
-
- loadUrlPreview(url);
-}
-
-
-PreviewImage::~PreviewImage()
-{
- delete ws;
- delete m_textLabel;
- delete m_imageLabel;
- delete m_backgroundLabel;
- delete m_previewLabel;
-}
-
-
-QPixmap PreviewImage::renderBackground(int w, int h, int t, int b, int l, int r)
-{
- QImage backImage(KStandardDirs::locate("appdata", "pics/bg.png"));
- QImage resultImage(QSize(w + l + r, h + t + b), QImage::Format_ARGB32_Premultiplied);
-
- if (!backImage.isNull())
- {
- int sw = backImage.width() - l - r;
- int sh = backImage.height() - t - b;
- QPainter pt(&resultImage);
- pt.setCompositionMode(QPainter::CompositionMode_Source);
- pt.fillRect(resultImage.rect(), Qt::transparent);
- pt.drawImage(QRect(0, 0, l, t), backImage, QRect(0, 0, l, t));
- pt.drawImage(QRect(l, 0, w, t), backImage, QRect(l, 0, sw, t));
- pt.drawImage(QRect(l + w, 0, r, t), backImage, QRect(l + sw, 0, r, t));
- pt.drawImage(QRect(0, t, l, h), backImage, QRect(0, t, l, sh));
- pt.drawImage(QRect(l, t, w, h), backImage, QRect(l, t, sw, sh));
- pt.drawImage(QRect(l + w, t, r, h), backImage, QRect(l + sw, t, r, sh));
- pt.drawImage(QRect(0, t + h, l , b), backImage, QRect(0, t + sh, l , b));
- pt.drawImage(QRect(l, t + h, w, b), backImage, QRect(l, t + sh, sw, b));
- pt.drawImage(QRect(l + w, t + h, w, b), backImage, QRect(l + sw, t + sh, sw, b));
- pt.end();
- }
-
- return QPixmap::fromImage(resultImage);
-}
-
-
-void PreviewImage::loadUrlPreview(const QUrl& url)
-{
- m_url = url;
-
- if(url.isEmpty())
- {
- showEmptyPreview();
- return;
- }
-
- m_previewLabel->setFixedSize(m_size); //unhide
-
- m_savePath = KStandardDirs::locateLocal("cache", QString("thumbs/") + guessNameFromUrl(m_url) + ".png", true);
-
- if(QFile::exists(m_savePath))
- {
- m_pixmap.load(m_savePath);
- m_imageLabel->setPixmap(m_pixmap);
- checkTitle();
- m_textLabel->setText(m_title);
- }
- else
- {
- loadingSnapshot = true;
- ws = new WebSnap( url );
- connect(ws, SIGNAL(finished()), this, SLOT(snapFinished()));
-
- QString path = KStandardDirs::locate("appdata", "pics/busywidget.gif");
-
- // load an animation waiting for site preview
- QMovie *movie = new QMovie(path, QByteArray(), this);
- movie->setSpeed(50);
- m_imageLabel->setMovie(movie);
- movie->start();
- m_textLabel->setText( i18n("Loading preview...") );
- setCursor(Qt::BusyCursor);
- }
-}
-
-
-void PreviewImage::snapFinished()
-{
- loadingSnapshot = false;
- QMovie *m = m_imageLabel->movie();
- delete m;
- m_imageLabel->setMovie(0);
-
- m_pixmap = ws->previewImage();
- m_imageLabel->setPixmap(m_pixmap);
- checkTitle();
- m_textLabel->setText(m_title);
-
- setCursor(Qt::PointingHandCursor);
-
- m_pixmap.save(m_savePath);
-
- if(m_index > -1)
- {
- // Update title
- QStringList names = ReKonfig::previewNames();
- // update url (for added thumbs)
- QStringList urls = ReKonfig::previewUrls();
-
- // stripTrailingSlash to be sure to get the same string for same address
- urls.replace(m_index, ws->snapUrl().toString(QUrl::StripTrailingSlash));
- names.replace(m_index, ws->snapTitle());
-
- ReKonfig::setPreviewNames(names);
- ReKonfig::setPreviewUrls(urls);
-
- ReKonfig::self()->writeConfig();
- }
-}
-
-
-void PreviewImage::showEmptyPreview()
-{
- if(!m_isFavorite)
- return;
-
- m_imageLabel->clear();
- m_textLabel->clear();
-
- m_previewLabel->setFixedSize(0,0); //hide
-
-
- m_button = new QToolButton();
- m_button->setDefaultAction(historyMenu());
- m_button->setPopupMode(QToolButton::InstantPopup);
- m_button->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
- m_button->setText(i18n("Add Preview"));
- m_button->setAutoRaise(true);
- m_button->setIconSize(QSize(48, 48));
- layout()->addWidget(m_button);
-}
-
-
-void PreviewImage::mouseDoubleClickEvent(QMouseEvent *event)
-{
- kDebug() << "no double click over here, thanks :D";
- Q_UNUSED(event);
-}
-
-
-void PreviewImage::mouseMoveEvent(QMouseEvent *event)
-{
- kDebug() << "moving mouse over preview image";
- Q_UNUSED(event)
-}
-
-
-void PreviewImage::mousePressEvent(QMouseEvent *event)
-{
- if(event->button() == Qt::LeftButton)
- {
- emit loadUrl(m_url, Rekonq::CurrentTab);
- return;
- }
- else if(event->button() == Qt::MidButton)
- {
- emit loadUrl(m_url, Rekonq::SettingOpenTab);
- return;
- }
-
- QWidget::mousePressEvent(event);
-}
-
-
-void PreviewImage::mouseReleaseEvent(QMouseEvent *event)
-{
- kDebug() << "NO000... don't leave your finger from the button!!";
- Q_UNUSED(event)
-}
-
-
-void PreviewImage::contextMenuEvent(QContextMenuEvent* event)
-{
- if(!m_isFavorite)
- return;
-
- if(loadingSnapshot)
- return;
-
- KMenu menu(this);
- KAction *a;
-
- if(!m_url.isEmpty())
- {
- a = new KAction(KIcon("edit-delete"), i18n("Remove Thumbnail"), this);
- connect(a, SIGNAL(triggered(bool)), this, SLOT(removeMe()));
- menu.addAction(a);
-
- a = new KAction(KIcon("view-refresh"), i18n("Refresh Thumbnail"), &menu);
- connect(a, SIGNAL(triggered(bool)), this, SLOT(refreshPreview()));
- menu.addAction(a);
- }
- menu.addAction(historyMenu());
-
- menu.exec(mapToGlobal(event->pos()));
-}
-
-
-KActionMenu* PreviewImage::historyMenu()
-{
- KActionMenu *histMenu = new KActionMenu(KIcon("insert-image"), i18n("Set Page to Preview"), this);
- QList<HistoryItem> history = Application::historyManager()->history();
-
- if(history.isEmpty())
- {
- KAction *a = new KAction(i18n("History is Empty"), this);
- a->setEnabled(false);
- histMenu->addAction(a);
- return histMenu;
- }
-
- int maxItems = 15;
- for (int i = 0; i < maxItems && i < history.size() ; ++i)
- {
- HistoryItem it = history.at(i);
- KAction *a = new KAction(Application::icon(it.url), it.title, this);
- QStringList urlData;
- urlData << it.url << it.title;
- a->setData(urlData);
- connect(a, SIGNAL(triggered(bool)), this, SLOT(setUrlFromAction()));
- histMenu->addAction(a);
- }
-
- return histMenu;
-}
-
-
-void PreviewImage::removeMe()
-{
- QStringList names = ReKonfig::previewNames();
- QStringList urls = ReKonfig::previewUrls();
-
- int index = urls.indexOf(QRegExp(m_url.toString(QUrl::StripTrailingSlash), Qt::CaseSensitive, QRegExp::FixedString));
-
- urls.replace(index, QString(""));
- names.replace(index, QString(""));
-
- ReKonfig::setPreviewNames(names);
- ReKonfig::setPreviewUrls(urls);
-
- // sync file data
- ReKonfig::self()->writeConfig();
-
- showEmptyPreview();
-
- m_url = "";
-}
-
-
-void PreviewImage::setUrlFromAction()
-{
- KAction *a = qobject_cast<KAction*>(sender());
- QStringList urlData = a->data().toStringList();
-
- m_url = KUrl(urlData.at(0));
- m_title = urlData.at(1);
- checkTitle();
-
- if(m_button)
- {
- m_imageLabel->layout()->deleteLater();
- m_button->menu()->deleteLater();
- m_button->deleteLater();
- }
- loadUrlPreview(m_url);
-
- // Update title
- QStringList names = ReKonfig::previewNames();
- // update url (for added thumbs)
- QStringList urls = ReKonfig::previewUrls();
-
- // stripTrailingSlash to be sure to get the same string for same address
- urls.replace(m_index, m_url.toString(QUrl::StripTrailingSlash));
- names.replace(m_index, m_title);
-
- ReKonfig::setPreviewNames(names);
- ReKonfig::setPreviewUrls(urls);
-
- ReKonfig::self()->writeConfig();
-}
-
-
-void PreviewImage::refreshPreview()
-{
- QString path = KStandardDirs::locateLocal("cache", QString("thumbs/") + guessNameFromUrl(m_url) + ".png", true);
- QFile::remove(path);
- loadUrlPreview(m_url);
-}
-
-
-QString PreviewImage::guessNameFromUrl(QUrl url)
-{
- QString name = url.toString( QUrl::RemoveScheme | QUrl::RemoveUserInfo | QUrl::StripTrailingSlash );
-
- // TODO learn Regular Expressions :)
- // and implement something better here..
- name.remove('/');
- name.remove('&');
- name.remove('.');
- name.remove('-');
- name.remove('_');
- name.remove('?');
- name.remove('=');
- name.remove('+');
-
- return name;
-}
-
-
-void PreviewImage::checkTitle()
-{
- if(m_title.length() > 23)
- {
- m_title.truncate(20);
- m_title += "...";
- }
-}
diff --git a/src/previewimage.h b/src/previewimage.h
deleted file mode 100644
index 4dd8df3b..00000000
--- a/src/previewimage.h
+++ /dev/null
@@ -1,101 +0,0 @@
-/* ============================================================
-*
-* This file is a part of the rekonq project
-*
-* Copyright (C) 2009 by Andrea Diamantini <adjam7 at gmail dot com>
-*
-*
-* This program is free software; you can redistribute it and/or
-* modify it under the terms of the GNU General Public License as
-* published by the Free Software Foundation; either version 2 of
-* the License or (at your option) version 3 or any later version
-* accepted by the membership of KDE e.V. (or its successor approved
-* by the membership of KDE e.V.), which shall act as a proxy
-* defined in Section 14 of version 3 of the license.
-*
-* This program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with this program. If not, see <http://www.gnu.org/licenses/>.
-*
-* ============================================================ */
-
-
-#ifndef PREVIEW_IMAGE_H
-#define PREVIEW_IMAGE_H
-
-// Local Includes
-#include "websnap.h"
-#include "application.h"
-
-// KDE Includes
-#include <KActionMenu>
-
-// Qt Includes
-#include <QLabel>
-#include <QFrame>
-#include <QImage>
-#include <QUrl>
-#include <QToolButton>
-#include <QSize>
-
-
-class PreviewImage : public QWidget
-{
- Q_OBJECT
-
-public:
- PreviewImage(const QUrl &url, const QString &title, int index, bool isFavorite);
- ~PreviewImage();
-
- QString guessNameFromUrl(QUrl url);
-
-public slots:
- void snapFinished();
- void removeMe();
- void setUrlFromAction();
- void refreshPreview();
-
-signals:
- void loadUrl(const KUrl &, const Rekonq::OpenType &);
-
-protected:
- void contextMenuEvent(QContextMenuEvent *event);
- void mouseDoubleClickEvent(QMouseEvent *event);
- void mouseMoveEvent(QMouseEvent *event);
- void mousePressEvent(QMouseEvent *event);
- void mouseReleaseEvent(QMouseEvent *event);
-
- void loadUrlPreview(const QUrl &url);
- KActionMenu *historyMenu();
- void showEmptyPreview();
-
-private:
- void checkTitle();
- QPixmap renderBackground(int w, int h, int t, int b, int l, int r);
-
- QPixmap m_pixmap;
- WebSnap *ws;
-
- QString m_savePath;
- bool loadingSnapshot;
-
- QUrl m_url;
- QString m_title;
- bool m_isFavorite;
- int m_index;
-
- QToolButton *m_button;
-
- QLabel *m_imageLabel;
- QLabel *m_textLabel;
- QLabel *m_backgroundLabel;
- QLabel *m_previewLabel;
-
- QSize m_size;
-};
-
-#endif // PREVIEW_IMAGE_H
diff --git a/src/rekonqpage/newtabpage.cpp b/src/rekonqpage/newtabpage.cpp
index 4299c8bb..a587502c 100644
--- a/src/rekonqpage/newtabpage.cpp
+++ b/src/rekonqpage/newtabpage.cpp
@@ -80,6 +80,10 @@ void NewTabPage::generate(const KUrl &url)
removePreview(url.fileName().toInt());
return;
}
+ if(url.directory() == QString("preview/modify"))
+ {
+ return;
+ }
}
@@ -125,28 +129,31 @@ void NewTabPage::favoritesPage()
for(int i=0; i<8; ++i)
{
- QWebElement speed;
+ KUrl url = urls.at(i);
+ QWebElement prev;
- if(urls.at(i).isEmpty())
- speed = emptyPreview();
- else if(!QFile::exists(WebSnap::fileForUrl(urls.at(i)).toLocalFile()))
- speed = loadingPreview(i, urls.at(i));
+ if(url.isEmpty())
+ prev = emptyPreview(i);
+ else if(!QFile::exists(WebSnap::fileForUrl(url).toLocalFile()))
+ prev = loadingPreview(i, url);
else
- speed = validPreview(i, urls.at(i), names.at(i));
+ prev = validPreview(i, url, names.at(i));
- speed.setAttribute("id", "preview" + QVariant(i).toString());
- m_root.appendInside(speed);
+ prev.setAttribute("id", "preview" + QVariant(i).toString());
+ m_root.appendInside(prev);
}
}
-QWebElement NewTabPage::emptyPreview()
+QWebElement NewTabPage::emptyPreview(int index)
{
QWebElement prev = markup(".thumbnail");
- prev.findFirst("img").setAttribute("src" , QString("file:///") +
+ 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()));
+ hideControls(prev);
return prev;
}
@@ -156,9 +163,11 @@ QWebElement NewTabPage::loadingPreview(int index, KUrl url)
{
QWebElement prev = markup(".thumbnail");
- prev.findFirst("img").setAttribute("src" ,
- QString("file:///") + KStandardDirs::locate("appdata", "pics/busywidget.gif"));
+ prev.findFirst(".preview img").setAttribute("src" ,
+ QString("file:///") + KStandardDirs::locate("appdata", "pics/busywidget.gif"));
prev.findFirst("span").appendInside(i18n("Loading Preview..."));
+ showControls(prev);
+
WebSnap *snap = new WebSnap(url);
snap->SetData(QVariant(index));
connect(snap, SIGNAL(finished()), SLOT(snapFinished()));
@@ -172,29 +181,43 @@ QWebElement NewTabPage::validPreview(int index, KUrl url, QString title)
KUrl previewPath = WebSnap::fileForUrl(url);
QString iString = QVariant(index).toString();
- prev.findFirst(".preview").setAttribute("src" , previewPath.toMimeDataString());
+ 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 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));
+ 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));
+ KIconLoader::global()->iconPath("edit-delete", KIconLoader::DefaultState));
prev.findFirst(".remove").setAttribute("href", QString("about:preview/remove/" + iString ));
+ showControls(prev);
+
+
return prev;
}
+void NewTabPage::hideControls(QWebElement e)
+{
+ e.findFirst(".remove").setStyleProperty("visibility", "hidden");
+ e.findFirst(".modify").setStyleProperty("visibility", "hidden");
+}
+void NewTabPage::showControls(QWebElement e)
+{
+ e.findFirst(".remove").setStyleProperty("visibility", "visible");
+ e.findFirst(".modify").setStyleProperty("visibility", "visible");
+}
+
+
void NewTabPage::snapFinished()
{
WebSnap *snap = qobject_cast<WebSnap*>(sender());
- QWebElement thumb = m_root.findFirst("#preview" + snap->data().toString());
- thumb.findFirst("img").setAttribute("src", WebSnap::fileForUrl(snap->snapUrl()).toMimeDataString());
- thumb.findFirst("p").setPlainText(snap->snapTitle());
+ QWebElement prev = m_root.findFirst("#preview" + snap->data().toString());
+ prev.replace(validPreview(snap->data().toInt(), snap->snapUrl(), snap->snapTitle()));
// Save the new config
QStringList names = ReKonfig::previewNames();
@@ -228,7 +251,7 @@ void NewTabPage::removePreview(int index)
// sync file data
ReKonfig::self()->writeConfig();
- prev.replace(emptyPreview());
+ prev.replace(emptyPreview(index));
}
@@ -357,13 +380,22 @@ void NewTabPage::createBookItem(const KBookmark &bookmark, QWebElement parent)
void NewTabPage::closedTabsPage()
{
QList<HistoryItem> links = Application::instance()->mainWindow()->mainView()->recentlyClosedTabs();
-
- foreach(const HistoryItem &item, links)
+
+ for(int i=0; i < links.count(); ++i)
{
- QWebElement closed = markup(".thumbnail");
- closed.findFirst("object").setAttribute("data" , item.url);
- closed.findFirst("param[name=title]").setAttribute("value", item.title);
- m_root.appendInside(closed);
+ HistoryItem item = links.at(i);
+ QWebElement prev;
+
+ if(item.url.isEmpty())
+ continue;
+ else if(!QFile::exists(WebSnap::fileForUrl(item.url).toLocalFile()))
+ prev = loadingPreview(i, item.url);
+ else
+ prev = validPreview(i, item.url, item.title);
+
+ prev.setAttribute("id", "preview" + QVariant(i).toString());
+ hideControls(prev);
+ m_root.appendInside(prev);
}
}
diff --git a/src/rekonqpage/newtabpage.h b/src/rekonqpage/newtabpage.h
index 84880a10..9ac743ea 100644
--- a/src/rekonqpage/newtabpage.h
+++ b/src/rekonqpage/newtabpage.h
@@ -63,10 +63,17 @@ protected: // these are the function to build the new tab page
void browsingMenu(const KUrl &currentUrl);
void favoritesPage();
- QWebElement emptyPreview();
+ QWebElement emptyPreview(int index);
QWebElement loadingPreview(int index, KUrl url);
QWebElement validPreview(int index, KUrl url, QString title);
+ /** This function takes a QwebElement with the .thumbnail structure.
+ It hides the "remove" and "modify" buttons->
+ */
+ void hideControls(QWebElement e);
+ void showControls(QWebElement e);
+
+
void historyPage();
void bookmarksPage();
void closedTabsPage();
diff --git a/src/webpluginfactory.cpp b/src/webpluginfactory.cpp
index aec4e18d..ac18fece 100644
--- a/src/webpluginfactory.cpp
+++ b/src/webpluginfactory.cpp
@@ -32,7 +32,6 @@
#include "rekonq.h"
#include "application.h"
#include "mainwindow.h"
-#include "previewimage.h"
#include "clicktoflash.h"
// KDE Includes
@@ -65,27 +64,7 @@ QObject *WebPluginFactory::create(const QString &mimeType,
const QStringList &argumentValues) const
{
kDebug() << "loading mimeType: " << mimeType;
-
- if(mimeType == QString("application/image-preview") )
- {
- QString title;
- int number = -1;
- bool isFavorite = false;
-
- int i;
- i = argumentNames.indexOf( QString("title") );
- if(i > -1)
- title = argumentValues.at(i);
- i = argumentNames.indexOf( QString("isFavorite") );
- if(i > -1)
- isFavorite = true;
- i = argumentNames.indexOf( QString("index") );
- if(i > -1)
- number = argumentValues.at(i).toInt();
-
- return new PreviewImage(url, title, number, isFavorite);
- }
-
+
if(ReKonfig::pluginsEnabled() == 0) // plugins are enabled
{
kDebug() << "No plugins found for" << mimeType << ". Falling back to QtWebKit ones...";
@@ -112,10 +91,7 @@ QList<QWebPluginFactory::Plugin> WebPluginFactory::plugins() const
{
QList<KWebPluginFactory::Plugin> plugins = KWebPluginFactory::plugins();
- QWebPluginFactory::Plugin p;
- p.name = "application/image-preview";
- p.description = "plugin for embedding Web snapped images";
- plugins.append(p);
+ KWebPluginFactory::Plugin p;
p.name = "application/x-shockwave-flash";
p.description = "Plugin for flash animations";