1 From 5b423e9aea7bc672b879359871a5c4c2b8a50e8d Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Ren=C3=A9=20Reucher?= <rene.reucher@batcom-it.net>
3 Date: Tue, 31 May 2022 19:20:34 +0200
4 Subject: [PATCH] wip: first version with support for QWebEngine instead of
9 src/htmleditor/htmleditor.cpp | 178 ++++++++++++++++++++--------------
10 src/htmleditor/htmleditor.ui | 74 +++++++-------
12 src/miniwebbrowser.cpp | 171 +++++++++++++++++---------------
13 src/miniwebbrowser.h | 15 ++-
14 src/options.cpp | 19 ++--
15 src/qmc2main.cpp | 12 ++-
16 9 files changed, 261 insertions(+), 218 deletions(-)
18 diff --git a/qmc2.pro b/qmc2.pro
19 index 46c736d60..15eae4c44 100644
23 # general project settings
24 isEmpty(TARGET):TARGET = qmc2
25 -QT += core gui widgets xml xmlpatterns network sql svg testlib webkitwidgets
26 +QT += core gui widgets xml xmlpatterns network sql svg testlib webenginewidgets
30 diff --git a/src/htmleditor/htmleditor.cpp b/src/htmleditor/htmleditor.cpp
31 index 2dff0d3cc..deb0f747b 100644
32 --- a/src/htmleditor/htmleditor.cpp
33 +++ b/src/htmleditor/htmleditor.cpp
35 #include <QMessageBox>
36 #include <QColorDialog>
38 -#include <QtWebKitWidgets/QWebFrame>
39 +#include <QWebEngineView>
40 #include <QListWidgetItem>
42 #include <algorithm> // std::sort()
43 @@ -120,7 +120,6 @@ HtmlEditor::HtmlEditor(QString editorName, bool embedded, QWidget *parent) :
47 - // replace the standard QWebView with the MiniWebBrowser's tweaked one
48 ui->verticalLayoutWYSIWYG->removeWidget(ui->webView);
50 ui->webView = new BrowserWidget(ui->tabWYSIWYG, 0);
51 @@ -224,6 +223,7 @@ HtmlEditor::HtmlEditor(QString editorName, bool embedded, QWidget *parent) :
52 connect(zoomSlider, SIGNAL(valueChanged(int)), SLOT(changeZoom(int)));
53 ui->standardToolBar->insertWidget(ui->actionZoomIn, zoomSlider);
56 #if defined(QMC2_BROWSER_PLUGINS_ENABLED)
57 ui->webView->page()->settings()->setAttribute(QWebSettings::PluginsEnabled, true);
59 @@ -231,6 +231,7 @@ HtmlEditor::HtmlEditor(QString editorName, bool embedded, QWidget *parent) :
61 ui->webView->page()->settings()->setAttribute(QWebSettings::ZoomTextOnly, false);
62 ui->webView->page()->settings()->setAttribute(QWebSettings::LocalStorageEnabled, true);
65 connect(ui->webView, SIGNAL(loadStarted()), this, SLOT(setLoadActive()));
66 connect(ui->webView, SIGNAL(loadFinished(bool)), this, SLOT(setLoadInactive()));
67 @@ -260,19 +261,17 @@ HtmlEditor::HtmlEditor(QString editorName, bool embedded, QWidget *parent) :
68 connect(ui->actionZoomOut, SIGNAL(triggered()), SLOT(zoomOut()));
69 connect(ui->actionZoomIn, SIGNAL(triggered()), SLOT(zoomIn()));
71 - // these are forwarded to the internal QWebView
72 - FORWARD_ACTION(ui->actionEditUndo, QWebPage::Undo);
73 - FORWARD_ACTION(ui->actionEditRedo, QWebPage::Redo);
74 - FORWARD_ACTION(ui->actionEditCut, QWebPage::Cut);
75 - FORWARD_ACTION(ui->actionEditCopy, QWebPage::Copy);
76 - FORWARD_ACTION(ui->actionEditPaste, QWebPage::Paste);
77 - FORWARD_ACTION(ui->actionFormatBold, QWebPage::ToggleBold);
78 - FORWARD_ACTION(ui->actionFormatItalic, QWebPage::ToggleItalic);
79 - FORWARD_ACTION(ui->actionFormatUnderline, QWebPage::ToggleUnderline);
81 - // Qt 4.5.0 has a bug: always returns 0 for QWebPage::SelectAll
82 - connect(ui->actionEditSelectAll, SIGNAL(triggered()), SLOT(editSelectAll()));
83 - // FIXME: still required?
84 + // these are forwarded to the internal QWebEngineView
85 + FORWARD_ACTION(ui->actionEditUndo, QWebEnginePage::Undo);
86 + FORWARD_ACTION(ui->actionEditRedo, QWebEnginePage::Redo);
87 + FORWARD_ACTION(ui->actionEditCut, QWebEnginePage::Cut);
88 + FORWARD_ACTION(ui->actionEditCopy, QWebEnginePage::Copy);
89 + FORWARD_ACTION(ui->actionEditPaste, QWebEnginePage::Paste);
91 + FORWARD_ACTION(ui->actionFormatBold, QWebEnginePage::ToggleBold);
92 + FORWARD_ACTION(ui->actionFormatItalic, QWebEnginePage::ToggleItalic);
93 + FORWARD_ACTION(ui->actionFormatUnderline, QWebEnginePage::ToggleUnderline);
96 connect(ui->actionStyleParagraph, SIGNAL(triggered()), SLOT(styleParagraph()));
97 connect(ui->actionStyleHeading1, SIGNAL(triggered()), SLOT(styleHeading1()));
98 @@ -310,27 +309,31 @@ HtmlEditor::HtmlEditor(QString editorName, bool embedded, QWidget *parent) :
99 connect(ui->webView->page(), SIGNAL(linkHovered(const QString &, const QString &, const QString &)), SLOT(linkHovered(const QString &, const QString &, const QString &)));
101 // this effectively *disables* internal link-following
102 - ui->webView->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
103 + //ui->webView->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
104 connect(ui->webView, SIGNAL(linkClicked(QUrl)), SLOT(openLink(QUrl)));
105 - ui->webView->pageAction(QWebPage::OpenImageInNewWindow)->setVisible(false);
106 - ui->webView->pageAction(QWebPage::DownloadImageToDisk)->setVisible(false);
107 - ui->webView->pageAction(QWebPage::OpenFrameInNewWindow)->setVisible(false);
108 - ui->webView->pageAction(QWebPage::OpenLinkInNewWindow)->setVisible(false);
109 - ui->webView->pageAction(QWebPage::OpenLink)->setVisible(false);
110 - ui->webView->pageAction(QWebPage::DownloadLinkToDisk)->setVisible(false);
111 - ui->webView->pageAction(QWebPage::Back)->setVisible(false);
112 - ui->webView->pageAction(QWebPage::Forward)->setVisible(false);
113 - ui->webView->pageAction(QWebPage::Stop)->setVisible(false);
114 - ui->webView->pageAction(QWebPage::Reload)->setVisible(false);
115 + //ui->webView->pageAction(QWebEnginePage::OpenImageInNewWindow)->setVisible(false);
116 + ui->webView->pageAction(QWebEnginePage::DownloadImageToDisk)->setVisible(false);
117 + //ui->webView->pageAction(QWebEnginePage::OpenFrameInNewWindow)->setVisible(false);
118 + ui->webView->pageAction(QWebEnginePage::OpenLinkInNewWindow)->setVisible(false);
119 + //ui->webView->pageAction(QWebEnginePage::OpenLink)->setVisible(false);
120 + ui->webView->pageAction(QWebEnginePage::DownloadLinkToDisk)->setVisible(false);
121 + ui->webView->pageAction(QWebEnginePage::Back)->setVisible(false);
122 + ui->webView->pageAction(QWebEnginePage::Forward)->setVisible(false);
123 + ui->webView->pageAction(QWebEnginePage::Stop)->setVisible(false);
124 + ui->webView->pageAction(QWebEnginePage::Reload)->setVisible(false);
126 ui->webView->setFocus();
127 - ui->webView->page()->setContentEditable(!actionReadOnly->isChecked());
128 + if ( actionReadOnly->isChecked() )
129 + ui->webView->page()->runJavaScript("document.documentElement.contentEditable = false");
131 + ui->webView->page()->runJavaScript("document.documentElement.contentEditable = true");
132 ui->plainTextEdit->setReadOnly(actionReadOnly->isChecked());
134 if ( !actionShowHTML->isChecked() )
137 - connect(ui->webView->page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(javaScriptWindowObjectCleared()));
139 + //connect(ui->webView->page(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(javaScriptWindowObjectCleared()));
141 changeZoom(qmc2Config->value(QMC2_FRONTEND_PREFIX + QString("HtmlEditor/%1/Zoom").arg(myEditorName), 100).toInt());
143 @@ -399,22 +402,26 @@ void HtmlEditor::loadFinished(bool)
145 void HtmlEditor::setContentEditable(bool readonly)
147 - ui->webView->page()->setContentEditable(!readonly);
149 + ui->webView->page()->runJavaScript("document.documentElement.contentEditable = false");
151 + ui->webView->page()->runJavaScript("document.documentElement.contentEditable = true");
152 ui->plainTextEdit->setReadOnly(readonly);
155 void HtmlEditor::checkRevertStatus()
157 if ( !fileName.isEmpty() ) {
159 - if ( loadedContent.isEmpty() )
160 - wasModified = false;
161 - else if ( ui->tabWidget->currentIndex() == 0 )
162 - wasModified = loadedContent != ui->webView->page()->mainFrame()->toHtml();
164 + bool wasModified = !loadedContent.isEmpty();
165 + if ( ui->tabWidget->currentIndex() == 0 ) {
166 + QString data("%1");
167 + ui->webView->page()->toHtml([data](const QString &result) { data.arg(result); });
168 + wasModified = loadedContent != data;
170 wasModified = loadedContent != ui->plainTextEdit->toPlainText();
172 - if ( ui->webView->page()->mainFrame()->toHtml() != emptyContent && wasModified ) {
173 + QString data("%1");
174 + ui->webView->page()->toHtml([data](const QString &result) { data.arg(result); });
175 + if ( data != emptyContent && wasModified ) {
177 ui->actionFileRevert->setVisible(f.exists());
179 @@ -446,13 +453,16 @@ QString &HtmlEditor::noScript(QString &data)
181 void HtmlEditor::fileNew()
183 - ui->webView->page()->setContentEditable(!actionReadOnly->isChecked());
184 + if ( actionReadOnly->isChecked() )
185 + ui->webView->page()->runJavaScript("document.documentElement.contentEditable = false");
187 + ui->webView->page()->runJavaScript("document.documentElement.contentEditable = true");
188 ui->plainTextEdit->setReadOnly(actionReadOnly->isChecked());
190 if ( !isEmbeddedEditor )
191 setCurrentFileName(QString());
193 - // quirk in QWebView: need an initial mouse click to show the cursor
194 + // quirk in QWebEngineView: need an initial mouse click to show the cursor
195 int mx = ui->webView->width() / 2;
196 int my = ui->webView->height() / 2;
197 QPoint center = QPoint(mx, my);
198 @@ -510,11 +520,12 @@ void HtmlEditor::fileOpenInBrowser()
200 connect(webBrowser->webViewBrowser->page(), SIGNAL(windowCloseRequested()), webBrowser, SLOT(close()));
201 if ( ui->tabWidget->currentIndex() == 1 ) {
202 - ui->webView->page()->mainFrame()->setHtml(ui->plainTextEdit->toPlainText());
203 + ui->webView->page()->setHtml(ui->plainTextEdit->toPlainText());
204 wysiwygDirty = false;
206 - QString data(ui->webView->page()->mainFrame()->toHtml());
207 - webBrowser->webViewBrowser->setHtml(noScript(data));
208 + QString data("%1");
209 + webBrowser->webViewBrowser->page()->toHtml([data](const QString &result) { data.arg(result); });
210 + webBrowser->webViewBrowser->page()->setHtml(noScript(data));
211 if ( !fileName.isEmpty() && QFile(fileName).exists() ) {
212 webBrowser->homeUrl = QUrl::fromUserInput(fileName);
213 webBrowser->comboBoxURL->lineEdit()->setText(webBrowser->homeUrl.toString());
214 @@ -540,10 +551,11 @@ bool HtmlEditor::fileSave()
215 bool success = file.open(QIODevice::WriteOnly);
217 if ( ui->tabWidget->currentIndex() == 1 ) {
218 - ui->webView->page()->mainFrame()->setHtml(ui->plainTextEdit->toPlainText());
219 + ui->webView->page()->setHtml(ui->plainTextEdit->toPlainText());
220 wysiwygDirty = false;
222 - QString content(ui->webView->page()->mainFrame()->toHtml());
223 + QString content("%1");
224 + ui->webView->page()->toHtml([content](const QString &result) { content.arg(result); });
225 QTextStream ts(&file);
226 ts << noScript(content);
228 @@ -572,10 +584,11 @@ bool HtmlEditor::fileSaveAs()
229 bool success = file.open(QIODevice::WriteOnly);
231 if ( ui->tabWidget->currentIndex() == 1 ) {
232 - ui->webView->page()->mainFrame()->setHtml(ui->plainTextEdit->toPlainText());
233 + ui->webView->page()->setHtml(ui->plainTextEdit->toPlainText());
234 wysiwygDirty = false;
236 - QString content(ui->webView->page()->mainFrame()->toHtml());
237 + QString content("%1");
238 + ui->webView->page()->toHtml([content](const QString &result) { content.arg(result); });
239 QTextStream ts(&file);
240 ts << noScript(content);
242 @@ -751,38 +764,41 @@ void HtmlEditor::zoomIn()
244 void HtmlEditor::editSelectAll()
246 - ui->webView->triggerPageAction(QWebPage::SelectAll);
247 + ui->webView->triggerPageAction(QWebEnginePage::SelectAll);
250 void HtmlEditor::execCommand(const QString &cmd)
252 - QWebFrame *frame = ui->webView->page()->mainFrame();
253 + QWebEnginePage *page = ui->webView->page();
254 QString js(QString("document.execCommand(\"%1\", false, null)").arg(cmd));
255 - frame->evaluateJavaScript(js);
256 + page->runJavaScript(js);
257 localModified = true;
260 void HtmlEditor::execCommand(const QString &cmd, const QString &arg)
262 - QWebFrame *frame = ui->webView->page()->mainFrame();
263 + QWebEnginePage *page = ui->webView->page();
264 QString js(QString("document.execCommand(\"%1\", false, \"%2\")").arg(cmd).arg(arg));
265 - frame->evaluateJavaScript(js);
266 + page->runJavaScript(js);
267 localModified = true;
270 bool HtmlEditor::queryCommandState(const QString &cmd)
272 - QWebFrame *frame = ui->webView->page()->mainFrame();
273 + QWebEnginePage *page = ui->webView->page();
274 QString js(QString("document.queryCommandState(\"%1\", false, null)").arg(cmd));
275 - QVariant result = frame->evaluateJavaScript(js);
276 - return result.toString().simplified().toLower() == "true";
277 + QString result("%1");
278 + page->runJavaScript(js, [result](const QVariant &r) { result.arg(r.toString()); });
279 + return result.simplified().toLower() == "true";
282 void HtmlEditor::styleParagraph()
284 execCommand("formatBlock", "p");
285 if ( generateEmptyContent ) {
286 - emptyContent = ui->webView->page()->mainFrame()->toHtml();
287 + QString data("%1");
288 + ui->webView->page()->toHtml([data](const QString &result) { data.arg(result); });
289 + emptyContent = data;
290 generateEmptyContent = false;
293 @@ -907,14 +923,16 @@ void HtmlEditor::formatBackgroundColor()
295 void HtmlEditor::adjustActions()
297 - FOLLOW_ENABLE(ui->actionEditUndo, QWebPage::Undo);
298 - FOLLOW_ENABLE(ui->actionEditRedo, QWebPage::Redo);
299 - FOLLOW_ENABLE(ui->actionEditCut, QWebPage::Cut);
300 - FOLLOW_ENABLE(ui->actionEditCopy, QWebPage::Copy);
301 - FOLLOW_ENABLE(ui->actionEditPaste, QWebPage::Paste);
302 - FOLLOW_CHECK(ui->actionFormatBold, QWebPage::ToggleBold);
303 - FOLLOW_CHECK(ui->actionFormatItalic, QWebPage::ToggleItalic);
304 - FOLLOW_CHECK(ui->actionFormatUnderline, QWebPage::ToggleUnderline);
305 + FOLLOW_ENABLE(ui->actionEditUndo, QWebEnginePage::Undo);
306 + FOLLOW_ENABLE(ui->actionEditRedo, QWebEnginePage::Redo);
307 + FOLLOW_ENABLE(ui->actionEditCut, QWebEnginePage::Cut);
308 + FOLLOW_ENABLE(ui->actionEditCopy, QWebEnginePage::Copy);
309 + FOLLOW_ENABLE(ui->actionEditPaste, QWebEnginePage::Paste);
311 + FOLLOW_CHECK(ui->actionFormatBold, QWebEnginePage::ToggleBold);
312 + FOLLOW_CHECK(ui->actionFormatItalic, QWebEnginePage::ToggleItalic);
313 + FOLLOW_CHECK(ui->actionFormatUnderline, QWebEnginePage::ToggleUnderline);
316 ui->actionFormatStrikethrough->setChecked(queryCommandState("strikeThrough"));
317 ui->actionFormatNumberedList->setChecked(queryCommandState("insertOrderedList"));
318 @@ -940,7 +958,7 @@ void HtmlEditor::changeTab(int index)
321 if ( wysiwygDirty ) {
322 - ui->webView->page()->mainFrame()->setHtml(ui->plainTextEdit->toPlainText());
323 + ui->webView->page()->setHtml(ui->plainTextEdit->toPlainText());
324 wysiwygDirty = false;
327 @@ -948,7 +966,9 @@ void HtmlEditor::changeTab(int index)
330 ui->plainTextEdit->blockSignals(true);
331 - ui->plainTextEdit->setPlainText(ui->webView->page()->mainFrame()->toHtml());
332 + QString data("%1");
333 + ui->webView->page()->toHtml([data](const QString &result) { data.arg(result); });
334 + ui->plainTextEdit->setPlainText(data);
335 ui->plainTextEdit->blockSignals(false);
338 @@ -1021,7 +1041,10 @@ bool HtmlEditor::load(const QString &f)
339 loadedContent = data;
341 ui->webView->setHtml(data);
342 - ui->webView->page()->setContentEditable(!actionReadOnly->isChecked());
343 + if ( actionReadOnly->isChecked() )
344 + ui->webView->page()->runJavaScript("document.documentElement.contentEditable = false");
346 + ui->webView->page()->runJavaScript("document.documentElement.contentEditable = true");
347 ui->plainTextEdit->setReadOnly(actionReadOnly->isChecked());
349 if ( fileName.isEmpty() )
350 @@ -1093,11 +1116,16 @@ bool HtmlEditor::loadTemplate(const QString &f)
352 if ( !qmc2CleaningUp && !stopLoading ) {
353 ui->webView->setHtml(data, QUrl::fromLocalFile(f));
354 - ui->webView->page()->setContentEditable(!actionReadOnly->isChecked());
355 + if ( actionReadOnly->isChecked() )
356 + ui->webView->page()->runJavaScript("document.documentElement.contentEditable = false");
358 + ui->webView->page()->runJavaScript("document.documentElement.contentEditable = true");
359 ui->plainTextEdit->setReadOnly(actionReadOnly->isChecked());
360 if ( fileName.isEmpty() )
361 setCurrentFileName(f);
362 - emptyContent = ui->webView->page()->mainFrame()->toHtml();
363 + QString data("%1");
364 + ui->webView->page()->toHtml([data](const QString &result) { data.arg(result); });
365 + emptyContent = data;
368 emptyContent = "QMC2_INVALID";
369 @@ -1107,8 +1135,9 @@ bool HtmlEditor::loadTemplate(const QString &f)
371 void HtmlEditor::javaScriptWindowObjectCleared()
373 - ui->webView->page()->mainFrame()->addToJavaScriptWindowObject("qmc2NotesEditorObject", this);
374 - ui->webView->page()->mainFrame()->addToJavaScriptWindowObject("qmc2NEO", this);
376 + //ui->webView->page()->addToJavaScriptWindowObject("qmc2NotesEditorObject", this);
377 + //ui->webView->page()->addToJavaScriptWindowObject("qmc2NEO", this);
380 QString HtmlEditor::getIconData()
381 @@ -1627,18 +1656,17 @@ bool HtmlEditor::save()
382 if ( emptyContent == "QMC2_INVALID" )
385 - if ( !ui->webView->page()->isModified() && !ui->plainTextEdit->document()->isModified() && !localModified )
388 if ( fileName.isEmpty() )
391 if ( ui->tabWidget->currentIndex() == 1 ) {
392 - ui->webView->page()->mainFrame()->setHtml(ui->plainTextEdit->toPlainText());
393 + ui->webView->page()->setHtml(ui->plainTextEdit->toPlainText());
394 wysiwygDirty = false;
397 - loadedContent = ui->webView->page()->mainFrame()->toHtml();
398 + QString data("%1");
399 + ui->webView->page()->toHtml([data](const QString &result) { data.arg(result); });
400 + loadedContent = data;
402 if ( loadedContent == emptyContent ) {
404 diff --git a/src/htmleditor/htmleditor.ui b/src/htmleditor/htmleditor.ui
405 index 8f64543bb..1bdab5bfa 100644
406 --- a/src/htmleditor/htmleditor.ui
407 +++ b/src/htmleditor/htmleditor.ui
412 - <widget class="QWebView" name="webView">
413 + <widget class="QWebEngineView" name="webView">
414 <property name="url">
416 <string>about:blank</string>
418 <string>Insert &image</string>
420 <property name="icon">
421 - <iconset resource="../qmc2.qrc">
422 + <iconset resource="../../qmc2.qrc">
423 <normaloff>:/htmleditor/images/image-x-generic.png</normaloff>:/htmleditor/images/image-x-generic.png</iconset>
425 <addaction name="actionInsertImageFromFile"/>
428 <action name="actionFileNew">
429 <property name="icon">
430 - <iconset resource="../qmc2.qrc">
431 + <iconset resource="../../qmc2.qrc">
432 <normaloff>:/htmleditor/images/document-new.png</normaloff>:/htmleditor/images/document-new.png</iconset>
434 <property name="text">
437 <action name="actionFileNewFromTemplate">
438 <property name="icon">
439 - <iconset resource="../qmc2.qrc">
440 + <iconset resource="../../qmc2.qrc">
441 <normaloff>:/htmleditor/images/document-new.png</normaloff>:/htmleditor/images/document-new.png</iconset>
443 <property name="text">
446 <action name="actionFileRevert">
447 <property name="icon">
448 - <iconset resource="../qmc2.qrc">
449 + <iconset resource="../../qmc2.qrc">
450 <normaloff>:/htmleditor/images/edit-undo.png</normaloff>:/htmleditor/images/edit-undo.png</iconset>
452 <property name="text">
455 <action name="actionFileOpen">
456 <property name="icon">
457 - <iconset resource="../qmc2.qrc">
458 + <iconset resource="../../qmc2.qrc">
459 <normaloff>:/htmleditor/images/document-open.png</normaloff>:/htmleditor/images/document-open.png</iconset>
461 <property name="text">
464 <action name="actionFileSave">
465 <property name="icon">
466 - <iconset resource="../qmc2.qrc">
467 + <iconset resource="../../qmc2.qrc">
468 <normaloff>:/htmleditor/images/document-save.png</normaloff>:/htmleditor/images/document-save.png</iconset>
470 <property name="text">
473 <action name="actionFileSaveAs">
474 <property name="icon">
475 - <iconset resource="../qmc2.qrc">
476 + <iconset resource="../../qmc2.qrc">
477 <normaloff>:/data/img/filesaveas.png</normaloff>:/data/img/filesaveas.png</iconset>
479 <property name="text">
482 <action name="actionFileOpenInBrowser">
483 <property name="icon">
484 - <iconset resource="../qmc2.qrc">
485 + <iconset resource="../../qmc2.qrc">
486 <normaloff>:/data/img/browser.png</normaloff>:/data/img/browser.png</iconset>
488 <property name="text">
491 <action name="actionEditUndo">
492 <property name="icon">
493 - <iconset resource="../qmc2.qrc">
494 + <iconset resource="../../qmc2.qrc">
495 <normaloff>:/htmleditor/images/edit-undo.png</normaloff>:/htmleditor/images/edit-undo.png</iconset>
497 <property name="text">
500 <action name="actionEditRedo">
501 <property name="icon">
502 - <iconset resource="../qmc2.qrc">
503 + <iconset resource="../../qmc2.qrc">
504 <normaloff>:/htmleditor/images/edit-redo.png</normaloff>:/htmleditor/images/edit-redo.png</iconset>
506 <property name="text">
509 <action name="actionEditCut">
510 <property name="icon">
511 - <iconset resource="../qmc2.qrc">
512 + <iconset resource="../../qmc2.qrc">
513 <normaloff>:/htmleditor/images/edit-cut.png</normaloff>:/htmleditor/images/edit-cut.png</iconset>
515 <property name="text">
518 <action name="actionEditCopy">
519 <property name="icon">
520 - <iconset resource="../qmc2.qrc">
521 + <iconset resource="../../qmc2.qrc">
522 <normaloff>:/htmleditor/images/edit-copy.png</normaloff>:/htmleditor/images/edit-copy.png</iconset>
524 <property name="text">
527 <action name="actionEditPaste">
528 <property name="icon">
529 - <iconset resource="../qmc2.qrc">
530 + <iconset resource="../../qmc2.qrc">
531 <normaloff>:/htmleditor/images/edit-paste.png</normaloff>:/htmleditor/images/edit-paste.png</iconset>
533 <property name="text">
536 <action name="actionEditSelectAll">
537 <property name="icon">
538 - <iconset resource="../qmc2.qrc">
539 + <iconset resource="../../qmc2.qrc">
540 <normaloff>:/htmleditor/images/edit-select-all.png</normaloff>:/htmleditor/images/edit-select-all.png</iconset>
542 <property name="text">
546 <property name="icon">
547 - <iconset resource="../qmc2.qrc">
548 + <iconset resource="../../qmc2.qrc">
549 <normaloff>:/htmleditor/images/format-text-bold.png</normaloff>:/htmleditor/images/format-text-bold.png</iconset>
551 <property name="text">
555 <property name="icon">
556 - <iconset resource="../qmc2.qrc">
557 + <iconset resource="../../qmc2.qrc">
558 <normaloff>:/htmleditor/images/format-text-italic.png</normaloff>:/htmleditor/images/format-text-italic.png</iconset>
560 <property name="text">
564 <property name="icon">
565 - <iconset resource="../qmc2.qrc">
566 + <iconset resource="../../qmc2.qrc">
567 <normaloff>:/htmleditor/images/format-text-underline.png</normaloff>:/htmleditor/images/format-text-underline.png</iconset>
569 <property name="text">
573 <property name="icon">
574 - <iconset resource="../qmc2.qrc">
575 + <iconset resource="../../qmc2.qrc">
576 <normaloff>:/htmleditor/images/format-text-strikethrough.png</normaloff>:/htmleditor/images/format-text-strikethrough.png</iconset>
578 <property name="text">
581 <action name="actionFormatAlignLeft">
582 <property name="icon">
583 - <iconset resource="../qmc2.qrc">
584 + <iconset resource="../../qmc2.qrc">
585 <normaloff>:/htmleditor/images/format-justify-left.png</normaloff>:/htmleditor/images/format-justify-left.png</iconset>
587 <property name="text">
590 <action name="actionFormatAlignCenter">
591 <property name="icon">
592 - <iconset resource="../qmc2.qrc">
593 + <iconset resource="../../qmc2.qrc">
594 <normaloff>:/htmleditor/images/format-justify-center.png</normaloff>:/htmleditor/images/format-justify-center.png</iconset>
596 <property name="text">
599 <action name="actionFormatAlignRight">
600 <property name="icon">
601 - <iconset resource="../qmc2.qrc">
602 + <iconset resource="../../qmc2.qrc">
603 <normaloff>:/htmleditor/images/format-justify-right.png</normaloff>:/htmleditor/images/format-justify-right.png</iconset>
605 <property name="text">
608 <action name="actionFormatAlignJustify">
609 <property name="icon">
610 - <iconset resource="../qmc2.qrc">
611 + <iconset resource="../../qmc2.qrc">
612 <normaloff>:/htmleditor/images/format-justify-fill.png</normaloff>:/htmleditor/images/format-justify-fill.png</iconset>
614 <property name="text">
617 <action name="actionFormatIncreaseIndent">
618 <property name="icon">
619 - <iconset resource="../qmc2.qrc">
620 + <iconset resource="../../qmc2.qrc">
621 <normaloff>:/htmleditor/images/format-indent-more.png</normaloff>:/htmleditor/images/format-indent-more.png</iconset>
623 <property name="text">
626 <action name="actionFormatDecreaseIndent">
627 <property name="icon">
628 - <iconset resource="../qmc2.qrc">
629 + <iconset resource="../../qmc2.qrc">
630 <normaloff>:/htmleditor/images/format-indent-less.png</normaloff>:/htmleditor/images/format-indent-less.png</iconset>
632 <property name="text">
636 <property name="icon">
637 - <iconset resource="../qmc2.qrc">
638 + <iconset resource="../../qmc2.qrc">
639 <normaloff>:/htmleditor/images/bulleted-list.png</normaloff>:/htmleditor/images/bulleted-list.png</iconset>
641 <property name="text">
645 <property name="icon">
646 - <iconset resource="../qmc2.qrc">
647 + <iconset resource="../../qmc2.qrc">
648 <normaloff>:/htmleditor/images/numbered-list.png</normaloff>:/htmleditor/images/numbered-list.png</iconset>
650 <property name="text">
653 <action name="actionInsertImageFromFile">
654 <property name="icon">
655 - <iconset resource="../qmc2.qrc">
656 + <iconset resource="../../qmc2.qrc">
657 <normaloff>:/htmleditor/images/document-open.png</normaloff>:/htmleditor/images/document-open.png</iconset>
659 <property name="text">
662 <action name="actionInsertImageFromUrl">
663 <property name="icon">
664 - <iconset resource="../qmc2.qrc">
665 + <iconset resource="../../qmc2.qrc">
666 <normaloff>:/htmleditor/images/text-html.png</normaloff>:/htmleditor/images/text-html.png</iconset>
668 <property name="text">
671 <action name="actionCreateLink">
672 <property name="icon">
673 - <iconset resource="../qmc2.qrc">
674 + <iconset resource="../../qmc2.qrc">
675 <normaloff>:/htmleditor/images/text-html.png</normaloff>:/htmleditor/images/text-html.png</iconset>
677 <property name="text">
680 <action name="actionZoomOut">
681 <property name="icon">
682 - <iconset resource="../qmc2.qrc">
683 + <iconset resource="../../qmc2.qrc">
684 <normaloff>:/htmleditor/images/list-remove.png</normaloff>:/htmleditor/images/list-remove.png</iconset>
686 <property name="text">
689 <action name="actionZoomIn">
690 <property name="icon">
691 - <iconset resource="../qmc2.qrc">
692 + <iconset resource="../../qmc2.qrc">
693 <normaloff>:/htmleditor/images/list-add.png</normaloff>:/htmleditor/images/list-add.png</iconset>
695 <property name="text">
698 <action name="actionInsertHtml">
699 <property name="icon">
700 - <iconset resource="../qmc2.qrc">
701 + <iconset resource="../../qmc2.qrc">
702 <normaloff>:/htmleditor/images/insert-html.png</normaloff>:/htmleditor/images/insert-html.png</iconset>
704 <property name="text">
707 <action name="actionInsertTable">
708 <property name="icon">
709 - <iconset resource="../qmc2.qrc">
710 + <iconset resource="../../qmc2.qrc">
711 <normaloff>:/htmleditor/images/insert-table.png</normaloff>:/htmleditor/images/insert-table.png</iconset>
713 <property name="text">
714 @@ -769,13 +769,13 @@
718 - <class>QWebView</class>
719 + <class>QWebEngineView</class>
720 <extends>QWidget</extends>
721 - <header>QtWebKitWidgets/QWebView</header>
722 + <header>QWebEngineView</header>
726 - <include location="../qmc2.qrc"/>
727 + <include location="../../qmc2.qrc"/>
731 diff --git a/src/macros.h b/src/macros.h
732 index a7b15451d..66b7534e7 100644
736 // ProjectMESS base URL (default)
737 #define QMC2_PROJECT_MESS_BASE_URL "http://www.progettoemma.net/mess/gioco.php?game=%1&list=%2"
739 -// maximum number of pages held in QtWebKit's page cache
740 -#define QMC2_BROWSER_CACHE_PAGES 100
743 #define QMC2_TO_UINT32(a) ((uchar)*((a) + 0) * (quint32)16777216ULL + \
744 (uchar)*((a) + 1) * (quint32)65536ULL + \
745 diff --git a/src/miniwebbrowser.cpp b/src/miniwebbrowser.cpp
746 index c704088fb..b9dbddae4 100644
747 --- a/src/miniwebbrowser.cpp
748 +++ b/src/miniwebbrowser.cpp
750 #include <QApplication>
751 #include <QDesktopWidget>
753 -#include <QtWebKitWidgets/QWebFrame>
754 -#include <QtWebKitWidgets/QWebInspector>
755 -#include <QWebHistory>
756 +#include <QWebEngineHistory>
757 +#include <QWebEngineSettings>
758 #include <QFontMetrics>
760 #include "settings.h"
761 @@ -29,8 +28,6 @@ MiniWebBrowser::MiniWebBrowser(QWidget *parent, bool useAsPdfViewer)
762 setObjectName("MiniWebBrowser");
763 m_isPdfViewer = useAsPdfViewer;
765 - QWebSettings::setMaximumPagesInCache(QMC2_BROWSER_CACHE_PAGES);
767 if ( MiniWebBrowser::supportedSchemes.isEmpty() )
768 MiniWebBrowser::supportedSchemes << "http" << "ftp" << "file";
770 @@ -64,17 +61,16 @@ MiniWebBrowser::MiniWebBrowser(QWidget *parent, bool useAsPdfViewer)
771 iconCache.setMaxCost(QMC2_BROWSER_ICONCACHE_SIZE);
773 // we want the same global network access manager for all browsers
774 - webViewBrowser->page()->setNetworkAccessManager(qmc2NetworkAccessManager);
775 + //webViewBrowser->page()->setNetworkAccessManager(qmc2NetworkAccessManager);
777 // we want to manipulate the link activation
778 - webViewBrowser->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks);
779 + //webViewBrowser->page()->setLinkDelegationPolicy(QWebEnginePage::DelegateAllLinks);
781 // connect page actions we provide
782 connect(webViewBrowser->page(), SIGNAL(downloadRequested(const QNetworkRequest &)), this, SLOT(processPageActionDownloadRequested(const QNetworkRequest &)));
783 connect(webViewBrowser->page(), SIGNAL(unsupportedContent(QNetworkReply *)), this, SLOT(processPageActionHandleUnsupportedContent(QNetworkReply *)));
784 connect(webViewBrowser->page(), SIGNAL(linkHovered(const QString &, const QString &, const QString &)), this, SLOT(webViewBrowser_linkHovered(const QString &, const QString &, const QString &)));
785 connect(webViewBrowser->page(), SIGNAL(statusBarVisibilityChangeRequested(bool)), this, SLOT(webViewBrowser_statusBarVisibilityChangeRequested(bool)));
786 - connect(webViewBrowser->page(), SIGNAL(frameCreated(QWebFrame *)), this, SLOT(webViewBrowser_frameCreated(QWebFrame *)));
788 connect(webViewBrowser, SIGNAL(linkClicked(const QUrl)), this, SLOT(webViewBrowser_linkClicked(const QUrl)));
789 connect(webViewBrowser, SIGNAL(urlChanged(const QUrl)), this, SLOT(webViewBrowser_urlChanged(const QUrl)));
790 @@ -89,97 +85,103 @@ MiniWebBrowser::MiniWebBrowser(QWidget *parent, bool useAsPdfViewer)
791 if ( isPdfViewer() ) {
793 // hide all page actions
794 - for (QWebPage::WebAction pa = QWebPage::OpenLink; pa != QWebPage::AlignRight; pa = static_cast<QWebPage::WebAction>(static_cast<int>(pa) + 1)) {
796 + for (QWebEnginePage::WebAction pa = QWebEnginePage::Back; pa != QWebEnginePage::InsertUnorderedList; pa = static_cast<QWebEnginePage::WebAction>(static_cast<int>(pa) + 1)) {
797 QAction *a= webViewBrowser->pageAction(pa);
799 a->setVisible(false);
804 // hide page actions we don't provide
805 - webViewBrowser->pageAction(QWebPage::OpenFrameInNewWindow)->setVisible(false);
806 + webViewBrowser->pageAction(QWebEnginePage::OpenFrameInNewWindow)->setVisible(false);
808 // change provided page actions to better fit our usage / integrate into QMC2's look
809 - webViewBrowser->pageAction(QWebPage::OpenLink)->setText(tr("Open link"));
810 - webViewBrowser->pageAction(QWebPage::OpenLink)->setIcon(QIcon(QString::fromUtf8(":/data/img/fileopen.png")));
811 - webViewBrowser->pageAction(QWebPage::OpenLinkInNewWindow)->setText(tr("Open link in new window"));
812 - webViewBrowser->pageAction(QWebPage::OpenLinkInNewWindow)->setIcon(QIcon(QString::fromUtf8(":/data/img/browser.png")));
813 - webViewBrowser->pageAction(QWebPage::OpenImageInNewWindow)->setText(tr("Open image in new window"));
814 - webViewBrowser->pageAction(QWebPage::OpenImageInNewWindow)->setIcon(QIcon(QString::fromUtf8(":/data/img/thumbnail.png")));
815 - webViewBrowser->pageAction(QWebPage::DownloadLinkToDisk)->setText(tr("Save link as..."));
816 - webViewBrowser->pageAction(QWebPage::DownloadLinkToDisk)->setIcon(QIcon(QString::fromUtf8(":/data/img/filesaveas.png")));
817 - webViewBrowser->pageAction(QWebPage::CopyLinkToClipboard)->setText(tr("Copy link"));
818 - webViewBrowser->pageAction(QWebPage::CopyLinkToClipboard)->setIcon(QIcon(QString::fromUtf8(":/data/img/editcopy.png")));
819 - webViewBrowser->pageAction(QWebPage::DownloadImageToDisk)->setText(tr("Save image as..."));
820 - webViewBrowser->pageAction(QWebPage::DownloadImageToDisk)->setIcon(QIcon(QString::fromUtf8(":/data/img/filesaveas.png")));
821 - webViewBrowser->pageAction(QWebPage::CopyImageToClipboard)->setText(tr("Copy image"));
822 - webViewBrowser->pageAction(QWebPage::CopyImageToClipboard)->setIcon(QIcon(QString::fromUtf8(":/data/img/editcopy.png")));
823 - webViewBrowser->pageAction(QWebPage::CopyImageUrlToClipboard)->setText(tr("Copy image address"));
824 - webViewBrowser->pageAction(QWebPage::Back)->setText(tr("Go back"));
825 - webViewBrowser->pageAction(QWebPage::Back)->setIcon(QIcon(QString::fromUtf8(":/data/img/back.png")));
826 - webViewBrowser->pageAction(QWebPage::Forward)->setText(tr("Go forward"));
827 - webViewBrowser->pageAction(QWebPage::Forward)->setIcon(QIcon(QString::fromUtf8(":/data/img/forward.png")));
828 - webViewBrowser->pageAction(QWebPage::Reload)->setText(tr("Reload"));
829 - webViewBrowser->pageAction(QWebPage::Reload)->setIcon(QIcon(QString::fromUtf8(":/data/img/reload.png")));
830 - webViewBrowser->pageAction(QWebPage::Stop)->setText(tr("Stop"));
831 - webViewBrowser->pageAction(QWebPage::Stop)->setIcon(QIcon(QString::fromUtf8(":/data/img/stop_browser.png")));
832 - webViewBrowser->pageAction(QWebPage::Copy)->setText(tr("Copy"));
833 - webViewBrowser->pageAction(QWebPage::Copy)->setIcon(QIcon(QString::fromUtf8(":/data/img/editcopy.png")));
834 + webViewBrowser->pageAction(QWebEnginePage::OpenLink)->setText(tr("Open link"));
835 + webViewBrowser->pageAction(QWebEnginePage::OpenLink)->setIcon(QIcon(QString::fromUtf8(":/data/img/fileopen.png")));
836 + webViewBrowser->pageAction(QWebEnginePage::OpenLinkInNewWindow)->setText(tr("Open link in new window"));
837 + webViewBrowser->pageAction(QWebEnginePage::OpenLinkInNewWindow)->setIcon(QIcon(QString::fromUtf8(":/data/img/browser.png")));
838 + webViewBrowser->pageAction(QWebEnginePage::OpenImageInNewWindow)->setText(tr("Open image in new window"));
839 + webViewBrowser->pageAction(QWebEnginePage::OpenImageInNewWindow)->setIcon(QIcon(QString::fromUtf8(":/data/img/thumbnail.png")));
840 + webViewBrowser->pageAction(QWebEnginePage::DownloadLinkToDisk)->setText(tr("Save link as..."));
841 + webViewBrowser->pageAction(QWebEnginePage::DownloadLinkToDisk)->setIcon(QIcon(QString::fromUtf8(":/data/img/filesaveas.png")));
842 + webViewBrowser->pageAction(QWebEnginePage::CopyLinkToClipboard)->setText(tr("Copy link"));
843 + webViewBrowser->pageAction(QWebEnginePage::CopyLinkToClipboard)->setIcon(QIcon(QString::fromUtf8(":/data/img/editcopy.png")));
844 + webViewBrowser->pageAction(QWebEnginePage::DownloadImageToDisk)->setText(tr("Save image as..."));
845 + webViewBrowser->pageAction(QWebEnginePage::DownloadImageToDisk)->setIcon(QIcon(QString::fromUtf8(":/data/img/filesaveas.png")));
846 + webViewBrowser->pageAction(QWebEnginePage::CopyImageToClipboard)->setText(tr("Copy image"));
847 + webViewBrowser->pageAction(QWebEnginePage::CopyImageToClipboard)->setIcon(QIcon(QString::fromUtf8(":/data/img/editcopy.png")));
848 + webViewBrowser->pageAction(QWebEnginePage::CopyImageUrlToClipboard)->setText(tr("Copy image address"));
849 + webViewBrowser->pageAction(QWebEnginePage::Back)->setText(tr("Go back"));
850 + webViewBrowser->pageAction(QWebEnginePage::Back)->setIcon(QIcon(QString::fromUtf8(":/data/img/back.png")));
851 + webViewBrowser->pageAction(QWebEnginePage::Forward)->setText(tr("Go forward"));
852 + webViewBrowser->pageAction(QWebEnginePage::Forward)->setIcon(QIcon(QString::fromUtf8(":/data/img/forward.png")));
853 + webViewBrowser->pageAction(QWebEnginePage::Reload)->setText(tr("Reload"));
854 + webViewBrowser->pageAction(QWebEnginePage::Reload)->setIcon(QIcon(QString::fromUtf8(":/data/img/reload.png")));
855 + webViewBrowser->pageAction(QWebEnginePage::Stop)->setText(tr("Stop"));
856 + webViewBrowser->pageAction(QWebEnginePage::Stop)->setIcon(QIcon(QString::fromUtf8(":/data/img/stop_browser.png")));
857 + webViewBrowser->pageAction(QWebEnginePage::Copy)->setText(tr("Copy"));
858 + webViewBrowser->pageAction(QWebEnginePage::Copy)->setIcon(QIcon(QString::fromUtf8(":/data/img/editcopy.png")));
859 #if defined(QMC2_BROWSER_EXTRAS_ENABLED)
860 - webViewBrowser->pageAction(QWebPage::InspectElement)->setText(tr("Inspect"));
861 - webViewBrowser->pageAction(QWebPage::InspectElement)->setIcon(QIcon(QString::fromUtf8(":/data/img/inspect.png")));
862 + webViewBrowser->pageAction(QWebEnginePage::InspectElement)->setText(tr("Inspect"));
863 + webViewBrowser->pageAction(QWebEnginePage::InspectElement)->setIcon(QIcon(QString::fromUtf8(":/data/img/inspect.png")));
867 // connect page actions to own routines
868 - connect(webViewBrowser->pageAction(QWebPage::Back), SIGNAL(triggered()), this, SLOT(checkBackAndForward()));
869 - connect(webViewBrowser->pageAction(QWebPage::Forward), SIGNAL(triggered()), this, SLOT(checkBackAndForward()));
870 + connect(webViewBrowser->pageAction(QWebEnginePage::Back), SIGNAL(triggered()), this, SLOT(checkBackAndForward()));
871 + connect(webViewBrowser->pageAction(QWebEnginePage::Forward), SIGNAL(triggered()), this, SLOT(checkBackAndForward()));
874 // setup browser settings
876 webViewBrowser->page()->settings()->setIconDatabasePath(Options::configPath());
877 - webViewBrowser->page()->settings()->setAttribute(QWebSettings::AutoLoadImages, true);
878 + webViewBrowser->page()->settings()->setAttribute(QWebEngineSettings::AutoLoadImages, true);
879 #if defined(QMC2_BROWSER_JAVASCRIPT_ENABLED)
880 - webViewBrowser->page()->settings()->setAttribute(QWebSettings::JavascriptEnabled, true);
881 - webViewBrowser->page()->settings()->setAttribute(QWebSettings::JavascriptCanOpenWindows, true);
882 - webViewBrowser->page()->settings()->setAttribute(QWebSettings::JavascriptCanAccessClipboard, true);
883 + webViewBrowser->page()->settings()->setAttribute(QWebEngineSettings::JavascriptEnabled, true);
884 + webViewBrowser->page()->settings()->setAttribute(QWebEngineSettings::JavascriptCanOpenWindows, true);
885 + webViewBrowser->page()->settings()->setAttribute(QWebEngineSettings::JavascriptCanAccessClipboard, true);
887 - webViewBrowser->page()->settings()->setAttribute(QWebSettings::JavascriptEnabled, false);
888 + webViewBrowser->page()->settings()->setAttribute(QWebEngineSettings::JavascriptEnabled, false);
890 #if defined(QMC2_BROWSER_JAVA_ENABLED)
891 - webViewBrowser->page()->settings()->setAttribute(QWebSettings::JavaEnabled, true);
892 + webViewBrowser->page()->settings()->setAttribute(QWebEngineSettings::JavaEnabled, true);
894 - webViewBrowser->page()->settings()->setAttribute(QWebSettings::JavaEnabled, false);
895 + webViewBrowser->page()->settings()->setAttribute(QWebEngineSettings::JavaEnabled, false);
897 #if defined(QMC2_BROWSER_PLUGINS_ENABLED)
898 - webViewBrowser->page()->settings()->setAttribute(QWebSettings::PluginsEnabled, true);
899 + webViewBrowser->page()->settings()->setAttribute(QWebEngineSettings::PluginsEnabled, true);
901 - webViewBrowser->page()->settings()->setAttribute(QWebSettings::PluginsEnabled, false);
902 + webViewBrowser->page()->settings()->setAttribute(QWebEngineSettings::PluginsEnabled, false);
904 - webViewBrowser->page()->settings()->setAttribute(QWebSettings::PrivateBrowsingEnabled, false);
905 + webViewBrowser->page()->settings()->setAttribute(QWebEngineSettings::PrivateBrowsingEnabled, false);
906 #if defined(QMC2_BROWSER_EXTRAS_ENABLED)
907 - webViewBrowser->page()->settings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, true);
908 + webViewBrowser->page()->settings()->setAttribute(QWebEngineSettings::DeveloperExtrasEnabled, true);
910 - webViewBrowser->page()->settings()->setAttribute(QWebSettings::DeveloperExtrasEnabled, false);
911 + webViewBrowser->page()->settings()->setAttribute(QWebEngineSettings::DeveloperExtrasEnabled, false);
913 - webViewBrowser->page()->settings()->setAttribute(QWebSettings::LinksIncludedInFocusChain, false);
914 - webViewBrowser->page()->settings()->setAttribute(QWebSettings::ZoomTextOnly, false);
915 - webViewBrowser->page()->settings()->setAttribute(QWebSettings::PrintElementBackgrounds, false);
916 - webViewBrowser->page()->settings()->setAttribute(QWebSettings::OfflineStorageDatabaseEnabled, false);
917 - webViewBrowser->page()->settings()->setAttribute(QWebSettings::OfflineWebApplicationCacheEnabled, false);
918 - webViewBrowser->page()->settings()->setAttribute(QWebSettings::LocalStorageEnabled, true);
919 + webViewBrowser->page()->settings()->setAttribute(QWebEngineSettings::LinksIncludedInFocusChain, false);
920 + webViewBrowser->page()->settings()->setAttribute(QWebEngineSettings::ZoomTextOnly, false);
921 + webViewBrowser->page()->settings()->setAttribute(QWebEngineSettings::PrintElementBackgrounds, false);
922 + webViewBrowser->page()->settings()->setAttribute(QWebEngineSettings::OfflineStorageDatabaseEnabled, false);
923 + webViewBrowser->page()->settings()->setAttribute(QWebEngineSettings::OfflineWebApplicationCacheEnabled, false);
924 + webViewBrowser->page()->settings()->setAttribute(QWebEngineSettings::LocalStorageEnabled, true);
925 #if defined(QMC2_BROWSER_PREFETCH_DNS_ENABLED)
926 - webViewBrowser->page()->settings()->setAttribute(QWebSettings::DnsPrefetchEnabled, true);
927 + webViewBrowser->page()->settings()->setAttribute(QWebEngineSettings::DnsPrefetchEnabled, true);
929 - webViewBrowser->page()->settings()->setAttribute(QWebSettings::DnsPrefetchEnabled, false);
930 + webViewBrowser->page()->settings()->setAttribute(QWebEngineSettings::DnsPrefetchEnabled, false);
934 connect(this, SIGNAL(titleChanged(QString &)), this, SLOT(changeTitle(QString &)));
936 #if defined(QMC2_BROWSER_EXTRAS_ENABLED)
937 - connect(webViewBrowser->pageAction(QWebPage::InspectElement), SIGNAL(triggered()), this, SLOT(postProcessPageActionInspect()), Qt::QueuedConnection);
938 + connect(webViewBrowser->pageAction(QWebEnginePage::InspectElement), SIGNAL(triggered()), this, SLOT(postProcessPageActionInspect()), Qt::QueuedConnection);
941 // we want to detect/handle unsupported content
942 - webViewBrowser->page()->setForwardUnsupportedContent(true);
943 + //webViewBrowser->page()->setForwardUnsupportedContent(true);
945 // status bar timeout connection
946 connect(&statusTimer, SIGNAL(timeout()), this, SLOT(statusTimeout()));
947 @@ -230,26 +232,32 @@ void MiniWebBrowser::on_toolButtonHighlight_clicked()
949 void MiniWebBrowser::on_toolButtonNext_clicked()
954 - webViewBrowser->page()->findText("", QWebPage::HighlightAllOccurrences);
955 - QWebPage::FindFlags flags = QWebPage::FindWrapsAroundDocument;
956 + webViewBrowser->page()->findText("", QWebEnginePage::HighlightAllOccurrences);
957 + QWebEnginePage::FindFlags flags = QWebEnginePage::FindWrapsAroundDocument;
958 if ( toolButtonCaseSensitive->isChecked() )
959 - flags |= QWebPage::FindCaseSensitively;
960 + flags |= QWebEnginePage::FindCaseSensitively;
961 webViewBrowser->page()->findText(iconLineEditSearch->text(), flags);
962 if ( toolButtonHighlight->isChecked() )
963 - webViewBrowser->page()->findText(iconLineEditSearch->text(), flags | QWebPage::HighlightAllOccurrences);
964 + webViewBrowser->page()->findText(iconLineEditSearch->text(), flags | QWebEnginePage::HighlightAllOccurrences);
968 void MiniWebBrowser::on_toolButtonPrevious_clicked()
973 - webViewBrowser->page()->findText("", QWebPage::HighlightAllOccurrences);
974 - QWebPage::FindFlags flags = QWebPage::FindWrapsAroundDocument | QWebPage::FindBackward;
975 + webViewBrowser->page()->findText("", QWebEnginePage::HighlightAllOccurrences);
976 + QWebEnginePage::FindFlags flags = QWebEnginePage::FindWrapsAroundDocument | QWebEnginePage::FindBackward;
977 if ( toolButtonCaseSensitive->isChecked() )
978 - flags |= QWebPage::FindCaseSensitively;
979 + flags |= QWebEnginePage::FindCaseSensitively;
980 webViewBrowser->page()->findText(iconLineEditSearch->text(), flags);
981 if ( toolButtonHighlight->isChecked() )
982 - webViewBrowser->page()->findText(iconLineEditSearch->text(), flags | QWebPage::HighlightAllOccurrences);
983 + webViewBrowser->page()->findText(iconLineEditSearch->text(), flags | QWebEnginePage::HighlightAllOccurrences);
987 void MiniWebBrowser::on_toolButtonToggleSearchBar_clicked()
988 @@ -287,6 +295,8 @@ void MiniWebBrowser::on_toolButtonForward_clicked()
989 void MiniWebBrowser::hideEvent(QHideEvent *e)
991 #if defined(QMC2_BROWSER_EXTRAS_ENABLED)
994 foreach (QWidget *widget, QApplication::topLevelWidgets()) {
995 if ( widget->inherits("QWebInspector") ) {
996 QWebInspector *inspector = (QWebInspector *)widget;
997 @@ -299,6 +309,7 @@ void MiniWebBrowser::hideEvent(QHideEvent *e)
1005 @@ -309,6 +320,8 @@ void MiniWebBrowser::hideEvent(QHideEvent *e)
1006 void MiniWebBrowser::postProcessPageActionInspect()
1008 #if defined(QMC2_BROWSER_EXTRAS_ENABLED)
1011 foreach (QWidget *widget, QApplication::topLevelWidgets()) {
1012 if ( widget->inherits("QWebInspector") ) {
1013 QWebInspector *inspector = (QWebInspector *)widget;
1014 @@ -318,6 +331,7 @@ void MiniWebBrowser::postProcessPageActionInspect()
1022 @@ -383,6 +397,7 @@ void MiniWebBrowser::webViewBrowser_linkClicked(const QUrl url)
1023 webBrowser->webViewBrowser->load(url);
1027 QWebHitTestResult hitTest = webViewBrowser->page()->mainFrame()->hitTestContent(webViewBrowser->lastMouseClickPosition);
1028 if ( hitTest.linkTargetFrame() )
1029 hitTest.linkTargetFrame()->load(url);
1030 @@ -390,6 +405,9 @@ void MiniWebBrowser::webViewBrowser_linkClicked(const QUrl url)
1031 webViewBrowser->load(url);
1032 webViewBrowser_urlChanged(url);
1035 + webViewBrowser->load(url);
1036 + webViewBrowser_urlChanged(url);
1039 QTimer::singleShot(0, this, SLOT(checkBackAndForward()));
1040 @@ -517,7 +535,7 @@ void MiniWebBrowser::webViewBrowser_iconChanged()
1041 if ( iconCache.contains(urlStr) )
1042 pageIcon = *iconCache[urlStr];
1043 if ( pageIcon.isNull() ) {
1044 - pageIcon = QWebSettings::iconForUrl(webViewBrowser->url());
1045 + //pageIcon = QWebEngineSettings::iconForUrl(webViewBrowser->url());
1046 if ( pageIcon.isNull() )
1047 pageIcon = QIcon(QString::fromUtf8(":/data/img/browser.png"));
1049 @@ -546,11 +564,6 @@ void MiniWebBrowser::webViewBrowser_statusBarVisibilityChangeRequested(bool visi
1050 progressBar->setVisible(visible);
1053 -void MiniWebBrowser::webViewBrowser_frameCreated(QWebFrame *frame)
1058 void MiniWebBrowser::statusTimeout()
1061 @@ -652,11 +665,11 @@ void MiniWebBrowser::setStatus(QString statusMessage)
1065 -QWebView *BrowserWidget::createWindow(QWebPage::WebWindowType type)
1066 +QWebEngineView *BrowserWidget::createWindow(QWebEnginePage::WebWindowType type)
1068 MiniWebBrowser *webBrowser = new MiniWebBrowser(0);
1069 - if ( type == QWebPage::WebModalDialog )
1070 - webBrowser->setWindowModality(Qt::ApplicationModal);
1071 + //if ( type == QWebEnginePage::WebModalDialog )
1072 + // webBrowser->setWindowModality(Qt::ApplicationModal);
1073 webBrowser->setAttribute(Qt::WA_DeleteOnClose);
1074 if ( parentBrowser )
1075 webBrowser->spinBoxZoom->setValue(parentBrowser->spinBoxZoom->value());
1076 @@ -679,6 +692,6 @@ void BrowserWidget::wheelEvent(QWheelEvent *e)
1080 - QWebView::wheelEvent(e);
1081 + QWebEngineView::wheelEvent(e);
1084 diff --git a/src/miniwebbrowser.h b/src/miniwebbrowser.h
1085 index 4beaafeb3..945892a01 100644
1086 --- a/src/miniwebbrowser.h
1087 +++ b/src/miniwebbrowser.h
1089 #define MINIWEBBROWSER_H
1092 -#include <QtWebKitWidgets/QWebView>
1093 +#include <QWebEngineView>
1094 #include <QMouseEvent>
1099 class MiniWebBrowser;
1101 -class BrowserWidget : public QWebView
1102 +class BrowserWidget : public QWebEngineView
1106 @@ -23,7 +23,7 @@ class BrowserWidget : public QWebView
1107 QTimer bwuDelayTimer;
1108 MiniWebBrowser *parentBrowser;
1110 - BrowserWidget(QWidget *parent, MiniWebBrowser *browserParent) : QWebView(parent)
1111 + BrowserWidget(QWidget *parent, MiniWebBrowser *browserParent) : QWebEngineView(parent)
1113 bwuDelayTimer.setSingleShot(true);
1114 lastMouseClickPosition = QPoint(-1, -1);
1115 @@ -38,22 +38,22 @@ class BrowserWidget : public QWebView
1116 void mousePressEvent(QMouseEvent *e)
1118 lastMouseClickPosition = e->pos();
1119 - QWebView::mousePressEvent(e);
1120 + QWebEngineView::mousePressEvent(e);
1122 void enterEvent(QEvent *e)
1124 - QWebView::enterEvent(e);
1125 + QWebEngineView::enterEvent(e);
1126 mouseCurrentlyOnView = true;
1127 emit mouseOnView(true);
1129 void leaveEvent(QEvent *e)
1131 - QWebView::leaveEvent(e);
1132 + QWebEngineView::leaveEvent(e);
1133 mouseCurrentlyOnView = false;
1134 emit mouseOnView(false);
1136 void wheelEvent(QWheelEvent *);
1137 - QWebView *createWindow(QWebPage::WebWindowType);
1138 + QWebEngineView *createWindow(QWebEnginePage::WebWindowType);
1141 class MiniWebBrowser : public QWidget, public Ui::MiniWebBrowser
1142 @@ -110,7 +110,6 @@ class MiniWebBrowser : public QWidget, public Ui::MiniWebBrowser
1143 void webViewBrowser_iconChanged();
1144 void webViewBrowser_linkHovered(const QString &, const QString &, const QString &);
1145 void webViewBrowser_statusBarVisibilityChangeRequested(bool);
1146 - void webViewBrowser_frameCreated(QWebFrame *);
1147 void statusTimeout();
1148 void adjustIconSizes();
1149 void setStatus(QString);
1150 diff --git a/src/options.cpp b/src/options.cpp
1151 index 0e0ee627a..4c92135fc 100644
1152 --- a/src/options.cpp
1153 +++ b/src/options.cpp
1155 #include <QSplashScreen>
1156 #include <QNetworkAccessManager>
1158 +#include <QWebEngineSettings>
1160 #include "options.h"
1162 @@ -207,7 +208,7 @@ Options::Options(QWidget *parent) :
1164 config = new Settings(QSettings::IniFormat, QSettings::UserScope, "qmc2");
1166 - QWebSettings::enablePersistentStorage(userScopePath);
1167 + //QWebEngineSettings::enablePersistentStorage(userScopePath);
1171 @@ -600,14 +601,14 @@ void Options::apply()
1172 tb->setIconSize(iconSizeMiddle);
1174 // global web-browser fonts
1175 - QWebSettings::globalSettings()->setFontFamily(QWebSettings::StandardFont, qApp->font().family());
1176 - QWebSettings::globalSettings()->setFontFamily(QWebSettings::SerifFont, qApp->font().family());
1177 - QWebSettings::globalSettings()->setFontFamily(QWebSettings::SansSerifFont, qApp->font().family());
1178 - QWebSettings::globalSettings()->setFontFamily(QWebSettings::FantasyFont, qApp->font().family());
1179 - QWebSettings::globalSettings()->setFontFamily(QWebSettings::CursiveFont, qApp->font().family());
1180 - QWebSettings::globalSettings()->setFontFamily(QWebSettings::FixedFont, logFont.family());
1181 - QWebSettings::globalSettings()->setFontSize(QWebSettings::DefaultFontSize, qApp->font().pointSize() + 1);
1182 - QWebSettings::globalSettings()->setFontSize(QWebSettings::DefaultFixedFontSize, logFont.pointSize() + 1);
1183 + QWebEngineSettings::defaultSettings()->setFontFamily(QWebEngineSettings::StandardFont, qApp->font().family());
1184 + QWebEngineSettings::defaultSettings()->setFontFamily(QWebEngineSettings::SerifFont, qApp->font().family());
1185 + QWebEngineSettings::defaultSettings()->setFontFamily(QWebEngineSettings::SansSerifFont, qApp->font().family());
1186 + QWebEngineSettings::defaultSettings()->setFontFamily(QWebEngineSettings::FantasyFont, qApp->font().family());
1187 + QWebEngineSettings::defaultSettings()->setFontFamily(QWebEngineSettings::CursiveFont, qApp->font().family());
1188 + QWebEngineSettings::defaultSettings()->setFontFamily(QWebEngineSettings::FixedFont, logFont.family());
1189 + QWebEngineSettings::defaultSettings()->setFontSize(QWebEngineSettings::DefaultFontSize, qApp->font().pointSize() + 1);
1190 + QWebEngineSettings::defaultSettings()->setFontSize(QWebEngineSettings::DefaultFixedFontSize, logFont.pointSize() + 1);
1191 #if QMC2_JOYSTICK == 1
1192 pushButtonRescanJoysticks->setIconSize(iconSize);
1193 pushButtonRemapJoystickFunction->setIconSize(iconSize);
1194 diff --git a/src/qmc2main.cpp b/src/qmc2main.cpp
1195 index 2298f0b4a..4cd3ed24f 100644
1196 --- a/src/qmc2main.cpp
1197 +++ b/src/qmc2main.cpp
1198 @@ -8130,8 +8130,10 @@ void MainWindow::projectMessLoadFinished(bool ok)
1199 QString cacheKey = qmc2SoftwareList->currentItem->text(QMC2_SWLIST_COLUMN_LIST) + "_" + qmc2SoftwareList->currentItem->text(QMC2_SWLIST_COLUMN_NAME);
1200 if ( qmc2ProjectMESSCache.contains(cacheKey) )
1201 qmc2ProjectMESSCache.remove(cacheKey);
1202 - QByteArray data = QMC2_COMPRESS(qmc2ProjectMESS->webViewBrowser->page()->mainFrame()->toHtml().toUtf8());
1203 - qmc2ProjectMESSCache.insert(cacheKey, new QByteArray(data), data.size());
1204 + QString data("%1");
1205 + qmc2ProjectMESS->webViewBrowser->page()->toHtml([data](const QString &result) { data.arg(result); });
1206 + QByteArray cdata = QMC2_COMPRESS(data.toUtf8());
1207 + qmc2ProjectMESSCache.insert(cacheKey, new QByteArray(cdata), cdata.size());
1210 // we only want to know this ONCE
1211 @@ -8146,8 +8148,10 @@ void MainWindow::projectMessSystemLoadStarted()
1212 void MainWindow::projectMessSystemLoadFinished(bool ok)
1215 - QByteArray projectMessData = QMC2_COMPRESS(qmc2ProjectMESSLookup->webViewBrowser->page()->mainFrame()->toHtml().toUtf8());
1216 - QString machName = qmc2CurrentItem->text(QMC2_MACHINELIST_COLUMN_NAME);
1217 + QString data("%1");
1218 + qmc2ProjectMESSLookup->webViewBrowser->page()->toHtml([data](const QString &result) { data.arg(result); });
1219 + QByteArray projectMessData = QMC2_COMPRESS(data.toUtf8());
1220 + QString machName(qmc2CurrentItem->text(QMC2_MACHINELIST_COLUMN_NAME));
1221 if ( qmc2ProjectMESSCache.contains(machName) )
1222 qmc2ProjectMESSCache.remove(machName);
1223 qmc2ProjectMESSCache.insert(machName, new QByteArray(projectMessData), projectMessData.size());
1224 diff --git a/src/qmc2main.cpp b/src/qmc2main.cpp
1225 index 4cd3ed24f..ec16009b2 100644
1226 --- a/src/qmc2main.cpp
1227 +++ b/src/qmc2main.cpp
1230 #include <QInputDialog>
1231 #include <QDesktopWidget>
1232 -#include <QtWebKitWidgets/QWebFrame>
1234 #include <algorithm> // std::sort()
1236 diff --git a/src/machinelist.cpp b/src/machinelist.cpp
1237 index 8c6944b29..4ccdc3c4b 100644
1238 --- a/src/machinelist.cpp
1239 +++ b/src/machinelist.cpp
1242 -#include <QtWebKitWidgets/QWebView>
1243 #include <QTextStream>
1244 #include <QHeaderView>
1245 #include <QTreeWidgetItem>