QWebEngineSettings *webEngineSettingsPointer = webEnginePagePointer->settings();
// Update the URL line edit when the URL changes.
- connect(privacyWebEngineViewPointer, SIGNAL(urlChanged(const QUrl)), this, SLOT(updateUrl(const QUrl)));
+ connect(privacyWebEngineViewPointer, &PrivacyWebEngineView::urlChanged, [privacyWebEngineViewPointer, this] (const QUrl &newUrl)
+ {
+ // Only update the UI if this is the current tab.
+ if (privacyWebEngineViewPointer == currentPrivacyWebEngineViewPointer)
+ {
+ // Update the URL line edit.
+ emit updateUrlLineEdit(newUrl);
- // Update the progress bar.
- connect(privacyWebEngineViewPointer, SIGNAL(loadStarted()), this, SLOT(loadStarted()));
- connect(privacyWebEngineViewPointer, SIGNAL(loadProgress(const int)), this, SLOT(loadProgress(const int)));
- connect(privacyWebEngineViewPointer, SIGNAL(loadFinished(const bool)), this, SLOT(loadFinished()));
+ // Update the status of the forward and back buttons.
+ emit updateBackAction(currentWebEngineHistoryPointer->canGoBack());
+ emit updateForwardAction(currentWebEngineHistoryPointer->canGoForward());
+ }
+
+ // Reapply the zoom factor. This is a bug in QWebEngineView that resets the zoom with every load. It can be removed once <https://redmine.stoutner.com/issues/799> is fixed.
+ privacyWebEngineViewPointer->setZoomFactor(currentZoomFactor);
+ });
+
+ // Update the progress bar when a load is started.
+ connect(privacyWebEngineViewPointer, &PrivacyWebEngineView::loadStarted, [privacyWebEngineViewPointer, this] ()
+ {
+ // Store the load progress.
+ privacyWebEngineViewPointer->loadProgressInt = 0;
+
+ // Show the progress bar if this is the current tab.
+ if (privacyWebEngineViewPointer == currentPrivacyWebEngineViewPointer)
+ emit showProgressBar(0);
+ });
+
+ // Update the progress bar when a load progresses.
+ connect(privacyWebEngineViewPointer, &PrivacyWebEngineView::loadProgress, [privacyWebEngineViewPointer, this] (const int progress)
+ {
+ // Store the load progress.
+ privacyWebEngineViewPointer->loadProgressInt = progress;
+
+ // Update the progress bar if this is the current tab.
+ if (privacyWebEngineViewPointer == currentPrivacyWebEngineViewPointer)
+ emit showProgressBar(progress);
+ });
+
+ // Update the progress bar when a load finishes.
+ connect(privacyWebEngineViewPointer, &PrivacyWebEngineView::loadFinished, [privacyWebEngineViewPointer, this] ()
+ {
+ // Store the load progress.
+ privacyWebEngineViewPointer->loadProgressInt = -1;
+
+ // Hide the progress bar if this is the current tab.
+ if (privacyWebEngineViewPointer == currentPrivacyWebEngineViewPointer)
+ emit hideProgressBar();
+ });
// Handle full screen requests.
connect(webEnginePagePointer, SIGNAL(fullScreenRequested(QWebEngineFullScreenRequest)), this, SLOT(fullScreenRequested(QWebEngineFullScreenRequest)));
// Limit WebRTC to public IP addresses.
webEngineSettingsPointer->setAttribute(QWebEngineSettings::WebRTCPublicInterfacesOnly, true);
- // Define an update cookie count lambda.
- auto updateCookieCount = [privacyWebEngineViewPointer, this] (const int numberOfCookies)
+ // Update the cookies action.
+ connect(privacyWebEngineViewPointer, &PrivacyWebEngineView::updateCookiesAction, [privacyWebEngineViewPointer, this] (const int numberOfCookies)
{
// Update the cookie action if the specified privacy WebEngine view is the current privacy WebEngine view.
if (privacyWebEngineViewPointer == currentPrivacyWebEngineViewPointer)
emit updateCookiesAction(numberOfCookies);
- };
-
- // Update the cookies action.
- connect(privacyWebEngineViewPointer, &PrivacyWebEngineView::updateCookiesAction, this, updateCookieCount);
+ });
// Process cookie changes.
connect(webEngineCookieStorePointer, SIGNAL(cookieAdded(QNetworkCookie)), privacyWebEngineViewPointer, SLOT(addCookieToList(QNetworkCookie)));
for (QNetworkCookie *cookiePointer : *durableCookiesListPointer)
addCookieToStore(*cookiePointer, webEngineCookieStorePointer);
- // Define an update tab title lambda.
- auto updateTabTitle = [privacyWebEngineViewPointer, this] (const QString &title)
+ // Update the title when it changes.
+ connect(privacyWebEngineViewPointer, &PrivacyWebEngineView::titleChanged, [this, privacyWebEngineViewPointer] (const QString &title)
{
// Get the index for this tab.
int tabIndex = tabWidgetPointer->indexOf(privacyWebEngineViewPointer);
// Update the title for this tab.
tabWidgetPointer->setTabText(tabIndex, title);
- };
- // Update the title when it changes.
- connect(privacyWebEngineViewPointer, &PrivacyWebEngineView::titleChanged, this, updateTabTitle);
+ // Update the window title if this is the current tab.
+ if (tabIndex == tabWidgetPointer->currentIndex())
+ emit updateWindowTitle(title);
+ });
- // Define an update tab icon lambda.
- auto updateTabIcon = [privacyWebEngineViewPointer, this] (const QIcon &icon)
+ // Update the icon when it changes.
+ connect(privacyWebEngineViewPointer, &PrivacyWebEngineView::iconChanged, [privacyWebEngineViewPointer, this] (const QIcon &icon)
{
// Get the index for this tab.
int tabIndex = tabWidgetPointer->indexOf(privacyWebEngineViewPointer);
tabWidgetPointer->setTabIcon(tabIndex, defaultTabIcon);
else
tabWidgetPointer->setTabIcon(tabIndex, icon);
- };
-
- // Update the icon when it changes.
- connect(privacyWebEngineViewPointer, &PrivacyWebEngineView::iconChanged, this, updateTabIcon);
+ });
// Move to the new tab.
tabWidgetPointer->setCurrentIndex(newTabIndex);
currentPrivacyWebEngineViewPointer->load(QUrl::fromUserInput(Settings::homepage()));
}
-void TabWidget::loadFinished() const
+PrivacyWebEngineView* TabWidget::loadBlankInitialWebsite()
{
- // Hide the progress bar.
- emit hideProgressBar();
+ // Apply the application settings.
+ applyApplicationSettings();
+
+ // Return the current privacy WebEngine view pointer.
+ return currentPrivacyWebEngineViewPointer;
}
void TabWidget::loadInitialWebsite()
}
}
-void TabWidget::loadProgress(const int &progress) const
-{
- // Show the progress bar.
- emit showProgressBar(progress);
-}
-
-void TabWidget::loadStarted() const
-{
- // Show the progress bar.
- emit showProgressBar(0);
-}
-
void TabWidget::loadUrlFromLineEdit(QString url) const
{
// Decide if the text is more likely to be a URL or a search.
emit clearUrlLineEditFocus();
// Update the UI.
+ emit updateBackAction(currentWebEngineHistoryPointer->canGoBack());
+ emit updateCookiesAction(currentPrivacyWebEngineViewPointer->cookieListPointer->size());
emit updateDomainSettingsIndicator(currentPrivacyWebEngineViewPointer->domainSettingsName != QStringLiteral(""));
+ emit updateDomStorageAction(currentWebEngineSettingsPointer->testAttribute(QWebEngineSettings::LocalStorageEnabled));
+ emit updateForwardAction(currentWebEngineHistoryPointer->canGoForward());
emit updateJavaScriptAction(currentWebEngineSettingsPointer->testAttribute(QWebEngineSettings::JavascriptEnabled));
emit updateLocalStorageAction(currentPrivacyWebEngineViewPointer->localStorageEnabled);
- emit updateDomStorageAction(currentWebEngineSettingsPointer->testAttribute(QWebEngineSettings::LocalStorageEnabled));
+ emit updateWindowTitle(currentPrivacyWebEngineViewPointer->title());
+ emit updateUrlLineEdit(currentPrivacyWebEngineViewPointer->url());
emit updateUserAgentActions(currentWebEngineProfilePointer->httpUserAgent(), true);
emit updateZoomFactorAction(currentPrivacyWebEngineViewPointer->zoomFactor());
- emit updateUrlLineEdit(currentPrivacyWebEngineViewPointer->url());
- emit updateCookiesAction(currentPrivacyWebEngineViewPointer->cookieListPointer->size());
-}
-void TabWidget::updateUrl(const QUrl &url) const
-{
- // Update the URL line edit.
- emit updateUrlLineEdit(url);
-
- // Update the status of the forward and back buttons.
- emit updateBackAction(currentWebEngineHistoryPointer->canGoBack());
- emit updateForwardAction(currentWebEngineHistoryPointer->canGoForward());
-
- // Reapply the zoom factor. This is a bug in QWebEngineView that resets the zoom with every load. <https://redmine.stoutner.com/issues/799>
- currentPrivacyWebEngineViewPointer->setZoomFactor(currentZoomFactor);
+ // Update the progress bar.
+ if (currentPrivacyWebEngineViewPointer->loadProgressInt >= 0)
+ emit showProgressBar(currentPrivacyWebEngineViewPointer->loadProgressInt);
+ else
+ emit hideProgressBar();
}