diff --git a/CMakeLists.txt b/CMakeLists.txt index c6662005..89002efc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,8 +20,8 @@ find_package (Qt5Widgets REQUIRED) find_package (Qt5Gui REQUIRED) find_package (Qt5Sql REQUIRED) find_package (Qt5Network REQUIRED) -find_package (Qt5WebKit REQUIRED) -find_package (Qt5WebKitWidgets REQUIRED) +find_package (Qt5WebEngine REQUIRED) +find_package (Qt5WebEngineWidgets REQUIRED) find_package(PkgConfig REQUIRED) pkg_check_modules(TIDY REQUIRED tidy) @@ -432,5 +432,5 @@ include_directories(${TIDY_INCLUDE_DIRS}) add_executable(nixnote2 ${nixnote2_src} ${nixnote2_hdr_moc}) add_executable(tests ${nixnote2_src} ${nixnote2_hdr_moc}) -target_link_libraries(nixnote2 Qt5::Widgets Qt5::Sql Qt5::Gui Qt5::Network Qt5:WebKit Qt5:WebKitWidgets) -target_link_libraries(tests Qt5::Widgets Qt5::Sql Qt5::Gui Qt5::Network Qt5:WebKit Qt5:WebKitWidgets) +target_link_libraries(nixnote2 Qt5::Widgets Qt5::Sql Qt5::Gui Qt5::Network Qt5:WebEngine Qt5:WebEngineWidgets) +target_link_libraries(tests Qt5::Widgets Qt5::Sql Qt5::Gui Qt5::Network Qt5:WebEngine Qt5:WebEngineWidgets) diff --git a/nixnote2.pro b/nixnote2.pro index 60a22e20..ec219de0 100644 --- a/nixnote2.pro +++ b/nixnote2.pro @@ -1,4 +1,4 @@ -QT += core gui widgets printsupport webkit webkitwidgets sql network xml dbus qml concurrent +QT += core gui widgets printsupport webkit webenginewidgets sql network xml dbus qml concurrent DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 unix { diff --git a/src/dialog/aboutdialog.cpp b/src/dialog/aboutdialog.cpp index 2762f150..ea62de17 100644 --- a/src/dialog/aboutdialog.cpp +++ b/src/dialog/aboutdialog.cpp @@ -18,7 +18,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ***********************************************************************************/ #include "aboutdialog.h" -#include +#include #include #include #include @@ -30,7 +30,7 @@ AboutDialog::AboutDialog(QDialog *parent) : QDialog(parent) { QVBoxLayout *mainLayout = new QVBoxLayout(); this->setLayout(mainLayout); - QWebView *page = new QWebView(); + QWebEngineView *page = new QWebEngineView(); QPushButton *okButton = new QPushButton(); okButton->setText(tr("OK")); mainLayout->addWidget(page); diff --git a/src/gui/browserWidgets/ntitleeditor.h b/src/gui/browserWidgets/ntitleeditor.h index e3588bd4..0308ef41 100644 --- a/src/gui/browserWidgets/ntitleeditor.h +++ b/src/gui/browserWidgets/ntitleeditor.h @@ -23,7 +23,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "src/qevercloud/QEverCloud/headers/QEverCloud.h" -#include +#include #include using namespace qevercloud; diff --git a/src/gui/browserWidgets/table/tablepropertiesdialog.cpp b/src/gui/browserWidgets/table/tablepropertiesdialog.cpp index 74de72a2..be3eb74d 100644 --- a/src/gui/browserWidgets/table/tablepropertiesdialog.cpp +++ b/src/gui/browserWidgets/table/tablepropertiesdialog.cpp @@ -105,7 +105,7 @@ TablePropertiesDialog::TablePropertiesDialog(QString tableCss, QString cellCss, tabs->addTab(tablePanel, tr("Table Properties")); tabs->addTab(cellPanel,tr("Cell Properties")); - preview = new QWebView(); + preview = new QWebEngineView(); mainLayout->addWidget(preview); mainLayout->addLayout(buttonLayout); diff --git a/src/gui/browserWidgets/table/tablepropertiesdialog.h b/src/gui/browserWidgets/table/tablepropertiesdialog.h index 7722a876..83c4427d 100644 --- a/src/gui/browserWidgets/table/tablepropertiesdialog.h +++ b/src/gui/browserWidgets/table/tablepropertiesdialog.h @@ -30,7 +30,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include #include #include -#include +#include #include #include #include @@ -111,7 +111,7 @@ class TablePropertiesDialog : public QDialog QPushButton *okButton; // Dialog box OK button QPushButton *cancelButton; // Dialog box cancel button QTabWidget *tabs; // Tab widget holding table & cell options - QWebView *preview; // HTML page showing the user's selected values + QWebEngineView *preview; // HTML page showing the user's selected values QLabel *paddingLabel; // Label used to show cell padding selection QHBoxLayout *borderSizeLayout; // layout used for the border size selection diff --git a/src/gui/findreplace.cpp b/src/gui/findreplace.cpp index 07a1f370..cabcfb3c 100644 --- a/src/gui/findreplace.cpp +++ b/src/gui/findreplace.cpp @@ -146,12 +146,12 @@ void FindReplace::textChanged() { -QWebPage::FindFlags FindReplace::getCaseSensitive() { - QWebPage::FindFlags ff; - ff = QWebPage::HighlightAllOccurrences; +QWebEnginePage::FindFlags FindReplace::getCaseSensitive() { + QWebEnginePage::FindFlags ff; + ff = QWebEnginePage::HighlightAllOccurrences; ff = 0; if (caseSensitive->isChecked()) - ff = ff | QWebPage::FindCaseSensitively; + ff = ff | QWebEnginePage::FindCaseSensitively; return ff; } diff --git a/src/gui/findreplace.h b/src/gui/findreplace.h index cc10df24..555bb7d5 100644 --- a/src/gui/findreplace.h +++ b/src/gui/findreplace.h @@ -25,7 +25,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include #include #include -#include +#include class FindReplace : public QWidget { @@ -44,7 +44,7 @@ class FindReplace : public QWidget QPushButton *replaceAllButton; QLineEdit *replaceLine; QCheckBox *caseSensitive; - QWebPage::FindFlags getCaseSensitive(); + QWebEnginePage::FindFlags getCaseSensitive(); signals: diff --git a/src/gui/nbrowserwindow.cpp b/src/gui/nbrowserwindow.cpp index 19904588..610c4577 100644 --- a/src/gui/nbrowserwindow.cpp +++ b/src/gui/nbrowserwindow.cpp @@ -219,9 +219,9 @@ NBrowserWindow::NBrowserWindow(QWidget *parent) : connect(editor->page(), SIGNAL(microFocusChanged()), this, SLOT(microFocusChanged())); connect(editor->page(), SIGNAL(contentsChanged()), this, SLOT(correctFontTagAttr())); - editor->page()->setLinkDelegationPolicy(QWebPage::DelegateAllLinks); - connect(editor->page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(exposeToJavascript())); - connect(editor->page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), editor, SLOT(exposeToJavascript())); + editor->page()->setLinkDelegationPolicy(QWebEnginePage::DelegateAllLinks); + connect(editor->page(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(exposeToJavascript())); + connect(editor->page(), SIGNAL(javaScriptWindowObjectCleared()), editor, SLOT(exposeToJavascript())); editor->page()->settings()->setAttribute(QWebSettings::PluginsEnabled, true); factory = new PluginFactory(this); @@ -584,7 +584,7 @@ void NBrowserWindow::setContent(qint32 lid) { // is this an ink note? if (inkNote) - editor->page()->setContentEditable(false); + editor->page()->runJavaScript("document.documentElement.contentEditable = false"); // Setup the alarm NoteAttributes attributes; @@ -660,7 +660,7 @@ void NBrowserWindow::setContent(qint32 lid) { if (criteria->isSearchStringSet()) { QStringList list = criteria->getSearchString().split(" "); for (int i = 0; i < list.size(); i++) { - editor->page()->findText(list[i], QWebPage::HighlightAllOccurrences); + editor->page()->findText(list[i], QWebEnginePage::HighlightAllOccurrences); } } @@ -690,7 +690,7 @@ void NBrowserWindow::setReadOnly(bool readOnly) { urlEditor.setFocusPolicy(Qt::NoFocus); notebookMenu.setEnabled(false); dateEditor.setEnabled(false); - editor->page()->setContentEditable(false); + editor->page()->runJavaScript("document.documentElement.contentEditable = false"); alarmButton.setEnabled(false); return; } @@ -701,7 +701,7 @@ void NBrowserWindow::setReadOnly(bool readOnly) { urlEditor.setFocusPolicy(Qt::StrongFocus); notebookMenu.setEnabled(true); dateEditor.setEnabled(true); - editor->page()->setContentEditable(true); + editor->page()->runJavaScript("document.documentElement.contentEditable = true"); alarmButton.setEnabled(true); } @@ -855,7 +855,7 @@ void NBrowserWindow::saveNoteContent() { exitPoint(points->value("ExitPoint_SaveNote")); // END EXIT POINT - QString contents = editor->editorPage->mainFrame()->documentElement().toOuterXml(); + QString contents = editor->editorPage->documentElement().toOuterXml(); EnmlFormatter formatter(contents, global.guiAvailable, global.passwordSafe, global.fileManager.getCryptoJarPath()); @@ -923,7 +923,7 @@ void NBrowserWindow::saveNoteContent() { // The undo edit button was pressed void NBrowserWindow::undoButtonPressed() { - this->editor->triggerPageAction(QWebPage::Undo); + this->editor->triggerPageAction(QWebEnginePage::Undo); this->editor->setFocus(); microFocusChanged(); } @@ -931,7 +931,7 @@ void NBrowserWindow::undoButtonPressed() { // The redo edit button was pressed void NBrowserWindow::redoButtonPressed() { - this->editor->triggerPageAction(QWebPage::Redo); + this->editor->triggerPageAction(QWebEnginePage::Redo); this->editor->setFocus(); microFocusChanged(); } @@ -939,7 +939,7 @@ void NBrowserWindow::redoButtonPressed() { // The cut button was pressed void NBrowserWindow::cutButtonPressed() { - this->editor->triggerPageAction(QWebPage::Cut); + this->editor->triggerPageAction(QWebEnginePage::Cut); this->editor->setFocus(); microFocusChanged(); } @@ -953,7 +953,7 @@ void NBrowserWindow::copyButtonPressed() { // If we have text selected if (this->editor->selectedText().trimmed() != "") { - this->editor->triggerPageAction(QWebPage::Copy); + this->editor->triggerPageAction(QWebEnginePage::Copy); this->editor->setFocus(); } else { // If we have an image selected, we copy it to the clipboard. @@ -1015,7 +1015,7 @@ void NBrowserWindow::pasteButtonPressed() { QString fileName = urls[i].toString().mid(8); #endif // End windows check attachFileSelected(fileName); - this->editor->triggerPageAction(QWebPage::InsertParagraphSeparator); + this->editor->triggerPageAction(QWebEnginePage::InsertParagraphSeparator); } } @@ -1043,7 +1043,7 @@ void NBrowserWindow::pasteButtonPressed() { if (hasWhitespace) { // hacky workaround to skip any postprocessing QLOG_DEBUG() << "1:1 insert (no preprocessing)"; - this->editor->triggerPageAction(QWebPage::Paste); + this->editor->triggerPageAction(QWebEnginePage::Paste); } else { if ((!hasHtml) && (!isEvernoteInAppLink)) { // this to add markup if it is a single url @@ -1102,7 +1102,7 @@ void NBrowserWindow::pasteButtonPressed() { // 2nd param: A Boolean, specifies if the UI should be shown or not QLOG_DEBUG() << "pasteButtonPressed: final textToPaste=" << textToPaste; QString script = QString("document.execCommand('insertHtml', false, '%1');").arg(textToPaste); - editor->page()->mainFrame()->evaluateJavaScript(script); + editor->page()->runJavaScript(script); } this->editor->setFocus(); @@ -1112,7 +1112,7 @@ void NBrowserWindow::pasteButtonPressed() { // The paste button was pressed void NBrowserWindow::selectAllButtonPressed() { - this->editor->triggerPageAction(QWebPage::SelectAll); + this->editor->triggerPageAction(QWebEnginePage::SelectAll); this->editor->setFocus(); microFocusChanged(); } @@ -1128,7 +1128,7 @@ void NBrowserWindow::pasteWithoutFormatButtonPressed() { QString text = mime->text(); QApplication::clipboard()->clear(); QApplication::clipboard()->setText(text, QClipboard::Clipboard); - this->editor->triggerPageAction(QWebPage::Paste); + this->editor->triggerPageAction(QWebEnginePage::Paste); // This is done because pasting into an encryption block // can cause multiple cells (which can't happen). It @@ -1145,7 +1145,7 @@ void NBrowserWindow::pasteWithoutFormatButtonPressed() { + QString( " workingNode.innerHTML = window.browserWindow.fixEncryptionPaste(workingNode.innerHTML);") + QString("} fixEncryption();"); - editor->page()->mainFrame()->evaluateJavaScript(js); + editor->page()->runJavaScript(js); } this->editor->setFocus(); @@ -1168,7 +1168,7 @@ QString NBrowserWindow::fixEncryptionPaste(QString data) { // The bold button was pressed / toggled void NBrowserWindow::boldButtonPressed() { - QAction *action = editor->page()->action(QWebPage::ToggleBold); + QAction *action = editor->page()->action(QWebEnginePage::ToggleBold); action->activate(QAction::Trigger); this->editor->setFocus(); microFocusChanged(); @@ -1177,7 +1177,7 @@ void NBrowserWindow::boldButtonPressed() { // The toggled button was pressed/toggled void NBrowserWindow::italicsButtonPressed() { - QAction *action = editor->page()->action(QWebPage::ToggleItalic); + QAction *action = editor->page()->action(QWebEnginePage::ToggleItalic); action->activate(QAction::Trigger); this->editor->setFocus(); microFocusChanged(); @@ -1186,7 +1186,7 @@ void NBrowserWindow::italicsButtonPressed() { // The underline button was toggled void NBrowserWindow::underlineButtonPressed() { - this->editor->triggerPageAction(QWebPage::ToggleUnderline); + this->editor->triggerPageAction(QWebEnginePage::ToggleUnderline); this->editor->setFocus(); microFocusChanged(); } @@ -1194,8 +1194,8 @@ void NBrowserWindow::underlineButtonPressed() { void NBrowserWindow::removeFormatButtonPressed() { // for some reason first call doesn't remove background color, but the second does... - this->editor->triggerPageAction(QWebPage::RemoveFormat); - this->editor->triggerPageAction(QWebPage::RemoveFormat); + this->editor->triggerPageAction(QWebEnginePage::RemoveFormat); + this->editor->triggerPageAction(QWebEnginePage::RemoveFormat); this->editor->setFocus(); microFocusChanged(); @@ -1204,7 +1204,7 @@ void NBrowserWindow::removeFormatButtonPressed() { void NBrowserWindow::htmlCleanup(HtmlCleanupMode mode) { QLOG_DEBUG() << "html cleanup, mode " << mode; - QWebElement rootElement = editor->editorPage->mainFrame()->documentElement(); + QWebElement rootElement = editor->editorPage->documentElement(); QString contents = rootElement.toOuterXml(); bool isSimplify = mode == HtmlCleanupMode::Simplify; @@ -1284,7 +1284,7 @@ void NBrowserWindow::htmlSimplify() { // The strikethrough button was pressed void NBrowserWindow::strikethroughButtonPressed() { - this->editor->triggerPageAction(QWebPage::ToggleStrikethrough); + this->editor->triggerPageAction(QWebEnginePage::ToggleStrikethrough); this->editor->setFocus(); microFocusChanged(); } @@ -1292,7 +1292,7 @@ void NBrowserWindow::strikethroughButtonPressed() { // The horizontal line button was pressed void NBrowserWindow::horizontalLineButtonPressed() { - this->editor->page()->mainFrame()->evaluateJavaScript( + this->editor->page()->runJavaScript( "document.execCommand('insertHorizontalRule', false, '');"); editor->setFocus(); microFocusChanged(); @@ -1301,7 +1301,7 @@ void NBrowserWindow::horizontalLineButtonPressed() { // The center align button was pressed void NBrowserWindow::alignCenterButtonPressed() { - this->editor->page()->mainFrame()->evaluateJavaScript( + this->editor->page()->runJavaScript( "document.execCommand('JustifyCenter', false, '');"); editor->setFocus(); microFocusChanged(); @@ -1322,7 +1322,7 @@ void NBrowserWindow::formatCodeButtonPressed() { buffer.append(text); buffer.append("
"); QString script = QString("document.execCommand('insertHtml', false, '%1');").arg(buffer); - editor->page()->mainFrame()->evaluateJavaScript(script).toString(); + editor->page()->runJavaScript(script).toString(); QKeyEvent *left = new QKeyEvent(QEvent::KeyPress, Qt::Key_Left, Qt::NoModifier); QCoreApplication::postEvent(editor->editorPage, left); @@ -1335,7 +1335,7 @@ void NBrowserWindow::syncButtonPressed() { // The full align button was pressed void NBrowserWindow::alignFullButtonPressed() { - this->editor->page()->mainFrame()->evaluateJavaScript( + this->editor->page()->runJavaScript( "document.execCommand('JustifyFull', false, '');"); editor->setFocus(); microFocusChanged(); @@ -1344,7 +1344,7 @@ void NBrowserWindow::alignFullButtonPressed() { // The left align button was pressed void NBrowserWindow::alignLeftButtonPressed() { - this->editor->page()->mainFrame()->evaluateJavaScript( + this->editor->page()->runJavaScript( "document.execCommand('JustifyLeft', false, '');"); editor->setFocus(); microFocusChanged(); @@ -1353,7 +1353,7 @@ void NBrowserWindow::alignLeftButtonPressed() { // The align right button was pressed void NBrowserWindow::alignRightButtonPressed() { - this->editor->page()->mainFrame()->evaluateJavaScript( + this->editor->page()->runJavaScript( "document.execCommand('JustifyRight', false, '');"); editor->setFocus(); microFocusChanged(); @@ -1362,7 +1362,7 @@ void NBrowserWindow::alignRightButtonPressed() { // The shift right button was pressed void NBrowserWindow::shiftRightButtonPressed() { - this->editor->page()->mainFrame()->evaluateJavaScript( + this->editor->page()->runJavaScript( "document.execCommand('indent', false, '');"); editor->setFocus(); microFocusChanged(); @@ -1371,7 +1371,7 @@ void NBrowserWindow::shiftRightButtonPressed() { // The shift left button was pressed void NBrowserWindow::shiftLeftButtonPressed() { - this->editor->page()->mainFrame()->evaluateJavaScript( + this->editor->page()->runJavaScript( "document.execCommand('outdent', false, '');"); editor->setFocus(); microFocusChanged(); @@ -1380,7 +1380,7 @@ void NBrowserWindow::shiftLeftButtonPressed() { // The number list button was pressed void NBrowserWindow::numberListButtonPressed() { - this->editor->page()->mainFrame()->evaluateJavaScript( + this->editor->page()->runJavaScript( "document.execCommand('InsertOrderedList', false, '');"); editor->setFocus(); microFocusChanged(); @@ -1389,7 +1389,7 @@ void NBrowserWindow::numberListButtonPressed() { // The bullet list button was pressed void NBrowserWindow::bulletListButtonPressed() { - this->editor->page()->mainFrame()->evaluateJavaScript( + this->editor->page()->runJavaScript( "document.execCommand('InsertUnorderedList', false, '');"); editor->setFocus(); microFocusChanged(); @@ -1414,7 +1414,7 @@ void NBrowserWindow::todoButtonPressed() { selectedHtml.replace(global.getCheckboxElement(true, false), ""); selectedHtml.replace(global.getCheckboxElement(false, false), ""); if (selectedHtml.length() < length) { - editor->page()->mainFrame()->evaluateJavaScript(script_start + + editor->page()->runJavaScript(script_start + selectedHtml + script_end); return; } @@ -1429,7 +1429,7 @@ void NBrowserWindow::todoButtonPressed() { ""; } - editor->page()->mainFrame()->evaluateJavaScript(script_start + html + script_end); + editor->page()->runJavaScript(script_start + html + script_end); editor->setFocus(); microFocusChanged(); } @@ -1459,7 +1459,7 @@ void NBrowserWindow::todoSetAllChecked(bool allSelected) { global.getCheckboxElement(false, true)); } - editor->page()->mainFrame()->evaluateJavaScript(script_start + html + script_end); + editor->page()->runJavaScript(script_start + html + script_end); } @@ -1496,7 +1496,7 @@ void NBrowserWindow::fontSizeSelected(int index) { text = "‌"; QString newText = "" + text + ""; QString script2 = QString("document.execCommand('insertHtml', false, '" + newText + "');"); - editor->page()->mainFrame()->evaluateJavaScript(script2); + editor->page()->runJavaScript(script2); QApplication::sendEvent(editor, backspacePressed); @@ -1505,7 +1505,7 @@ void NBrowserWindow::fontSizeSelected(int index) { delete backspacePressed; } else { QString script = QString("document.execCommand('fontSize', false, 5);"); - editor->page()->mainFrame()->evaluateJavaScript(script); + editor->page()->runJavaScript(script); // document.execCommand fontSize will generate font tag with 'size' // attribute set, which now and then makes the following font size @@ -1521,7 +1521,7 @@ void NBrowserWindow::fontSizeSelected(int index) { void NBrowserWindow::insertHtml(QString html) { QString script = QString("document.execCommand('insertHtml', false, '%1');").arg(html); - editor->page()->mainFrame()->evaluateJavaScript(script); + editor->page()->runJavaScript(script); microFocusChanged(); } @@ -1532,7 +1532,7 @@ void NBrowserWindow::fontNameSelected(int index) { buttonBar->fontSizes->blockSignals(true); buttonBar->loadFontSizeComboBox(font); buttonBar->fontSizes->blockSignals(false); - this->editor->page()->mainFrame()->evaluateJavaScript( + this->editor->page()->runJavaScript( "document.execCommand('fontName', false, '" + font + "');"); editor->setFocus(); microFocusChanged(); @@ -1544,7 +1544,7 @@ void NBrowserWindow::fontColorClicked() { QColor *color = buttonBar->fontColorMenuWidget->getCurrentColor(); QLOG_DEBUG() << "Setting text color to: " << buttonBar->fontColorMenuWidget->getCurrentColorName(); if (color->isValid()) { - this->editor->page()->mainFrame()->evaluateJavaScript( + this->editor->page()->runJavaScript( "document.execCommand('foreColor', false, '" + color->name() + "');"); editor->setFocus(); microFocusChanged(); @@ -1559,7 +1559,7 @@ void NBrowserWindow::fontHighlightClicked() { QColor *color = buttonBar->highlightColorMenuWidget->getCurrentColor(); QLOG_DEBUG() << "Setting text background color to: " << buttonBar->highlightColorMenuWidget->getCurrentColorName(); if (color->isValid()) { - this->editor->page()->mainFrame()->evaluateJavaScript( + this->editor->page()->runJavaScript( "document.execCommand('backColor', false, '" + color->name() + "');"); editor->setFocus(); microFocusChanged(); @@ -1602,7 +1602,7 @@ void NBrowserWindow::insertLinkButtonPressed() { QString durl = dialog.getUrl().trimmed().replace("'", "\\'"); QString url = QString("%3").arg(durl, durl, selectedText); QString script = QString("document.execCommand('insertHtml', false, '%1')").arg(url); - editor->page()->mainFrame()->evaluateJavaScript(script); + editor->page()->runJavaScript(script); return; } @@ -1621,7 +1621,7 @@ void NBrowserWindow::insertLinkButtonPressed() { + QString(" }") + QString("}") + QString("} getCursorPos();"); - editor->page()->mainFrame()->evaluateJavaScript(js); + editor->page()->runJavaScript(js); if (dialog.getUrl().trimmed() != "") { contentChanged(); @@ -1647,7 +1647,7 @@ void NBrowserWindow::insertLinkButtonPressed() { + QString(" }") + QString("}") + QString("} getCursorPos();"); - editor->page()->mainFrame()->evaluateJavaScript(js); + editor->page()->runJavaScript(js); contentChanged(); } @@ -1673,7 +1673,7 @@ void NBrowserWindow::removeLinkButtonPressed() { + QString(" }") + QString("}") + QString("} getCursorPos();"); - editor->page()->mainFrame()->evaluateJavaScript(js); + editor->page()->runJavaScript(js); contentChanged(); } @@ -1707,7 +1707,7 @@ void NBrowserWindow::insertQuickLinkButtonPressed() { + QString("\" title=\"") + text + QString("\">") + text + QString(""); QString script = QString("document.execCommand('insertHtml', false, '") + url + QString("');"); - editor->page()->mainFrame()->evaluateJavaScript(script); + editor->page()->runJavaScript(script); return; } } @@ -1749,7 +1749,7 @@ void NBrowserWindow::insertTableButtonPressed() { newHTML = newHTML + ""; QString script = "document.execCommand('insertHtml', false, '" + newHTML + "');"; - editor->page()->mainFrame()->evaluateJavaScript(script); + editor->page()->runJavaScript(script); contentChanged(); } @@ -1779,7 +1779,7 @@ void NBrowserWindow::insertTableRowButtonPressed() { " workingNode = workingNode.parentNode;" " }" "} insertTableRow();"; - editor->page()->mainFrame()->evaluateJavaScript(js); + editor->page()->runJavaScript(js); contentChanged(); } @@ -1811,7 +1811,7 @@ void NBrowserWindow::insertTableColumnButtonPressed() { " cell.innerHTML = ' '; " " }" "} insertTableColumn();"; - editor->page()->mainFrame()->evaluateJavaScript(js); + editor->page()->runJavaScript(js); contentChanged(); } @@ -1848,7 +1848,7 @@ void NBrowserWindow::tablePropertiesButtonPressed() { " window.browserWindow.setTableStyle(style);" " }" "} tableProperties();"; - editor->page()->mainFrame()->evaluateJavaScript(js); + editor->page()->runJavaScript(js); QLOG_DEBUG() << this->tableStyle; QLOG_DEBUG() << this->tableCellStyle; @@ -1888,7 +1888,7 @@ void NBrowserWindow::tablePropertiesButtonPressed() { " }" "} setTableProperties();"; js = js.arg(newTableStyle).arg(newCellStyle); - editor->page()->mainFrame()->evaluateJavaScript(js); + editor->page()->runJavaScript(js); this->editor->isDirty = true; microFocusChanged(); } @@ -1911,7 +1911,7 @@ void NBrowserWindow::deleteTableRowButtonPressed() { " workingNode = workingNode.parentNode;" " }" "} deleteTableRow();"; - editor->page()->mainFrame()->evaluateJavaScript(js); + editor->page()->runJavaScript(js); contentChanged(); } @@ -1939,7 +1939,7 @@ void NBrowserWindow::deleteTableColumnButtonPressed() { " workingNode.rows[i].deleteCell(current); " " }" "} deleteTableColumn();"; - editor->page()->mainFrame()->evaluateJavaScript(js); + editor->page()->runJavaScript(js); contentChanged(); } @@ -1974,7 +1974,7 @@ void NBrowserWindow::rotateImage(qreal + selectedFileName); editor-> setHtml(editor - ->page()->mainFrame()-> + ->page()-> toHtml() @@ -1991,7 +1991,7 @@ void NBrowserWindow::rotateImage(qreal // Reload the web page editor-> - triggerPageAction(QWebPage::ReloadAndBypassCache); + triggerPageAction(QWebEnginePage::ReloadAndBypassCache); contentChanged(); @@ -1999,7 +1999,7 @@ void NBrowserWindow::rotateImage(qreal void NBrowserWindow::updateImageHash(QByteArray newhash) { - QString content = editor->page()->mainFrame()->toHtml(); + QString content = editor->page()->toHtml(); int pos = content.indexOf("", pos); @@ -2012,7 +2012,7 @@ void NBrowserWindow::updateImageHash(QByteArray newhash) { QString newcontent = content.mid(0, pos) + section + content.mid(endPos); QByteArray c; c.append(newcontent); - editor->page()->mainFrame()->setContent(c); + editor->page()->setContent(c); rtable.updateResourceHash(selectedFileLid, newhash); return; } @@ -2123,7 +2123,7 @@ void NBrowserWindow::microFocusChanged() { + QString(" }") + QString("} getCursorPos();"); - editor->page()->mainFrame()->evaluateJavaScript(js); + editor->page()->runJavaScript(js); QString js2 = QString("function getFontSize() {") + QString(" var node = document.getSelection().anchorNode;") + @@ -2133,7 +2133,7 @@ void NBrowserWindow::microFocusChanged() { QString(" window.browserWindow.changeDisplayFontSize(size);") + QString(" window.browserWindow.changeDisplayFontName(font);") + QString("} getFontSize();"); - editor->page()->mainFrame()->evaluateJavaScript(js2); + editor->page()->runJavaScript(js2); saveTimer.setInterval(global.autoSaveInterval); saveTimer.start(); @@ -2149,7 +2149,7 @@ void NBrowserWindow::modifyFontTagAttr(int size) { QString(" }") + QString("}"); - editor->page()->mainFrame()->evaluateJavaScript(js); + editor->page()->runJavaScript(js); } // When a font size is selected, and the page content is empty, any keyboard input @@ -2180,7 +2180,7 @@ void NBrowserWindow::tabPressed() { return; if (!insideList && !insideTable) { QString script_start = "document.execCommand('insertHtml', false, '          ');"; - editor->page()->mainFrame()->evaluateJavaScript(script_start); + editor->page()->runJavaScript(script_start); return; } if (insideList) { @@ -2211,7 +2211,7 @@ void NBrowserWindow::tabPressed() { " var tableColumns = nodes.length;" " window.browserWindow.setTableCursorPositionTab(rowCount, colCount, tableRows, tableColumns);" "} getCursorPosition();"; - editor->page()->mainFrame()->evaluateJavaScript(js); + editor->page()->runJavaScript(js); } } @@ -2248,7 +2248,7 @@ void NBrowserWindow::backtabPressed() { " var tableColumns = nodes.length;" " window.browserWindow.setTableCursorPositionBackTab(rowCount, colCount, tableRows, tableColumns);" "} getCursorPosition();"; - editor->page()->mainFrame()->evaluateJavaScript(js); + editor->page()->runJavaScript(js); } } @@ -2260,7 +2260,7 @@ bool NBrowserWindow::enterPressed() { QString script = "document.execCommand('insertHTML', false, ' ');"; - editor->page()->mainFrame()->evaluateJavaScript(script); + editor->page()->runJavaScript(script); return true; // QKeyEvent *down = new QKeyEvent(QEvent::KeyPress, Qt::Key_Down, Qt::NoModifier); @@ -2300,7 +2300,7 @@ void NBrowserWindow::setBackgroundColor(QString value) { + QString("document.body.style.background = color;") + QString("}") + QString("changeBackground('" + value + "');"); - editor->page()->mainFrame()->evaluateJavaScript(js); + editor->page()->runJavaScript(js); setDirty(this->lid, true); this->editor->isDirty = true; @@ -2450,7 +2450,7 @@ void NBrowserWindow::clear() { } editor->blockSignals(true); editor->setContent(""); - editor->page()->setContentEditable(false); + editor->page()->runJavaScript("document.documentElement.contentEditable = false"); lid = -1; editor->blockSignals(false); @@ -2471,7 +2471,7 @@ void NBrowserWindow::clear() { urlEditor.blockSignals(false); // dateEditor.setEnabled(false); -// editor->page()->setContentEditable(false); +// editor->page()->runJavaScript("document.documentElement.contentEditable = false"); dateEditor.clear(); } @@ -2482,7 +2482,7 @@ void NBrowserWindow::setSource() { if (sourceEdit == nullptr || sourceEdit->hasFocus()) return; - QString text = editor->editorPage->mainFrame()->toHtml(); + QString text = editor->editorPage->toHtml(); sourceEdit->blockSignals(true); int body = text.indexOf("page()->mainFrame()->addToJavaScriptWindowObject("browserWindow", this); + editor->page()->addToJavaScriptWindowObject("browserWindow", this); } @@ -2695,10 +2695,10 @@ void NBrowserWindow::editLatex(QString incomingLid) { QString script_start = "document.execCommand('insertHTML', false, '"; QString script_end = "');"; - editor->page()->mainFrame()->evaluateJavaScript(script_start + buffer + script_end); + editor->page()->runJavaScript(script_start + buffer + script_end); } else { QLOG_DEBUG() << "latex: replace"; - QString oldHtml = editor->page()->mainFrame()->toHtml(); + QString oldHtml = editor->page()->toHtml(); int startPos = oldHtml.indexOf("page()->mainFrame()->setHtml(oldHtml); + editor->page()->setHtml(oldHtml); editor->reload(); contentChanged(); } else { @@ -2761,7 +2761,7 @@ void NBrowserWindow::insertTime() { void NBrowserWindow::insertDateTimeUsingFormat(const QString &format) const { QDateTime dt = QDateTime::currentDateTime(); QString dts = dt.toString(format); - editor->page()->mainFrame()->evaluateJavaScript("document.execCommand('insertHtml', false, '" + dts + "');"); + editor->page()->runJavaScript("document.execCommand('insertHtml', false, '" + dts + "');"); editor->setFocus(); } @@ -2818,7 +2818,7 @@ void NBrowserWindow::insertImage(const QMimeData *mime) { buffer.append("\">"); // Insert the actual note - editor->page()->mainFrame()->evaluateJavaScript( + editor->page()->runJavaScript( script_start + buffer + script_end); return; @@ -3074,7 +3074,7 @@ QString NBrowserWindow::stripContentsForPrint() { // Start removing object tags QString contents = this->editor->selectedHtml().trimmed(); if (contents == "") - contents = editor->editorPage->mainFrame()->toHtml(); + contents = editor->editorPage->toHtml(); int pos = contents.indexOf("", pos); @@ -3234,7 +3234,7 @@ void NBrowserWindow::printNote() { void NBrowserWindow::noteSourceUpdated() { - scrollPoint = editor->page()->mainFrame()->scrollPosition(); + scrollPoint = editor->page()->scrollPosition(); connect(editor, SIGNAL(loadFinished(bool)), this, SLOT(repositionAfterSourceEdit(bool))); QByteArray ba; QString source = sourceEdit->toPlainText(); @@ -3250,7 +3250,7 @@ void NBrowserWindow::noteSourceUpdated() { // Called after the source is edited and a reposition is needed to keep the page from being positioned at the top void NBrowserWindow::repositionAfterSourceEdit(bool) { - editor->page()->mainFrame()->setScrollPosition(scrollPoint); + editor->page()->setScrollPosition(scrollPoint); disconnect(editor, SIGNAL(loadFinished(bool)), this, SLOT(repositionAfterSourceEdit(bool))); } @@ -3260,7 +3260,7 @@ void NBrowserWindow::updateResourceHash(qint32 noteLid, QByteArray oldHash, QByt if (noteLid != lid) return; - QString content = editor->editorPage->mainFrame()->documentElement().toOuterXml(); + QString content = editor->editorPage->documentElement().toOuterXml(); // Start going through & looking for the old hash int pos = content.indexOf(""); // Insert the actual image - editor->page()->mainFrame()->evaluateJavaScript(script_start + buffer + script_end); + editor->page()->runJavaScript(script_start + buffer + script_end); return; } @@ -3390,7 +3390,7 @@ void NBrowserWindow::attachFileSelected(QString filename) { buffer.append("\" type=\"application/pdf\" />"); // Insert the actual image - editor->page()->mainFrame()->evaluateJavaScript(script_start + buffer + script_end); + editor->page()->runJavaScript(script_start + buffer + script_end); } else { QLOG_INFO() << "attachFileSelected: other object"; @@ -3427,7 +3427,7 @@ void NBrowserWindow::attachFileSelected(QString filename) { const QString &html = script_start + buffer + script_end; QLOG_INFO() << "attachFileSelected: inserting HTML " << html; - editor->page()->mainFrame()->evaluateJavaScript(html); + editor->page()->runJavaScript(html); } } @@ -3614,15 +3614,15 @@ void NBrowserWindow::removeEncryption(QString id, QString plainText, bool perman mimeData->setData("text/html", plainText.toUtf8()); QApplication::clipboard()->setMimeData(mimeData, QClipboard::Clipboard); - this->editor->triggerPageAction(QWebPage::Paste); + this->editor->triggerPageAction(QWebEnginePage::Paste); // currently readonly - as edit encrypted is unstable - editor->page()->setContentEditable(false); + editor->page()->runJavaScript("document.documentElement.contentEditable = false"); return; } - QString html = editor->page()->mainFrame()->toHtml(); + QString html = editor->page()->toHtml(); QString text = html; int imagePos = html.indexOf(" -1) { text = text.mid(0, imagePos) + plainText + text.mid(endPos + 1); - editor->page()->mainFrame()->setHtml(text); + editor->page()->setHtml(text); editor->reload(); if (permanent) { contentChanged(); @@ -3690,7 +3690,7 @@ void NBrowserWindow::encryptButtonPressed() { QString script_start = "document.execCommand('insertHtml', false, '"; QString script_end = "');"; - editor->page()->mainFrame()->evaluateJavaScript(script_start + buffer + script_end); + editor->page()->runJavaScript(script_start + buffer + script_end); } @@ -3817,16 +3817,16 @@ void NBrowserWindow::spellCheckPressed() { } QLOG_DEBUG() << SPELLCHECKER_DLG ":Preparing page for spell check"; - QWebPage *page = editor->page(); - page->action(QWebPage::MoveToStartOfDocument); - page->mainFrame()->setFocus(); + QWebEnginePage *page = editor->page(); + page->action(QWebEnginePage::MoveToStartOfDocument); + page->setFocus(); Qt::KeyboardModifier ctrl(Qt::ControlModifier); QKeyEvent key(QEvent::KeyPress, Qt::Key_Home, ctrl); editor->keyPressEvent(&key); - page->mainFrame()->setFocus(); + page->setFocus(); - QString plainText(page->mainFrame()->toPlainText()); + QString plainText(page->toPlainText()); QLOG_DEBUG_FILE("spell-1.txt", plainText); //QLOG_INFO() << "spell plain before: " << plainText; plainText = plainText @@ -3884,8 +3884,8 @@ void NBrowserWindow::spellCheckPressed() { QLOG_DEBUG() << SPELLCHECKER_DLG ": replacing by: " << replacement; QApplication::clipboard()->setText(replacement); //1: pasteButtonPressed(); - //2: this->editor->triggerPageAction(QWebPage::Paste); - page->triggerAction(QWebPage::Paste); + //2: this->editor->triggerPageAction(QWebEnginePage::Paste); + page->triggerAction(QWebEnginePage::Paste); } else if (result == DONE_CHANGELANGUAGE) { // let restart the loop @@ -3959,7 +3959,7 @@ void NBrowserWindow::handleUrls(const QMimeData *mime) { editor->setFocus(); QApplication::clipboard()->clear(); QApplication::clipboard()->setText(file, QClipboard::Clipboard); - this->editor->triggerPageAction(QWebPage::Paste); + this->editor->triggerPageAction(QWebEnginePage::Paste); } } } @@ -3973,7 +3973,7 @@ void NBrowserWindow::handleUrls(const QMimeData *mime) { * so we need to keep the contents in sync. * */ void NBrowserWindow::noteContentEdited() { - emit noteContentEditedSignal(uuid, lid, editor->editorPage->mainFrame()->documentElement().toOuterXml()); + emit noteContentEditedSignal(uuid, lid, editor->editorPage->documentElement().toOuterXml()); } @@ -4115,13 +4115,13 @@ void NBrowserWindow::newTagFocusShortcut() { // User pressed the superscript editor button void NBrowserWindow::superscriptButtonPressed() { - editor->page()->mainFrame()->evaluateJavaScript("document.execCommand('superscript')"); + editor->page()->runJavaScript("document.execCommand('superscript')"); } // User pressed the subscript editor button void NBrowserWindow::subscriptButtonPressed() { - editor->page()->mainFrame()->evaluateJavaScript("document.execCommand('subscript');"); + editor->page()->runJavaScript("document.execCommand('subscript');"); } QString base64_encode(QString string) { @@ -4323,7 +4323,7 @@ void NBrowserWindow::findReplaceInNotePressed() { return; bool found = false; found = editor->page()->findText(find, - findReplace->getCaseSensitive() | QWebPage::FindWrapsAroundDocument); + findReplace->getCaseSensitive() | QWebEnginePage::FindWrapsAroundDocument); if (!found) return; @@ -4343,7 +4343,7 @@ void NBrowserWindow::findReplaceAllInNotePressed() { bool found = false; while (true) { found = editor->page()->findText(find, - findReplace->getCaseSensitive() | QWebPage::FindWrapsAroundDocument); + findReplace->getCaseSensitive() | QWebEnginePage::FindWrapsAroundDocument); if (!found) return; QApplication::clipboard()->setText(replace); @@ -4361,14 +4361,14 @@ void NBrowserWindow::findNextInNote() { QString find = findReplace->findLine->text(); if (find != "") editor->page()->findText(find, - findReplace->getCaseSensitive() | QWebPage::FindWrapsAroundDocument); + findReplace->getCaseSensitive() | QWebEnginePage::FindWrapsAroundDocument); // The background color of the occurances // when finding text under Windows is // light gray, not recognizable enough, // for better experience, add a background // color for them here. #ifdef _WIN32 - editor->page()->findText(find, QWebPage::HighlightAllOccurrences); + editor->page()->findText(find, QWebEnginePage::HighlightAllOccurrences); #endif } @@ -4382,11 +4382,11 @@ void NBrowserWindow::findPrevInNote() { QString find = findReplace->findLine->text(); if (find != "") editor->page()->findText(find, - findReplace->getCaseSensitive() | QWebPage::FindBackward | - QWebPage::FindWrapsAroundDocument); + findReplace->getCaseSensitive() | QWebEnginePage::FindBackward | + QWebEnginePage::FindWrapsAroundDocument); #ifdef _WIN32 - editor->page()->findText(find, QWebPage::HighlightAllOccurrences); + editor->page()->findText(find, QWebEnginePage::HighlightAllOccurrences); #endif } @@ -4448,7 +4448,7 @@ void NBrowserWindow::exitPoint(ExitPoint *exit) { QStringList tags; tagEditor.getTags(tags); saveExit->setTags(tags); - saveExit->setContents(editor->page()->mainFrame()->toHtml()); + saveExit->setContents(editor->page()->toHtml()); // Set exit ready & call it. saveExit->setExitReady(); diff --git a/src/gui/nwebpage.cpp b/src/gui/nwebpage.cpp index 3b71ebdd..73ec0721 100644 --- a/src/gui/nwebpage.cpp +++ b/src/gui/nwebpage.cpp @@ -19,26 +19,25 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "nwebpage.h" #include -#include #include "src/global.h" //******************************************************* -//* This class inherits everything from QWebPage. It +//* This class inherits everything from QWebEnginePage. It //* handles some of the special things we need in -//* QWebPage to be able to edit notes. +//* QWebEnginePage to be able to edit notes. //******************************************************* extern Global global; NWebPage::NWebPage(QWidget *parent) : - QWebPage(parent) + QWebEnginePage(parent) { connect(this,SIGNAL(contentsChanged()), this, SLOT(editAlert())); - mainFrame()->setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAsNeeded); + setScrollBarPolicy(Qt::Horizontal, Qt::ScrollBarAsNeeded); } -// This class overrides the one provided by QWebPage. This shows us +// This class overrides the one provided by QWebEnginePage. This shows us // any javascript console messages that are produced. void NWebPage::javaScriptConsoleMessage(QString message, int lineNumber, QString sourceID) { QLOG_DEBUG() << "Javascript message: " << "Line: " << lineNumber << " Source: " << sourceID << diff --git a/src/gui/nwebpage.h b/src/gui/nwebpage.h index 63f235a8..bc426263 100644 --- a/src/gui/nwebpage.h +++ b/src/gui/nwebpage.h @@ -20,15 +20,15 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #ifndef NWEBPAGE_H #define NWEBPAGE_H -#include +#include //******************************************************* -//* This class inherits everything from QWebPage. It +//* This class inherits everything from QWebEnginePage. It //* handles some of the special things we need in -//* QWebPage to be able to edit notes. +//* QWebEnginePage to be able to edit notes. //******************************************************* -class NWebPage : public QWebPage +class NWebPage : public QWebEnginePage { Q_OBJECT public: diff --git a/src/gui/nwebview.cpp b/src/gui/nwebview.cpp index 5ddd4b9f..9366c1c3 100644 --- a/src/gui/nwebview.cpp +++ b/src/gui/nwebview.cpp @@ -21,9 +21,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "nwebview.h" #include "nwebpage.h" #include "src/global.h" -#include #include -#include +#include #include #include "src/settings/colorsettings.h" @@ -36,15 +35,15 @@ extern Global global; //**************************************************** -//* This inherits everything from QWebView. It is +//* This inherits everything from QWebEngineView. It is //* useful to allow us to setup things that are //* needed to view & edit notes. //**************************************************** // Override the constructor so we always use a NWebPage -// rather than a QWebPage +// rather than a QWebEnginePage NWebView::NWebView(NBrowserWindow *parent) : - QWebView(parent) + QWebEngineView(parent) { this->parent = parent; editorPage = new NWebPage(this); @@ -252,7 +251,7 @@ NWebView::NWebView(NBrowserWindow *parent) : connect(editorPage, SIGNAL(downloadRequested(QNetworkRequest)), this, SLOT(downloadRequested(QNetworkRequest))); connect(editorPage, SIGNAL(contentsChanged()), this, SLOT(editAlert())); - editorPage->setContentEditable(true); + editorPage->runJavaScript("document.documentElement.contentEditable = true"); // Set some of the menus as disabled until a user selects an image or attachment downloadAttachmentAction()->setEnabled(false); @@ -261,9 +260,9 @@ NWebView::NWebView(NBrowserWindow *parent) : openAction->setEnabled(false); downloadImageAction()->setEnabled(false); - connect(this->page()->mainFrame(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(exposeToJavascript())); + connect(this->page(), SIGNAL(javaScriptWindowObjectCleared()), this, SLOT(exposeToJavascript())); - // this->setStyleSheet("QWebView,html,body { background-color : red; foreground-color : white; }"); + // this->setStyleSheet("QWebEngineView,html,body { background-color : red; foreground-color : white; }"); // //////////////// // QString qss = global.fileManager.getQssDirPathUser(""); // if (qss == "") @@ -330,12 +329,12 @@ NWebView::~NWebView() { QAction *NWebView::downloadAttachmentAction() { - return pageAction(QWebPage::DownloadLinkToDisk); + return pageAction(QWebEnginePage::DownloadLinkToDisk); } QAction *NWebView::downloadImageAction() { - return pageAction(QWebPage::DownloadImageToDisk); + return pageAction(QWebEnginePage::DownloadImageToDisk); } QAction* NWebView::setupColorMenuOption(QString color) { @@ -349,7 +348,7 @@ QAction* NWebView::setupColorMenuOption(QString color) { void NWebView::focusOutEvent(QFocusEvent *e) { - QWebView::focusOutEvent(e); + QWebEngineView::focusOutEvent(e); titleEditor->checkNoteTitleChange(); } @@ -369,7 +368,7 @@ void NWebView::editAlert() { void NWebView::exposeToJavascript() { - page()->mainFrame()->addToJavaScriptWindowObject("editorWindow", this); + page()->addToJavaScriptWindowObject("editorWindow", this); } @@ -464,7 +463,7 @@ bool NWebView::event(QEvent *event) if (event->type() == QEvent::MouseButtonDblClick) { QLOG_DEBUG() << "NWebView::event: DOUBLE CLICK!!!"; } - return QWebView::event(event); + return QWebEngineView::event(event); } @@ -473,12 +472,12 @@ void NWebView::keyPressEvent(QKeyEvent *e) { // This is done because if we set the content as editable, the scroll keys are // ignored by wbkit. if (e->key() == Qt::Key_PageUp || e->key() == Qt::Key_PageDown) { - int bottom = this->page()->mainFrame()->geometry().bottom(); - int top = this->page()->mainFrame()->geometry().top(); + int bottom = this->page()->geometry().bottom(); + int top = this->page()->geometry().top(); int scrollValue = top-bottom; if (e->key() == Qt::Key_PageDown) scrollValue = -1*scrollValue; - page()->mainFrame()->scroll(0,scrollValue); + page()->scroll(0,scrollValue); } // Exit presentation mode @@ -508,7 +507,7 @@ void NWebView::keyPressEvent(QKeyEvent *e) { return; } - QWebView::keyPressEvent(e); + QWebEngineView::keyPressEvent(e); } @@ -537,7 +536,7 @@ void NWebView::setTitleEditor(NTitleEditor *editor) { void NWebView::setDefaultTitle() { - QString body = this->page()->mainFrame()->toPlainText(); + QString body = this->page()->toPlainText(); titleEditor->setTitleFromContent(body); } @@ -638,7 +637,7 @@ void NWebView::setContent(const QByteArray &data) { // https://forum.qt.io/topic/10832/memory-size-increases-per-page-load/4 QByteArray content = data; content.replace("history()->clear(); diff --git a/src/gui/nwebview.h b/src/gui/nwebview.h index 1a615173..fd93034c 100644 --- a/src/gui/nwebview.h +++ b/src/gui/nwebview.h @@ -20,7 +20,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #ifndef NWEBVIEW_H #define NWEBVIEW_H -#include +#include #include "src/gui/nwebpage.h" #include #include @@ -38,7 +38,7 @@ class NBrowserWindow; //* useful to allow us to setup things that are //* needed to view & edit notes. //**************************************************** -class NWebView : public QWebView +class NWebView : public QWebEngineView { Q_OBJECT private: diff --git a/src/gui/plugins/pluginfactory.cpp b/src/gui/plugins/pluginfactory.cpp index c9d0eaa0..5f2b5f5f 100644 --- a/src/gui/plugins/pluginfactory.cpp +++ b/src/gui/plugins/pluginfactory.cpp @@ -25,7 +25,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. PluginFactory::PluginFactory(QObject *parent) : QWebPluginFactory(parent) { - manager = new QNetworkAccessManager(this); } QList PluginFactory::plugins() const diff --git a/src/gui/plugins/pluginfactory.h b/src/gui/plugins/pluginfactory.h index 0835ab2f..38f15461 100644 --- a/src/gui/plugins/pluginfactory.h +++ b/src/gui/plugins/pluginfactory.h @@ -21,17 +21,14 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #define POPPLERFACTORY_H #include -#include #if QT_VERSION < 0x050000 #include #else #include #endif #include "src/gui/plugins/popplerviewer.h" -#include +#include -class QNetworkAccessManager; -class QNetworkReply; class PluginFactory : public QWebPluginFactory { @@ -44,8 +41,7 @@ class PluginFactory : public QWebPluginFactory QList plugins() const; private: - QNetworkAccessManager *manager; - QWebPage *editor; + QWebEnginePage *editor; signals: diff --git a/src/html/NoteFormatterBase.h b/src/html/NoteFormatterBase.h index 42ea02b4..5225188f 100644 --- a/src/html/NoteFormatterBase.h +++ b/src/html/NoteFormatterBase.h @@ -20,9 +20,8 @@ #ifndef NOTEFORMATTERBASE_H #define NOTEFORMATTERBASE_H -#include -#include -#include +#include +#include #include #include #include diff --git a/src/html/enmlformatter.cpp b/src/html/enmlformatter.cpp index 2e3083ba..ad3402f9 100644 --- a/src/html/enmlformatter.cpp +++ b/src/html/enmlformatter.cpp @@ -19,8 +19,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include -#include -#include +#include #include #include #include @@ -395,13 +394,13 @@ void EnmlFormatter::rebuildNoteEnml() { QLOG_DEBUG_FILE("fmt-pre-dt-check.html", getContent()); QLOG_DEBUG() << ENML_MODULE_LOGPREFIX " rebuildNoteEnml guiAvailable=" << guiAvailable; if (guiAvailable) { - QWebPage page; + QWebEnginePage page; QEventLoop loop; - page.mainFrame()->setContent(getContentBytes()); + page->setContent(getContentBytes()); QObject::connect(&page, SIGNAL(loadFinished(bool)), &loop, SLOT(quit())); loop.exit(); - QWebElement bodyElement = page.mainFrame()->documentElement().findFirst("body"); + QWebElement bodyElement = page->documentElement().findFirst("body"); removeInvalidAttributes(bodyElement); recursiveTreeCleanup(bodyElement, 0); QString xml = bodyElement.toOuterXml(); diff --git a/src/html/enmlformatter.h b/src/html/enmlformatter.h index 6d83b437..d825e213 100644 --- a/src/html/enmlformatter.h +++ b/src/html/enmlformatter.h @@ -22,7 +22,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #define ENMLFORMATTER_H #include -#include +#include #include #include #include diff --git a/src/html/noteformatter.cpp b/src/html/noteformatter.cpp index 3b1682ee..1e43aa1c 100644 --- a/src/html/noteformatter.cpp +++ b/src/html/noteformatter.cpp @@ -108,7 +108,7 @@ void NoteFormatter::setNoteHistory(bool value) { QString NoteFormatter::enmlToNoteHTML(QString enml) { - QWebPage page; + QWebEnginePage page; QEventLoop loop; QLOG_TRACE() << "Before preHTMLFormat"; QString html = ""; @@ -122,13 +122,13 @@ QString NoteFormatter::enmlToNoteHTML(QString enml) { QByteArray htmlPage; htmlPage.append(html); QLOG_TRACE() << "About to set content"; - page.mainFrame()->setContent(htmlPage); + page->setContent(htmlPage); QObject::connect(&page, SIGNAL(loadFinished(bool)), &loop, SLOT(quit())); QLOG_TRACE() << "Starting to modify tags"; modifyTags(page); QLOG_TRACE() << "Done modifying tags"; - html = page.mainFrame()->toHtml(); + html = page->toHtml(); return html; } @@ -235,13 +235,13 @@ QString NoteFormatter::preHtmlFormat(QString note) { them into HTML tags. Things like en-media & en-crypt have no HTML values, so we turn them into HTML. */ -void NoteFormatter::modifyTags(QWebPage &doc) { +void NoteFormatter::modifyTags(QWebEnginePage &doc) { QLOG_TRACE_IN(); tempFiles.clear(); // Modify en-media tags QLOG_TRACE() << "Searching for all en-media tags;"; - QWebElementCollection anchors = doc.mainFrame()->findAllElements("en-media"); + QWebElementCollection anchors = doc->findAllElements("en-media"); QLOG_TRACE() << "Search complete: " << anchors.toList().size(); foreach(QWebElement enmedia, anchors) { @@ -262,14 +262,14 @@ void NoteFormatter::modifyTags(QWebPage &doc) { } // Modify todo tags - anchors = doc.mainFrame()->findAllElements("en-todo"); + anchors = doc->findAllElements("en-todo"); qint32 enTodoCount = anchors.count(); for (qint32 i = enTodoCount - 1; i >= 0; i--) { QWebElement enmedia = anchors.at(i); modifyTodoTags(enmedia); } - anchors = doc.mainFrame()->findAllElements("en-crypt"); + anchors = doc->findAllElements("en-crypt"); qint32 enCryptLen = anchors.count(); for (qint32 i = enCryptLen - 1; i >= 0; i--) { QWebElement enmedia = anchors.at(i); @@ -313,7 +313,7 @@ void NoteFormatter::modifyTags(QWebPage &doc) { // Modify link tags - anchors = doc.mainFrame()->findAllElements("a"); + anchors = doc->findAllElements("a"); enCryptLen = anchors.count(); for (qint32 i = 0; i < anchors.count(); i++) { QWebElement element = anchors.at(i); diff --git a/src/html/noteformatter.h b/src/html/noteformatter.h index d21294e0..7a58d310 100644 --- a/src/html/noteformatter.h +++ b/src/html/noteformatter.h @@ -20,9 +20,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #ifndef NOTEFORMATTER_H #define NOTEFORMATTER_H -#include -#include -#include +#include +#include #include #include #include @@ -61,7 +60,7 @@ class NoteFormatter : public NoteFormatterBase { void modifyTodoTags(QWebElement &todo); - void modifyTags(QWebPage &doc); + void modifyTags(QWebEnginePage &doc); QString findIcon(qint32 lid, Resource r, QString fileExt); diff --git a/src/html/thumbnailer.cpp b/src/html/thumbnailer.cpp index 569c21eb..543733a9 100644 --- a/src/html/thumbnailer.cpp +++ b/src/html/thumbnailer.cpp @@ -18,9 +18,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ***********************************************************************************/ #include "thumbnailer.h" -#include -#include -#include +#include +#include #include #include #include @@ -39,23 +38,23 @@ Thumbnailer::~Thumbnailer() { } -void Thumbnailer::capturePage(qint32 lid, QWebPage *page) { - qreal zoomFactor = page->mainFrame()->zoomFactor(); +void Thumbnailer::capturePage(qint32 lid, QWebEnginePage *page) { + qreal zoomFactor = page->zoomFactor(); QSize viewportSize = page->viewportSize(); - page->mainFrame()->setZoomFactor(3); + page->setZoomFactor(3); page->setViewportSize(QSize(300,300)); QImage pix(QSize(300,300), QImage::Format_ARGB32); QPainter painter; painter.begin(&pix); QRegion region = QRegion(0, 0, 300, 300); - page->mainFrame()->render(&painter, region); + page->render(&painter, region); painter.end(); QString filename = global.fileManager.getThumbnailDirPath() + QString::number(lid) +".png"; pix.save(filename); - page->mainFrame()->setZoomFactor(zoomFactor); + page->setZoomFactor(zoomFactor); page->setViewportSize(viewportSize); NoteTable ntable(db); diff --git a/src/html/thumbnailer.h b/src/html/thumbnailer.h index fe7cb563..258921ea 100644 --- a/src/html/thumbnailer.h +++ b/src/html/thumbnailer.h @@ -21,7 +21,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #ifndef THUMBNAILER_H #define THUMBNAILER_H -#include +#include #include #include @@ -42,7 +42,7 @@ class Thumbnailer : public QObject public: Thumbnailer(DatabaseConnection *db); ~Thumbnailer(); - void capturePage(qint32 lid, QWebPage *page); + void capturePage(qint32 lid, QWebEnginePage *page); }; #endif // THUMBNAILER_H diff --git a/src/nixnote.cpp b/src/nixnote.cpp index 2f39efb1..0c6a0559 100644 --- a/src/nixnote.cpp +++ b/src/nixnote.cpp @@ -3643,7 +3643,7 @@ void NixNote::onExportAsPdf() { noteTableView->getSelectedLids(lids); if (pdfExportWindow == nullptr) { - pdfExportWindow = new QWebView(); + pdfExportWindow = new QWebEngineView(); connect(pdfExportWindow, SIGNAL(loadFinished(bool)), this, SLOT(onExportAsPdfReady(bool))); } diff --git a/src/nixnote.h b/src/nixnote.h index 0f985e0c..263f4745 100644 --- a/src/nixnote.h +++ b/src/nixnote.h @@ -82,7 +82,7 @@ class NixNote : public QMainWindow private: static NixNote *singleton; // static pointer to singleton instance of this class QTranslator *nixnoteTranslator; - QWebView *pdfExportWindow; + QWebEngineView *pdfExportWindow; DatabaseConnection *db; // The database connection NTableView *noteTableView; NSearchView *searchTreeView; diff --git a/src/qevercloud/CHANGELOG.md b/src/qevercloud/CHANGELOG.md index 49b885c0..93bc346a 100644 --- a/src/qevercloud/CHANGELOG.md +++ b/src/qevercloud/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## 6.2.0.ah + * Remove Qt5WebKit use + ## 6.2.0 * Fix OAuth with Qt5WebKit with a hack * Implement OAuth via system browser so that neither Qt5WebKir nor Qt5WebEngine could be required diff --git a/src/qevercloud/CMakeLists.txt b/src/qevercloud/CMakeLists.txt index 239e5265..1796e868 100644 --- a/src/qevercloud/CMakeLists.txt +++ b/src/qevercloud/CMakeLists.txt @@ -114,13 +114,8 @@ if(BUILD_TRANSLATIONS) endif() if(BUILD_WITH_OAUTH_SUPPORT) - if(USE_QT5_WEBKIT OR Qt5Core_VERSION VERSION_LESS "5.6.0") - file(READ QEverCloud/cmake/modules/QEverCloudFindQt5DependenciesWebKit.cmake WEBKIT_DEPS_FILE) - file(APPEND ${PROJECT_BINARY_DIR}/QEverCloud-${QEVERCLOUD_QT_VERSION}FindQtDependencies.cmake "${WEBKIT_DEPS_FILE}") - elseif(NOT QEVERCLOUD_USE_SYSTEM_BROWSER) - file(READ QEverCloud/cmake/modules/QEverCloudFindQt5DependenciesWebEngineCore.cmake WEBENGINE_CORE_DEPS_FILE) - file(APPEND ${PROJECT_BINARY_DIR}/QEverCloud-${QEVERCLOUD_QT_VERSION}FindQtDependencies.cmake "${WEBENGINE_CORE_DEPS_FILE}") - endif() + file(READ QEverCloud/cmake/modules/QEverCloudFindQt5DependenciesWebEngineCore.cmake WEBENGINE_CORE_DEPS_FILE) + file(APPEND ${PROJECT_BINARY_DIR}/QEverCloud-${QEVERCLOUD_QT_VERSION}FindQtDependencies.cmake "${WEBENGINE_CORE_DEPS_FILE}") endif() find_package(Sanitizers) diff --git a/src/qevercloud/QEverCloud/CMakeLists.txt b/src/qevercloud/QEverCloud/CMakeLists.txt index 004dbbb2..74106a76 100644 --- a/src/qevercloud/QEverCloud/CMakeLists.txt +++ b/src/qevercloud/QEverCloud/CMakeLists.txt @@ -89,8 +89,6 @@ set(${PROJECT_NAME}_TR_SOURCES ${SOURCES} src/oauth/OAuthWebEngine.h src/oauth/OAuthWebEngine.cpp - src/oauth/OAuthWebKit.h - src/oauth/OAuthWebKit.cpp src/oauth/OAuthSystemBrowser.h src/oauth/OAuthSystemBrowser.cpp src/oauth/OAuth.cpp) @@ -103,18 +101,12 @@ if(BUILD_WITH_OAUTH_SUPPORT) list(APPEND SOURCES src/oauth/NetworkCookieJar.cpp src/oauth/OAuthWebEngine.cpp) - elseif(QEVERCLOUD_USE_SYSTEM_BROWSER) + else() list(APPEND PRIVATE_HEADERS src/oauth/OAuthSystemBrowser.h) list(APPEND SOURCES src/oauth/OAuthSystemBrowser.cpp) - else() - list(APPEND PRIVATE_HEADERS - src/oauth/OAuthWebKit.h) - - list(APPEND SOURCES - src/oauth/OAuthWebKit.cpp) endif() list(APPEND SOURCES @@ -140,7 +132,7 @@ else() endif() if(QEVERCLOUD_USE_QT_WEB_ENGINE EQUAL QEVERCLOUD_USE_SYSTEM_BROWSER) - message(FATAL_ERROR "QEverCloud can be built either with QtWebKit or QtWebEngine or system browser backend for OAuth") + message(FATAL_ERROR "QEverCloud can be built either with QtWebEngine or system browser backend for OAuth") endif() if(QEVERCLOUD_USE_QT_WEB_ENGINE) diff --git a/src/qevercloud/QEverCloud/cmake/modules/QEverCloudFindQt5DependenciesWebKit.cmake b/src/qevercloud/QEverCloud/cmake/modules/QEverCloudFindQt5DependenciesWebKit.cmake deleted file mode 100644 index f5a3094d..00000000 --- a/src/qevercloud/QEverCloud/cmake/modules/QEverCloudFindQt5DependenciesWebKit.cmake +++ /dev/null @@ -1,2 +0,0 @@ -QEverCloudFindPackageWrapper(Qt5WebKit ${QEVERCLOUD_FIND_PACKAGE_ARG}) -QEverCloudFindPackageWrapper(Qt5WebKitWidgets ${QEVERCLOUD_FIND_PACKAGE_ARG}) diff --git a/src/qevercloud/QEverCloud/cmake/modules/QEverCloudSetupQt.cmake b/src/qevercloud/QEverCloud/cmake/modules/QEverCloudSetupQt.cmake index 753b0580..808b614b 100644 --- a/src/qevercloud/QEverCloud/cmake/modules/QEverCloudSetupQt.cmake +++ b/src/qevercloud/QEverCloud/cmake/modules/QEverCloudSetupQt.cmake @@ -35,48 +35,27 @@ if(BUILD_TRANSLATIONS) endif() if(BUILD_WITH_OAUTH_SUPPORT AND NOT QEVERCLOUD_USE_SYSTEM_BROWSER) - if(USE_QT5_WEBKIT OR Qt5Core_VERSION VERSION_LESS "5.6.0") - include(QEverCloudFindQt5DependenciesWebKit) - else() - include(QEverCloudFindQt5DependenciesWebEngineCore) - set(QEVERCLOUD_USE_QT_WEB_ENGINE TRUE) - endif() + include(QEverCloudFindQt5DependenciesWebEngineCore) + set(QEVERCLOUD_USE_QT_WEB_ENGINE TRUE) if(QEVERCLOUD_USE_QT_WEB_ENGINE) add_definitions(-DQEVERCLOUD_USE_QT_WEB_ENGINE) endif() - if(USE_QT5_WEBKIT) - list(APPEND QT_INCLUDES - ${QT_INCLUDES} - ${Qt5WebKit_INCLUDE_DIRS} - ${Qt5WebKitWidgets_INCLUDE_DIRS}) - - list(APPEND QT_LIBRARIES - ${QT_LIBRARIES} - ${Qt5WebKit_LIBRARIES} - ${Qt5WebKitWidgets_LIBRARIES}) - - list(APPEND QT_DEFINITIONS - ${QT_DEFINITIONS} - ${Qt5WebKit_DEFINITIONS} - ${Qt5WebKitWidgets_DEFINITIONS}) - else() - list(APPEND QT_INCLUDES - ${QT_INCLUDES} - ${Qt5WebEngineCore_INCLUDE_DIRS} - ${Qt5WebEngineWidgets_INCLUDE_DIRS}) - - list(APPEND QT_LIBRARIES - ${QT_LIBRARIES} - ${Qt5WebEngineCore_LIBRARIES} - ${Qt5WebEngineWidgets_LIBRARIES}) - - list(APPEND QT_DEFINITIONS - ${QT_DEFINITIONS} - ${Qt5WebEngineCore_DEFINITIONS} - ${Qt5WebEngineWidgets_DEFINITIONS}) - endif() + list(APPEND QT_INCLUDES + ${QT_INCLUDES} + ${Qt5WebEngineCore_INCLUDE_DIRS} + ${Qt5WebEngineWidgets_INCLUDE_DIRS}) + + list(APPEND QT_LIBRARIES + ${QT_LIBRARIES} + ${Qt5WebEngineCore_LIBRARIES} + ${Qt5WebEngineWidgets_LIBRARIES}) + + list(APPEND QT_DEFINITIONS + ${QT_DEFINITIONS} + ${Qt5WebEngineCore_DEFINITIONS} + ${Qt5WebEngineWidgets_DEFINITIONS}) endif() list(REMOVE_DUPLICATES QT_INCLUDES) diff --git a/src/qevercloud/QEverCloud/src/oauth/OAuth.cpp b/src/qevercloud/QEverCloud/src/oauth/OAuth.cpp index 80afd451..17a21062 100644 --- a/src/qevercloud/QEverCloud/src/oauth/OAuth.cpp +++ b/src/qevercloud/QEverCloud/src/oauth/OAuth.cpp @@ -13,10 +13,8 @@ #if QEVERCLOUD_USE_QT_WEB_ENGINE #include "OAuthWebEngine.h" -#elif QEVERCLOUD_USE_SYSTEM_BROWSER -#include "OAuthSystemBrowser.h" #else -#include "OAuthWebKit.h" +#include "OAuthSystemBrowser.h" #endif #include diff --git a/src/qevercloud/QEverCloud/src/oauth/OAuthWebKit.cpp b/src/qevercloud/QEverCloud/src/oauth/OAuthWebKit.cpp deleted file mode 100644 index 491ccbdf..00000000 --- a/src/qevercloud/QEverCloud/src/oauth/OAuthWebKit.cpp +++ /dev/null @@ -1,130 +0,0 @@ -/** - * Copyright (c) 2023 Dmitry Ivanov - * - * This file is a part of QEverCloud project and is distributed under the terms - * of MIT license: https://opensource.org/licenses/MIT - */ - -#include "OAuthWebKit.h" - -#include "NetworkCookieJar.h" -#include "Utils.h" - -#include -#include - -namespace qevercloud { - -EvernoteOAuthWebViewPrivate::EvernoteOAuthWebViewPrivate(QWidget * parent) : - QWebView(parent) -{ - auto * pNam = page()->networkAccessManager(); - pNam->setProxy(evernoteNetworkProxy()); - pNam->setCookieJar(new NetworkCookieJar); -} - -EvernoteOAuthWebViewPrivate::~EvernoteOAuthWebViewPrivate() -{ - QWebSettings::clearMemoryCaches(); -} - -void EvernoteOAuthWebViewPrivate::clearHtml() -{ - setHtml(QLatin1String("")); -} - -void EvernoteOAuthWebViewPrivate::onUrlChanged(const QUrl & url) -{ - const auto urlString = url.toString(); - if (!urlString.contains(QString::fromUtf8("%1?").arg(oauthCallbackUrl()))) { - // Hack which appears to solve the problem of login page freezing on - // analytics pitstop - back(); - return; - } - - onOAuthCallback(urlString); -} - -void EvernoteOAuthWebViewPrivate::onAuthenticationFinished(bool success) -{ - Q_EMIT authenticationFinished(success); -} - -void EvernoteOAuthWebViewPrivate::openOAuthPage(QUrl pageUrl) -{ - QEC_DEBUG("oauth[webkit]", "EvernoteOAuthWebViewPrivate::openOAuthPage"); - - QObject::connect( - this, &EvernoteOAuthWebViewPrivate::urlChanged, - this, &EvernoteOAuthWebViewPrivate::onUrlChanged); - - QNetworkRequest request; - request.setUrl(pageUrl); - request.setRawHeader( - QByteArray("Accept-Language"), httpAcceptLanguage().toUtf8()); - - load(request); -} - -void EvernoteOAuthWebViewPrivate::onOAuthResponseReceived() -{ - QObject::disconnect( - this, &EvernoteOAuthWebViewPrivate::urlChanged, - this, &EvernoteOAuthWebViewPrivate::onUrlChanged); - - QMetaObject::invokeMethod(this, "clearHtml", Qt::QueuedConnection); -} - -void EvernoteOAuthWebViewPrivate::clear() -{ - setHtml(QLatin1String("")); - history()->clear(); -} - -QObject * EvernoteOAuthWebViewPrivate::context() -{ - return this; -} - -bool EvernoteOAuthWebViewPrivate::onStartAuthentication() -{ - setHtml(QLatin1String("")); - history()->clear(); - return true; -} - -QString EvernoteOAuthWebViewPrivate::oauthCallbackUrl() const -{ - return QStringLiteral("nnoauth"); -} - -QNetworkAccessManager * EvernoteOAuthWebViewPrivate::networkAccessManager( - QObject * rf) -{ - return page()->networkAccessManager(); -} - -QList EvernoteOAuthWebViewPrivate::extractCookies( - ReplyFetcher * rf) -{ - Q_ASSERT(rf); - - auto * pNam = rf->networkAccessManager(); - if (Q_UNLIKELY(!pNam)) { - QEC_WARNING("oauth[webkit]", "Failed to extract cookies after OAuth: " - << "network access manager instance expired"); - return {}; - } - - auto * pCookieJar = qobject_cast(pNam->cookieJar()); - if (Q_UNLIKELY(!pCookieJar)) { - QEC_WARNING("oauth[webkit]", "Failed to extract cookies after OAuth: " - << "unexpected instance of cookie jar"); - return {}; - } - - return pCookieJar->allCookies(); -} - -} // namespace qevercloud diff --git a/src/qevercloud/QEverCloud/src/oauth/OAuthWebKit.h b/src/qevercloud/QEverCloud/src/oauth/OAuthWebKit.h deleted file mode 100644 index 7153aa8e..00000000 --- a/src/qevercloud/QEverCloud/src/oauth/OAuthWebKit.h +++ /dev/null @@ -1,55 +0,0 @@ -/** - * Copyright (c) 2023 Dmitry Ivanov - * - * This file is a part of QEverCloud project and is distributed under the terms - * of MIT license: https://opensource.org/licenses/MIT - */ - -#ifndef QEVERCLOUD_OAUTH_WEBKIT_H -#define QEVERCLOUD_OAUTH_WEBKIT_H - -#include "AbstractOAuthEngine.h" - -#include -#include -#include -#include -#include - -namespace qevercloud { - -class EvernoteOAuthWebViewPrivate: public QWebView, public AbstractOAuthEngine -{ - Q_OBJECT -public: - explicit EvernoteOAuthWebViewPrivate(QWidget * parent = nullptr); - ~EvernoteOAuthWebViewPrivate() override; - -Q_SIGNALS: - void authenticationFinished(bool success); - -public Q_SLOTS: - void clearHtml(); - -private Q_SLOTS: - void onUrlChanged(const QUrl & url); - -private: // AbstractOAuthEngine - void onAuthenticationFinished(bool success) override; - void openOAuthPage(QUrl pageUrl) override; - void onOAuthResponseReceived() override; - void clear() override; - [[nodiscard]] QObject * context() override; - [[nodiscard]] bool onStartAuthentication() override; - [[nodiscard]] QString oauthCallbackUrl() const override; - - [[nodiscard]] QNetworkAccessManager * networkAccessManager( - QObject * rf) override; - - [[nodiscard]] QList extractCookies( - ReplyFetcher * pReplyFetcher) override; -}; - -} // namespace qevercloud - -#endif // QEVERCLOUD_OAUTH_WEBKIT_H diff --git a/src/qevercloud/README.md b/src/qevercloud/README.md index d8939221..52eed416 100644 --- a/src/qevercloud/README.md +++ b/src/qevercloud/README.md @@ -58,15 +58,13 @@ QEverCloud depends on the following Qt components: * Qt5Core * Qt5Widgets * Qt5Network - * (Optional) Qt5WebKit an Qt5WebKitWidgets * (Optional) Qt5WebEngine and Qt5WebEngineWidgets -The dependencies on Qt5WebKit or Qt5WebEngine are only actual if the library is built with OAuth support. But even then there is an option to build the library with OAuth support but without the dependency on either of these components. More on this below. +The dependencies on Qt5WebEngine are only actual if the library is built with OAuth support. But even then there is an option to build the library with OAuth support but without the dependency on either of these components. More on this below. By default the library is built with OAuth support and uses Qt5WebEngine for it. The following cmake parameters are available to alter this behaviour: * `-DBUILD_WITH_OAUTH_SUPPORT=NO` would disable building with OAuth support entirely. - * `-DUSE_QT5_WEBKIT=ON` would build the library with OAuth using Qt5WebKit for web page rendering. - * `-DQEVERCLOUD_USE_SYSTEM_BROWSER=ON` would build the library with OAuth not using either Qt5WebKit or Qt5WebEngine but instead delegating some portion of OAuth procedure to the system browser. + * `-DQEVERCLOUD_USE_SYSTEM_BROWSER=ON` would build the library with OAuth not using either Qt5WebEngine but instead delegating some portion of OAuth procedure to the system browser. If Qt5's Qt5Test module is found during the pre-build configuration step, the unit tests are enabled and can be run with `make test` and more verbose `make check` commands. diff --git a/testsrc/testdata/qwebelement.html b/testsrc/testdata/qwebelement.html index 2705e1c5..8a9b00ea 100644 --- a/testsrc/testdata/qwebelement.html +++ b/testsrc/testdata/qwebelement.html @@ -134,7 +134,7 @@

QWebElement Class

Header: #include <QWebElement> -
qmake: QT += webkitwidgets
Since: Qt 4.6
    + qmake: QT += webenginewidgets Since: Qt 4.6 diff --git a/testsrc/tests.pro b/testsrc/tests.pro index a548d39a..21333c29 100644 --- a/testsrc/tests.pro +++ b/testsrc/tests.pro @@ -1,6 +1,6 @@ message("Out path: $${OUT_PWD}") -QT += core widgets printsupport webkit webkitwidgets sql network xml dbus qml testlib +QT += core widgets printsupport webkit webenginewidgets sql network xml dbus qml testlib CONFIG += link_pkgconfig PKGCONFIG += tidy diff --git a/themes.ini b/themes.ini index bf14dcb3..1aed80d0 100644 --- a/themes.ini +++ b/themes.ini @@ -49,7 +49,7 @@ searchInputCss=QLineEdit { padding-right: 1px; } ## Sear #noteTabCss= ## Note tab header #tagTreeCss= ## Tag selection tree #trashTreeCss= ## Trash selection tree -#noteContentsCss= ## Note contents QWebView +#noteContentsCss= ## Note contents QWebEngineView #trayMenuCss= ## Tray icon popup menu #treeWidgetEditorCss= ## Used when changing a tree item name #treeWidgetPanelCss= ## Left panel that holds shortcuts, notebooks, tags, saved searches & trash. @@ -344,7 +344,7 @@ noteTableViewHeaderCss=background-color: #23252e; noteTabCss= ## Note tab header #tagTreeCss= ## Tag selection tree #trashTreeCss= ## Trash selection tree -#noteContentsCss= ## Note contents QWebView +#noteContentsCss= ## Note contents QWebEngineView #trayMenuCss= ## Tray icon popup menu #treeWidgetEditorCss= ## Used when changing a tree item name treeWidgetPanelCss=background-color: #23252e; color: white; ## Left panel that holds shortcuts, notebooks, tags, saved searches & trash.