diff options
author | Andrea Diamantini <adjam7@gmail.com> | 2013-01-23 19:04:05 +0100 |
---|---|---|
committer | Andrea Diamantini <adjam7@gmail.com> | 2013-01-23 19:04:05 +0100 |
commit | facc2f92fe73d4e925510fcb2936483798efba6a (patch) | |
tree | 6e01c451eb3c84a6b6b0978c7a870c7df0bbb966 /src/tabwindow | |
parent | Remove double "rekonq - rekonq" from title (diff) | |
download | rekonq-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/tabwindow')
-rw-r--r-- | src/tabwindow/tabwindow.cpp | 30 | ||||
-rw-r--r-- | src/tabwindow/tabwindow.h | 1 |
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); |