diff --git a/src/lib/tabwidget/tabbar.cpp b/src/lib/tabwidget/tabbar.cpp index 162dec4ed..5179ceb99 100644 --- a/src/lib/tabwidget/tabbar.cpp +++ b/src/lib/tabwidget/tabbar.cpp @@ -26,6 +26,7 @@ #include "iconprovider.h" #include "tabcontextmenu.h" #include "searchenginesmanager.h" +#include "tabmrumodel.h" #include #include @@ -425,11 +426,13 @@ void TabBar::currentTabChanged(int index) // Don't hide close buttons when dragging tabs if (m_dragStartPosition.isNull()) { showCloseButton(index); - hideCloseButton(m_tabWidget->lastTabIndex()); - + if (m_lastTab) { + hideCloseButton(m_lastTab->tabIndex()); + } QTimer::singleShot(100, this, [this]() { ensureVisible(); }); } + m_lastTab = webTab(index); m_tabWidget->currentTabChanged(index); } diff --git a/src/lib/tabwidget/tabbar.h b/src/lib/tabwidget/tabbar.h index c5d649879..73fe3c702 100644 --- a/src/lib/tabwidget/tabbar.h +++ b/src/lib/tabwidget/tabbar.h @@ -18,8 +18,9 @@ #ifndef TABBAR_H #define TABBAR_H -#include "combotabbar.h" +#include +#include "combotabbar.h" #include "qzcommon.h" class BrowserWindow; @@ -88,6 +89,7 @@ private: QPoint m_dragStartPosition; bool m_forceHidden; + QPointer m_lastTab; }; #endif // TABBAR_H diff --git a/src/lib/tabwidget/tabwidget.cpp b/src/lib/tabwidget/tabwidget.cpp index 748c2c159..c0c07c413 100644 --- a/src/lib/tabwidget/tabwidget.cpp +++ b/src/lib/tabwidget/tabwidget.cpp @@ -321,7 +321,6 @@ int TabWidget::addView(const LoadRequest &req, const Qz::NewTabPositionFlags &op int TabWidget::addView(const LoadRequest &req, const QString &title, const Qz::NewTabPositionFlags &openFlags, bool selectLine, int position, bool pinned) { QUrl url = req.url(); - m_lastTab = weTab(); m_currentTabFresh = false; if (url.isEmpty() && !(openFlags & Qz::NT_CleanTab)) { @@ -512,7 +511,6 @@ void TabWidget::currentTabChanged(int index) WebTab* webTab = weTab(index); webTab->tabActivated(); - m_lastTab = webTab; LocationBar* locBar = webTab->locationBar(); @@ -535,8 +533,6 @@ void TabWidget::tabWasMoved(int before, int after) void TabWidget::setCurrentIndex(int index) { - m_lastTab = weTab(); - TabStackedWidget::setCurrentIndex(index); } @@ -576,16 +572,6 @@ WebTab *TabWidget::webTab(int index) const return index < 0 ? weTab() : weTab(index); } -WebTab *TabWidget::lastTab() const -{ - return m_lastTab; -} - -int TabWidget::lastTabIndex() const -{ - return m_lastTab ? m_lastTab->tabIndex() : -1; -} - int TabWidget::extraReservedWidth() const { return m_buttonAddTab->width(); diff --git a/src/lib/tabwidget/tabwidget.h b/src/lib/tabwidget/tabwidget.h index bbb00cc08..ff608d18d 100644 --- a/src/lib/tabwidget/tabwidget.h +++ b/src/lib/tabwidget/tabwidget.h @@ -85,9 +85,6 @@ public: WebTab *webTab(int index = -1) const; - WebTab *lastTab() const; - int lastTabIndex() const; - TabBar* tabBar() const; ClosedTabsManager* closedTabsManager() const; QList allTabs(bool withPinned = true); @@ -172,7 +169,6 @@ private: AddTabButton* m_buttonAddTab; AddTabButton* m_buttonAddTab2; - QPointer m_lastTab; QPointer m_lastBackgroundTab; bool m_dontCloseWithOneTab;