From b3b413c6605a9d0f10c63fd1cdd844836bbfe8f1 Mon Sep 17 00:00:00 2001 From: Juraj Oravec Date: Sun, 16 Apr 2023 15:02:55 +0200 Subject: [PATCH] Skip show/hide close button when restoring session BUG: 455012 Signed-off-by: Juraj Oravec --- src/lib/tabwidget/tabbar.cpp | 9 +++++++-- src/lib/tabwidget/tabbar.h | 4 ++++ src/lib/tabwidget/tabwidget.cpp | 4 ++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/lib/tabwidget/tabbar.cpp b/src/lib/tabwidget/tabbar.cpp index 45ee719d7..dc012c007 100644 --- a/src/lib/tabwidget/tabbar.cpp +++ b/src/lib/tabwidget/tabbar.cpp @@ -326,7 +326,7 @@ WebTab* TabBar::webTab(int index) const void TabBar::showCloseButton(int index) { - if (!validIndex(index)) { + if (!validIndex(index) || m_isRestoring) { return; } @@ -358,7 +358,7 @@ void TabBar::contextMenuEvent(QContextMenuEvent* event) void TabBar::hideCloseButton(int index) { - if (!validIndex(index) || tabsClosable()) { + if (!validIndex(index) || tabsClosable() || m_isRestoring) { return; } @@ -730,4 +730,9 @@ void TabBar::dropEvent(QDropEvent* event) } } +void TabBar::setIsRestoring(bool restoring) +{ + m_isRestoring = restoring; +} + #include "tabbar.moc" diff --git a/src/lib/tabwidget/tabbar.h b/src/lib/tabwidget/tabbar.h index 84c6ca5ec..7e967aea2 100644 --- a/src/lib/tabwidget/tabbar.h +++ b/src/lib/tabwidget/tabbar.h @@ -43,6 +43,8 @@ public: void wheelEvent(QWheelEvent* event) override; + void setIsRestoring(bool restoring); + Q_SIGNALS: void moveAddTabButton(int posX); @@ -90,6 +92,8 @@ private: bool m_forceHidden; QPointer m_lastTab; + + bool m_isRestoring = false; }; #endif // TABBAR_H diff --git a/src/lib/tabwidget/tabwidget.cpp b/src/lib/tabwidget/tabwidget.cpp index fcf4f0795..e6fb36d2f 100644 --- a/src/lib/tabwidget/tabwidget.cpp +++ b/src/lib/tabwidget/tabwidget.cpp @@ -849,6 +849,8 @@ bool TabWidget::restoreState(const QVector &tabs, int currentT return false; } + m_tabBar->setIsRestoring(true); + QVector>> childTabs; for (int i = 0; i < tabs.size(); ++i) { @@ -870,6 +872,8 @@ bool TabWidget::restoreState(const QVector &tabs, int currentT } } + m_tabBar->setIsRestoring(false); + setCurrentIndex(currentTab); QTimer::singleShot(0, m_tabBar, SLOT(ensureVisible(int,int)));