summaryrefslogtreecommitdiff
path: root/src/tabwindow
diff options
context:
space:
mode:
Diffstat (limited to 'src/tabwindow')
-rw-r--r--src/tabwindow/tabwindow.cpp30
-rw-r--r--src/tabwindow/tabwindow.h1
2 files changed, 31 insertions, 0 deletions
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);