From 51feccf3cc0939d42c3ff237eb17f9a6091f1dd8 Mon Sep 17 00:00:00 2001 From: Andreas Sturmlechner Date: Fri, 23 Oct 2020 15:32:39 +0200 Subject: [PATCH] Port to QtWebEngineWidgets Fixes https://invent.kde.org/multimedia/kdenlive/-/issues/775 Signed-off-by: Andreas Sturmlechner --- CMakeLists.txt | 2 +- src/CMakeLists.txt | 12 ++++++------ src/qt-oauth-lib/logindialog.cpp | 4 ++-- src/qt-oauth-lib/logindialog.h | 3 +-- src/qt-oauth-lib/oauth2.h | 4 ++-- src/ui/logindialog_ui.ui | 6 +++--- src/utils/resourcewidget.cpp | 14 +++++++------- 7 files changed, 22 insertions(+), 23 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d434f1e31..a3f838433 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -71,7 +71,7 @@ if(WIN32) set(MLT_PREFIX "..") else() set(MLT_PREFIX ${MLT_ROOT_DIR}) - find_package(Qt5 OPTIONAL_COMPONENTS WebKitWidgets QUIET) + find_package(Qt5 OPTIONAL_COMPONENTS WebEngineWidgets QUIET) endif() if(KF5FileMetaData_FOUND) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 551178133..8356d4e47 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -65,7 +65,7 @@ add_subdirectory(transitions) add_subdirectory(utils) add_subdirectory(widgets) add_subdirectory(xml) -if(Qt5WebKitWidgets_FOUND) +if(Qt5WebEngineWidgets_FOUND) add_subdirectory(qt-oauth-lib) endif() ## top_SRCS @@ -178,12 +178,12 @@ if(KF5_PURPOSE) target_link_libraries(kdenliveLib KF5::Purpose KF5::PurposeWidgets) endif() -if(Qt5WebKitWidgets_FOUND) - message(STATUS "Found Qt5 WebKitWidgets. You can use your Freesound.org credentials to download files") - target_compile_definitions(kdenliveLib PRIVATE -DQT5_USE_WEBKIT) - target_link_libraries(kdenliveLib Qt5::WebKitWidgets) +if(Qt5WebEngineWidgets_FOUND) + message(STATUS "Found Qt5 WebEngineWidgets. You can use your Freesound.org credentials to download files") + target_compile_definitions(kdenliveLib PRIVATE -DQT5_USE_WEBENGINE) + target_link_libraries(kdenliveLib Qt5::WebEngineWidgets) else() - message(STATUS "Qt5 WebKitWidgets not found. You cannot use your Freesound.org credentials, only preview files can be downloaded from the Online Resources Widget") + message(STATUS "Qt5 WebEngineWidgets not found. You cannot use your Freesound.org credentials, only preview files can be downloaded from the Online Resources Widget") endif() if(Q_WS_X11) diff --git a/src/qt-oauth-lib/logindialog.cpp b/src/qt-oauth-lib/logindialog.cpp index a41aa420b..111978831 100644 --- a/src/qt-oauth-lib/logindialog.cpp +++ b/src/qt-oauth-lib/logindialog.cpp @@ -38,7 +38,7 @@ #include "ui_logindialog_ui.h" #include "kdenlive_debug.h" -#include +#include LoginDialog::LoginDialog(QWidget *parent) : QDialog(parent) @@ -54,7 +54,7 @@ LoginDialog::LoginDialog(QWidget *parent) i18n("Enter your freesound account details to download the highest quality version of this file. Or use the High Quality " "preview file instead (no freesound account required).")); // m_ui->textBrowser - connect(m_ui->webView, &QWebView::urlChanged, this, &LoginDialog::urlChanged); + connect(m_ui->webView, &QWebEngineView::urlChanged, this, &LoginDialog::urlChanged); } LoginDialog::~LoginDialog() diff --git a/src/qt-oauth-lib/logindialog.h b/src/qt-oauth-lib/logindialog.h index 963b38ec5..c34383bf2 100644 --- a/src/qt-oauth-lib/logindialog.h +++ b/src/qt-oauth-lib/logindialog.h @@ -47,11 +47,10 @@ class LoginDialog; /** \brief This is the dialog that is used to login to freesound - \details It contains a QWebView object to display the freesound web page. I did try using a QTextBrowser + \details It contains a QWebEngineView object to display the freesound web page. I did try using a QTextBrowser for this purpose but it responds to the URL that is used to connect with "No document for https://www.freesound.org/apiv2/oauth2/authorize/?client_id=3duhagdr874c&redirect_uri=https://www.freesound.org/home/app_permissions/permission_granted/&response_type=code" - The use of QWebView adds a dependency on the KF5WebKit to kdenlive. Need install libkf5webkit5-dev package on ubuntu */ class LoginDialog : public QDialog { diff --git a/src/qt-oauth-lib/oauth2.h b/src/qt-oauth-lib/oauth2.h index f28724455..03993a214 100644 --- a/src/qt-oauth-lib/oauth2.h +++ b/src/qt-oauth-lib/oauth2.h @@ -45,7 +45,7 @@ const QLatin1String OAuth2_strClientSecret("441d88374716e7a3503997151e4780566f007313"); // obtained when ttguy registered the kdenlive application with freesound #endif -#ifdef QT5_USE_WEBKIT +#ifdef QT5_USE_WEBENGINE class LoginDialog; @@ -135,6 +135,6 @@ private: void buildLoginDialog(); }; -#endif // QT5_USE_WEBKIT +#endif // QT5_USE_WEBENGINE #endif // OAUTH2_H diff --git a/src/ui/logindialog_ui.ui b/src/ui/logindialog_ui.ui index 20827d686..e98a68ed2 100644 --- a/src/ui/logindialog_ui.ui +++ b/src/ui/logindialog_ui.ui @@ -15,7 +15,7 @@ - + about:blank @@ -51,9 +51,9 @@ - QWebView + QWebEngineView QWidget -
QtWebKitWidgets/QWebView
+
QtWebEngineWidgets/QWebEngineView
diff --git a/src/utils/resourcewidget.cpp b/src/utils/resourcewidget.cpp index 79bb48898..d0eaa225b 100644 --- a/src/utils/resourcewidget.cpp +++ b/src/utils/resourcewidget.cpp @@ -49,7 +49,7 @@ #include #include -#ifdef QT5_USE_WEBKIT +#ifdef QT5_USE_WEBENGINE #include "qt-oauth-lib/oauth2.h" #endif @@ -103,7 +103,7 @@ ResourceWidget::ResourceWidget(QString folder, QWidget *parent) search_text->setFocus(); connect(search_text, SIGNAL(returnPressed()), this, SLOT(slotStartSearch())); -#ifdef QT5_USE_WEBKIT +#ifdef QT5_USE_WEBENGINE m_pOAuth2 = new OAuth2(this); connect(m_pOAuth2, &OAuth2::accessTokenReceived, this, &ResourceWidget::slotAccessTokenReceived); connect(m_pOAuth2, &OAuth2::accessDenied, this, &ResourceWidget::slotFreesoundAccessDenied); @@ -375,7 +375,7 @@ void ResourceWidget::slotSaveItem(const QString &originalUrl) path.append(m_currentService->getDefaultDownloadName(item)); if (m_currentService->serviceType == AbstractService::FREESOUND) { -#ifdef QT5_USE_WEBKIT +#ifdef QT5_USE_WEBENGINE sFileExt = m_currentService->getExtension(search_results->currentItem()); #else sFileExt = QStringLiteral("*.") + m_currentInfo.HQpreview.section(QLatin1Char('.'), -1); @@ -402,7 +402,7 @@ void ResourceWidget::slotSaveItem(const QString &originalUrl) } slotSetDescription(QString()); button_import->setEnabled(false); // disable buttons while download runs. enabled in slotGotFile -#ifdef QT5_USE_WEBKIT +#ifdef QT5_USE_WEBENGINE if (m_currentService->serviceType == AbstractService::FREESOUND) { // open a dialog to authenticate with free sound and download the file m_pOAuth2->obtainAccessToken(); // when job finished ResourceWidget::slotAccessTokenReceived will be called } else { // not freesound - do file download via a KIO file copy job @@ -841,7 +841,7 @@ void ResourceWidget::DownloadRequestFinished(QNetworkReply *reply) m_desc.append(m_saveLocation); updateLayout(); } else { -#ifdef QT5_USE_WEBKIT +#ifdef QT5_USE_WEBENGINE m_pOAuth2->ForgetAccessToken(); #endif m_desc.append(QStringLiteral("
") + i18n("Error Saving File")); @@ -850,11 +850,11 @@ void ResourceWidget::DownloadRequestFinished(QNetworkReply *reply) } else { if (reply->error() == QNetworkReply::AuthenticationRequiredError) { -#ifdef QT5_USE_WEBKIT +#ifdef QT5_USE_WEBENGINE m_pOAuth2->obtainNewAccessToken(); #endif } else { -#ifdef QT5_USE_WEBKIT +#ifdef QT5_USE_WEBENGINE m_pOAuth2->ForgetAccessToken(); #endif m_desc.append(QStringLiteral("
") + i18n("Error Downloading File. Error code: %1", reply->error()) + QStringLiteral("
")); -- 2.29.1