summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2010-08-28 19:24:19 +0200
committerAndrea Diamantini <adjam7@gmail.com>2010-08-28 19:24:19 +0200
commitf0c11eadaa4b77a4e36130b014b62cd6200c8211 (patch)
tree556625dc98766a444ea2b916e76446c2cb379357 /src
parentMerge commit 'refs/merge-requests/192' of git://gitorious.org/rekonq/mainline (diff)
downloadrekonq-f0c11eadaa4b77a4e36130b014b62cd6200c8211.tar.xz
Switching to "KDE" icon cache. While this "brute force" change can be dangerous,
it seems let everything work as expected (at least here). It also lets us to retrieve icons when sites are not visited (eg: search engines or old bookmarks) It also contains fixes & improvements for icons management in History & Bookmarks classes. More code to maintain, but more things working.Let's see what'll happen...
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt4
-rw-r--r--src/application.cpp39
-rw-r--r--src/application.h9
-rw-r--r--src/bookmarks/bookmarkprovider.cpp4
-rw-r--r--src/bookmarks/bookmarkstreemodel.cpp5
-rw-r--r--src/history/historymodels.cpp3
-rw-r--r--src/iconmanager.cpp154
-rw-r--r--src/iconmanager.h61
-rw-r--r--src/mainview.cpp6
-rw-r--r--src/mainwindow.cpp5
-rw-r--r--src/protocolhandler.cpp1
-rw-r--r--src/search/searchengine.cpp10
-rw-r--r--src/tabbar.cpp3
-rw-r--r--src/urlbar/listitem.cpp18
-rw-r--r--src/urlbar/listitem.h2
-rw-r--r--src/urlbar/rsswidget.cpp3
-rw-r--r--src/urlbar/urlbar.cpp19
-rw-r--r--src/urlbar/urlbar.h2
-rw-r--r--src/webicon.cpp74
-rw-r--r--src/webicon.h58
-rw-r--r--src/webpage.cpp22
-rw-r--r--src/webpage.h1
-rw-r--r--src/webtab.cpp6
-rw-r--r--src/webview.cpp3
24 files changed, 439 insertions, 73 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 03c1e062..95995183 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -11,7 +11,7 @@ SET( rekonq_KDEINIT_SRCS
clicktoflash.cpp
filterurljob.cpp
findbar.cpp
- zoombar.cpp
+ iconmanager.cpp
mainview.cpp
mainwindow.cpp
networkaccessmanager.cpp
@@ -22,6 +22,7 @@ SET( rekonq_KDEINIT_SRCS
sessionmanager.cpp
tabbar.cpp
walletbar.cpp
+ webicon.cpp
webinspectorpanel.cpp
webpage.cpp
webpluginfactory.cpp
@@ -29,6 +30,7 @@ SET( rekonq_KDEINIT_SRCS
websnap.cpp
webview.cpp
webtab.cpp
+ zoombar.cpp
#----------------------------------------
history/autosaver.cpp
history/historymanager.cpp
diff --git a/src/application.cpp b/src/application.cpp
index df4c3d51..d66e290f 100644
--- a/src/application.cpp
+++ b/src/application.cpp
@@ -43,6 +43,7 @@
#include "sessionmanager.h"
#include "adblockmanager.h"
#include "opensearchmanager.h"
+#include "iconmanager.h"
#include "webview.h"
#include "filterurljob.h"
#include "tabbar.h"
@@ -66,6 +67,7 @@ QWeakPointer<BookmarkProvider> Application::s_bookmarkProvider;
QWeakPointer<SessionManager> Application::s_sessionManager;
QWeakPointer<AdBlockManager> Application::s_adblockManager;
QWeakPointer<OpenSearchManager> Application::s_opensearchManager;
+QWeakPointer<IconManager> Application::s_iconManager;
Application::Application()
@@ -250,10 +252,6 @@ void Application::postLaunch()
setWindowIcon(KIcon("rekonq"));
- // set Icon Database Path to store "favicons" associated with web sites
- QString directory = KStandardDirs::locateLocal("cache" , "" , true);
- QWebSettings::setIconDatabasePath(directory);
-
Application::historyManager();
Application::sessionManager();
@@ -331,38 +329,13 @@ OpenSearchManager *Application::opensearchManager()
}
-KIcon Application::icon(const KUrl &url)
+IconManager *Application::iconManager()
{
- // avoid infinite loop at startup
- if (Application::instance()->mainWindowList().isEmpty())
- return KIcon("text-html");
-
- // first things first..
- if (url.isEmpty())
- return KIcon("text-html");
-
- QByteArray encodedUrl = url.toEncoded();
- // rekonq icons..
- if (encodedUrl == QByteArray("about:home"))
- return KIcon("go-home");
- if (encodedUrl == QByteArray("about:closedTabs"))
- return KIcon("tab-close");
- if (encodedUrl == QByteArray("about:history"))
- return KIcon("view-history");
- if (encodedUrl == QByteArray("about:bookmarks"))
- return KIcon("bookmarks");
- if (encodedUrl == QByteArray("about:favorites"))
- return KIcon("emblem-favorite");
- if (encodedUrl == QByteArray("about:downloads"))
- return KIcon("download");
-
- KIcon icon = KIcon(QWebSettings::iconForUrl(url));
- if (icon.isNull())
+ if (s_iconManager.isNull())
{
- kDebug() << "null icon";
- icon = KIcon("text-html");
+ s_iconManager = new IconManager(instance());
}
- return icon;
+ return s_iconManager.data();
}
diff --git a/src/application.h b/src/application.h
index a08d883c..26f5cf74 100644
--- a/src/application.h
+++ b/src/application.h
@@ -52,6 +52,7 @@ class HistoryManager;
class MainWindow;
class SessionManager;
class AdBlockManager;
+class IconManager;
class WebView;
@@ -107,14 +108,13 @@ public:
MainWindow *newMainWindow(bool withTab = true);
MainWindowList mainWindowList();
- static KIcon icon(const KUrl &url);
-
static HistoryManager *historyManager();
static BookmarkProvider *bookmarkProvider();
static SessionManager *sessionManager();
static AdBlockManager *adblockManager();
static OpenSearchManager *opensearchManager();
-
+ static IconManager *iconManager();
+
// DOWNLOADS MANAGEMENT METHODS
void addDownload(const QString &srcUrl, const QString &destUrl);
DownloadList downloads();
@@ -152,7 +152,8 @@ private:
static QWeakPointer<SessionManager> s_sessionManager;
static QWeakPointer<AdBlockManager> s_adblockManager;
static QWeakPointer<OpenSearchManager> s_opensearchManager;
-
+ static QWeakPointer<IconManager> s_iconManager;
+
MainWindowList m_mainWindows;
};
diff --git a/src/bookmarks/bookmarkprovider.cpp b/src/bookmarks/bookmarkprovider.cpp
index ec02ed31..3459108d 100644
--- a/src/bookmarks/bookmarkprovider.cpp
+++ b/src/bookmarks/bookmarkprovider.cpp
@@ -39,6 +39,7 @@
// KDE Includes
#include <KActionCollection>
#include <KStandardDirs>
+#include <KMimeType>
// Qt Includes
#include <QtCore/QFile>
@@ -230,7 +231,8 @@ void BookmarkProvider::fillBookmarkBar(BookmarkToolBar *toolBar)
void BookmarkProvider::slotAddBookmark()
{
- rootGroup().addBookmark(bookmarkOwner()->currentTitle(), bookmarkOwner()->currentUrl());
+ QString url = bookmarkOwner()->currentUrl();
+ rootGroup().addBookmark(bookmarkOwner()->currentTitle(), url, KMimeType::favIconForUrl( KUrl(url) ) );
bookmarkManager()->emitChanged();
}
diff --git a/src/bookmarks/bookmarkstreemodel.cpp b/src/bookmarks/bookmarkstreemodel.cpp
index ee19daf1..ba106ca5 100644
--- a/src/bookmarks/bookmarkstreemodel.cpp
+++ b/src/bookmarks/bookmarkstreemodel.cpp
@@ -62,8 +62,11 @@ QVariant BtmItem::data(int role) const
return m_kbm.text();
if (role == Qt::DecorationRole)
+ {
+ kDebug() << "BOOKMARK ICON: " << m_kbm.icon();
return KIcon(m_kbm.icon());
-
+ }
+
if (role == Qt::UserRole)
return m_kbm.url();
diff --git a/src/history/historymodels.cpp b/src/history/historymodels.cpp
index 9da755c5..a820db0f 100644
--- a/src/history/historymodels.cpp
+++ b/src/history/historymodels.cpp
@@ -35,6 +35,7 @@
// Local Includes
#include "application.h"
+#include "iconmanager.h"
// KDE Includes
#include <KStandardDirs>
@@ -144,7 +145,7 @@ QVariant HistoryModel::data(const QModelIndex &index, int role) const
case Qt::DecorationRole:
if (index.column() == 0)
{
- return Application::icon(item.url);
+ return Application::iconManager()->iconForUrl(item.url);
}
case Qt::ToolTipRole:
QString tooltip = "";
diff --git a/src/iconmanager.cpp b/src/iconmanager.cpp
new file mode 100644
index 00000000..694af6a5
--- /dev/null
+++ b/src/iconmanager.cpp
@@ -0,0 +1,154 @@
+/* ============================================================
+*
+* This file is a part of the rekonq project
+*
+* Copyright (C) 2010 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 "iconmanager.h"
+#include "iconmanager.moc"
+
+// Local Includes
+#include "application.h"
+#include "webicon.h"
+
+// KDE Includes
+#include <kmimetype.h>
+#include <KStandardDirs>
+
+// Qt Includes
+#include <QDBusInterface>
+#include <QDBusReply>
+#include <QWebElement>
+#include <QWebFrame>
+#include <QAction>
+
+
+IconManager::IconManager(QObject *parent)
+ : QObject(parent)
+{
+}
+
+
+IconManager::~IconManager()
+{
+}
+
+
+KIcon IconManager::iconForUrl(const KUrl &url)
+{
+ // first things first.. avoid infinite loop at startup
+ if (url.isEmpty() || Application::instance()->mainWindowList().isEmpty())
+ return KIcon("text-html");
+
+ QByteArray encodedUrl = url.toEncoded();
+ // rekonq icons..
+ if (encodedUrl == QByteArray("about:home"))
+ return KIcon("go-home");
+ if (encodedUrl == QByteArray("about:closedTabs"))
+ return KIcon("tab-close");
+ if (encodedUrl == QByteArray("about:history"))
+ return KIcon("view-history");
+ if (encodedUrl == QByteArray("about:bookmarks"))
+ return KIcon("bookmarks");
+ if (encodedUrl == QByteArray("about:favorites"))
+ return KIcon("emblem-favorite");
+ if (encodedUrl == QByteArray("about:downloads"))
+ return KIcon("download");
+
+ QString i = KMimeType::favIconForUrl(url);
+ QString faviconDir = KStandardDirs::locateLocal("cache" , "" , true);
+ if(!i.isEmpty())
+ {
+ return KIcon(faviconDir + i);
+ }
+ kDebug() << "Icon NOT Found. returning text-html one";
+
+ return KIcon("text-html");
+}
+
+
+void IconManager::provideIcon(QWebPage *page, const KUrl &url, bool notify)
+{
+ if(url.scheme() == QL1S("about"))
+ {
+ kDebug() << "URL: " << url << ". about scheme. Aborting...";
+ return;
+ }
+ QUrl u(url.url());
+ QString rootUrlString = u.toString( QUrl::RemovePassword
+ | QUrl::RemoveUserInfo
+ | QUrl::RemovePath
+ | QUrl::RemoveQuery
+ | QUrl::StripTrailingSlash);
+
+ // check if icon exists
+ if(!KMimeType::favIconForUrl(url).isEmpty())
+ {
+ kDebug() << "icon JUST present. Aborting...";
+ if(notify)
+ emit iconChanged();
+ return;
+ }
+
+ // find ico url
+ KUrl iconUrl(rootUrlString + QL1S("/favicon.ico"));
+
+ QWebElement root = page->mainFrame()->documentElement();
+ QWebElement e = root.findFirst(QL1S("link[rel~=\"icon\"]"));
+ QString relUrlString = e.attribute(QL1S("href"));
+ if(relUrlString.isEmpty())
+ {
+ e = root.findFirst(QL1S("link[rel~=\"shortcut icon\"]"));
+ relUrlString = e.attribute(QL1S("href"));
+ }
+
+ if(!relUrlString.isEmpty())
+ {
+ iconUrl = relUrlString.startsWith("http")
+ ? KUrl(relUrlString)
+ : KUrl(rootUrlString + relUrlString) ;
+ }
+
+ kDebug() << "ICON URL: " << iconUrl;
+
+ QString faviconDir = KStandardDirs::locateLocal("cache" , "favicons/" , true);
+
+ int r = rootUrlString.indexOf(':');
+ kDebug() << rootUrlString;
+ kDebug() << r;
+
+ KUrl destUrl(faviconDir + rootUrlString.mid(r+3) + ".png");
+ kDebug() << "DEST URL: " << destUrl;
+
+ // download icon
+ KIO::Job *job = KIO::file_copy(iconUrl, destUrl, -1, KIO::HideProgressInfo);
+ if(notify)
+ connect(job, SIGNAL(result(KJob*)), this, SIGNAL(iconChanged()));
+}
+
+
+void IconManager::downloadIconFromUrl(const KUrl &url)
+{
+ new WebIcon(url, this);
+}
diff --git a/src/iconmanager.h b/src/iconmanager.h
new file mode 100644
index 00000000..794e61bd
--- /dev/null
+++ b/src/iconmanager.h
@@ -0,0 +1,61 @@
+/* ============================================================
+*
+* This file is a part of the rekonq project
+*
+* Copyright (C) 2010 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 ICON_MANAGER_H
+#define ICON_MANAGER_H
+
+// Rekonq Includes
+#include "rekonq_defines.h"
+
+// KDE Includes
+#include <KUrl>
+#include <KIcon>
+#include <KIO/Job>
+
+// Qt Includes
+#include <QWebPage>
+
+
+class REKONQ_TESTS_EXPORT IconManager : public QObject
+{
+ Q_OBJECT
+
+public:
+ IconManager(QObject *parent = 0);
+ virtual ~IconManager();
+
+ KIcon iconForUrl(const KUrl &url);
+
+ void provideIcon(QWebPage *page, const KUrl &url, bool notify = true);
+
+ void downloadIconFromUrl(const KUrl &url);
+
+Q_SIGNALS:
+ void iconChanged();
+};
+
+
+#endif // ICON_MANAGER_H
diff --git a/src/mainview.cpp b/src/mainview.cpp
index dc759c9e..75d98b39 100644
--- a/src/mainview.cpp
+++ b/src/mainview.cpp
@@ -38,6 +38,7 @@
#include "tabbar.h"
#include "urlbar.h"
#include "sessionmanager.h"
+#include "iconmanager.h"
// KDE Includes
#include <KUrl>
@@ -322,7 +323,6 @@ WebTab *MainView::newWebTab(bool focused)
// connecting webview with mainview
connect(tab->view(), SIGNAL(loadStarted()), this, SLOT(webViewLoadStarted()));
connect(tab->view(), SIGNAL(loadFinished(bool)), this, SLOT(webViewLoadFinished(bool)));
- connect(tab->view(), SIGNAL(iconChanged()), this, SLOT(webViewIconChanged()));
connect(tab->view(), SIGNAL(titleChanged(const QString &)), this, SLOT(webViewTitleChanged(const QString &)));
connect(tab->view(), SIGNAL(urlChanged(const QUrl &)), this, SLOT(webViewUrlChanged(const QUrl &)));
@@ -576,7 +576,7 @@ void MainView::webViewIconChanged()
int index = indexOf(view->parentWidget());
if (-1 != index)
{
- KIcon icon = Application::icon(view->url());
+ KIcon icon = Application::iconManager()->iconForUrl(view->url());
QLabel *label = animatedLoading(index, false);
QMovie *movie = label->movie();
delete movie;
@@ -725,7 +725,7 @@ void MainView::detachTab(int index, MainWindow *toWindow)
w = Application::instance()->newMainWindow(false);
else
w = toWindow;
- w->mainView()->addTab(tab, Application::icon(u), label);
+ w->mainView()->addTab(tab, Application::iconManager()->iconForUrl(u), label);
w->mainView()->widgetBar()->insertWidget(0, bar);
w->mainView()->updateTabBar();
}
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index 44cc6d59..5bacb699 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -50,6 +50,7 @@
#include "tabbar.h"
#include "adblockmanager.h"
#include "analyzerpanel.h"
+#include "iconmanager.h"
// Ui Includes
#include "ui_cleardata.h"
@@ -1233,7 +1234,7 @@ void MainWindow::aboutToShowBackMenu()
QWebHistoryItem item = history->currentItem();
KAction *action = new KAction(this);
action->setData(listCount + offset++);
- KIcon icon = Application::icon(item.url());
+ KIcon icon = Application::iconManager()->iconForUrl(item.url());
action->setIcon(icon);
action->setText(item.title());
m_historyBackMenu->addAction(action);
@@ -1244,7 +1245,7 @@ void MainWindow::aboutToShowBackMenu()
QWebHistoryItem item = historyList.at(i);
KAction *action = new KAction(this);
action->setData(i + offset);
- KIcon icon = Application::icon(item.url());
+ KIcon icon = Application::iconManager()->iconForUrl(item.url());
action->setIcon(icon);
action->setText(item.title());
m_historyBackMenu->addAction(action);
diff --git a/src/protocolhandler.cpp b/src/protocolhandler.cpp
index 5cc09f44..d52433bc 100644
--- a/src/protocolhandler.cpp
+++ b/src/protocolhandler.cpp
@@ -108,6 +108,7 @@ bool ProtocolHandler::preHandling(const QNetworkRequest &request, QWebFrame *fra
return false;
}
+ kDebug() << "EVALUATING JAVASCRIPT...";
QVariant result = frame->evaluateJavaScript(scriptSource);
return true;
}
diff --git a/src/search/searchengine.cpp b/src/search/searchengine.cpp
index 7065d55f..38f063a4 100644
--- a/src/search/searchengine.cpp
+++ b/src/search/searchengine.cpp
@@ -27,6 +27,8 @@
//local includes
#include "searchengine.h"
+#include "application.h"
+#include "iconmanager.h"
// Auto Includes
#include "rekonq.h"
@@ -59,7 +61,13 @@ void SearchEngine::reload()
{
service = KService::serviceByDesktopPath(QString("searchproviders/%1.desktop").arg(engine));
if (service)
- favorites << service;
+ {
+ QUrl url = service->property("Query").toUrl();
+ kDebug() << "ENGINE URL: " << url;
+ Application::iconManager()->downloadIconFromUrl(url);
+
+ favorites << service;
+ }
}
m_favorites = favorites;
diff --git a/src/tabbar.cpp b/src/tabbar.cpp
index 98243e71..f4da2e54 100644
--- a/src/tabbar.cpp
+++ b/src/tabbar.cpp
@@ -39,6 +39,7 @@
#include "webtab.h"
#include "websnap.h"
#include "mainview.h"
+#include "iconmanager.h"
// KDE Includes
#include <KShortcut>
@@ -379,7 +380,7 @@ void TabBar::setupHistoryActions()
foreach (const HistoryItem &item, mv->recentlyClosedTabs())
{
- KAction *a = new KAction(Application::icon(item.url), item.title, this);
+ KAction *a = new KAction(Application::iconManager()->iconForUrl(item.url), item.title, this);
a->setData(item.url);
connect(a, SIGNAL(triggered()), mv, SLOT(openClosedTab()));
am->addAction(a);
diff --git a/src/urlbar/listitem.cpp b/src/urlbar/listitem.cpp
index 5bd2253f..6c09f9a5 100644
--- a/src/urlbar/listitem.cpp
+++ b/src/urlbar/listitem.cpp
@@ -37,6 +37,7 @@
#include "websnap.h"
#include "completionwidget.h"
#include "searchengine.h"
+#include "iconmanager.h"
// KDE Includes
#include <KIcon>
@@ -187,12 +188,20 @@ QLabel *TypeIconLabel::getIcon(QString icon)
IconLabel::IconLabel(const QString &icon, QWidget *parent)
: QLabel(parent)
{
- QPixmap pixmapIcon = Application::icon(KUrl(icon)).pixmap(16);
+ QPixmap pixmapIcon = Application::iconManager()->iconForUrl(KUrl(icon)).pixmap(16);
setFixedSize(16, 16);
setPixmap(pixmapIcon);
}
+IconLabel::IconLabel(const KIcon &icon, QWidget *parent)
+ : QLabel(parent)
+{
+ QPixmap pixmapIcon = icon.pixmap(16);
+ setFixedSize(16, 16);
+ setPixmap(pixmapIcon);
+}
+
// ---------------------------------------------------------------
@@ -294,7 +303,8 @@ SearchListItem::SearchListItem(const UrlSearchItem &item, const QString &text, Q
m_url = SearchEngine::buildQuery(engine, query);
- m_iconLabel = new IconLabel("edit-find", this); //TODO: get the default engine icon (will be easy in KDE SC 4.5)
+ KIcon icon = Application::iconManager()->iconForUrl( SearchEngine::defaultEngine()->property("Query").toUrl() );
+ m_iconLabel = new IconLabel(icon, this); //TODO: get the default engine icon (will be easy in KDE SC 4.5)
m_titleLabel = new TextLabel(searchItemTitle(engine->name(), query), query, this);
m_engineBar = new EngineBar(engine, parent);
@@ -328,7 +338,7 @@ QString SearchListItem::searchItemTitle(QString engine, QString text)
void SearchListItem::changeSearchEngine(KService::Ptr engine)
{
m_titleLabel->setText(searchItemTitle(engine->name(), m_text));
- m_iconLabel->setPixmap(Application::icon(KUrl(engine->property("Query").toString())).pixmap(16));
+ m_iconLabel->setPixmap( Application::iconManager()->iconForUrl(KUrl(engine->property("Query").toString())).pixmap(16) );
m_url = SearchEngine::buildQuery(engine, m_text);
qobject_cast<CompletionWidget *>(parent())->setSearchEngine(engine);
}
@@ -371,7 +381,7 @@ KAction *EngineBar::newEngineAction(KService::Ptr engine, KService::Ptr selected
KUrl url = KUrl( u.toString( QUrl::RemovePath | QUrl::RemoveQuery ) );
kDebug() << "Engine NAME: " << engine->name() << " URL: " << url;
- KAction *a = new KAction(Application::icon(url), engine->name(), this);
+ KAction *a = new KAction(Application::iconManager()->iconForUrl(url), engine->name(), this);
a->setCheckable(true);
if (engine->desktopEntryName() == selectedEngine->desktopEntryName()) a->setChecked(true);
a->setData(engine->entryPath());
diff --git a/src/urlbar/listitem.h b/src/urlbar/listitem.h
index 06a02b80..37b22f47 100644
--- a/src/urlbar/listitem.h
+++ b/src/urlbar/listitem.h
@@ -37,6 +37,7 @@
// KDE Includes
#include <KToolBar>
#include <KService>
+#include <KIcon>
// Qt Includes
#include <QWidget>
@@ -107,6 +108,7 @@ class IconLabel : public QLabel
public:
explicit IconLabel(const QString &icon, QWidget *parent = 0);
+ explicit IconLabel(const KIcon &icon, QWidget *parent = 0);
};
diff --git a/src/urlbar/rsswidget.cpp b/src/urlbar/rsswidget.cpp
index 6cd63b95..25587502 100644
--- a/src/urlbar/rsswidget.cpp
+++ b/src/urlbar/rsswidget.cpp
@@ -33,6 +33,7 @@
#include "mainwindow.h"
#include "webtab.h"
#include "webview.h"
+#include "iconmanager.h"
// KDE Includes
#include <KLocalizedString>
@@ -75,7 +76,7 @@ RSSWidget::RSSWidget(const QMap< KUrl, QString > &map, QWidget *parent)
m_agregators->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
m_agregators->addItem(KIcon("akregator"), QString("Akregator"));
- m_agregators->addItem(Application::icon(KUrl("http://google.com/reader")), i18n("Google Reader"));
+ m_agregators->addItem(Application::iconManager()->iconForUrl(KUrl("http://google.com/reader")), i18n("Google Reader"));
layout->addRow(agregator, m_agregators);
diff --git a/src/urlbar/urlbar.cpp b/src/urlbar/urlbar.cpp
index 65c0a213..0b966b74 100644
--- a/src/urlbar/urlbar.cpp
+++ b/src/urlbar/urlbar.cpp
@@ -43,6 +43,7 @@
#include "completionwidget.h"
#include "bookmarkprovider.h"
#include "bookmarkwidget.h"
+#include "iconmanager.h"
// KDE Includes
#include <KBookmarkManager>
@@ -110,7 +111,8 @@ UrlBar::UrlBar(QWidget *parent)
connect(_tab->view(), SIGNAL(urlChanged(const QUrl &)), this, SLOT(setQUrl(const QUrl &)));
connect(_tab->view(), SIGNAL(loadFinished(bool)), this, SLOT(loadFinished()));
connect(_tab->view(), SIGNAL(loadStarted()), this, SLOT(clearRightIcons()));
-
+ connect(_tab->view(), SIGNAL(iconChanged()), this, SLOT(refreshFavicon()));
+
// bookmark icon
connect(Application::bookmarkProvider()->bookmarkManager(), SIGNAL(changed(const QString &, const QString &)), this, SLOT(onBookmarksChanged()));
@@ -145,7 +147,7 @@ void UrlBar::setQUrl(const QUrl& url)
clearFocus();
KLineEdit::setUrl(url);
setCursorPosition(0);
- _icon->setIcon(Application::icon(url));
+ refreshFavicon();
}
}
@@ -494,3 +496,16 @@ void UrlBar::suggest()
if(!_box.isNull())
_box.data()->suggestUrls( text() );
}
+
+
+void UrlBar::refreshFavicon()
+{
+ kDebug() << "------------------ REFRESH ME!!! -------------";
+// if( u.scheme() == QL1S("about") )
+// {
+// kDebug() << "ABOUT SCHEME...";
+// return;
+// }
+
+ _icon->setIcon(Application::iconManager()->iconForUrl(_tab->view()->url()));
+}
diff --git a/src/urlbar/urlbar.h b/src/urlbar/urlbar.h
index 8808661b..6e05ea7e 100644
--- a/src/urlbar/urlbar.h
+++ b/src/urlbar/urlbar.h
@@ -108,6 +108,8 @@ private slots:
void showBookmarkInfo(const QPoint &pos);
void onBookmarksChanged();
+ void refreshFavicon();
+
protected:
void paintEvent(QPaintEvent *event);
void keyPressEvent(QKeyEvent *event);
diff --git a/src/webicon.cpp b/src/webicon.cpp
new file mode 100644
index 00000000..2aa35a41
--- /dev/null
+++ b/src/webicon.cpp
@@ -0,0 +1,74 @@
+/* ============================================================
+*
+* This file is a part of the rekonq project
+*
+* Copyright (C) 2010 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 "webicon.h"
+#include "webicon.moc"
+
+// Local Includes
+#include "application.h"
+#include "iconmanager.h"
+
+// Qt Includes
+#include <QtCore/QTimer>
+#include <QtGui/QAction>
+#include <QtWebKit/QWebFrame>
+#include <QtWebKit/QWebSettings>
+
+
+WebIcon::WebIcon(const KUrl& url, QObject *parent)
+ : QObject(parent)
+ , m_url(url)
+{
+ m_page.settings()->setAttribute(QWebSettings::PluginsEnabled, false);
+ m_page.settings()->setAttribute(QWebSettings::JavascriptEnabled, false);
+ m_page.settings()->setAttribute(QWebSettings::PrivateBrowsingEnabled, true);
+
+ connect(&m_page, SIGNAL(loadFinished(bool)), this, SLOT(saveIcon(bool)));
+ QTimer::singleShot(0, this, SLOT(load()));
+}
+
+
+WebIcon::~WebIcon()
+{
+ m_page.action(QWebPage::Stop)->trigger();
+ m_page.deleteLater();
+}
+
+
+void WebIcon::load()
+{
+ m_page.mainFrame()->load(m_url);
+}
+
+
+void WebIcon::saveIcon(bool b)
+{
+ if(b)
+ Application::iconManager()->provideIcon(&m_page, m_url, false);
+
+ this->deleteLater();
+}
diff --git a/src/webicon.h b/src/webicon.h
new file mode 100644
index 00000000..d8b20e10
--- /dev/null
+++ b/src/webicon.h
@@ -0,0 +1,58 @@
+/* ============================================================
+*
+* This file is a part of the rekonq project
+*
+* Copyright (C) 2010 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 WEB_ICON_H
+#define WEB_ICON_H
+
+// Rekonq Includes
+#include "rekonq_defines.h"
+
+// KDE Includes
+#include <KUrl>
+#include <KIcon>
+
+// Qt Includes
+#include <QWebPage>
+
+
+class REKONQ_TESTS_EXPORT WebIcon : public QObject
+{
+ Q_OBJECT
+
+public:
+ explicit WebIcon(const KUrl &url, QObject *parent = 0);
+ ~WebIcon();
+
+private slots:
+ void load();
+ void saveIcon(bool);
+
+private:
+ QWebPage m_page;
+ KUrl m_url;
+};
+
+#endif //WEB_ICON_H
diff --git a/src/webpage.cpp b/src/webpage.cpp
index 9167c96d..fbccbbe5 100644
--- a/src/webpage.cpp
+++ b/src/webpage.cpp
@@ -46,7 +46,7 @@
#include "networkaccessmanager.h"
#include "adblockmanager.h"
#include "urlbar.h"
-//#include "websnap.h"
+#include "iconmanager.h"
#include "sslinfodialog_p.h"
@@ -212,9 +212,12 @@ WebPage::WebPage(QWidget *parent)
// ----- last stuffs
connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(manageNetworkErrors(QNetworkReply*)));
connect(this, SIGNAL(loadFinished(bool)), this, SLOT(loadFinished(bool)));
+ connect(this, SIGNAL(loadStarted()), this, SLOT(loadStarted()));
// protocol handler signals
connect(&_protHandler, SIGNAL(downloadUrl(const KUrl &)), this, SLOT(downloadUrl(const KUrl &)));
+
+ connect(Application::iconManager(), SIGNAL(iconChanged()), mainFrame(), SIGNAL(iconChanged()));
}
@@ -473,10 +476,17 @@ void WebPage::handleUnsupportedContent(QNetworkReply *reply)
}
+void WebPage::loadStarted()
+{
+ Application::iconManager()->provideIcon(this, _loadingUrl);
+}
+
+
void WebPage::loadFinished(bool ok)
{
Q_UNUSED(ok);
+
Application::adblockManager()->applyHidingRules(this);
QStringList list = ReKonfig::walletBlackList();
@@ -488,16 +498,6 @@ void WebPage::loadFinished(bool ok)
{
wallet()->fillFormData(mainFrame());
}
-
-/* this dead code is for try WebSnap::renderVisiblePagePreview()
- if (ok)
- {
- QPixmap preview = WebSnap::renderVisiblePagePreview(*this);
- QString path = WebSnap::imagePathFromUrl(mainFrame()->url().toString());
- QFile::remove(path);
- preview.save(path);
- }
-*/
}
diff --git a/src/webpage.h b/src/webpage.h
index f3d201c2..f9f4d9bf 100644
--- a/src/webpage.h
+++ b/src/webpage.h
@@ -83,6 +83,7 @@ private slots:
void handleUnsupportedContent(QNetworkReply *reply);
void manageNetworkErrors(QNetworkReply *reply);
void loadFinished(bool);
+ void loadStarted();
void showSSLInfo(QPoint);
void updateImage(bool ok);
diff --git a/src/webtab.cpp b/src/webtab.cpp
index d5c5b478..2826123d 100644
--- a/src/webtab.cpp
+++ b/src/webtab.cpp
@@ -133,12 +133,6 @@ void WebTab::updateProgress(int p)
void WebTab::loadFinished(bool)
{
m_progress = 0;
- if(_walletBar.isNull())
- {
- kDebug() << "OK, it's null";
- }
- else
- kDebug() << "NO, it's NOT null";
}
diff --git a/src/webview.cpp b/src/webview.cpp
index 49ca66df..2c800036 100644
--- a/src/webview.cpp
+++ b/src/webview.cpp
@@ -39,6 +39,7 @@
#include "bookmarkprovider.h"
#include "searchengine.h"
#include "websnap.h"
+#include "iconmanager.h"
// KDE Includes
#include <KService>
@@ -203,7 +204,7 @@ void WebView::contextMenuEvent(QContextMenuEvent *event)
foreach(KService::Ptr engine, SearchEngine::favorites())
{
a = new KAction(engine->name(), this);
- a->setIcon(Application::icon(SearchEngine::buildQuery(engine, "")));
+ a->setIcon(Application::iconManager()->iconForUrl(SearchEngine::buildQuery(engine, "")));
a->setData(engine->entryPath());
connect(a, SIGNAL(triggered(bool)), this, SLOT(search()));
searchMenu->addAction(a);