From fa4fba5f49af8e4b50d9bf222459d8e88799f907 Mon Sep 17 00:00:00 2001 From: David Rosca Date: Thu, 4 Jan 2018 16:55:59 +0100 Subject: [PATCH] BrowserWindow: Add tabCount() method --- src/lib/app/browserwindow.cpp | 7 ++++++- src/lib/app/browserwindow.h | 1 + src/lib/app/mainapplication.cpp | 2 +- src/lib/session/recoveryjsobject.cpp | 3 +-- src/plugins/TabManager/tabmanagerwidget.cpp | 4 ++-- 5 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/lib/app/browserwindow.cpp b/src/lib/app/browserwindow.cpp index 4f4d14518..7ea8e5f35 100644 --- a/src/lib/app/browserwindow.cpp +++ b/src/lib/app/browserwindow.cpp @@ -100,7 +100,7 @@ BrowserWindow::SavedWindow::SavedWindow(BrowserWindow *window) virtualDesktop = window->getCurrentVirtualDesktop(); #endif - const int tabsCount = window->tabWidget()->count(); + const int tabsCount = window->tabCount(); tabs.reserve(tabsCount); for (int i = 0; i < tabsCount; ++i) { TabbedWebView *webView = window->weView(i); @@ -648,6 +648,11 @@ void BrowserWindow::goBack() weView()->back(); } +int BrowserWindow::tabCount() const +{ + return m_tabWidget->count(); +} + TabbedWebView* BrowserWindow::weView() const { return weView(m_tabWidget->currentIndex()); diff --git a/src/lib/app/browserwindow.h b/src/lib/app/browserwindow.h index c385343de..ec429c87b 100644 --- a/src/lib/app/browserwindow.h +++ b/src/lib/app/browserwindow.h @@ -103,6 +103,7 @@ public: SideBar* addSideBar(); void saveSideBarSettings(); + int tabCount() const; TabbedWebView* weView() const; TabbedWebView* weView(int index) const; diff --git a/src/lib/app/mainapplication.cpp b/src/lib/app/mainapplication.cpp index 8fe7a611a..a02614d6a 100644 --- a/src/lib/app/mainapplication.cpp +++ b/src/lib/app/mainapplication.cpp @@ -429,7 +429,7 @@ void MainApplication::openSession(BrowserWindow* window, RestoreData &restoreDat if (!window) window = createWindow(Qz::BW_OtherRestoredWindow); - if (window->tabWidget()->count() != 0) { + if (window->tabCount() != 0) { // This can only happen when recovering crashed session! // Don't restore tabs in current window as user already opened some new tabs. createWindow(Qz::BW_OtherRestoredWindow)->restoreWindow(restoreData.windows.takeAt(0)); diff --git a/src/lib/session/recoveryjsobject.cpp b/src/lib/session/recoveryjsobject.cpp index 4886a5ea9..f6b7b78f9 100644 --- a/src/lib/session/recoveryjsobject.cpp +++ b/src/lib/session/recoveryjsobject.cpp @@ -23,7 +23,6 @@ #include "browserwindow.h" #include "qztools.h" #include "iconprovider.h" -#include "tabwidget.h" #include @@ -123,7 +122,7 @@ void RecoveryJsObject::closeTab() return; } - if (view->browserWindow()->tabWidget()->count() > 1) { + if (view->browserWindow()->tabCount() > 1) { view->closeView(); } else { view->browserWindow()->close(); diff --git a/src/plugins/TabManager/tabmanagerwidget.cpp b/src/plugins/TabManager/tabmanagerwidget.cpp index 58993bcf6..8bae6c279 100644 --- a/src/plugins/TabManager/tabmanagerwidget.cpp +++ b/src/plugins/TabManager/tabmanagerwidget.cpp @@ -539,7 +539,7 @@ static void detachTabsTo(BrowserWindow* targetWindow, const QHashtabWidget()->detachTab(webTab); - if (mainWindow && mainWindow->tabWidget()->count() == 0) { + if (mainWindow && mainWindow->tabCount() == 0) { mainWindow->close(); mainWindow = 0; } @@ -553,7 +553,7 @@ void TabManagerWidget::detachSelectedTabs(const QHash & { if (tabsHash.isEmpty() || (tabsHash.uniqueKeys().size() == 1 && - tabsHash.size() == tabsHash.keys().at(0)->tabWidget()->count())) { + tabsHash.size() == tabsHash.keys().at(0)->tabCount())) { return; }