1728 lines
57 KiB
Diff
1728 lines
57 KiB
Diff
|
From 101b1170ef8484df732ccbff235dc28fc91f1a26 Mon Sep 17 00:00:00 2001
|
||
|
From: Maik Qualmann <metzpinguin@gmail.com>
|
||
|
Date: Wed, 28 Mar 2018 22:13:01 +0200
|
||
|
Subject: add possibility to use QWebEngine instead of QWebKit with compile
|
||
|
flag CCBUGS: 363859
|
||
|
|
||
|
---
|
||
|
bootstrap.linux | 1 +
|
||
|
bootstrap.macports | 1 +
|
||
|
core/CMakeLists.txt | 10 +-
|
||
|
core/app/CMakeLists.txt | 34 +-
|
||
|
core/app/utils/digikam_config.h.cmake.in | 3 +
|
||
|
core/app/views/stackedview.cpp | 11 +-
|
||
|
core/app/views/welcomepageview.cpp | 8 +-
|
||
|
core/app/views/welcomepageview_qwebengine.cpp | 222 +++++++++++
|
||
|
core/app/views/welcomepageview_qwebengine.h | 87 +++++
|
||
|
.../geolocation/geoiface/backend-googlemaps-js.js | 12 +-
|
||
|
core/libs/dialogs/CMakeLists.txt | 20 +-
|
||
|
core/libs/dialogs/webbrowserdlg_qwebengine.cpp | 228 ++++++++++++
|
||
|
core/libs/dialogs/webbrowserdlg_qwebengine.h | 76 ++++
|
||
|
core/libs/widgets/mainview/dxmlguiwindow.cpp | 7 +-
|
||
|
.../htmlgallery/wizard/htmlfinalpage.cpp | 8 +-
|
||
|
core/utilities/geolocation/geoiface/CMakeLists.txt | 20 +-
|
||
|
.../geoiface/backends/backendgooglemaps.cpp | 29 +-
|
||
|
.../geolocation/geoiface/widgets/htmlwidget.cpp | 2 +-
|
||
|
.../geolocation/geoiface/widgets/htmlwidget.h | 2 +-
|
||
|
.../geoiface/widgets/htmlwidget_qwebengine.cpp | 409 +++++++++++++++++++++
|
||
|
.../geoiface/widgets/htmlwidget_qwebengine.h | 119 ++++++
|
||
|
21 files changed, 1278 insertions(+), 31 deletions(-)
|
||
|
create mode 100644 core/app/views/welcomepageview_qwebengine.cpp
|
||
|
create mode 100644 core/app/views/welcomepageview_qwebengine.h
|
||
|
create mode 100644 core/libs/dialogs/webbrowserdlg_qwebengine.cpp
|
||
|
create mode 100644 core/libs/dialogs/webbrowserdlg_qwebengine.h
|
||
|
create mode 100644 core/utilities/geolocation/geoiface/widgets/htmlwidget_qwebengine.cpp
|
||
|
create mode 100644 core/utilities/geolocation/geoiface/widgets/htmlwidget_qwebengine.h
|
||
|
|
||
|
diff --git a/bootstrap.linux b/bootstrap.linux
|
||
|
index a877a31..5ecf3b8 100755
|
||
|
--- a/bootstrap.linux
|
||
|
+++ b/bootstrap.linux
|
||
|
@@ -91,6 +91,7 @@ $CMAKE_BINARY -G "$MAKEFILES_TYPE" . \
|
||
|
-DENABLE_MEDIAPLAYER=ON \
|
||
|
-DENABLE_DBUS=ON \
|
||
|
-DENABLE_APPSTYLES=ON \
|
||
|
+ -DENABLE_QWEBENGINE=OFF \
|
||
|
-Wno-dev \
|
||
|
$SOURCEDIR && echo "$MESSAGE"
|
||
|
|
||
|
diff --git a/bootstrap.macports b/bootstrap.macports
|
||
|
index 41a331a..562552f 100755
|
||
|
--- a/bootstrap.macports
|
||
|
+++ b/bootstrap.macports
|
||
|
@@ -85,6 +85,7 @@ cmake -G "$MAKEFILES_TYPE" . \
|
||
|
-DENABLE_KIO=OFF \
|
||
|
-DENABLE_LEGACY=OFF \
|
||
|
-DENABLE_APPSTYLES=OFF \
|
||
|
+ -DENABLE_QWEBENGINE=OFF \
|
||
|
-DAPPLE_SUPPRESS_X11_WARNING=ON \
|
||
|
-DCMAKE_COLOR_MAKEFILE=ON \
|
||
|
-DCMAKE_BUILD_WITH_INSTALL_RPATH=ON \
|
||
|
diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt
|
||
|
index 856954c..8f7163b 100644
|
||
|
--- a/core/CMakeLists.txt
|
||
|
+++ b/core/CMakeLists.txt
|
||
|
@@ -104,6 +104,7 @@ option(ENABLE_AKONADICONTACTSUPPORT "Build digiKam with KDE Mail Contacts suppor
|
||
|
option(ENABLE_MEDIAPLAYER "Build digiKam with Media Player support (default=OFF)" OFF)
|
||
|
option(ENABLE_DBUS "Build digiKam with DBUS support (default=ON)" ON)
|
||
|
option(ENABLE_APPSTYLES "Build digiKam with support for changing the widget application style (default=OFF)" OFF)
|
||
|
+option(ENABLE_QWEBENGINE "Build digiKam with QWebEngine instead of QWebKit (default=OFF)" OFF)
|
||
|
|
||
|
# Mysql support options (experimental):
|
||
|
option(ENABLE_MYSQLSUPPORT "Build digiKam with MySQL dabatase support (default=ON)" ON)
|
||
|
@@ -124,10 +125,15 @@ find_package(Qt5 ${QT_MIN_VERSION}
|
||
|
Sql
|
||
|
Xml
|
||
|
PrintSupport
|
||
|
- WebKitWidgets
|
||
|
Network
|
||
|
)
|
||
|
|
||
|
+if(ENABLE_QWEBENGINE)
|
||
|
+ find_package(Qt5 ${QT_MIN_VERSION} NO_MODULE COMPONENTS WebEngineWidgets)
|
||
|
+else()
|
||
|
+ find_package(Qt5 ${QT_MIN_VERSION} NO_MODULE COMPONENTS WebKitWidgets)
|
||
|
+endif()
|
||
|
+
|
||
|
find_package(Qt5 ${QT_MIN_VERSION}
|
||
|
OPTIONAL_COMPONENTS
|
||
|
DBus
|
||
|
@@ -415,6 +421,7 @@ MACRO_BOOL_TO_01(ENABLE_INTERNALMYSQL HAVE_INTERNALMYSQL)
|
||
|
MACRO_BOOL_TO_01(ENABLE_MEDIAPLAYER HAVE_MEDIAPLAYER)
|
||
|
MACRO_BOOL_TO_01(ENABLE_DBUS HAVE_DBUS)
|
||
|
MACRO_BOOL_TO_01(ENABLE_APPSTYLES HAVE_APPSTYLE_SUPPORT)
|
||
|
+MACRO_BOOL_TO_01(ENABLE_QWEBENGINE HAVE_QWEBENGINE)
|
||
|
|
||
|
# Whether to use Qt's scaling to downscale previews. Under MacOSX, Qt
|
||
|
# can make use of the higher physical resolution of Retina
|
||
|
@@ -440,6 +447,7 @@ PRINT_COMPONENT_COMPILE_STATUS("MySQL Database Support" ENABLE_MYSQLSUPPORT)
|
||
|
PRINT_COMPONENT_COMPILE_STATUS("MySQL Internal Support" ENABLE_INTERNALMYSQL)
|
||
|
PRINT_COMPONENT_COMPILE_STATUS("DBUS Support" ENABLE_DBUS)
|
||
|
PRINT_COMPONENT_COMPILE_STATUS("App. Style Support" ENABLE_APPSTYLES)
|
||
|
+PRINT_COMPONENT_COMPILE_STATUS("QWebEngine Support" ENABLE_QWEBENGINE)
|
||
|
|
||
|
# ==============================================================================
|
||
|
|
||
|
diff --git a/core/app/CMakeLists.txt b/core/app/CMakeLists.txt
|
||
|
index 23571bd..9b9be3c 100644
|
||
|
--- a/core/app/CMakeLists.txt
|
||
|
+++ b/core/app/CMakeLists.txt
|
||
|
@@ -93,7 +93,6 @@ endif()
|
||
|
endif()
|
||
|
|
||
|
include_directories($<TARGET_PROPERTY:Qt5::PrintSupport,INTERFACE_INCLUDE_DIRECTORIES>
|
||
|
- $<TARGET_PROPERTY:Qt5::WebKitWidgets,INTERFACE_INCLUDE_DIRECTORIES>
|
||
|
$<TARGET_PROPERTY:Qt5::Gui,INTERFACE_INCLUDE_DIRECTORIES>
|
||
|
$<TARGET_PROPERTY:Qt5::Xml,INTERFACE_INCLUDE_DIRECTORIES>
|
||
|
$<TARGET_PROPERTY:Qt5::Widgets,INTERFACE_INCLUDE_DIRECTORIES>
|
||
|
@@ -107,6 +106,12 @@ include_directories($<TARGET_PROPERTY:Qt5::PrintSupport,INTERFACE_INCLUDE_DIRECT
|
||
|
$<TARGET_PROPERTY:KF5::XmlGui,INTERFACE_INCLUDE_DIRECTORIES>
|
||
|
$<TARGET_PROPERTY:KF5::Service,INTERFACE_INCLUDE_DIRECTORIES>)
|
||
|
|
||
|
+if(ENABLE_QWEBENGINE)
|
||
|
+ include_directories($<TARGET_PROPERTY:Qt5::WebEngineWidgets,INTERFACE_INCLUDE_DIRECTORIES>)
|
||
|
+else()
|
||
|
+ include_directories($<TARGET_PROPERTY:Qt5::WebKitWidgets,INTERFACE_INCLUDE_DIRECTORIES>)
|
||
|
+endif()
|
||
|
+
|
||
|
if(KF5KIO_FOUND)
|
||
|
include_directories($<TARGET_PROPERTY:KF5::KIOWidgets,INTERFACE_INCLUDE_DIRECTORIES>)
|
||
|
endif()
|
||
|
@@ -140,7 +145,6 @@ target_link_libraries(digikamcore
|
||
|
Qt5::Xml
|
||
|
Qt5::Widgets
|
||
|
Qt5::Sql
|
||
|
- Qt5::WebKitWidgets
|
||
|
Qt5::PrintSupport
|
||
|
Qt5::Concurrent
|
||
|
|
||
|
@@ -166,6 +170,12 @@ target_link_libraries(digikamcore
|
||
|
libraw
|
||
|
)
|
||
|
|
||
|
+if(ENABLE_QWEBENGINE)
|
||
|
+ target_link_libraries(digikamcore PUBLIC Qt5::WebEngineWidgets)
|
||
|
+else()
|
||
|
+ target_link_libraries(digikamcore PUBLIC Qt5::WebKitWidgets)
|
||
|
+endif()
|
||
|
+
|
||
|
if(ENABLE_DBUS)
|
||
|
target_link_libraries(digikamcore PUBLIC Qt5::DBus)
|
||
|
endif()
|
||
|
@@ -344,7 +354,6 @@ set(libdigikamgui_SRCS
|
||
|
|
||
|
views/imagepreviewviewitem.cpp
|
||
|
views/imagepreviewview.cpp
|
||
|
- views/welcomepageview.cpp
|
||
|
views/leftsidebarwidgets.cpp
|
||
|
views/digikamview.cpp
|
||
|
views/trashview.cpp
|
||
|
@@ -353,6 +362,18 @@ set(libdigikamgui_SRCS
|
||
|
${digikamadaptor_SRCS}
|
||
|
)
|
||
|
|
||
|
+if(ENABLE_QWEBENGINE)
|
||
|
+ set(libdigikamgui_SRCS
|
||
|
+ ${libdigikamgui_SRCS}
|
||
|
+ views/welcomepageview_qwebengine.cpp
|
||
|
+ )
|
||
|
+else()
|
||
|
+ set(libdigikamgui_SRCS
|
||
|
+ ${libdigikamgui_SRCS}
|
||
|
+ views/welcomepageview.cpp
|
||
|
+ )
|
||
|
+endif()
|
||
|
+
|
||
|
if(${Marble_FOUND})
|
||
|
set(libdigikamgui_SRCS
|
||
|
${libdigikamgui_SRCS}
|
||
|
@@ -432,7 +453,6 @@ target_link_libraries(digikamgui
|
||
|
Qt5::Gui
|
||
|
Qt5::Widgets
|
||
|
Qt5::Sql
|
||
|
- Qt5::WebKitWidgets
|
||
|
Qt5::PrintSupport
|
||
|
|
||
|
KF5::Solid
|
||
|
@@ -443,6 +463,12 @@ target_link_libraries(digikamgui
|
||
|
${OpenCV_LIBRARIES}
|
||
|
)
|
||
|
|
||
|
+if(ENABLE_QWEBENGINE)
|
||
|
+ target_link_libraries(digikamgui PUBLIC Qt5::WebEngineWidgets)
|
||
|
+else()
|
||
|
+ target_link_libraries(digikamgui PUBLIC Qt5::WebKitWidgets)
|
||
|
+endif()
|
||
|
+
|
||
|
if(ENABLE_DBUS)
|
||
|
target_link_libraries(digikamgui PUBLIC Qt5::DBus)
|
||
|
endif()
|
||
|
diff --git a/core/app/utils/digikam_config.h.cmake.in b/core/app/utils/digikam_config.h.cmake.in
|
||
|
index a4df21a..27046df 100644
|
||
|
--- a/core/app/utils/digikam_config.h.cmake.in
|
||
|
+++ b/core/app/utils/digikam_config.h.cmake.in
|
||
|
@@ -108,6 +108,9 @@
|
||
|
/* Define to 1 if changing application styles is supported */
|
||
|
#cmakedefine HAVE_APPSTYLE_SUPPORT 1
|
||
|
|
||
|
+/* Define to 1 if system use QWebEngine instead of QWebKit */
|
||
|
+#cmakedefine HAVE_QWEBENGINE 1
|
||
|
+
|
||
|
#define LIBEXEC_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/${LIBEXEC_INSTALL_DIR}"
|
||
|
|
||
|
/*
|
||
|
diff --git a/core/app/views/stackedview.cpp b/core/app/views/stackedview.cpp
|
||
|
index 554156a..4295b48 100644
|
||
|
--- a/core/app/views/stackedview.cpp
|
||
|
+++ b/core/app/views/stackedview.cpp
|
||
|
@@ -48,18 +48,23 @@
|
||
|
#include "imagethumbnailbar.h"
|
||
|
#include "loadingcacheinterface.h"
|
||
|
#include "previewlayout.h"
|
||
|
-#include "welcomepageview.h"
|
||
|
#include "thumbbardock.h"
|
||
|
#include "tableview.h"
|
||
|
#include "trashview.h"
|
||
|
#include "dimg.h"
|
||
|
|
||
|
+#ifdef HAVE_QWEBENGINE
|
||
|
+# include "welcomepageview_qwebengine.h"
|
||
|
+#else
|
||
|
+# include "welcomepageview.h"
|
||
|
+#endif
|
||
|
+
|
||
|
#ifdef HAVE_MEDIAPLAYER
|
||
|
-#include "mediaplayerview.h"
|
||
|
+# include "mediaplayerview.h"
|
||
|
#endif //HAVE_MEDIAPLAYER
|
||
|
|
||
|
#ifdef HAVE_MARBLE
|
||
|
-#include "mapwidgetview.h"
|
||
|
+# include "mapwidgetview.h"
|
||
|
#endif // HAVE_MARBLE
|
||
|
|
||
|
namespace Digikam
|
||
|
diff --git a/core/app/views/welcomepageview.cpp b/core/app/views/welcomepageview.cpp
|
||
|
index fee2172..a54bba6 100644
|
||
|
--- a/core/app/views/welcomepageview.cpp
|
||
|
+++ b/core/app/views/welcomepageview.cpp
|
||
|
@@ -41,11 +41,17 @@
|
||
|
|
||
|
// Local includes
|
||
|
|
||
|
+#include "digikam_config.h"
|
||
|
#include "digikam_debug.h"
|
||
|
#include "digikam_version.h"
|
||
|
#include "daboutdata.h"
|
||
|
#include "thememanager.h"
|
||
|
-#include "webbrowserdlg.h"
|
||
|
+
|
||
|
+#ifdef HAVE_QWEBENGINE
|
||
|
+# include "webbrowserdlg_qwebengine.h"
|
||
|
+#else
|
||
|
+# include "webbrowserdlg.h"
|
||
|
+#endif
|
||
|
|
||
|
namespace Digikam
|
||
|
{
|
||
|
diff --git a/core/app/views/welcomepageview_qwebengine.cpp b/core/app/views/welcomepageview_qwebengine.cpp
|
||
|
new file mode 100644
|
||
|
index 0000000..ea964f8
|
||
|
--- /dev/null
|
||
|
+++ b/core/app/views/welcomepageview_qwebengine.cpp
|
||
|
@@ -0,0 +1,222 @@
|
||
|
+/* ============================================================
|
||
|
+ *
|
||
|
+ * This file is a part of digiKam project
|
||
|
+ * http://www.digikam.org
|
||
|
+ *
|
||
|
+ * Date : 2006-12-20
|
||
|
+ * Description : a widget to display a welcome page
|
||
|
+ * on root album.
|
||
|
+ *
|
||
|
+ * Copyright (C) 2006-2018 by Gilles Caulier <caulier dot gilles at gmail dot com>
|
||
|
+ * Copyright (C) 2009-2011 by Andi Clemens <andi dot clemens at gmail dot com>
|
||
|
+ * Copyright (C) 2015 by Mohamed Anwer <m dot anwer at gmx dot com>
|
||
|
+ *
|
||
|
+ * This program is free software; you can redistribute it
|
||
|
+ * and/or modify it under the terms of the GNU General
|
||
|
+ * Public License as published by the Free Software Foundation;
|
||
|
+ * either version 2, or (at your option)
|
||
|
+ * any later version.
|
||
|
+ *
|
||
|
+ * This program is distributed in the hope that it will be useful,
|
||
|
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
+ * GNU General Public License for more details.
|
||
|
+ *
|
||
|
+ * ============================================================ */
|
||
|
+
|
||
|
+#include "welcomepageview_qwebengine.h"
|
||
|
+
|
||
|
+// Qt includes
|
||
|
+
|
||
|
+#include <QFile>
|
||
|
+#include <QFileInfo>
|
||
|
+#include <QTimer>
|
||
|
+#include <QWidget>
|
||
|
+#include <QApplication>
|
||
|
+#include <QStandardPaths>
|
||
|
+
|
||
|
+// KDE includes
|
||
|
+
|
||
|
+#include <klocalizedstring.h>
|
||
|
+
|
||
|
+// Local includes
|
||
|
+
|
||
|
+#include "digikam_debug.h"
|
||
|
+#include "digikam_version.h"
|
||
|
+#include "daboutdata.h"
|
||
|
+#include "thememanager.h"
|
||
|
+#include "webbrowserdlg.h"
|
||
|
+
|
||
|
+namespace Digikam
|
||
|
+{
|
||
|
+
|
||
|
+WelcomePageViewPage::WelcomePageViewPage(QObject* const parent)
|
||
|
+ : QWebEnginePage(parent)
|
||
|
+{
|
||
|
+}
|
||
|
+
|
||
|
+WelcomePageViewPage::~WelcomePageViewPage()
|
||
|
+{
|
||
|
+}
|
||
|
+
|
||
|
+bool WelcomePageViewPage::acceptNavigationRequest(const QUrl& url, QWebEnginePage::NavigationType type, bool)
|
||
|
+{
|
||
|
+ if (type == QWebEnginePage::NavigationTypeLinkClicked)
|
||
|
+ {
|
||
|
+ emit linkClicked(url);
|
||
|
+ return false;
|
||
|
+ }
|
||
|
+
|
||
|
+ return true;
|
||
|
+}
|
||
|
+
|
||
|
+// ----------------------------------------------------------------------------
|
||
|
+
|
||
|
+WelcomePageView::WelcomePageView(QWidget* const parent)
|
||
|
+ : QWebEngineView(parent)
|
||
|
+{
|
||
|
+ setFocusPolicy(Qt::WheelFocus);
|
||
|
+ setContextMenuPolicy(Qt::NoContextMenu);
|
||
|
+
|
||
|
+ WelcomePageViewPage* const wpage = new WelcomePageViewPage(this);
|
||
|
+ setPage(wpage);
|
||
|
+
|
||
|
+ // ------------------------------------------------------------
|
||
|
+
|
||
|
+ connect(wpage, SIGNAL(linkClicked(const QUrl&)),
|
||
|
+ this, SLOT(slotUrlOpen(const QUrl&)));
|
||
|
+
|
||
|
+ connect(ThemeManager::instance(), SIGNAL(signalThemeChanged()),
|
||
|
+ this, SLOT(slotThemeChanged()));
|
||
|
+
|
||
|
+ QTimer::singleShot(0, this, SLOT(slotThemeChanged()));
|
||
|
+}
|
||
|
+
|
||
|
+WelcomePageView::~WelcomePageView()
|
||
|
+{
|
||
|
+}
|
||
|
+
|
||
|
+void WelcomePageView::slotUrlOpen(const QUrl& url)
|
||
|
+{
|
||
|
+ WebBrowserDlg* const browser = new WebBrowserDlg(url, this);
|
||
|
+ browser->show();
|
||
|
+}
|
||
|
+
|
||
|
+QStringList WelcomePageView::featuresTabContent() const
|
||
|
+{
|
||
|
+ QStringList newFeatures;
|
||
|
+ newFeatures << i18n("Port to Qt5 and KF5;");
|
||
|
+ newFeatures << i18n("Replacing digiKam KIOSlaves by a multi-threaded interface to query the database;");
|
||
|
+ newFeatures << i18n("Replacing Qt5::Multimedia dependency by QtAV framework to handle video files;");
|
||
|
+ newFeatures << i18n("Add embedded trash support for each collection instead desktop trash;");
|
||
|
+ newFeatures << i18n("Thumbs and preview video support is now delegate to QT5Multimedia framework;");
|
||
|
+ newFeatures << i18n("Mysql internal server is now configurable as Sqlite to store database files at a customized place;");
|
||
|
+ newFeatures << i18n("Mysql internal/remote server is now configurable with first run assistant;");
|
||
|
+ newFeatures << i18n("Add a new garbage collector tool to cleanup database;");
|
||
|
+ newFeatures << i18n("Add a new batch queue manager tool to convert RAW files to DNG;");
|
||
|
+ newFeatures << i18n("Add a new tool to export contents in html gallery;");
|
||
|
+ newFeatures << i18n("Add a new tool to export contents as a video slideshow;");
|
||
|
+ newFeatures << i18n("Add a new tool to export contents by email;");
|
||
|
+ newFeatures << i18n("Add a new batch queue manager tool to adjust time and date metadata;");
|
||
|
+ newFeatures << i18n("Add a new batch queue manager tool to detect and fix red-eyes automatically;");
|
||
|
+ newFeatures << i18n("Add a new option in editor and light table to import images from a digital scanner;");
|
||
|
+ newFeatures << i18n("Add a new option in editor and light table to edit metadata;");
|
||
|
+ newFeatures << i18n("Add a new option in editor and light table to edit geolocation;");
|
||
|
+ newFeatures << i18n("Add a new option in editor and light table to run presentation tool;");
|
||
|
+ newFeatures << i18n("Add a new editor tool to detect and fix red-eyes automatically;");
|
||
|
+ newFeatures << i18n("Add a new editor tool to perform color change based on Lut3D;");
|
||
|
+ newFeatures << i18n("Add a new tool in camera import interface to convert RAW files to DNG;");
|
||
|
+ newFeatures << i18n("Add a new tool to export items on local network through UPNP/DLNA;");
|
||
|
+ newFeatures << i18n("Consolidation of Mysql database backend;");
|
||
|
+ newFeatures << i18n("Improved startup time with differed scan for new items stage.");
|
||
|
+ newFeatures << i18n("Presentation and Slideshow tools now support video.");
|
||
|
+ // Add new features here...
|
||
|
+ newFeatures << i18n("...and much more.");
|
||
|
+
|
||
|
+ QString featureItems;
|
||
|
+
|
||
|
+ for (int i = 0 ; i < newFeatures.count() ; ++i)
|
||
|
+ {
|
||
|
+ featureItems += i18n("<li>%1</li>\n", newFeatures.at(i));
|
||
|
+ }
|
||
|
+
|
||
|
+ QString tabHeader = i18n("New Features");
|
||
|
+ QString tabContent =
|
||
|
+ i18n("<h3>%1</h3><ul>%2</ul>",
|
||
|
+ i18n("Some of the new features in this release of digiKam include (compared to digiKam 4.x):"),
|
||
|
+ featureItems
|
||
|
+ );
|
||
|
+
|
||
|
+ return QStringList() << tabHeader << tabContent;
|
||
|
+}
|
||
|
+
|
||
|
+QStringList WelcomePageView::aboutTabContent() const
|
||
|
+{
|
||
|
+ QString tabHeader = i18n("About");
|
||
|
+ QString tabContent =
|
||
|
+ i18n("<h3>%1</h3><h3>%2</h3><ul>%3</ul>",
|
||
|
+ i18n("digiKam is an open source photo management program designed to import, organize, enhance, search and export your digital images to and from your computer."),
|
||
|
+ i18n("Currently, you are in the Album view mode of digiKam. Albums are the places where your files are stored, and are identical to the folders on your hard disk."),
|
||
|
+ i18n("<li>%1</li><li>%2</li>",
|
||
|
+ i18n("digiKam has many powerful features which are described in the <a href=\"https://docs.kde.org/trunk5/en/extragear-graphics/digikam/index.html\">documentation</a>"),
|
||
|
+ i18n("The <a href=\"http://www.digikam.org\">digiKam homepage</a> provides information about new versions of digiKam."))
|
||
|
+ );
|
||
|
+ return QStringList() << tabHeader << tabContent;
|
||
|
+}
|
||
|
+
|
||
|
+QByteArray WelcomePageView::fileToString(const QString& aFileName) const
|
||
|
+{
|
||
|
+ QByteArray result;
|
||
|
+ QFileInfo info(aFileName);
|
||
|
+ unsigned int readLen;
|
||
|
+ unsigned int len = info.size();
|
||
|
+ QFile file(aFileName);
|
||
|
+
|
||
|
+ if (aFileName.isEmpty() || len == 0 ||
|
||
|
+ !info.exists() || info.isDir() || !info.isReadable() ||
|
||
|
+ !file.open(QIODevice::Unbuffered|QIODevice::ReadOnly))
|
||
|
+ {
|
||
|
+ return QByteArray();
|
||
|
+ }
|
||
|
+
|
||
|
+ result.resize(len + 2);
|
||
|
+ readLen = file.read(result.data(), len);
|
||
|
+
|
||
|
+ if (result[len-1] != '\n')
|
||
|
+ {
|
||
|
+ result[len++] = '\n';
|
||
|
+ ++readLen;
|
||
|
+ }
|
||
|
+
|
||
|
+ result[len] = '\0';
|
||
|
+
|
||
|
+ if (readLen < len)
|
||
|
+ {
|
||
|
+ return QByteArray();
|
||
|
+ }
|
||
|
+
|
||
|
+ return result;
|
||
|
+}
|
||
|
+
|
||
|
+void WelcomePageView::slotThemeChanged()
|
||
|
+{
|
||
|
+ QString appTitle = i18n("digiKam");
|
||
|
+ QString slogan = DAboutData::digiKamSlogan();
|
||
|
+ QString locationHtml = QStandardPaths::locate(QStandardPaths::GenericDataLocation, QLatin1String("digikam/about/main.html"));
|
||
|
+
|
||
|
+ QString content = QString::fromUtf8(fileToString(locationHtml));
|
||
|
+ content = content.arg(appTitle)
|
||
|
+ .arg(slogan)
|
||
|
+ .arg(i18n("Welcome to digiKam %1", QLatin1String(digikam_version)))
|
||
|
+ .arg(featuresTabContent()[0])
|
||
|
+ .arg(aboutTabContent()[0])
|
||
|
+ .arg(i18n("Background Image Credits"))
|
||
|
+ .arg(featuresTabContent()[1])
|
||
|
+ .arg(aboutTabContent()[1]);
|
||
|
+
|
||
|
+ //qCDebug(DIGIKAM_GENERAL_LOG) << content;
|
||
|
+
|
||
|
+ setHtml(content, QUrl::fromLocalFile(locationHtml));
|
||
|
+}
|
||
|
+
|
||
|
+} // namespace Digikam
|
||
|
diff --git a/core/app/views/welcomepageview_qwebengine.h b/core/app/views/welcomepageview_qwebengine.h
|
||
|
new file mode 100644
|
||
|
index 0000000..97582e2
|
||
|
--- /dev/null
|
||
|
+++ b/core/app/views/welcomepageview_qwebengine.h
|
||
|
@@ -0,0 +1,87 @@
|
||
|
+/* ============================================================
|
||
|
+ *
|
||
|
+ * This file is a part of digiKam project
|
||
|
+ * http://www.digikam.org
|
||
|
+ *
|
||
|
+ * Date : 2006-12-20
|
||
|
+ * Description : a widget to display a welcome page
|
||
|
+ * on root album.
|
||
|
+ *
|
||
|
+ * Copyright (C) 2006-2018 by Gilles Caulier <caulier dot gilles at gmail dot com>
|
||
|
+ * Copyright (C) 2009-2011 by Andi Clemens <andi dot clemens at gmail dot com>
|
||
|
+ * Copyright (C) 2015 by Mohamed Anwer <m dot anwer at gmx dot com>
|
||
|
+ *
|
||
|
+ * This program is free software; you can redistribute it
|
||
|
+ * and/or modify it under the terms of the GNU General
|
||
|
+ * Public License as published by the Free Software Foundation;
|
||
|
+ * either version 2, or (at your option)
|
||
|
+ * any later version.
|
||
|
+ *
|
||
|
+ * This program is distributed in the hope that it will be useful,
|
||
|
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
+ * GNU General Public License for more details.
|
||
|
+ *
|
||
|
+ * ============================================================ */
|
||
|
+
|
||
|
+#ifndef WELCOME_PAGE_VIEW_QWEBENGINE_H
|
||
|
+#define WELCOME_PAGE_VIEW_QWEBENGINE_H
|
||
|
+
|
||
|
+// Qt includes
|
||
|
+
|
||
|
+#include <QString>
|
||
|
+#include <QByteArray>
|
||
|
+#include <QUrl>
|
||
|
+#include <QWebEngineView>
|
||
|
+#include <QWebEnginePage>
|
||
|
+
|
||
|
+// Local includes
|
||
|
+
|
||
|
+#include "digikam_export.h"
|
||
|
+
|
||
|
+namespace Digikam
|
||
|
+{
|
||
|
+
|
||
|
+class WelcomePageViewPage : public QWebEnginePage
|
||
|
+{
|
||
|
+ Q_OBJECT
|
||
|
+
|
||
|
+public:
|
||
|
+
|
||
|
+ explicit WelcomePageViewPage(QObject* const parent = 0);
|
||
|
+ virtual ~WelcomePageViewPage();
|
||
|
+
|
||
|
+ bool acceptNavigationRequest(const QUrl&, QWebEnginePage::NavigationType, bool);
|
||
|
+
|
||
|
+Q_SIGNALS:
|
||
|
+
|
||
|
+ void linkClicked(const QUrl&);
|
||
|
+
|
||
|
+};
|
||
|
+
|
||
|
+// -------------------------------------------------------------------
|
||
|
+
|
||
|
+class WelcomePageView : public QWebEngineView
|
||
|
+{
|
||
|
+ Q_OBJECT
|
||
|
+
|
||
|
+public:
|
||
|
+
|
||
|
+ explicit WelcomePageView(QWidget* const parent);
|
||
|
+ ~WelcomePageView();
|
||
|
+
|
||
|
+private:
|
||
|
+
|
||
|
+ QByteArray fileToString(const QString& aFileName) const;
|
||
|
+ QStringList featuresTabContent() const;
|
||
|
+ QStringList aboutTabContent() const;
|
||
|
+
|
||
|
+private Q_SLOTS:
|
||
|
+
|
||
|
+ void slotUrlOpen(const QUrl&);
|
||
|
+ void slotThemeChanged();
|
||
|
+};
|
||
|
+
|
||
|
+} // namespace Digikam
|
||
|
+
|
||
|
+#endif // WELCOME_PAGE_VIEW_QWEBENGINE_H
|
||
|
diff --git a/core/data/geolocation/geoiface/backend-googlemaps-js.js b/core/data/geolocation/geoiface/backend-googlemaps-js.js
|
||
|
index 456586a..12d9151 100644
|
||
|
--- a/core/data/geolocation/geoiface/backend-googlemaps-js.js
|
||
|
+++ b/core/data/geolocation/geoiface/backend-googlemaps-js.js
|
||
|
@@ -47,10 +47,15 @@ var projectionHelper = null;
|
||
|
|
||
|
function kgeomapPostEventString(eventString)
|
||
|
{
|
||
|
+ // We keep these 2 lines for backwards compatibility with QWebView
|
||
|
eventBuffer.push(eventString);
|
||
|
window.status = '(event)';
|
||
|
+
|
||
|
+ // We use this when porting to QWebEngineView
|
||
|
+ console.log('(event)'+eventString);
|
||
|
}
|
||
|
|
||
|
+// We keep this function for backwards compatibility with QWebView
|
||
|
function kgeomapReadEventStrings()
|
||
|
{
|
||
|
var eventBufferString = eventBuffer.join('|');
|
||
|
@@ -759,9 +764,10 @@ function kgeomapInitialize()
|
||
|
// google.maps.event.addListener(map, 'bounds_changed', function() {
|
||
|
// kgeomapPostEventString('MB');
|
||
|
// });
|
||
|
- // google.maps.event.addListener(map, 'zoom_changed', function() {
|
||
|
- // kgeomapPostEventString('ZC');
|
||
|
- // });
|
||
|
+ google.maps.event.addListener(map, 'zoom_changed', function()
|
||
|
+ {
|
||
|
+ kgeomapPostEventString('ZC');
|
||
|
+ });
|
||
|
google.maps.event.addListener(map, 'idle', function()
|
||
|
{
|
||
|
kgeomapPostEventString('id');
|
||
|
diff --git a/core/libs/dialogs/CMakeLists.txt b/core/libs/dialogs/CMakeLists.txt
|
||
|
index 5bba683..4b8c443 100644
|
||
|
--- a/core/libs/dialogs/CMakeLists.txt
|
||
|
+++ b/core/libs/dialogs/CMakeLists.txt
|
||
|
@@ -25,9 +25,20 @@ set(libdialogs_SRCS
|
||
|
dconfigdlgwidgets.cpp
|
||
|
dmessagebox.cpp
|
||
|
dsplashscreen.cpp
|
||
|
- webbrowserdlg.cpp
|
||
|
)
|
||
|
|
||
|
+if(ENABLE_QWEBENGINE)
|
||
|
+ set(libdialogs_SRCS
|
||
|
+ ${libdialogs_SRCS}
|
||
|
+ webbrowserdlg_qwebengine.cpp
|
||
|
+ )
|
||
|
+else()
|
||
|
+ set(libdialogs_SRCS
|
||
|
+ ${libdialogs_SRCS}
|
||
|
+ webbrowserdlg.cpp
|
||
|
+ )
|
||
|
+endif()
|
||
|
+
|
||
|
set(libdeletedialog_SRCS
|
||
|
deletedialog.cpp
|
||
|
)
|
||
|
@@ -41,13 +52,18 @@ include_directories(
|
||
|
$<TARGET_PROPERTY:Qt5::Gui,INTERFACE_INCLUDE_DIRECTORIES>
|
||
|
$<TARGET_PROPERTY:Qt5::Widgets,INTERFACE_INCLUDE_DIRECTORIES>
|
||
|
$<TARGET_PROPERTY:Qt5::Core,INTERFACE_INCLUDE_DIRECTORIES>
|
||
|
- $<TARGET_PROPERTY:Qt5::WebKitWidgets,INTERFACE_INCLUDE_DIRECTORIES>
|
||
|
|
||
|
$<TARGET_PROPERTY:KF5::I18n,INTERFACE_INCLUDE_DIRECTORIES>
|
||
|
$<TARGET_PROPERTY:KF5::XmlGui,INTERFACE_INCLUDE_DIRECTORIES>
|
||
|
$<TARGET_PROPERTY:KF5::ConfigCore,INTERFACE_INCLUDE_DIRECTORIES>
|
||
|
)
|
||
|
|
||
|
+if(ENABLE_QWEBENGINE)
|
||
|
+ include_directories($<TARGET_PROPERTY:Qt5::WebEngineWidgets,INTERFACE_INCLUDE_DIRECTORIES>)
|
||
|
+else()
|
||
|
+ include_directories($<TARGET_PROPERTY:Qt5::WebKitWidgets,INTERFACE_INCLUDE_DIRECTORIES>)
|
||
|
+endif()
|
||
|
+
|
||
|
#used by digikamcore
|
||
|
add_library(digikamdialogscore_src OBJECT ${libdialogs_SRCS})
|
||
|
|
||
|
diff --git a/core/libs/dialogs/webbrowserdlg_qwebengine.cpp b/core/libs/dialogs/webbrowserdlg_qwebengine.cpp
|
||
|
new file mode 100644
|
||
|
index 0000000..f1fc612
|
||
|
--- /dev/null
|
||
|
+++ b/core/libs/dialogs/webbrowserdlg_qwebengine.cpp
|
||
|
@@ -0,0 +1,228 @@
|
||
|
+/* ============================================================
|
||
|
+ *
|
||
|
+ * This file is a part of digiKam project
|
||
|
+ * http://www.digikam.org
|
||
|
+ *
|
||
|
+ * Date : 2017-06-21
|
||
|
+ * Description : a simple web browser dialog based on Qt WebEngine.
|
||
|
+ *
|
||
|
+ * Copyright (C) 2017-2018 by Gilles Caulier <caulier dot gilles at gmail dot com>
|
||
|
+ *
|
||
|
+ * This program is free software; you can redistribute it
|
||
|
+ * and/or modify it under the terms of the GNU General
|
||
|
+ * Public License as published by the Free Software Foundation;
|
||
|
+ * either version 2, or (at your option)
|
||
|
+ * any later version.
|
||
|
+ *
|
||
|
+ * This program is distributed in the hope that it will be useful,
|
||
|
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
+ * GNU General Public License for more details.
|
||
|
+ *
|
||
|
+ * ============================================================ */
|
||
|
+
|
||
|
+#include "webbrowserdlg_qwebengine.h"
|
||
|
+
|
||
|
+// Qt includes
|
||
|
+
|
||
|
+#include <QGridLayout>
|
||
|
+#include <QApplication>
|
||
|
+#include <QStyle>
|
||
|
+#include <QIcon>
|
||
|
+#include <QWebEngineView>
|
||
|
+#include <QWebEnginePage>
|
||
|
+#include <QToolBar>
|
||
|
+#include <QDesktopServices>
|
||
|
+#include <QDebug>
|
||
|
+
|
||
|
+// KDE includes
|
||
|
+
|
||
|
+#include <klocalizedstring.h>
|
||
|
+#include <ksharedconfig.h>
|
||
|
+
|
||
|
+// Local includes
|
||
|
+
|
||
|
+#include "statusprogressbar.h"
|
||
|
+#include "searchtextbar.h"
|
||
|
+#include "dxmlguiwindow.h"
|
||
|
+
|
||
|
+namespace Digikam
|
||
|
+{
|
||
|
+
|
||
|
+class WebBrowserDlg::Private
|
||
|
+{
|
||
|
+public:
|
||
|
+
|
||
|
+ Private()
|
||
|
+ {
|
||
|
+ browser = 0;
|
||
|
+ toolbar = 0;
|
||
|
+ progressbar = 0;
|
||
|
+ searchbar = 0;
|
||
|
+ }
|
||
|
+
|
||
|
+public:
|
||
|
+
|
||
|
+ QUrl home;
|
||
|
+ QWebEngineView* browser;
|
||
|
+ QToolBar* toolbar;
|
||
|
+ StatusProgressBar* progressbar;
|
||
|
+ SearchTextBar* searchbar;
|
||
|
+};
|
||
|
+
|
||
|
+WebBrowserDlg::WebBrowserDlg(const QUrl& url, QWidget* const parent)
|
||
|
+ : QDialog(parent),
|
||
|
+ d(new Private)
|
||
|
+{
|
||
|
+ setModal(false);
|
||
|
+ d->home = url;
|
||
|
+ d->browser = new QWebEngineView(this);
|
||
|
+
|
||
|
+ // --------------------------
|
||
|
+
|
||
|
+ d->toolbar = new QToolBar(this);
|
||
|
+ d->toolbar->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
|
||
|
+ d->toolbar->addAction(d->browser->pageAction(QWebEnginePage::Back));
|
||
|
+ d->toolbar->addAction(d->browser->pageAction(QWebEnginePage::Forward));
|
||
|
+ d->toolbar->addAction(d->browser->pageAction(QWebEnginePage::Reload));
|
||
|
+ d->toolbar->addAction(d->browser->pageAction(QWebEnginePage::Stop));
|
||
|
+
|
||
|
+ QAction* const gohome = new QAction(QIcon::fromTheme(QLatin1String("go-home")),
|
||
|
+ i18n("Home"), this);
|
||
|
+ gohome->setToolTip(i18n("Go back to Home page"));
|
||
|
+ d->toolbar->addAction(gohome);
|
||
|
+
|
||
|
+ QAction* const deskweb = new QAction(QIcon::fromTheme(QLatin1String("internet-web-browser")),
|
||
|
+ i18n("Desktop Browser"), this);
|
||
|
+ deskweb->setToolTip(i18n("Open Home page with default desktop Web browser"));
|
||
|
+ d->toolbar->addAction(deskweb);
|
||
|
+
|
||
|
+ // --------------------------
|
||
|
+
|
||
|
+ d->searchbar = new SearchTextBar(this, QLatin1String("WebBrowserDlgSearchBar"));
|
||
|
+ d->searchbar->setHighlightOnResult(true);
|
||
|
+
|
||
|
+ d->progressbar = new StatusProgressBar(this);
|
||
|
+ d->progressbar->setProgressTotalSteps(100);
|
||
|
+ d->progressbar->setAlignment(Qt::AlignLeft);
|
||
|
+ d->progressbar->setNotify(false);
|
||
|
+
|
||
|
+ // ----------------------
|
||
|
+
|
||
|
+ QGridLayout* const grid = new QGridLayout(this);
|
||
|
+ grid->setSpacing(QApplication::style()->pixelMetric(QStyle::PM_DefaultLayoutSpacing));
|
||
|
+ grid->addWidget(d->toolbar, 0, 0, 1, 1);
|
||
|
+ grid->addWidget(d->searchbar, 0, 2, 1, 1);
|
||
|
+ grid->addWidget(d->browser, 1, 0, 1, 3);
|
||
|
+ grid->addWidget(d->progressbar, 2, 0, 1, 3);
|
||
|
+ grid->setColumnStretch(1, 10);
|
||
|
+ grid->setRowStretch(1, 10);
|
||
|
+ setLayout(grid);
|
||
|
+
|
||
|
+ // ----------------------
|
||
|
+/*
|
||
|
+#if QT_VERSION >= 0x050700
|
||
|
+ connect(d->browser, SIGNAL(iconChanged(const QIcon&)),
|
||
|
+ this, SLOT(slotIconChanged(const QIcon&)));
|
||
|
+#endif
|
||
|
+*/
|
||
|
+ connect(d->browser, SIGNAL(titleChanged(const QString&)),
|
||
|
+ this, SLOT(slotTitleChanged(const QString&)));
|
||
|
+
|
||
|
+ connect(d->browser, SIGNAL(urlChanged(const QUrl&)),
|
||
|
+ this, SLOT(slotUrlChanged(const QUrl&)));
|
||
|
+
|
||
|
+ connect(d->browser, SIGNAL(loadStarted()),
|
||
|
+ this, SLOT(slotLoadingStarted()));
|
||
|
+
|
||
|
+ connect(d->browser, SIGNAL(loadFinished(bool)),
|
||
|
+ this, SLOT(slotLoadingFinished(bool)));
|
||
|
+
|
||
|
+ connect(d->searchbar, SIGNAL(signalSearchTextSettings(const SearchTextSettings&)),
|
||
|
+ this, SLOT(slotSearchTextChanged(const SearchTextSettings&)));
|
||
|
+
|
||
|
+ connect(d->browser, SIGNAL(loadProgress(int)),
|
||
|
+ d->progressbar, SLOT(setProgressValue(int)));
|
||
|
+
|
||
|
+ connect(gohome, SIGNAL(triggered()),
|
||
|
+ this, SLOT(slotGoHome()));
|
||
|
+
|
||
|
+ connect(deskweb, SIGNAL(triggered()),
|
||
|
+ this, SLOT(slotDesktopWebBrowser()));
|
||
|
+
|
||
|
+ // ----------------------
|
||
|
+
|
||
|
+ KConfigGroup group = KSharedConfig::openConfig()->group("WebBrowserDlg");
|
||
|
+
|
||
|
+ winId();
|
||
|
+ windowHandle()->resize(800, 600);
|
||
|
+ DXmlGuiWindow::restoreWindowSize(windowHandle(), group);
|
||
|
+ resize(windowHandle()->size());
|
||
|
+
|
||
|
+ slotGoHome();
|
||
|
+}
|
||
|
+
|
||
|
+WebBrowserDlg::~WebBrowserDlg()
|
||
|
+{
|
||
|
+ delete d;
|
||
|
+}
|
||
|
+
|
||
|
+void WebBrowserDlg::closeEvent(QCloseEvent* e)
|
||
|
+{
|
||
|
+ KConfigGroup group = KSharedConfig::openConfig()->group(QLatin1String("WebBrowserDlg"));
|
||
|
+ DXmlGuiWindow::saveWindowSize(windowHandle(), group);
|
||
|
+
|
||
|
+ e->accept();
|
||
|
+}
|
||
|
+
|
||
|
+void WebBrowserDlg::slotUrlChanged(const QUrl& url)
|
||
|
+{
|
||
|
+ d->progressbar->setText(url.toString());
|
||
|
+}
|
||
|
+
|
||
|
+void WebBrowserDlg::slotTitleChanged(const QString& title)
|
||
|
+{
|
||
|
+ setWindowTitle(title);
|
||
|
+}
|
||
|
+
|
||
|
+void WebBrowserDlg::slotIconChanged(const QIcon& icon)
|
||
|
+{
|
||
|
+ setWindowIcon(icon);
|
||
|
+}
|
||
|
+
|
||
|
+void WebBrowserDlg::slotLoadingStarted()
|
||
|
+{
|
||
|
+ d->progressbar->setProgressBarMode(StatusProgressBar::ProgressBarMode);
|
||
|
+}
|
||
|
+
|
||
|
+void WebBrowserDlg::slotLoadingFinished(bool b)
|
||
|
+{
|
||
|
+ QString curUrl = d->browser->url().toString();
|
||
|
+
|
||
|
+ d->progressbar->setProgressBarMode(StatusProgressBar::TextMode, curUrl);
|
||
|
+
|
||
|
+ if (!b)
|
||
|
+ {
|
||
|
+ d->progressbar->setText(i18n("Cannot load page %1", curUrl));
|
||
|
+ }
|
||
|
+}
|
||
|
+
|
||
|
+void WebBrowserDlg::slotSearchTextChanged(const SearchTextSettings& settings)
|
||
|
+{
|
||
|
+ d->browser->findText(settings.text,
|
||
|
+ (settings.caseSensitive == Qt::CaseSensitive) ? QWebEnginePage::FindCaseSensitively
|
||
|
+ : QWebEnginePage::FindFlags(),
|
||
|
+ [this](bool found) { d->searchbar->slotSearchResult(found); });
|
||
|
+}
|
||
|
+
|
||
|
+void WebBrowserDlg::slotGoHome()
|
||
|
+{
|
||
|
+ d->browser->setUrl(d->home);
|
||
|
+}
|
||
|
+
|
||
|
+void WebBrowserDlg::slotDesktopWebBrowser()
|
||
|
+{
|
||
|
+ QDesktopServices::openUrl(d->home);
|
||
|
+}
|
||
|
+
|
||
|
+} // namespace Digikam
|
||
|
diff --git a/core/libs/dialogs/webbrowserdlg_qwebengine.h b/core/libs/dialogs/webbrowserdlg_qwebengine.h
|
||
|
new file mode 100644
|
||
|
index 0000000..30c15bf
|
||
|
--- /dev/null
|
||
|
+++ b/core/libs/dialogs/webbrowserdlg_qwebengine.h
|
||
|
@@ -0,0 +1,76 @@
|
||
|
+/* ============================================================
|
||
|
+ *
|
||
|
+ * This file is a part of digiKam project
|
||
|
+ * http://www.digikam.org
|
||
|
+ *
|
||
|
+ * Date : 2017-06-21
|
||
|
+ * Description : a simple web browser dialog based on Qt WebEngine.
|
||
|
+ *
|
||
|
+ * Copyright (C) 2017-2018 by Gilles Caulier <caulier dot gilles at gmail dot com>
|
||
|
+ *
|
||
|
+ * This program is free software; you can redistribute it
|
||
|
+ * and/or modify it under the terms of the GNU General
|
||
|
+ * Public License as published by the Free Software Foundation;
|
||
|
+ * either version 2, or (at your option)
|
||
|
+ * any later version.
|
||
|
+ *
|
||
|
+ * This program is distributed in the hope that it will be useful,
|
||
|
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
+ * GNU General Public License for more details.
|
||
|
+ *
|
||
|
+ * ============================================================ */
|
||
|
+
|
||
|
+#ifndef WEB_BROWSER_DLG_QWEBENGINE_H
|
||
|
+#define WEB_BROWSER_DLG_QWEBENGINE_H
|
||
|
+
|
||
|
+// Qt include
|
||
|
+
|
||
|
+#include <QDialog>
|
||
|
+#include <QWidget>
|
||
|
+#include <QUrl>
|
||
|
+#include <QString>
|
||
|
+#include <QCloseEvent>
|
||
|
+
|
||
|
+// Local includes
|
||
|
+
|
||
|
+#include "digikam_export.h"
|
||
|
+
|
||
|
+namespace Digikam
|
||
|
+{
|
||
|
+
|
||
|
+class SearchTextSettings;
|
||
|
+
|
||
|
+class DIGIKAM_EXPORT WebBrowserDlg : public QDialog
|
||
|
+{
|
||
|
+ Q_OBJECT
|
||
|
+
|
||
|
+public:
|
||
|
+
|
||
|
+ explicit WebBrowserDlg(const QUrl& url, QWidget* const parent = 0);
|
||
|
+ ~WebBrowserDlg();
|
||
|
+
|
||
|
+private Q_SLOTS:
|
||
|
+
|
||
|
+ void slotUrlChanged(const QUrl&);
|
||
|
+ void slotLoadingStarted();
|
||
|
+ void slotLoadingFinished(bool);
|
||
|
+ void slotIconChanged(const QIcon&);
|
||
|
+ void slotTitleChanged(const QString&);
|
||
|
+ void slotSearchTextChanged(const SearchTextSettings&);
|
||
|
+ void slotGoHome();
|
||
|
+ void slotDesktopWebBrowser();
|
||
|
+
|
||
|
+protected:
|
||
|
+
|
||
|
+ void closeEvent(QCloseEvent*);
|
||
|
+
|
||
|
+private:
|
||
|
+
|
||
|
+ class Private;
|
||
|
+ Private* const d;
|
||
|
+};
|
||
|
+
|
||
|
+} // namespace Digikam
|
||
|
+
|
||
|
+#endif // WEB_BROWSER_DLG_QWEBENGINE_H
|
||
|
diff --git a/core/libs/widgets/mainview/dxmlguiwindow.cpp b/core/libs/widgets/mainview/dxmlguiwindow.cpp
|
||
|
index 86e8c53..75274c1 100644
|
||
|
--- a/core/libs/widgets/mainview/dxmlguiwindow.cpp
|
||
|
+++ b/core/libs/widgets/mainview/dxmlguiwindow.cpp
|
||
|
@@ -69,7 +69,12 @@
|
||
|
#include "digikam_debug.h"
|
||
|
#include "digikam_globals.h"
|
||
|
#include "daboutdata.h"
|
||
|
-#include "webbrowserdlg.h"
|
||
|
+
|
||
|
+#ifdef HAVE_QWEBENGINE
|
||
|
+# include "webbrowserdlg_qwebengine.h"
|
||
|
+#else
|
||
|
+# include "webbrowserdlg.h"
|
||
|
+#endif
|
||
|
|
||
|
namespace Digikam
|
||
|
{
|
||
|
diff --git a/core/utilities/assistants/htmlgallery/wizard/htmlfinalpage.cpp b/core/utilities/assistants/htmlgallery/wizard/htmlfinalpage.cpp
|
||
|
index 7c9d01c..3de55e4 100644
|
||
|
--- a/core/utilities/assistants/htmlgallery/wizard/htmlfinalpage.cpp
|
||
|
+++ b/core/utilities/assistants/htmlgallery/wizard/htmlfinalpage.cpp
|
||
|
@@ -40,6 +40,7 @@
|
||
|
|
||
|
// Local includes
|
||
|
|
||
|
+#include "digikam_config.h"
|
||
|
#include "htmlwizard.h"
|
||
|
#include "abstractthemeparameter.h"
|
||
|
#include "galleryinfo.h"
|
||
|
@@ -48,7 +49,12 @@
|
||
|
#include "digikam_debug.h"
|
||
|
#include "dprogresswdg.h"
|
||
|
#include "dhistoryview.h"
|
||
|
-#include "webbrowserdlg.h"
|
||
|
+
|
||
|
+#ifdef HAVE_QWEBENGINE
|
||
|
+# include "webbrowserdlg_qwebengine.h"
|
||
|
+#else
|
||
|
+# include "webbrowserdlg.h"
|
||
|
+#endif
|
||
|
|
||
|
namespace Digikam
|
||
|
{
|
||
|
diff --git a/core/utilities/geolocation/geoiface/CMakeLists.txt b/core/utilities/geolocation/geoiface/CMakeLists.txt
|
||
|
index 18fec7b..23c52a9 100644
|
||
|
--- a/core/utilities/geolocation/geoiface/CMakeLists.txt
|
||
|
+++ b/core/utilities/geolocation/geoiface/CMakeLists.txt
|
||
|
@@ -26,13 +26,23 @@ set(libgeoiface_SRCS backends/mapbackend.cpp
|
||
|
tiles/itemmarkertiler.cpp
|
||
|
tiles/tilegrouper.cpp
|
||
|
tiles/tileindex.cpp
|
||
|
- widgets/htmlwidget.cpp
|
||
|
widgets/mapwidget.cpp
|
||
|
widgets/placeholderwidget.cpp
|
||
|
)
|
||
|
|
||
|
+if(ENABLE_QWEBENGINE)
|
||
|
+ set(libgeoiface_SRCS
|
||
|
+ ${libgeoiface_SRCS}
|
||
|
+ widgets/htmlwidget_qwebengine.cpp
|
||
|
+ )
|
||
|
+else()
|
||
|
+ set(libgeoiface_SRCS
|
||
|
+ ${libgeoiface_SRCS}
|
||
|
+ widgets/htmlwidget.cpp
|
||
|
+ )
|
||
|
+endif()
|
||
|
+
|
||
|
include_directories($<TARGET_PROPERTY:Qt5::Xml,INTERFACE_INCLUDE_DIRECTORIES>
|
||
|
- $<TARGET_PROPERTY:Qt5::WebKitWidgets,INTERFACE_INCLUDE_DIRECTORIES>
|
||
|
$<TARGET_PROPERTY:Qt5::Network,INTERFACE_INCLUDE_DIRECTORIES>
|
||
|
$<TARGET_PROPERTY:Qt5::Gui,INTERFACE_INCLUDE_DIRECTORIES>
|
||
|
$<TARGET_PROPERTY:Qt5::Core,INTERFACE_INCLUDE_DIRECTORIES>
|
||
|
@@ -44,6 +54,12 @@ include_directories($<TARGET_PROPERTY:Qt5::Xml,INTERFACE_INCLUDE_DIRECTORIES>
|
||
|
${MARBLE_INCLUDE_DIR}
|
||
|
)
|
||
|
|
||
|
+if(ENABLE_QWEBENGINE)
|
||
|
+ include_directories($<TARGET_PROPERTY:Qt5::WebEngineWidgets,INTERFACE_INCLUDE_DIRECTORIES>)
|
||
|
+else()
|
||
|
+ include_directories($<TARGET_PROPERTY:Qt5::WebKitWidgets,INTERFACE_INCLUDE_DIRECTORIES>)
|
||
|
+endif()
|
||
|
+
|
||
|
# Marble translations need explicit loading
|
||
|
ecm_create_qm_loader(libgeoiface_SRCS marble_qt)
|
||
|
|
||
|
diff --git a/core/utilities/geolocation/geoiface/backends/backendgooglemaps.cpp b/core/utilities/geolocation/geoiface/backends/backendgooglemaps.cpp
|
||
|
index b242192..b2897cd 100644
|
||
|
--- a/core/utilities/geolocation/geoiface/backends/backendgooglemaps.cpp
|
||
|
+++ b/core/utilities/geolocation/geoiface/backends/backendgooglemaps.cpp
|
||
|
@@ -46,11 +46,17 @@
|
||
|
|
||
|
// Local includes
|
||
|
|
||
|
-#include "htmlwidget.h"
|
||
|
+#include "digikam_config.h"
|
||
|
+#include "digikam_debug.h"
|
||
|
#include "mapwidget.h"
|
||
|
#include "abstractmarkertiler.h"
|
||
|
#include "geomodelhelper.h"
|
||
|
-#include "digikam_debug.h"
|
||
|
+
|
||
|
+#ifdef HAVE_QWEBENGINE
|
||
|
+# include "htmlwidget_qwebengine.h"
|
||
|
+#else
|
||
|
+# include "htmlwidget.h"
|
||
|
+#endif
|
||
|
|
||
|
namespace Digikam
|
||
|
{
|
||
|
@@ -683,7 +689,7 @@ void BackendGoogleMaps::slotHTMLEvents(const QStringList& events)
|
||
|
|
||
|
if (zoomProbablyChanged && !mapTypeChanged)
|
||
|
{
|
||
|
- d->cacheZoom = d->htmlWidget->runScript(QLatin1String("kgeomapGetZoom();")).toInt();
|
||
|
+ d->cacheZoom = d->htmlWidget->runScript(QLatin1String("kgeomapGetZoom();"), false).toInt();
|
||
|
emit signalZoomChanged(QString::fromLatin1("googlemaps:%1").arg(d->cacheZoom));
|
||
|
}
|
||
|
|
||
|
@@ -701,7 +707,7 @@ void BackendGoogleMaps::slotHTMLEvents(const QStringList& events)
|
||
|
|
||
|
if (mapBoundsProbablyChanged)
|
||
|
{
|
||
|
- const QString mapBoundsString = d->htmlWidget->runScript(QLatin1String("kgeomapGetBounds();")).toString();
|
||
|
+ const QString mapBoundsString = d->htmlWidget->runScript(QLatin1String("kgeomapGetBounds();"), false).toString();
|
||
|
GeoIfaceHelperParseBoundsString(mapBoundsString, &d->cacheBounds);
|
||
|
}
|
||
|
|
||
|
@@ -764,11 +770,12 @@ bool BackendGoogleMaps::screenCoordinates(const GeoCoordinates& coordinates, QPo
|
||
|
if (!d->isReady)
|
||
|
return false;
|
||
|
|
||
|
- const QString pointStringResult=d->htmlWidget->runScript(
|
||
|
+ const QString pointStringResult = d->htmlWidget->runScript(
|
||
|
QString::fromLatin1("kgeomapLatLngToPixel(%1, %2);")
|
||
|
.arg(coordinates.latString())
|
||
|
- .arg(coordinates.lonString())
|
||
|
- ).toString();
|
||
|
+ .arg(coordinates.lonString()),
|
||
|
+ false
|
||
|
+ ).toString();
|
||
|
const bool isValid = GeoIfaceHelperParseXYStringToPoint(
|
||
|
pointStringResult,
|
||
|
point);
|
||
|
@@ -994,8 +1001,8 @@ void BackendGoogleMaps::updateActionAvailability()
|
||
|
void BackendGoogleMaps::updateZoomMinMaxCache()
|
||
|
{
|
||
|
// TODO: these functions seem to cause problems, the map is not fully updated after a few calls
|
||
|
-// d->cacheMaxZoom = d->htmlWidget->runScript("kgeomapGetMaxZoom();").toInt();
|
||
|
-// d->cacheMinZoom = d->htmlWidget->runScript("kgeomapGetMinZoom();").toInt();
|
||
|
+// d->cacheMaxZoom = d->htmlWidget->runScript("kgeomapGetMaxZoom();", false).toInt();
|
||
|
+// d->cacheMinZoom = d->htmlWidget->runScript("kgeomapGetMinZoom();", false).toInt();
|
||
|
}
|
||
|
|
||
|
void BackendGoogleMaps::slotThumbnailAvailableForIndex(const QVariant& index, const QPixmap& pixmap)
|
||
|
@@ -1328,7 +1335,7 @@ void BackendGoogleMaps::slotTracksChanged(const QList<TrackManager::TrackChanges
|
||
|
if (!s->trackManager)
|
||
|
{
|
||
|
// no track manager, clear all tracks
|
||
|
- const QVariant successClear = d->htmlWidget->runScript(QString::fromLatin1("kgeomapClearTracks();"));
|
||
|
+ const QVariant successClear = d->htmlWidget->runScript(QString::fromLatin1("kgeomapClearTracks();"), false);
|
||
|
|
||
|
return;
|
||
|
}
|
||
|
@@ -1424,7 +1431,7 @@ void BackendGoogleMaps::slotTrackVisibilityChanged(const bool newState)
|
||
|
}
|
||
|
else if (d->htmlWidget)
|
||
|
{
|
||
|
- const QVariant successClear = d->htmlWidget->runScript(QString::fromLatin1("kgeomapClearTracks();"));
|
||
|
+ const QVariant successClear = d->htmlWidget->runScript(QString::fromLatin1("kgeomapClearTracks();"), false);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
diff --git a/core/utilities/geolocation/geoiface/widgets/htmlwidget.cpp b/core/utilities/geolocation/geoiface/widgets/htmlwidget.cpp
|
||
|
index 29d0906..3dac61e 100644
|
||
|
--- a/core/utilities/geolocation/geoiface/widgets/htmlwidget.cpp
|
||
|
+++ b/core/utilities/geolocation/geoiface/widgets/htmlwidget.cpp
|
||
|
@@ -255,7 +255,7 @@ void HTMLWidget::slotScanForJSMessages(const QString& message)
|
||
|
/**
|
||
|
* @brief Wrapper around executeScript to catch more errors
|
||
|
*/
|
||
|
-QVariant HTMLWidget::runScript(const QString& scriptCode)
|
||
|
+QVariant HTMLWidget::runScript(const QString& scriptCode, bool)
|
||
|
{
|
||
|
GEOIFACE_ASSERT(d->isReady);
|
||
|
|
||
|
diff --git a/core/utilities/geolocation/geoiface/widgets/htmlwidget.h b/core/utilities/geolocation/geoiface/widgets/htmlwidget.h
|
||
|
index 9a76ef9..f97b6a1 100644
|
||
|
--- a/core/utilities/geolocation/geoiface/widgets/htmlwidget.h
|
||
|
+++ b/core/utilities/geolocation/geoiface/widgets/htmlwidget.h
|
||
|
@@ -49,7 +49,7 @@ public:
|
||
|
~HTMLWidget();
|
||
|
|
||
|
void loadInitialHTML(const QString& initialHTML);
|
||
|
- QVariant runScript(const QString& scriptCode);
|
||
|
+ QVariant runScript(const QString& scriptCode, bool async = true);
|
||
|
bool runScript2Coordinates(const QString& scriptCode, GeoCoordinates* const coordinates);
|
||
|
void mouseModeChanged(const GeoMouseModes mouseMode);
|
||
|
void setSelectionRectangle(const GeoCoordinates::Pair& searchCoordinates);
|
||
|
diff --git a/core/utilities/geolocation/geoiface/widgets/htmlwidget_qwebengine.cpp b/core/utilities/geolocation/geoiface/widgets/htmlwidget_qwebengine.cpp
|
||
|
new file mode 100644
|
||
|
index 0000000..0387245
|
||
|
--- /dev/null
|
||
|
+++ b/core/utilities/geolocation/geoiface/widgets/htmlwidget_qwebengine.cpp
|
||
|
@@ -0,0 +1,409 @@
|
||
|
+/* ============================================================
|
||
|
+ *
|
||
|
+ * This file is a part of digiKam project
|
||
|
+ * http://www.digikam.org
|
||
|
+ *
|
||
|
+ * Date : 2009-12-01
|
||
|
+ * Description : Widget for displaying HTML in the backends
|
||
|
+ *
|
||
|
+ * Copyright (C) 2010-2018 by Gilles Caulier <caulier dot gilles at gmail dot com>
|
||
|
+ * Copyright (C) 2009-2011 by Michael G. Hansen <mike at mghansen dot de>
|
||
|
+ * Copyright (C) 2015 by Mohamed Anwer <mohammed dot ahmed dot anwer at gmail dot com>
|
||
|
+ *
|
||
|
+ * This program is free software; you can redistribute it
|
||
|
+ * and/or modify it under the terms of the GNU General
|
||
|
+ * Public License as published by the Free Software Foundation;
|
||
|
+ * either version 2, or (at your option)
|
||
|
+ * any later version.
|
||
|
+ *
|
||
|
+ * This program is distributed in the hope that it will be useful,
|
||
|
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
+ * GNU General Public License for more details.
|
||
|
+ *
|
||
|
+ * ============================================================ */
|
||
|
+
|
||
|
+#include "htmlwidget_qwebengine.h"
|
||
|
+
|
||
|
+// Qt includes
|
||
|
+
|
||
|
+#include <QEventLoop>
|
||
|
+#include <QResizeEvent>
|
||
|
+#include <QCoreApplication>
|
||
|
+#include <QWebEngineSettings>
|
||
|
+
|
||
|
+// Local includes
|
||
|
+
|
||
|
+#include "geoifacecommon.h"
|
||
|
+#include "geoifacetypes.h"
|
||
|
+#include "digikam_debug.h"
|
||
|
+
|
||
|
+namespace Digikam
|
||
|
+{
|
||
|
+
|
||
|
+HTMLWidgetPage::HTMLWidgetPage(HTMLWidget* const parent)
|
||
|
+ : QWebEnginePage(parent)
|
||
|
+{
|
||
|
+ m_timer = new QTimer(this);
|
||
|
+ m_timer->setInterval(100);
|
||
|
+ m_timer->setSingleShot(true);
|
||
|
+
|
||
|
+ connect(m_timer, SIGNAL(timeout()),
|
||
|
+ this, SLOT(slotSendHTMLEvents()),
|
||
|
+ Qt::QueuedConnection);
|
||
|
+}
|
||
|
+
|
||
|
+HTMLWidgetPage::~HTMLWidgetPage()
|
||
|
+{
|
||
|
+}
|
||
|
+
|
||
|
+void HTMLWidgetPage::javaScriptConsoleMessage(JavaScriptConsoleMessageLevel /*level*/, const QString& message, int /*lineNumber*/, const QString& /*sourceID*/)
|
||
|
+{
|
||
|
+ if (!message.startsWith(QLatin1String("(event)")))
|
||
|
+ return;
|
||
|
+
|
||
|
+ qCDebug(DIGIKAM_GEOIFACE_LOG) << message;
|
||
|
+
|
||
|
+ const QString eventString = message.mid(7);
|
||
|
+
|
||
|
+ if (eventString.isEmpty())
|
||
|
+ return;
|
||
|
+
|
||
|
+ m_events << eventString;
|
||
|
+
|
||
|
+ m_timer->start();
|
||
|
+}
|
||
|
+
|
||
|
+void HTMLWidgetPage::slotSendHTMLEvents()
|
||
|
+{
|
||
|
+ emit signalHTMLEvents(m_events);
|
||
|
+ m_events.clear();
|
||
|
+}
|
||
|
+
|
||
|
+// ---------------------------------------------------------------------------------------------
|
||
|
+
|
||
|
+class HTMLWidget::Private
|
||
|
+{
|
||
|
+public:
|
||
|
+
|
||
|
+ Private()
|
||
|
+ : parent(0),
|
||
|
+ child(0),
|
||
|
+ hpage(0),
|
||
|
+ isReady(false),
|
||
|
+ selectionStatus(false),
|
||
|
+ firstSelectionPoint(),
|
||
|
+ intermediateSelectionPoint(),
|
||
|
+ firstSelectionScreenPoint(),
|
||
|
+ intermediateSelectionScreenPoint()
|
||
|
+ {
|
||
|
+ }
|
||
|
+
|
||
|
+ QWidget* parent;
|
||
|
+ QWidget* child;
|
||
|
+ HTMLWidgetPage* hpage;
|
||
|
+
|
||
|
+ bool isReady;
|
||
|
+ bool selectionStatus;
|
||
|
+
|
||
|
+ GeoCoordinates firstSelectionPoint;
|
||
|
+ GeoCoordinates intermediateSelectionPoint;
|
||
|
+
|
||
|
+ QPoint firstSelectionScreenPoint;
|
||
|
+ QPoint intermediateSelectionScreenPoint;
|
||
|
+};
|
||
|
+
|
||
|
+HTMLWidget::HTMLWidget(QWidget* const parent)
|
||
|
+ : QWebEngineView(parent),
|
||
|
+ d(new Private()),
|
||
|
+ s(0)
|
||
|
+{
|
||
|
+ d->parent = parent;
|
||
|
+ setAcceptDrops(false);
|
||
|
+ setFocusPolicy(Qt::WheelFocus);
|
||
|
+ // settings()->setAttribute(QWebEngineSettings::WebGLEnabled, false);
|
||
|
+
|
||
|
+ d->hpage = new HTMLWidgetPage(this);
|
||
|
+ setPage(d->hpage);
|
||
|
+
|
||
|
+ d->parent->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
||
|
+
|
||
|
+ connect(this, SIGNAL(loadProgress(int)),
|
||
|
+ this, SLOT(progress(int)));
|
||
|
+
|
||
|
+ connect(this, SIGNAL(loadFinished(bool)),
|
||
|
+ this, SLOT(slotHTMLCompleted(bool)));
|
||
|
+
|
||
|
+ connect(d->hpage, SIGNAL(signalHTMLEvents(QStringList)),
|
||
|
+ this, SIGNAL(signalHTMLEvents(QStringList)));
|
||
|
+
|
||
|
+ if (d->parent)
|
||
|
+ {
|
||
|
+ d->parent->installEventFilter(this);
|
||
|
+ }
|
||
|
+
|
||
|
+ d->child = findChild<QWidget*>();
|
||
|
+
|
||
|
+ if (d->child)
|
||
|
+ {
|
||
|
+ d->child->installEventFilter(this);
|
||
|
+ }
|
||
|
+}
|
||
|
+
|
||
|
+HTMLWidget::~HTMLWidget()
|
||
|
+{
|
||
|
+ delete d;
|
||
|
+}
|
||
|
+
|
||
|
+void HTMLWidget::progress(int progress)
|
||
|
+{
|
||
|
+ qCDebug(DIGIKAM_GEOIFACE_LOG) << "Maps Loading Progress: " << progress << "%";
|
||
|
+}
|
||
|
+
|
||
|
+void HTMLWidget::slotHTMLCompleted(bool ok)
|
||
|
+{
|
||
|
+ qCDebug(DIGIKAM_GEOIFACE_LOG) << "Map Loading Completed: " << ok;
|
||
|
+ d->isReady = ok;
|
||
|
+
|
||
|
+ emit signalJavaScriptReady();
|
||
|
+}
|
||
|
+
|
||
|
+/**
|
||
|
+ * @brief Wrapper around executeScript to catch more errors
|
||
|
+ */
|
||
|
+QVariant HTMLWidget::runScript(const QString& scriptCode, bool async)
|
||
|
+{
|
||
|
+ GEOIFACE_ASSERT(d->isReady);
|
||
|
+
|
||
|
+ if (!d->isReady)
|
||
|
+ return QVariant();
|
||
|
+
|
||
|
+ //qCDebug(DIGIKAM_GEOIFACE_LOG) << scriptCode;
|
||
|
+
|
||
|
+ if(async)
|
||
|
+ {
|
||
|
+ page()->runJavaScript(scriptCode);
|
||
|
+ }
|
||
|
+ else
|
||
|
+ {
|
||
|
+ QVariant ret;
|
||
|
+ QEventLoop loop;
|
||
|
+ // lambda c11 function capturing value returned by java script code which is not synchro with QWebEngineView.
|
||
|
+ // See https://wiki.qt.io/Porting_from_QtWebKit_to_QtWebEngine.
|
||
|
+ page()->runJavaScript(scriptCode, [&ret, &loop](const QVariant& result){ ret.setValue(result); loop.quit(); });
|
||
|
+
|
||
|
+ loop.exec();
|
||
|
+
|
||
|
+ return ret;
|
||
|
+ }
|
||
|
+
|
||
|
+ return true;
|
||
|
+}
|
||
|
+
|
||
|
+/**
|
||
|
+ * @brief Execute a script which returns coordinates and parse these
|
||
|
+ */
|
||
|
+bool HTMLWidget::runScript2Coordinates(const QString& scriptCode, GeoCoordinates* const coordinates)
|
||
|
+{
|
||
|
+ const QVariant scriptResult = runScript(scriptCode, false);
|
||
|
+
|
||
|
+ return GeoIfaceHelperParseLatLonString(scriptResult.toString(), coordinates);
|
||
|
+}
|
||
|
+
|
||
|
+bool HTMLWidget::eventFilter(QObject* object, QEvent* event)
|
||
|
+{
|
||
|
+ if (d->parent && object == d->parent)
|
||
|
+ {
|
||
|
+
|
||
|
+ if (event->type() == QEvent::Resize)
|
||
|
+ {
|
||
|
+ QResizeEvent* const resizeEvent = dynamic_cast<QResizeEvent*>(event);
|
||
|
+
|
||
|
+ if (resizeEvent)
|
||
|
+ {
|
||
|
+ resize(resizeEvent->size());
|
||
|
+ }
|
||
|
+ }
|
||
|
+ }
|
||
|
+ else if (d->child && object == d->child)
|
||
|
+ {
|
||
|
+ if (event->type() == QEvent::MouseButtonRelease)
|
||
|
+ {
|
||
|
+ QMouseEvent* const e = dynamic_cast<QMouseEvent*>(event);
|
||
|
+
|
||
|
+ if (s->currentMouseMode == MouseModeRegionSelection)
|
||
|
+ {
|
||
|
+ if (!d->firstSelectionPoint.hasCoordinates())
|
||
|
+ {
|
||
|
+ runScript2Coordinates(QString::fromLatin1("kgeomapPixelToLatLng(%1, %2);")
|
||
|
+ .arg(e->x())
|
||
|
+ .arg(e->y()),
|
||
|
+ &d->firstSelectionPoint);
|
||
|
+
|
||
|
+ d->firstSelectionScreenPoint = QPoint(e->x(), e->y());
|
||
|
+ }
|
||
|
+ else
|
||
|
+ {
|
||
|
+ runScript2Coordinates(QString::fromLatin1("kgeomapPixelToLatLng(%1, %2);")
|
||
|
+ .arg(e->x())
|
||
|
+ .arg(e->y()),
|
||
|
+ &d->intermediateSelectionPoint);
|
||
|
+
|
||
|
+ d->intermediateSelectionScreenPoint = QPoint(e->x(), e->y());
|
||
|
+
|
||
|
+ qreal lonWest, latNorth, lonEast, latSouth;
|
||
|
+
|
||
|
+ if (d->firstSelectionScreenPoint.x() < d->intermediateSelectionScreenPoint.x())
|
||
|
+ {
|
||
|
+ lonWest = d->firstSelectionPoint.lon();
|
||
|
+ lonEast = d->intermediateSelectionPoint.lon();
|
||
|
+ }
|
||
|
+ else
|
||
|
+ {
|
||
|
+ lonEast = d->firstSelectionPoint.lon();
|
||
|
+ lonWest = d->intermediateSelectionPoint.lon();
|
||
|
+ }
|
||
|
+
|
||
|
+ if (d->firstSelectionScreenPoint.y() < d->intermediateSelectionScreenPoint.y())
|
||
|
+ {
|
||
|
+ latNorth = d->firstSelectionPoint.lat();
|
||
|
+ latSouth = d->intermediateSelectionPoint.lat();
|
||
|
+ }
|
||
|
+ else
|
||
|
+ {
|
||
|
+ latNorth = d->intermediateSelectionPoint.lat();
|
||
|
+ latSouth = d->firstSelectionPoint.lat();
|
||
|
+ }
|
||
|
+
|
||
|
+ runScript(QLatin1String("kgeomapRemoveTemporarySelectionRectangle();"));
|
||
|
+ runScript(QString::fromLatin1("kgeomapSetSelectionRectangle(%1, %2, %3, %4);")
|
||
|
+ .arg(lonWest)
|
||
|
+ .arg(latNorth)
|
||
|
+ .arg(lonEast)
|
||
|
+ .arg(latSouth));
|
||
|
+
|
||
|
+ const GeoCoordinates::Pair selectionCoordinates(
|
||
|
+ GeoCoordinates(latNorth, lonWest),
|
||
|
+ GeoCoordinates(latSouth, lonEast));
|
||
|
+
|
||
|
+ d->firstSelectionPoint.clear();
|
||
|
+ d->intermediateSelectionPoint.clear();
|
||
|
+
|
||
|
+ emit selectionHasBeenMade(selectionCoordinates);
|
||
|
+ }
|
||
|
+ }
|
||
|
+ }
|
||
|
+ else if (event->type() == QEvent::MouseMove)
|
||
|
+ {
|
||
|
+ QMouseEvent* const e = dynamic_cast<QMouseEvent*>(event);
|
||
|
+
|
||
|
+ if (s->currentMouseMode == MouseModeRegionSelection &&
|
||
|
+ d->firstSelectionPoint.hasCoordinates())
|
||
|
+ {
|
||
|
+ runScript2Coordinates(QString::fromLatin1("kgeomapPixelToLatLng(%1, %2);")
|
||
|
+ .arg(e->x())
|
||
|
+ .arg(e->y()),
|
||
|
+ &d->intermediateSelectionPoint);
|
||
|
+
|
||
|
+ d->intermediateSelectionScreenPoint = QPoint(e->x(), e->y());
|
||
|
+
|
||
|
+ qCDebug(DIGIKAM_GEOIFACE_LOG) << d->firstSelectionScreenPoint << QLatin1String(" ") << d->intermediateSelectionScreenPoint;
|
||
|
+
|
||
|
+ qreal lonWest, latNorth, lonEast, latSouth;
|
||
|
+
|
||
|
+ if (d->firstSelectionScreenPoint.x() < d->intermediateSelectionScreenPoint.x())
|
||
|
+ {
|
||
|
+ lonWest = d->firstSelectionPoint.lon();
|
||
|
+ lonEast = d->intermediateSelectionPoint.lon();
|
||
|
+ }
|
||
|
+ else
|
||
|
+ {
|
||
|
+ lonEast = d->firstSelectionPoint.lon();
|
||
|
+ lonWest = d->intermediateSelectionPoint.lon();
|
||
|
+ }
|
||
|
+
|
||
|
+ if (d->firstSelectionScreenPoint.y() < d->intermediateSelectionScreenPoint.y())
|
||
|
+ {
|
||
|
+ latNorth = d->firstSelectionPoint.lat();
|
||
|
+ latSouth = d->intermediateSelectionPoint.lat();
|
||
|
+ }
|
||
|
+ else
|
||
|
+ {
|
||
|
+ latNorth = d->intermediateSelectionPoint.lat();
|
||
|
+ latSouth = d->firstSelectionPoint.lat();
|
||
|
+ }
|
||
|
+
|
||
|
+ runScript(QString::fromLatin1("kgeomapSetTemporarySelectionRectangle(%1, %2, %3, %4);")
|
||
|
+ .arg(lonWest)
|
||
|
+ .arg(latNorth)
|
||
|
+ .arg(lonEast)
|
||
|
+ .arg(latSouth));
|
||
|
+ }
|
||
|
+ }
|
||
|
+ }
|
||
|
+
|
||
|
+ return false;
|
||
|
+}
|
||
|
+
|
||
|
+void HTMLWidget::setSelectionRectangle(const GeoCoordinates::Pair& searchCoordinates)
|
||
|
+{
|
||
|
+ if (!searchCoordinates.first.hasCoordinates())
|
||
|
+ {
|
||
|
+ runScript(QString::fromLatin1("kgeomapRemoveSelectionRectangle();"));
|
||
|
+ return;
|
||
|
+ }
|
||
|
+
|
||
|
+ qreal West = searchCoordinates.first.lon();
|
||
|
+ qreal North = searchCoordinates.first.lat();
|
||
|
+ qreal East = searchCoordinates.second.lon();
|
||
|
+ qreal South = searchCoordinates.second.lat();
|
||
|
+
|
||
|
+ runScript(QString::fromLatin1("kgeomapSetSelectionRectangle(%1, %2, %3, %4);")
|
||
|
+ .arg(West).arg(North).arg(East).arg(South));
|
||
|
+}
|
||
|
+
|
||
|
+void HTMLWidget::removeSelectionRectangle()
|
||
|
+{
|
||
|
+ runScript(QLatin1String("kgeomapRemoveSelectionRectangle();"));
|
||
|
+}
|
||
|
+
|
||
|
+void HTMLWidget::mouseModeChanged(const GeoMouseModes mouseMode)
|
||
|
+{
|
||
|
+ const bool inSelectionMode = (mouseMode == MouseModeRegionSelection);
|
||
|
+
|
||
|
+ if (inSelectionMode)
|
||
|
+ {
|
||
|
+ d->firstSelectionPoint.clear();
|
||
|
+ d->intermediateSelectionPoint.clear();
|
||
|
+ runScript(QString::fromLatin1("kgeomapSelectionModeStatus(%1);").arg(inSelectionMode));
|
||
|
+ }
|
||
|
+ else
|
||
|
+ {
|
||
|
+ runScript(QString::fromLatin1("kgeomapSelectionModeStatus(%1);").arg(inSelectionMode));
|
||
|
+ }
|
||
|
+}
|
||
|
+
|
||
|
+void HTMLWidget::centerOn(const qreal west, const qreal north,
|
||
|
+ const qreal east, const qreal south,
|
||
|
+ const bool useSaneZoomLevel)
|
||
|
+{
|
||
|
+/*
|
||
|
+ qCDebug(DIGIKAM_GEOIFACE_LOG) << "West:" << west
|
||
|
+ << " North:" << north
|
||
|
+ << " East:" << east
|
||
|
+ << " South:" << south;
|
||
|
+*/
|
||
|
+ runScript(QString::fromLatin1("kgeomapSetMapBoundaries(%1, %2, %3, %4, %5);")
|
||
|
+ .arg(west)
|
||
|
+ .arg(north)
|
||
|
+ .arg(east)
|
||
|
+ .arg(south)
|
||
|
+ .arg(useSaneZoomLevel ? 1 : 0));
|
||
|
+}
|
||
|
+
|
||
|
+void HTMLWidget::setSharedGeoIfaceObject(GeoIfaceSharedData* const sharedData)
|
||
|
+{
|
||
|
+ s = sharedData;
|
||
|
+}
|
||
|
+
|
||
|
+} // namespace Digikam
|
||
|
diff --git a/core/utilities/geolocation/geoiface/widgets/htmlwidget_qwebengine.h b/core/utilities/geolocation/geoiface/widgets/htmlwidget_qwebengine.h
|
||
|
new file mode 100644
|
||
|
index 0000000..14cebb3
|
||
|
--- /dev/null
|
||
|
+++ b/core/utilities/geolocation/geoiface/widgets/htmlwidget_qwebengine.h
|
||
|
@@ -0,0 +1,119 @@
|
||
|
+/* ============================================================
|
||
|
+ *
|
||
|
+ * This file is a part of digiKam project
|
||
|
+ * http://www.digikam.org
|
||
|
+ *
|
||
|
+ * Date : 2009-12-01
|
||
|
+ * Description : Widget for displaying HTML in the backends
|
||
|
+ *
|
||
|
+ * Copyright (C) 2010-2018 by Gilles Caulier <caulier dot gilles at gmail dot com>
|
||
|
+ * Copyright (C) 2009-2011 by Michael G. Hansen <mike at mghansen dot de>
|
||
|
+ * Copyright (C) 2015 by Mohamed Anwer <mohammed dot ahmed dot anwer at gmail dot com>
|
||
|
+ *
|
||
|
+ * This program is free software; you can redistribute it
|
||
|
+ * and/or modify it under the terms of the GNU General
|
||
|
+ * Public License as published by the Free Software Foundation;
|
||
|
+ * either version 2, or (at your option)
|
||
|
+ * any later version.
|
||
|
+ *
|
||
|
+ * This program is distributed in the hope that it will be useful,
|
||
|
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
+ * GNU General Public License for more details.
|
||
|
+ *
|
||
|
+ * ============================================================ */
|
||
|
+
|
||
|
+#ifndef HTML_WIDGET_QWEBENGINE_H
|
||
|
+#define HTML_WIDGET_QWEBENGINE_H
|
||
|
+
|
||
|
+// Qt includes
|
||
|
+
|
||
|
+#include <QTimer>
|
||
|
+#include <QWebEngineView>
|
||
|
+#include <QWebEnginePage>
|
||
|
+
|
||
|
+// Local includes
|
||
|
+
|
||
|
+#include "geoifacecommon.h"
|
||
|
+#include "geoifacetypes.h"
|
||
|
+#include "geocoordinates.h"
|
||
|
+
|
||
|
+namespace Digikam
|
||
|
+{
|
||
|
+
|
||
|
+class HTMLWidget;
|
||
|
+
|
||
|
+class HTMLWidgetPage : public QWebEnginePage
|
||
|
+{
|
||
|
+ Q_OBJECT
|
||
|
+
|
||
|
+public:
|
||
|
+
|
||
|
+ explicit HTMLWidgetPage(HTMLWidget* const parent = 0);
|
||
|
+ virtual ~HTMLWidgetPage();
|
||
|
+
|
||
|
+Q_SIGNALS:
|
||
|
+
|
||
|
+ void signalHTMLEvents(const QStringList& events);
|
||
|
+
|
||
|
+private Q_SLOTS:
|
||
|
+
|
||
|
+ void slotSendHTMLEvents();
|
||
|
+
|
||
|
+protected:
|
||
|
+
|
||
|
+ void javaScriptConsoleMessage(JavaScriptConsoleMessageLevel, const QString&, int, const QString&);
|
||
|
+
|
||
|
+private:
|
||
|
+
|
||
|
+ QStringList m_events;
|
||
|
+ QTimer* m_timer;
|
||
|
+};
|
||
|
+
|
||
|
+// -------------------------------------------------------------------
|
||
|
+
|
||
|
+class HTMLWidget : public QWebEngineView
|
||
|
+{
|
||
|
+ Q_OBJECT
|
||
|
+
|
||
|
+public:
|
||
|
+
|
||
|
+ explicit HTMLWidget(QWidget* const parent = 0);
|
||
|
+ ~HTMLWidget();
|
||
|
+
|
||
|
+ void loadInitialHTML(const QString& initialHTML);
|
||
|
+ QVariant runScript(const QString& scriptCode, bool async = true);
|
||
|
+ bool runScript2Coordinates(const QString& scriptCode, GeoCoordinates* const coordinates);
|
||
|
+ void mouseModeChanged(const GeoMouseModes mouseMode);
|
||
|
+ void setSelectionRectangle(const GeoCoordinates::Pair& searchCoordinates);
|
||
|
+ void removeSelectionRectangle();
|
||
|
+ void centerOn(const qreal west, const qreal north, const qreal east, const qreal south,
|
||
|
+ const bool useSaneZoomLevel = true);
|
||
|
+ void setSharedGeoIfaceObject(GeoIfaceSharedData* const sharedData);
|
||
|
+
|
||
|
+Q_SIGNALS:
|
||
|
+
|
||
|
+ void signalHTMLEvents(const QStringList& events);
|
||
|
+ void signalJavaScriptReady();
|
||
|
+ void selectionHasBeenMade(const Digikam::GeoCoordinates::Pair& coordinatesRect);
|
||
|
+
|
||
|
+protected:
|
||
|
+
|
||
|
+ bool eventFilter(QObject*, QEvent*);
|
||
|
+
|
||
|
+protected Q_SLOTS:
|
||
|
+
|
||
|
+ void slotHTMLCompleted(bool ok);
|
||
|
+ void progress(int progress);
|
||
|
+
|
||
|
+private:
|
||
|
+
|
||
|
+ class Private;
|
||
|
+ Private* const d;
|
||
|
+
|
||
|
+ GeoIfaceSharedData* s;
|
||
|
+};
|
||
|
+
|
||
|
+} // namespace Digikam
|
||
|
+
|
||
|
+#endif // HTML_WIDGET_QWEBENGINE_H
|
||
|
--
|
||
|
cgit v0.11.2
|
||
|
|