mirror of
https://invent.kde.org/system/dolphin
synced 2024-09-17 15:31:20 +00:00
[Tab Bar] Resolve tab icon only if visible
Calling KIO::iconNameForUrl will determine mime type of the file potentially blocking. Don't needless do it when the tab bar isn't visible. Differential Revision: https://phabricator.kde.org/D23295
This commit is contained in:
parent
41f7f4e4e8
commit
63c195b7ed
|
@ -171,7 +171,7 @@ void DolphinTabWidget::openNewTab(const QUrl& primaryUrl, const QUrl& secondaryU
|
||||||
if (tabPlacement == AfterCurrentTab) {
|
if (tabPlacement == AfterCurrentTab) {
|
||||||
newTabIndex = currentIndex() + 1;
|
newTabIndex = currentIndex() + 1;
|
||||||
}
|
}
|
||||||
insertTab(newTabIndex, tabPage, QIcon::fromTheme(KIO::iconNameForUrl(primaryUrl)), tabName(tabPage));
|
insertTab(newTabIndex, tabPage, QIcon() /* loaded in tabInserted */, tabName(tabPage));
|
||||||
|
|
||||||
if (focusWidget) {
|
if (focusWidget) {
|
||||||
// The DolphinViewContainer grabbed the keyboard focus. As the tab is opened
|
// The DolphinViewContainer grabbed the keyboard focus. As the tab is opened
|
||||||
|
@ -324,7 +324,12 @@ void DolphinTabWidget::tabUrlChanged(const QUrl& url)
|
||||||
const int index = indexOf(qobject_cast<QWidget*>(sender()));
|
const int index = indexOf(qobject_cast<QWidget*>(sender()));
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
tabBar()->setTabText(index, tabName(tabPageAt(index)));
|
tabBar()->setTabText(index, tabName(tabPageAt(index)));
|
||||||
|
if (tabBar()->isVisible()) {
|
||||||
tabBar()->setTabIcon(index, QIcon::fromTheme(KIO::iconNameForUrl(url)));
|
tabBar()->setTabIcon(index, QIcon::fromTheme(KIO::iconNameForUrl(url)));
|
||||||
|
} else {
|
||||||
|
// Mark as dirty, actually load once the tab bar actually gets shown
|
||||||
|
tabBar()->setTabIcon(index, QIcon());
|
||||||
|
}
|
||||||
|
|
||||||
// Emit the currentUrlChanged signal if the url of the current tab has been changed.
|
// Emit the currentUrlChanged signal if the url of the current tab has been changed.
|
||||||
if (index == currentIndex()) {
|
if (index == currentIndex()) {
|
||||||
|
@ -352,6 +357,13 @@ void DolphinTabWidget::tabInserted(int index)
|
||||||
QTabWidget::tabInserted(index);
|
QTabWidget::tabInserted(index);
|
||||||
|
|
||||||
if (count() > 1) {
|
if (count() > 1) {
|
||||||
|
// Resolve all pending tab icons
|
||||||
|
for (int i = 0; i < count(); ++i) {
|
||||||
|
if (tabBar()->tabIcon(i).isNull()) {
|
||||||
|
tabBar()->setTabIcon(i, QIcon::fromTheme(KIO::iconNameForUrl(tabPageAt(i)->activeViewContainer()->url())));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
tabBar()->show();
|
tabBar()->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue