X-Git-Url: https://gitweb.stoutner.com/?a=blobdiff_plain;f=src%2Fwidgets%2FTabWidget.cpp;h=2f4582a9b2e6943af0b7c32982823315ae400aa0;hb=7c6edb3608791950c6146ac242e2b6f493ca8e8c;hp=f8044e2152f2b02784460de8ac79e10fe7d274a8;hpb=6a4af266d064e144822e46dc193f6d8c27ea6eb5;p=PrivacyBrowserPC.git diff --git a/src/widgets/TabWidget.cpp b/src/widgets/TabWidget.cpp index f8044e2..2f4582a 100644 --- a/src/widgets/TabWidget.cpp +++ b/src/widgets/TabWidget.cpp @@ -171,7 +171,7 @@ void TabWidget::addFirstTab() qTabWidgetPointer->currentWidget()->setFocus(); } -PrivacyWebEngineView* TabWidget::addTab(const bool removeUrlLineEditFocus, const bool backgroundTab) +PrivacyWebEngineView* TabWidget::addTab(const bool removeUrlLineEditFocus, const bool backgroundTab, const QString urlString) { // Create a privacy WebEngine view. PrivacyWebEngineView *privacyWebEngineViewPointer = new PrivacyWebEngineView(); @@ -344,12 +344,12 @@ PrivacyWebEngineView* TabWidget::addTab(const bool removeUrlLineEditFocus, const } }); - // Update the zoom factor when changed by CTRL-Scrolling. This can be modified when is fixed. + // Update the zoom actions when changed by CTRL-Scrolling. This can be modified when is fixed. connect(webEnginePagePointer, &QWebEnginePage::contentsSizeChanged, [webEnginePagePointer, this] () { - // Only update the zoom factor action text if this is the current tab. + // Only update the zoom actions if this is the current tab. if (webEnginePagePointer == currentWebEnginePagePointer) - emit updateZoomFactorAction(webEnginePagePointer->zoomFactor()); + emit updateZoomActions(webEnginePagePointer->zoomFactor()); }); // Display find text results. @@ -454,6 +454,9 @@ PrivacyWebEngineView* TabWidget::addTab(const bool removeUrlLineEditFocus, const if (removeUrlLineEditFocus) emit clearUrlLineEditFocus(); + if (urlString != nullptr) + privacyWebEngineViewPointer->load(QUrl::fromUserInput(urlString)); + // Return the privacy WebEngine view pointer. return privacyWebEngineViewPointer; } @@ -670,6 +673,24 @@ std::list* TabWidget::getCookieList() const return currentPrivacyWebEngineViewPointer->cookieListPointer; } +QIcon TabWidget::getCurrentTabFavoritIcon() const +{ + // Return the current Privacy WebEngine favorite icon. + return currentPrivacyWebEngineViewPointer->favoriteIcon; +} + +QString TabWidget::getCurrentTabTitle() const +{ + // Return the current Privacy WebEngine title. + return currentPrivacyWebEngineViewPointer->title(); +} + +QString TabWidget::getCurrentTabUrl() const +{ + // Return the current Privacy WebEngine URL as a string. + return currentPrivacyWebEngineViewPointer->url().toString(); +} + QString& TabWidget::getDomainSettingsName() const { // Return the domain settings name. @@ -715,7 +736,7 @@ void TabWidget::loadInitialWebsite() void TabWidget::loadUrlFromLineEdit(QString url) const { // Decide if the text is more likely to be a URL or a search. - if (url.startsWith("file://")) // The text is likely a file URL. + if (url.startsWith("file://") || url.startsWith("view-source:")) // The text is likely a file or view source URL. { // Load the URL. currentPrivacyWebEngineViewPointer->load(QUrl::fromUserInput(url)); @@ -903,15 +924,15 @@ void TabWidget::showSaveDialog(QWebEngineDownloadItem *webEngineDownloadItemPoin // Set the notification text. fileDownloadNotificationPointer->setText(i18nc("Downloading notification text", "Downloading %1", saveFileName)); + // Get the download icon from the theme. + QIcon downloadIcon = QIcon::fromTheme(QLatin1String("download"), QIcon::fromTheme(QLatin1String("document-save"))); + // Set the notification icon. - fileDownloadNotificationPointer->setIconName(QLatin1String("download")); + fileDownloadNotificationPointer->setIconName(downloadIcon.name()); // Set the action list cancel button. fileDownloadNotificationPointer->setActions(QStringList({i18nc("Download notification action","Cancel")})); - // Set the notification to display indefinitely. - fileDownloadNotificationPointer->setFlags(KNotification::Persistent); - // Prevent the notification from being autodeleted if it is closed. Otherwise, the updates to the notification below cause a crash. fileDownloadNotificationPointer->setAutoDelete(false); @@ -1068,12 +1089,13 @@ void TabWidget::updateUiFromWebEngineView(const PrivacyWebEngineView *privacyWeb if (privacyWebEngineViewPointer == currentPrivacyWebEngineViewPointer) { // Update the UI. + emit updateDefaultZoomFactor(currentPrivacyWebEngineViewPointer->defaultZoomFactor); emit updateDomainSettingsIndicator(currentPrivacyWebEngineViewPointer->domainSettingsName != QLatin1String("")); emit updateJavaScriptAction(currentWebEngineSettingsPointer->testAttribute(QWebEngineSettings::JavascriptEnabled)); emit updateLocalStorageAction(currentPrivacyWebEngineViewPointer->localStorageEnabled); emit updateDomStorageAction(currentWebEngineSettingsPointer->testAttribute(QWebEngineSettings::LocalStorageEnabled)); emit updateUserAgentActions(currentWebEngineProfilePointer->httpUserAgent(), true); - emit updateZoomFactorAction(currentPrivacyWebEngineViewPointer->zoomFactor()); + emit updateZoomActions(currentPrivacyWebEngineViewPointer->zoomFactor()); } } @@ -1091,6 +1113,7 @@ void TabWidget::updateUiWithTabSettings() emit clearUrlLineEditFocus(); // Update the actions. + emit updateDefaultZoomFactor(currentPrivacyWebEngineViewPointer->defaultZoomFactor); emit updateBackAction(currentWebEngineHistoryPointer->canGoBack()); emit updateCookiesAction(currentPrivacyWebEngineViewPointer->cookieListPointer->size()); emit updateDomStorageAction(currentWebEngineSettingsPointer->testAttribute(QWebEngineSettings::LocalStorageEnabled)); @@ -1098,7 +1121,7 @@ void TabWidget::updateUiWithTabSettings() emit updateJavaScriptAction(currentWebEngineSettingsPointer->testAttribute(QWebEngineSettings::JavascriptEnabled)); emit updateLocalStorageAction(currentPrivacyWebEngineViewPointer->localStorageEnabled); emit updateUserAgentActions(currentWebEngineProfilePointer->httpUserAgent(), true); - emit updateZoomFactorAction(currentPrivacyWebEngineViewPointer->zoomFactor()); + emit updateZoomActions(currentPrivacyWebEngineViewPointer->zoomFactor()); // Update the URL. emit updateWindowTitle(currentPrivacyWebEngineViewPointer->title());