/*
- * Copyright 2022 Soren Stoutner <soren@stoutner.com>.
+ * Copyright 2022-2023 Soren Stoutner <soren@stoutner.com>.
*
* This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
*
emit hideProgressBar();
});
+ // Update the zoom factor when changed by CTRL-Scrolling. This can be modified when <https://redmine.stoutner.com/issues/845> is fixed.
+ connect(webEnginePagePointer, &QWebEnginePage::contentsSizeChanged, [webEnginePagePointer, this] ()
+ {
+ // Only update the zoom factor action text if this is the current tab.
+ if (webEnginePagePointer == currentWebEnginePagePointer)
+ emit updateZoomFactorAction(webEnginePagePointer->zoomFactor());
+ });
+
// Display find text results.
connect(webEnginePagePointer, SIGNAL(findTextFinished(const QWebEngineFindTextResult &)), this, SLOT(findTextFinished(const QWebEngineFindTextResult &)));
return false;
});
- // Disable JavaScript by default (this prevetns JavaScript from being enabled on a new tab before domain settings are loaded).
+ // Disable JavaScript by default (this prevents JavaScript from being enabled on a new tab before domain settings are loaded).
webEngineSettingsPointer->setAttribute(QWebEngineSettings::JavascriptEnabled, false);
// Don't allow JavaScript to open windows.
// Limit WebRTC to public IP addresses.
webEngineSettingsPointer->setAttribute(QWebEngineSettings::WebRTCPublicInterfacesOnly, true);
+ // Enable the PDF viewer (it should be enabled by default, but it is nice to be explicit in case the defaults change).
+ webEngineSettingsPointer->setAttribute(QWebEngineSettings::PdfViewerEnabled, true);
+
+ // Plugins must be enabled for the PDF viewer to work. <https://doc.qt.io/qt-5/qtwebengine-features.html#pdf-file-viewing>
+ webEngineSettingsPointer->setAttribute(QWebEngineSettings::PluginsEnabled, true);
+
// Update the cookies action.
connect(privacyWebEngineViewPointer, &PrivacyWebEngineView::updateCookiesAction, [privacyWebEngineViewPointer, this] (const int numberOfCookies)
{
webEngineProfilePointer->setSpellCheckEnabled(true);
// Set the spell check language.
- webEngineProfilePointer->setSpellCheckLanguages({QLatin1String("en_US")});
+ webEngineProfilePointer->setSpellCheckLanguages(Settings::spellCheckLanguages());
// Populate the zoom factor. This is necessary if a URL is being loaded, like a local URL, that does not trigger `applyDomainSettings()`.
privacyWebEngineViewPointer->setZoomFactor(Settings::zoomFactor());
// Store the search engine string.
searchEngineUrl = SearchEngineHelper::getSearchUrl(searchEngineName);
- // Update the search engine actionas.
+ // Update the search engine actions.
emit updateSearchEngineActions(searchEngineName, false);
}
currentPrivacyWebEngineViewPointer->setZoomFactor(zoomFactor);
}
+void TabWidget::applySpellCheckLanguages() const
+{
+ // Get the number of tab.
+ int numberOfTabs = tabWidgetPointer->count();
+
+ // Set the spell check languages for each tab.
+ for (int i = 0; i < numberOfTabs; ++i)
+ {
+ // Get the WebEngine view pointer.
+ PrivacyWebEngineView *webEngineViewPointer = qobject_cast<PrivacyWebEngineView *>(tabWidgetPointer->currentWidget());
+
+ // Get the WebEngine page pointer.
+ QWebEnginePage *webEnginePagePointer = webEngineViewPointer->page();
+
+ // Get the WebEngine profile pointer.
+ QWebEngineProfile *webEngineProfilePointer = webEnginePagePointer->profile();
+
+ // Set the spell check languages.
+ webEngineProfilePointer->setSpellCheckLanguages(Settings::spellCheckLanguages());
+ }
+}
+
void TabWidget::back() const
{
// Go back.
// Update the notification when the download progresses.
connect(webEngineDownloadItemPointer, &QWebEngineDownloadItem::downloadProgress, [fileDownloadNotificationPointer, saveFileName] (qint64 bytesReceived, qint64 totalBytes)
{
- // Calculate the download percentage.
- int downloadPercentage = 100 * bytesReceived / totalBytes;
-
// Set the new text. Total bytes will be 0 if the download size is unknown.
if (totalBytes > 0)
+ {
+ // Calculate the download percentage.
+ int downloadPercentage = 100 * bytesReceived / totalBytes;
+
+ // Set the file download notification text.
fileDownloadNotificationPointer->setText(i18nc("Download progress notification text", "%1\% of %2 downloaded (%3 of %4 bytes)", downloadPercentage, saveFileName,
bytesReceived, totalBytes));
+ }
else
+ {
+ // Set the file download notification text.
fileDownloadNotificationPointer->setText(i18nc("Download progress notification text", "%1: %2 bytes downloaded", saveFileName, bytesReceived));
+ }
// Display the updated notification.
fileDownloadNotificationPointer->update();
void TabWidget::toggleLocalStorage()
{
- // Toggle local storeage.
+ // Toggle local storage.
currentPrivacyWebEngineViewPointer->localStorageEnabled = !currentPrivacyWebEngineViewPointer->localStorageEnabled;
// Update the local storage action.