fix:popup javascript windows

This commit is contained in:
xiaoyifang 2022-03-11 00:41:35 +08:00
parent 982c480451
commit 3a092947da
4 changed files with 23 additions and 10 deletions

View file

@ -328,10 +328,10 @@ ArticleView::ArticleView( QWidget * parent, ArticleNetworkAccessManager & nm, Au
ui.searchFrame->installEventFilter( this );
ui.ftsSearchFrame->installEventFilter( this );
QWebEngineSettings * settings = ui.definition->page()->settings();
settings->defaultSettings()->setAttribute( QWebEngineSettings::WebAttribute::LocalContentCanAccessRemoteUrls, true );
settings->defaultSettings()->setAttribute( QWebEngineSettings::WebAttribute::LocalContentCanAccessFileUrls, true );
settings->defaultSettings()->setAttribute( QWebEngineSettings::WebAttribute::ErrorPageEnabled, false);
// QWebEngineSettings * settings = ui.definition->page()->settings();
// settings->defaultSettings()->setAttribute( QWebEngineSettings::WebAttribute::LocalContentCanAccessRemoteUrls, true );
// settings->defaultSettings()->setAttribute( QWebEngineSettings::WebAttribute::LocalContentCanAccessFileUrls, true );
// settings->defaultSettings()->setAttribute( QWebEngineSettings::WebAttribute::ErrorPageEnabled, false);
// Load the default blank page instantly, so there would be no flicker.
QString contentType;

View file

@ -6,6 +6,8 @@
#include <QWebEngineView>
#include <QApplication>
#include <QTimer>
#include <QDialog>
#include <QMainWindow>
#ifdef Q_OS_WIN32
#include <qt_windows.h>
@ -34,6 +36,17 @@ void ArticleWebView::triggerPageAction( QWebEnginePage::WebAction action, bool c
QWebEngineView::triggerPageAction( action, checked );
}
QWebEngineView * ArticleWebView::createWindow( QWebEnginePage::WebWindowType type )
{
QMainWindow * dlg = new QMainWindow( this );
QWebEngineView * webbrowser = new QWebEngineView( this );
dlg->setCentralWidget(webbrowser);
dlg->setMinimumSize(400,400);
dlg->show();
return webbrowser;
}
bool ArticleWebView::event( QEvent * event )
{
if (event->type() == QEvent::ChildAdded) {

View file

@ -27,7 +27,6 @@ public:
ArticleWebView( QWidget * parent );
~ArticleWebView();
void setUp( Config::Class * cfg );
bool isMidButtonPressed() const
@ -52,7 +51,7 @@ public:
void doubleClicked( QPoint pos );
protected:
QWebEngineView *createWindow(QWebEnginePage::WebWindowType type);
bool event( QEvent * event );
void singleClickAction(QMouseEvent *event);
void sendCustomMouseEvent(QEvent::Type type);

View file

@ -1303,12 +1303,13 @@ void MainWindow::applyProxySettings()
void MainWindow::applyWebSettings()
{
QWebEngineSettings *defaultSettings = QWebEngineSettings::defaultSettings();
defaultSettings->setAttribute(QWebEngineSettings::PluginsEnabled, cfg.preferences.enableWebPlugins);
defaultSettings->setAttribute(QWebEngineSettings::PlaybackRequiresUserGesture, false);
QWebEngineSettings * defaultSettings = QWebEngineSettings::defaultSettings();
defaultSettings->setAttribute( QWebEngineSettings::PluginsEnabled, cfg.preferences.enableWebPlugins );
defaultSettings->setAttribute( QWebEngineSettings::PlaybackRequiresUserGesture, false );
defaultSettings->setAttribute( QWebEngineSettings::WebAttribute::LocalContentCanAccessRemoteUrls, true );
defaultSettings->setAttribute( QWebEngineSettings::WebAttribute::LocalContentCanAccessFileUrls, true );
defaultSettings->setAttribute( QWebEngineSettings::WebAttribute::ErrorPageEnabled, false);
defaultSettings->setAttribute( QWebEngineSettings::WebAttribute::ErrorPageEnabled, false );
defaultSettings->setAttribute( QWebEngineSettings::WebAttribute::JavascriptCanOpenWindows, true );
}
void MainWindow::setupNetworkCache( int maxSize )