From 7cefc22c0a70d569f2ae3acec686589209edb227 Mon Sep 17 00:00:00 2001 From: nowrep Date: Wed, 12 Feb 2014 13:50:06 +0100 Subject: [PATCH] [Flicker] Fixed flicker when opening new tabs with sites that loads instantly Eg. this happens for internal qupzilla: pages Also early set locationbar's url to newly opened tab's url. --- src/lib/navigation/navigationbar.cpp | 12 ++++++++++++ src/lib/navigation/navigationbar.h | 4 ++++ src/lib/tools/combotabbar.cpp | 1 + src/lib/webview/tabwidget.cpp | 9 +++++++++ 4 files changed, 26 insertions(+) diff --git a/src/lib/navigation/navigationbar.cpp b/src/lib/navigation/navigationbar.cpp index 059abfa04..25a3859ea 100644 --- a/src/lib/navigation/navigationbar.cpp +++ b/src/lib/navigation/navigationbar.cpp @@ -29,6 +29,7 @@ #include "webpage.h" #include "qzsettings.h" +#include #include #include #include @@ -241,6 +242,12 @@ void NavigationBar::setLayoutSpacing(int spacing) m_layout->setSpacing(spacing); } +void NavigationBar::pauseUpdates() +{ + setUpdatesEnabled(false); + QTimer::singleShot(100, this, SLOT(enableUpdates())); +} + void NavigationBar::aboutToShowHistoryBackMenu() { if (!m_menuBack || !p_QupZilla->weView()) { @@ -316,6 +323,11 @@ void NavigationBar::clearHistory() refreshHistory(); } +void NavigationBar::enableUpdates() +{ + setUpdatesEnabled(true); +} + void NavigationBar::contextMenuRequested(const QPoint &pos) { p_QupZilla->popupToolbarsMenu(mapToGlobal(pos)); diff --git a/src/lib/navigation/navigationbar.h b/src/lib/navigation/navigationbar.h index fb1cfcc4d..38f607013 100644 --- a/src/lib/navigation/navigationbar.h +++ b/src/lib/navigation/navigationbar.h @@ -63,6 +63,9 @@ public: int layoutSpacing() const; void setLayoutSpacing(int spacing); + // Pause updates for 100 msecs + void pauseUpdates(); + signals: public slots: @@ -81,6 +84,7 @@ private slots: void goAtHistoryIndexInNewTab(int index = -1); void clearHistory(); + void enableUpdates(); void contextMenuRequested(const QPoint &pos); diff --git a/src/lib/tools/combotabbar.cpp b/src/lib/tools/combotabbar.cpp index 084f81448..0b8d8e75a 100644 --- a/src/lib/tools/combotabbar.cpp +++ b/src/lib/tools/combotabbar.cpp @@ -308,6 +308,7 @@ void ComboTabBar::closeTabFromButton() void ComboTabBar::enableUpdates() { setUpdatesEnabled(true); + updateTabBars(); } void ComboTabBar::updateTabBars() diff --git a/src/lib/webview/tabwidget.cpp b/src/lib/webview/tabwidget.cpp index 34b2e9355..98dff72ae 100644 --- a/src/lib/webview/tabwidget.cpp +++ b/src/lib/webview/tabwidget.cpp @@ -324,6 +324,12 @@ int TabWidget::addView(QNetworkRequest req, const QString &title, const Qz::NewT QtWin::extendFrameIntoClientArea(p_QupZilla); } #endif + // Pause updates, so pages that loads instantly (eg. qupzilla: internal pages) don't cause + // flickering in navigationbar (load button and locationbar) + // Also disable updates of tabwidget, so background of webview doesn't flashes + p_QupZilla->navigationBar()->pauseUpdates(); + setUpdatesEnabled(false); + QUrl url = req.url(); m_lastTabIndex = currentIndex(); @@ -361,6 +367,7 @@ int TabWidget::addView(QNetworkRequest req, const QString &title, const Qz::NewT TabbedWebView* webView = weTab(index)->view(); locBar->setWebView(webView); + locBar->showUrl(url); setTabText(index, title); setTabIcon(index, qIconProvider->emptyWebIcon()); @@ -400,6 +407,8 @@ int TabWidget::addView(QNetworkRequest req, const QString &title, const Qz::NewT } } + setUpdatesEnabled(true); + #ifdef Q_OS_WIN QTimer::singleShot(0, p_QupZilla, SLOT(applyBlurToMainWindow())); #endif