show JS alerts in a better way

This commit is contained in:
Martin Rotter 2024-08-06 11:44:03 +02:00
parent 9c7f3c4b1c
commit 9952329e74
3 changed files with 8 additions and 1 deletions

View File

@ -52,7 +52,6 @@ class RSSGUARD_DLLSPEC WebEngineViewer : public QWebEngineView, public WebViewer
protected:
virtual ContextMenuData provideContextMenuData(QContextMenuEvent* event) const;
virtual QWebEngineView* createWindow(QWebEnginePage::WebWindowType type);
virtual void contextMenuEvent(QContextMenuEvent* event);
virtual bool event(QEvent* event);

View File

@ -71,6 +71,13 @@ void WebEnginePage::hideUnwantedElements() {
}
}
void WebEnginePage::javaScriptAlert(const QUrl& security_origin, const QString& msg) {
qApp
->showGuiMessage(Notification::Event::GeneralEvent,
GuiMessage(tr("Website alert"),
tr("URL %1 reports this important message: %2").arg(security_origin.toString(), msg)));
}
bool WebEnginePage::acceptNavigationRequest(const QUrl& url, NavigationType type, bool is_main_frame) {
if (type == NavigationType::NavigationTypeLinkClicked) {
bool open_externally_now =

View File

@ -25,6 +25,7 @@ class WebEnginePage : public QWebEnginePage {
void hideUnwantedElements();
protected:
virtual void javaScriptAlert(const QUrl& security_origin, const QString& msg);
virtual bool acceptNavigationRequest(const QUrl& url, NavigationType type, bool is_main_frame);
virtual void javaScriptConsoleMessage(JavaScriptConsoleMessageLevel level,
const QString& message,