summaryrefslogtreecommitdiff
path: root/src/urlbar
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/urlbar
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/urlbar')
-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
5 files changed, 37 insertions, 7 deletions
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);