Better profile support, only 1 web server per context, multiple windows per context
This commit is contained in:
@@ -36,7 +36,7 @@ static void displ1(QSslCertificate &cert, QList<QSslCertificate::SubjectInfo > l
|
||||
};
|
||||
*/
|
||||
|
||||
WebviewWindow::WebviewWindow(WebviewWindow *parent, bool has_scp, QByteArray scp_pem)
|
||||
WebviewWindow::WebviewWindow(QWebEngineProfile *profile, WebviewWindow *parent)
|
||||
: QMainWindow{parent}
|
||||
{
|
||||
static int profile_nr = 0;
|
||||
@@ -51,21 +51,7 @@ WebviewWindow::WebviewWindow(WebviewWindow *parent, bool has_scp, QByteArray scp
|
||||
_moved = 0;
|
||||
_resized = 0;
|
||||
|
||||
QWebEngineProfileBuilder b;
|
||||
if (has_scp) {
|
||||
profile_nr += 1;
|
||||
char buf[100];
|
||||
sprintf(buf, "profile-%d", profile_nr);
|
||||
QString name(buf);
|
||||
QSslCertificate cert(scp_pem);
|
||||
|
||||
QList<QSslCertificate> certs;
|
||||
certs.append(cert);
|
||||
b.setAdditionalTrustedCertificates(certs);
|
||||
_profile = b.createProfile(name);
|
||||
} else {
|
||||
_profile = QWebEngineProfile::defaultProfile();
|
||||
}
|
||||
_profile = profile;
|
||||
|
||||
if (parent != nullptr) {
|
||||
setWindowModality(Qt::WindowModality::WindowModal);
|
||||
@@ -78,7 +64,9 @@ WebviewWindow::WebviewWindow(WebviewWindow *parent, bool has_scp, QByteArray scp
|
||||
|
||||
void WebviewWindow::navigationRequested(QWebEngineNavigationRequest &req)
|
||||
{
|
||||
if (req.navigationType() == QWebEngineNavigationRequest::NavigationType::TypedNavigation) {
|
||||
QWebEngineNavigationRequest::NavigationType t = req.navigationType();
|
||||
if (t == QWebEngineNavigationRequest::NavigationType::TypedNavigation ||
|
||||
t == QWebEngineNavigationRequest::RedirectNavigation) {
|
||||
req.accept();
|
||||
} else {
|
||||
EventContainer e("navigation-request");
|
||||
@@ -226,8 +214,9 @@ void WebviewWindow::addView(WebViewQt *v, Rktwebview_qt *c)
|
||||
_view = v;
|
||||
this->setCentralWidget(v);
|
||||
|
||||
QWebEnginePage *page;
|
||||
QWebEnginePage *page = _view->page();
|
||||
|
||||
/*
|
||||
if (_profile == nullptr) {
|
||||
page = _view->page();
|
||||
} else {
|
||||
@@ -255,6 +244,7 @@ void WebviewWindow::addView(WebViewQt *v, Rktwebview_qt *c)
|
||||
);
|
||||
evt_script.setWorldId(QWebEngineScript::ApplicationWorld);
|
||||
//col.insert(evt_script);
|
||||
*/
|
||||
|
||||
connect(page, &QWebEnginePage::loadFinished, this, [this](bool ok) {
|
||||
_container->pageLoaded(_view->id(), ok);
|
||||
|
||||
Reference in New Issue
Block a user