diff options
author | Lindsay Mathieson <lindsay.mathieson@gmail.com> | 2013-01-24 20:17:06 +1000 |
---|---|---|
committer | Lindsay Mathieson <lindsay.mathieson@gmail.com> | 2013-01-24 20:17:06 +1000 |
commit | a068a29d7c33211a5d4e5ebc1a0227feba158b65 (patch) | |
tree | c25dd2e9da9d5242390d2bce41e6292ca3f2df78 /src/tabwindow | |
parent | Added option for opening new tabs next to current (default to true). Otherwis... (diff) | |
parent | Improve icon management code (diff) | |
download | rekonq-a068a29d7c33211a5d4e5ebc1a0227feba158b65.tar.xz |
Merge branch 'master' of git.kde.org:rekonq
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); |