1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 10:46:35 +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)
{
if (!validIndex(index) || m_isRestoring) {
if (!validIndex(index)) {
return;
}
@ -358,7 +358,7 @@ void TabBar::contextMenuEvent(QContextMenuEvent* event)
void TabBar::hideCloseButton(int index)
{
if (!validIndex(index) || tabsClosable() || m_isRestoring) {
if (!validIndex(index) || tabsClosable()) {
return;
}
@ -422,7 +422,7 @@ void TabBar::currentTabChanged(int index)
}
// Don't hide close buttons when dragging tabs
if (m_dragStartPosition.isNull()) {
if (m_dragStartPosition.isNull() && !m_isRestoring) {
showCloseButton(index);
if (m_lastTab) {
hideCloseButton(m_lastTab->tabIndex());
@ -436,6 +436,10 @@ void TabBar::currentTabChanged(int index)
void TabBar::setTabText(int index, const QString &text)
{
if (m_isRestoring) {
return;
}
QString tabText = text;
// Avoid Alt+letter shortcuts
@ -735,4 +739,9 @@ void TabBar::setIsRestoring(bool restoring)
m_isRestoring = restoring;
}
bool TabBar::isRestoring()
{
return m_isRestoring;
}
#include "tabbar.moc"

View File

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

View File

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