1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-21 03:06:34 +01:00

SessionRestore: Set tab title after at the end

This change saves a lot of recalculations which is done after each tab
is added.

Signed-off-by: Juraj Oravec <jurajoravec@mailo.com>
This commit is contained in:
Juraj Oravec 2023-07-21 00:58:15 +02:00
parent b3b413c660
commit 24e6fe3d38
Signed by: SGOrava
GPG Key ID: 13660A3F1D9F093B
3 changed files with 27 additions and 10 deletions

View File

@ -326,7 +326,7 @@ WebTab* TabBar::webTab(int index) const
void TabBar::showCloseButton(int index) void TabBar::showCloseButton(int index)
{ {
if (!validIndex(index) || m_isRestoring) { if (!validIndex(index)) {
return; return;
} }
@ -358,7 +358,7 @@ void TabBar::contextMenuEvent(QContextMenuEvent* event)
void TabBar::hideCloseButton(int index) void TabBar::hideCloseButton(int index)
{ {
if (!validIndex(index) || tabsClosable() || m_isRestoring) { if (!validIndex(index) || tabsClosable()) {
return; return;
} }
@ -422,7 +422,7 @@ void TabBar::currentTabChanged(int index)
} }
// Don't hide close buttons when dragging tabs // Don't hide close buttons when dragging tabs
if (m_dragStartPosition.isNull()) { if (m_dragStartPosition.isNull() && !m_isRestoring) {
showCloseButton(index); showCloseButton(index);
if (m_lastTab) { if (m_lastTab) {
hideCloseButton(m_lastTab->tabIndex()); hideCloseButton(m_lastTab->tabIndex());
@ -436,6 +436,10 @@ void TabBar::currentTabChanged(int index)
void TabBar::setTabText(int index, const QString &text) void TabBar::setTabText(int index, const QString &text)
{ {
if (m_isRestoring) {
return;
}
QString tabText = text; QString tabText = text;
// Avoid Alt+letter shortcuts // Avoid Alt+letter shortcuts
@ -735,4 +739,9 @@ void TabBar::setIsRestoring(bool restoring)
m_isRestoring = restoring; m_isRestoring = restoring;
} }
bool TabBar::isRestoring()
{
return m_isRestoring;
}
#include "tabbar.moc" #include "tabbar.moc"

View File

@ -44,6 +44,7 @@ public:
void wheelEvent(QWheelEvent* event) override; void wheelEvent(QWheelEvent* event) override;
void setIsRestoring(bool restoring); void setIsRestoring(bool restoring);
bool isRestoring();
Q_SIGNALS: Q_SIGNALS:
void moveAddTabButton(int posX); void moveAddTabButton(int posX);

View File

@ -507,17 +507,19 @@ void TabWidget::currentTabChanged(int index)
m_lastBackgroundTab = nullptr; m_lastBackgroundTab = nullptr;
m_currentTabFresh = false; m_currentTabFresh = false;
WebTab* webTab = weTab(index); if (!m_tabBar->isRestoring()) {
webTab->tabActivated(); WebTab* webTab = weTab(index);
webTab->tabActivated();
LocationBar* locBar = webTab->locationBar(); LocationBar* locBar = webTab->locationBar();
if (locBar && m_locationBars->indexOf(locBar) != -1) { if (locBar && m_locationBars->indexOf(locBar) != -1) {
m_locationBars->setCurrentWidget(locBar); m_locationBars->setCurrentWidget(locBar);
}
m_window->currentTabChanged();
} }
m_window->currentTabChanged();
Q_EMIT changed(); Q_EMIT changed();
} }
@ -874,6 +876,11 @@ bool TabWidget::restoreState(const QVector<WebTab::SavedTab> &tabs, int currentT
m_tabBar->setIsRestoring(false); m_tabBar->setIsRestoring(false);
auto const l_allTabs = allTabs();
for (const WebTab* tab : l_allTabs) {
m_tabBar->setTabText(tab->tabIndex(), tab->title());
}
setCurrentIndex(currentTab); setCurrentIndex(currentTab);
QTimer::singleShot(0, m_tabBar, SLOT(ensureVisible(int,int))); QTimer::singleShot(0, m_tabBar, SLOT(ensureVisible(int,int)));