summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrea Diamantini <adjam7@gmail.com>2013-01-23 19:04:05 +0100
committerAndrea Diamantini <adjam7@gmail.com>2013-01-23 19:04:05 +0100
commitfacc2f92fe73d4e925510fcb2936483798efba6a (patch)
tree6e01c451eb3c84a6b6b0978c7a870c7df0bbb966 /src
parentRemove double "rekonq - rekonq" from title (diff)
downloadrekonq-facc2f92fe73d4e925510fcb2936483798efba6a.tar.xz
Improve icon management code
In the 1.x way, IconManager notified all the tabs about icons changed. This way, just the interested tab is :)
Diffstat (limited to 'src')
-rw-r--r--src/icons/iconmanager.cpp14
-rw-r--r--src/icons/iconmanager.h3
-rw-r--r--src/tabwindow/tabwindow.cpp30
-rw-r--r--src/tabwindow/tabwindow.h1
-rw-r--r--src/webtab/webpage.cpp3
-rw-r--r--src/webwindow/webwindow.cpp1
-rw-r--r--src/webwindow/webwindow.h3
7 files changed, 35 insertions, 20 deletions
diff --git a/src/icons/iconmanager.cpp b/src/icons/iconmanager.cpp
index 49d637ad..e0408577 100644
--- a/src/icons/iconmanager.cpp
+++ b/src/icons/iconmanager.cpp
@@ -115,27 +115,15 @@ void IconManager::provideIcon(QWebFrame *mFrame, const KUrl &url, bool notify)
{
// provide icons just for http/https sites
if (!url.scheme().startsWith(QL1S("http")))
- {
- if (notify)
- emit iconChanged();
return;
- }
// do not load new icons in private browsing..
if (mFrame->page()->settings()->testAttribute(QWebSettings::PrivateBrowsingEnabled))
- {
- if (notify)
- emit iconChanged();
return;
- }
// check if icon exists
if (!favIconForUrl(url).isEmpty())
- {
- if (notify)
- emit iconChanged();
return;
- }
// the simplest way..
const QString rootUrlString = url.scheme() + QL1S("://") + url.host();
@@ -165,7 +153,7 @@ void IconManager::provideIcon(QWebFrame *mFrame, const KUrl &url, bool notify)
IconDownloader *id = new IconDownloader(faviconUrl, destUrl, this);
if (notify)
- connect(id, SIGNAL(iconReady()), this, SIGNAL(iconChanged()));
+ connect(id, SIGNAL(iconReady()), mFrame, SIGNAL(iconChanged()));
}
diff --git a/src/icons/iconmanager.h b/src/icons/iconmanager.h
index 02ae6763..9f39f965 100644
--- a/src/icons/iconmanager.h
+++ b/src/icons/iconmanager.h
@@ -64,9 +64,6 @@ public:
void saveDesktopIconForUrl(const KUrl &u);
-Q_SIGNALS:
- void iconChanged();
-
private:
IconManager(QObject *parent = 0);
diff --git a/src/tabwindow/tabwindow.cpp b/src/tabwindow/tabwindow.cpp
index e0b6224a..4f58ce3e 100644
--- a/src/tabwindow/tabwindow.cpp
+++ b/src/tabwindow/tabwindow.cpp
@@ -247,6 +247,7 @@ WebWindow *TabWindow::prepareNewTab(WebPage *page)
WebWindow *tab = new WebWindow(this, _isPrivateBrowsing, page);
connect(tab, SIGNAL(titleChanged(QString)), this, SLOT(tabTitleChanged(QString)));
+ connect(tab, SIGNAL(iconChanged()), this, SLOT(tabIconChanged()));
connect(tab, SIGNAL(loadStarted()), this, SLOT(tabLoadStarted()));
connect(tab, SIGNAL(loadFinished(bool)), this, SLOT(tabLoadFinished(bool)));
@@ -409,6 +410,33 @@ void TabWindow::tabTitleChanged(const QString &title)
}
+void TabWindow::tabIconChanged()
+{
+ WebWindow *tab = qobject_cast<WebWindow *>(sender());
+ if (!tab)
+ return;
+
+ if (tab->isLoading())
+ return;
+
+ int index = indexOf(tab);
+
+ if (-1 == index)
+ return;
+
+ QLabel *label = qobject_cast<QLabel* >(tabBar()->tabButton(index, QTabBar::LeftSide));
+ if (!label)
+ {
+ label = new QLabel(this);
+ tabBar()->setTabButton(index, QTabBar::LeftSide, 0);
+ tabBar()->setTabButton(index, QTabBar::LeftSide, label);
+ }
+
+ KIcon ic = IconManager::self()->iconForUrl(tab->url());
+ label->setPixmap(ic.pixmap(16, 16));
+}
+
+
void TabWindow::tabLoadStarted()
{
WebWindow *tab = qobject_cast<WebWindow *>(sender());
@@ -604,6 +632,7 @@ void TabWindow::detachTab(int index, TabWindow *toWindow)
// WARNING: Code copied from prepareNewTab method.
// Any new changes there should be applied here...
disconnect(tab, SIGNAL(titleChanged(QString)), this, SLOT(tabTitleChanged(QString)));
+ disconnect(tab, SIGNAL(iconChanged()), this, SLOT(tabIconChanged()));
disconnect(tab, SIGNAL(loadStarted()), this, SLOT(tabLoadStarted()));
disconnect(tab, SIGNAL(loadFinished(bool)), this, SLOT(tabLoadFinished(bool)));
disconnect(tab, SIGNAL(pageCreated(WebPage*)), this, SLOT(pageCreated(WebPage*)));
@@ -612,6 +641,7 @@ void TabWindow::detachTab(int index, TabWindow *toWindow)
// WARNING: Code copied from prepareNewTab method.
// Any new changes there should be applied here...
connect(tab, SIGNAL(titleChanged(QString)), w, SLOT(tabTitleChanged(QString)));
+ connect(tab, SIGNAL(iconChanged()), w, SLOT(tabIconChanged()));
connect(tab, SIGNAL(loadStarted()), w, SLOT(tabLoadStarted()));
connect(tab, SIGNAL(loadFinished(bool)), w, SLOT(tabLoadFinished(bool)));
connect(tab, SIGNAL(pageCreated(WebPage*)), w, SLOT(pageCreated(WebPage*)));
diff --git a/src/tabwindow/tabwindow.h b/src/tabwindow/tabwindow.h
index c3df016c..3a00ac4a 100644
--- a/src/tabwindow/tabwindow.h
+++ b/src/tabwindow/tabwindow.h
@@ -92,6 +92,7 @@ private Q_SLOTS:
void updateNewTabButtonPosition();
void tabTitleChanged(const QString &);
+ void tabIconChanged();
void tabLoadStarted();
void tabLoadFinished(bool);
diff --git a/src/webtab/webpage.cpp b/src/webtab/webpage.cpp
index a501c4bb..958dc5c1 100644
--- a/src/webtab/webpage.cpp
+++ b/src/webtab/webpage.cpp
@@ -177,9 +177,6 @@ WebPage::WebPage(QWidget *parent, bool isPrivateBrowsing)
// protocol handler signals
connect(&_protHandler, SIGNAL(downloadUrl(KUrl)), this, SLOT(downloadUrl(KUrl)));
-
- // TODO: Remove me and implement an icon retriever for each tab
- connect(IconManager::self(), SIGNAL(iconChanged()), mainFrame(), SIGNAL(iconChanged()));
}
diff --git a/src/webwindow/webwindow.cpp b/src/webwindow/webwindow.cpp
index 33cb6142..73543374 100644
--- a/src/webwindow/webwindow.cpp
+++ b/src/webwindow/webwindow.cpp
@@ -122,6 +122,7 @@ WebWindow::WebWindow(QWidget *parent, bool isPrivateBrowsing, WebPage *pg)
// things changed signals
connect(_tab->view(), SIGNAL(titleChanged(QString)), this, SIGNAL(titleChanged(QString)));
+ connect(_tab->view(), SIGNAL(iconChanged()), this, SIGNAL(iconChanged()));
// check view signals
connect(_tab->view(), SIGNAL(loadStarted()), this, SLOT(webLoadStarted()));
diff --git a/src/webwindow/webwindow.h b/src/webwindow/webwindow.h
index e8e77dd7..de927305 100644
--- a/src/webwindow/webwindow.h
+++ b/src/webwindow/webwindow.h
@@ -145,7 +145,8 @@ private Q_SLOTS:
Q_SIGNALS:
void titleChanged(QString);
-
+ void iconChanged();
+
void loadStarted();
void loadProgress(int);
void loadFinished(bool);