From 8e12480dc9c4d192a0c73172774fe740fab10192 Mon Sep 17 00:00:00 2001 From: Vlad Date: Mon, 15 Aug 2016 14:54:54 +0300 Subject: [PATCH] Show navigation in new tab in fullscreen mode (#2055) --- src/lib/app/browserwindow.cpp | 7 +++++++ src/lib/tabwidget/tabwidget.cpp | 16 ++++++++++++++++ src/lib/tabwidget/tabwidget.h | 4 ++++ 3 files changed, 27 insertions(+) diff --git a/src/lib/app/browserwindow.cpp b/src/lib/app/browserwindow.cpp index f863f7062..66fd5f0de 100644 --- a/src/lib/app/browserwindow.cpp +++ b/src/lib/app/browserwindow.cpp @@ -970,6 +970,10 @@ void BrowserWindow::removeActions(const QList &actions) void BrowserWindow::addTab() { m_tabWidget->addView(QUrl(), Qz::NT_SelectedNewEmptyTab, true); + m_tabWidget->setCurrentTabFresh(true); + + if (isFullScreen()) + showNavigationWithFullScreen(); } void BrowserWindow::webSearch() @@ -1035,6 +1039,9 @@ void BrowserWindow::showNavigationWithFullScreen() void BrowserWindow::hideNavigationWithFullScreen() { + if (m_tabWidget->isCurrentTabFresh()) + return; + if (!m_hideNavigationTimer->isActive()) { m_hideNavigationTimer->start(); } diff --git a/src/lib/tabwidget/tabwidget.cpp b/src/lib/tabwidget/tabwidget.cpp index bfdcb8e8a..41dc4d008 100644 --- a/src/lib/tabwidget/tabwidget.cpp +++ b/src/lib/tabwidget/tabwidget.cpp @@ -230,6 +230,16 @@ void TabWidget::updateClosedTabsButton() m_buttonClosedTabs->setEnabled(canRestoreTab()); } +bool TabWidget::isCurrentTabFresh() const +{ + return m_currentTabFresh; +} + +void TabWidget::setCurrentTabFresh(bool currentTabFresh) +{ + m_currentTabFresh = currentTabFresh; +} + void TabWidget::tabBarOverFlowChanged(bool overflowed) { // Show buttons inside tabbar @@ -324,6 +334,7 @@ int TabWidget::addView(const LoadRequest &req, const QString &title, const Qz::N { QUrl url = req.url(); m_lastTabIndex = currentIndex(); + m_currentTabFresh = false; if (url.isEmpty() && !(openFlags & Qz::NT_CleanTab)) { url = m_urlOnNewTab; @@ -367,6 +378,10 @@ int TabWidget::addView(const LoadRequest &req, const QString &title, const Qz::N connect(webTab->webView(), SIGNAL(wantsCloseTab(int)), this, SLOT(closeTab(int))); connect(webTab->webView(), SIGNAL(urlChanged(QUrl)), this, SIGNAL(changed())); connect(webTab->webView(), SIGNAL(ipChanged(QString)), m_window->ipLabel(), SLOT(setText(QString))); + connect(webTab->webView(), &WebView::urlChanged, this, [this](const QUrl &url) { + if (url != m_urlOnNewTab) + m_currentTabFresh = false; + }); if (url.isValid() && url != req.url()) { LoadRequest r(req); @@ -489,6 +504,7 @@ void TabWidget::currentTabChanged(int index) m_lastBackgroundTabIndex = -1; m_lastTabIndex = index; + m_currentTabFresh = false; WebTab* webTab = weTab(index); LocationBar* locBar = webTab->locationBar(); diff --git a/src/lib/tabwidget/tabwidget.h b/src/lib/tabwidget/tabwidget.h index 4d8a8fd61..467b9278f 100644 --- a/src/lib/tabwidget/tabwidget.h +++ b/src/lib/tabwidget/tabwidget.h @@ -93,6 +93,8 @@ public: ClosedTabsManager* closedTabsManager() const; QList allTabs(bool withPinned = true); bool canRestoreTab() const; + bool isCurrentTabFresh() const; + void setCurrentTabFresh(bool currentTabFresh); QStackedWidget* locationBars() const; ToolButton* buttonClosedTabs() const; @@ -164,6 +166,8 @@ private: bool m_newTabAfterActive; bool m_newEmptyTabAfterActive; QUrl m_urlOnNewTab; + + bool m_currentTabFresh; }; #endif // TABWIDGET_H