tabWidgetPointer->currentWidget()->setFocus();
}
-PrivacyWebEngineView* TabWidget::addTab(const bool focusNewWebEngineView)
+PrivacyWebEngineView* TabWidget::addTab(const bool removeUrlLineEditFocus, const bool backgroundTab)
{
// Create a privacy WebEngine view.
PrivacyWebEngineView *privacyWebEngineViewPointer = new PrivacyWebEngineView();
emit hideProgressBar();
});
+ // Display find text results.
+ connect(webEnginePagePointer, SIGNAL(findTextFinished(const QWebEngineFindTextResult &)), this, SLOT(findTextFinished(const QWebEngineFindTextResult &)));
+
// Handle full screen requests.
connect(webEnginePagePointer, SIGNAL(fullScreenRequested(QWebEngineFullScreenRequest)), this, SLOT(fullScreenRequested(QWebEngineFullScreenRequest)));
tabWidgetPointer->setTabIcon(tabIndex, icon);
});
- // Move to the new tab.
- tabWidgetPointer->setCurrentIndex(newTabIndex);
+ // Enable spell checking.
+ webEngineProfilePointer->setSpellCheckEnabled(true);
+
+ // Set the spell check language.
+ webEngineProfilePointer->setSpellCheckLanguages({QStringLiteral("en_US")});
+
+ // 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());
+
+ // Move to the new tab if it is not a background tab.
+ if (!backgroundTab)
+ tabWidgetPointer->setCurrentIndex(newTabIndex);
// Clear the URL line edit focus so that it populates correctly when opening a new tab from the context menu.
- if (focusNewWebEngineView)
+ if (removeUrlLineEditFocus)
emit clearUrlLineEditFocus();
// Return the privacy WebEngine view pointer.
}
}
+void TabWidget::findPrevious(const QString &text) const
+{
+ // Store the current text.
+ currentPrivacyWebEngineViewPointer->findString = text;
+
+ // Find the previous text in the current privacy WebEngine.
+ if (currentPrivacyWebEngineViewPointer->findCaseSensitive)
+ currentPrivacyWebEngineViewPointer->findText(text, QWebEnginePage::FindCaseSensitively|QWebEnginePage::FindBackward);
+ else
+ currentPrivacyWebEngineViewPointer->findText(text, QWebEnginePage::FindBackward);
+}
+
+void TabWidget::findText(const QString &text) const
+{
+ // Store the current text.
+ currentPrivacyWebEngineViewPointer->findString = text;
+
+ // Find the text in the current privacy WebEngine.
+ if (currentPrivacyWebEngineViewPointer->findCaseSensitive)
+ currentPrivacyWebEngineViewPointer->findText(text, QWebEnginePage::FindCaseSensitively);
+ else
+ currentPrivacyWebEngineViewPointer->findText(text);
+
+ // Clear the currently selected text in the WebEngine page if the find text is empty.
+ if (text.isEmpty())
+ currentWebEnginePagePointer->action(QWebEnginePage::Unselect)->activate(QAction::Trigger);
+}
+
+void TabWidget::findTextFinished(const QWebEngineFindTextResult &findTextResult)
+{
+ // Update the find text UI if it wasn't simply wiping the current find text selection. Otherwise the UI temporarially flashes `0/0`.
+ if (wipingCurrentFindTextSelection) // The current selection is being wiped.
+ {
+ // Reset the flag.
+ wipingCurrentFindTextSelection = false;
+ }
+ else // A new search has been performed.
+ {
+ // Store the result.
+ currentPrivacyWebEngineViewPointer->findTextResult = findTextResult;
+
+ // Update the UI.
+ emit updateFindTextResults(findTextResult);
+ }
+}
+
void TabWidget::forward() const
{
// Go forward.
currentPrivacyWebEngineViewPointer->reload();
}
+void TabWidget::toggleFindCaseSensitive(const QString &text)
+{
+ // Toggle find case sensitive.
+ currentPrivacyWebEngineViewPointer->findCaseSensitive = !currentPrivacyWebEngineViewPointer->findCaseSensitive;
+
+ // Set the wiping current find text selection flag.
+ wipingCurrentFindTextSelection = true;
+
+ // Wipe the previous search. Otherwise currently highlighted words will remain highlighted.
+ findText(QStringLiteral(""));
+
+ // Update the find text.
+ findText(text);
+}
+
void TabWidget::toggleJavaScript() const
{
// Toggle JavaScript.
// Clear the URL line edit focus.
emit clearUrlLineEditFocus();
- // Update the UI.
+ // Update the actions.
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 updateWindowTitle(currentPrivacyWebEngineViewPointer->title());
- emit updateUrlLineEdit(currentPrivacyWebEngineViewPointer->url());
emit updateUserAgentActions(currentWebEngineProfilePointer->httpUserAgent(), true);
emit updateZoomFactorAction(currentPrivacyWebEngineViewPointer->zoomFactor());
+ // Update the URL.
+ emit updateWindowTitle(currentPrivacyWebEngineViewPointer->title());
+ emit updateDomainSettingsIndicator(currentPrivacyWebEngineViewPointer->domainSettingsName != QStringLiteral(""));
+ emit updateUrlLineEdit(currentPrivacyWebEngineViewPointer->url());
+
+ // Update the find text.
+ emit updateFindText(currentPrivacyWebEngineViewPointer->findString, currentPrivacyWebEngineViewPointer->findCaseSensitive);
+ emit updateFindTextResults(currentPrivacyWebEngineViewPointer->findTextResult);
+
// Update the progress bar.
if (currentPrivacyWebEngineViewPointer->loadProgressInt >= 0)
emit showProgressBar(currentPrivacyWebEngineViewPointer->loadProgressInt);