diff --git a/core/utilities/geolocation/geoiface/widgets/htmlwidget_qwebengine.cpp b/core/utilities/geolocation/geoiface/widgets/htmlwidget_qwebengine.cpp index 3bffe476e5..d719342843 100644 --- a/core/utilities/geolocation/geoiface/widgets/htmlwidget_qwebengine.cpp +++ b/core/utilities/geolocation/geoiface/widgets/htmlwidget_qwebengine.cpp @@ -1,443 +1,444 @@ /* ============================================================ * * This file is a part of digiKam project * https://www.digikam.org * * Date : 2009-12-01 * Description : Widget for displaying HTML in the backends * * Copyright (C) 2010-2020 by Gilles Caulier * Copyright (C) 2009-2011 by Michael G. Hansen * Copyright (C) 2015 by Mohamed_Anwer * * 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 #include #include #include #include // 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 Q_DECL_HIDDEN HTMLWidget::Private { public: explicit Private() : parent(nullptr), child(nullptr), hpage(nullptr), 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(nullptr) { d->parent = parent; setAcceptDrops(false); setFocusPolicy(Qt::WheelFocus); d->hpage = new HTMLWidgetPage(this); setPage(d->hpage); #if QTWEBENGINEWIDGETS_VERSION >= QT_VERSION_CHECK(5, 7, 0) settings()->setAttribute(QWebEngineSettings::WebGLEnabled, false); settings()->setAttribute(QWebEngineSettings::Accelerated2dCanvasEnabled, false); #endif 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); } 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 c++11 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 QVariant(); } /** * @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 (object == this) { if (event->type() == QEvent::ChildAdded) { d->child = findChild(); if (d->child) { d->child->installEventFilter(this); } } return QWebEngineView::eventFilter(object, event); } else if (d->parent && (object == d->parent)) { if (event->type() == QEvent::Resize) { QResizeEvent* const resizeEvent = dynamic_cast(event); if (resizeEvent) { resize(resizeEvent->size()); } } } else if (d->child && (object == d->child)) { if (event->type() == QEvent::MouseButtonRelease) { QMouseEvent* const e = dynamic_cast(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(event); - if ((s->currentMouseMode == MouseModeRegionSelection) && + if (e && + (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 << QLatin1Char(' ') << 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(QLatin1String("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/project/bundles/mxe/config.sh b/project/bundles/mxe/config.sh index a6a00c0ce7..f0d0a23eb0 100644 --- a/project/bundles/mxe/config.sh +++ b/project/bundles/mxe/config.sh @@ -1,77 +1,77 @@ #!/bin/bash # Copyright (c) 2013-2020 by Gilles Caulier # # Redistribution and use is allowed according to the terms of the BSD license. # For details see the accompanying COPYING-CMAKE-SCRIPTS file. ######################################################################## # Absolute path where are downloaded all tarballs to compile. DOWNLOAD_DIR="`pwd`/temp.dwnld" # Absolute path where are compiled all tarballs BUILDING_DIR="`pwd`/temp.build" #------------------------------------------------------------------------------------------- # MXE configuration #------------ # IMPORTANT: Target Windows architecture to build installer. Possible values: 32 or 64 bits. -MXE_ARCHBITS=64 +MXE_ARCHBITS=32 #------------ if [[ $MXE_ARCHBITS == 32 ]]; then # Windows 32 bits shared MXE_BUILD_TARGETS="i686-w64-mingw32.shared" MXE_BUILDROOT="`pwd`/build.win32" elif [[ $MXE_ARCHBITS == 64 ]]; then # Windows 64 bits shared MXE_BUILD_TARGETS="x86_64-w64-mingw32.shared" MXE_BUILDROOT="`pwd`/build.win64" else echo "Unsupported or wrong target Windows architecture: $MXE_ARCHBITS bits." exit -1 fi echo "Target Windows architecture: $MXE_ARCHBITS bits." MXE_GIT_URL="https://github.com/mxe/mxe.git" MXE_GIT_REVISION=master MXE_INSTALL_PREFIX=${MXE_BUILDROOT}/usr/${MXE_BUILD_TARGETS}/ MXE_TOOLCHAIN=${MXE_INSTALL_PREFIX}/share/cmake/mxe-conf.cmake #------------------------------------------------------------------------------------------- # URL to git repository to checkout digiKam source code DK_GITURL="git@invent.kde.org:kde/digikam.git" # digiKam tarball information. DK_URL="http://download.kde.org/stable/digikam" # Location to build source code. DK_BUILDTEMP=~/dktemp # digiKam tag version from git. Official tarball do not include extra shared libraries. # The list of tags can be listed with this url: https://quickgit.kde.org/?p=digikam.git&a=tags # If you want to package current implemntation from git, use "master" as tag. #DK_VERSION=v7.0.0-beta2 DK_VERSION=master #DK_VERSION=development/dplugins # Installer sub version to differentiates newer updates of the installer itself, even if the underlying application hasn’t changed. #DK_EPOCH="-01" # Epoch with time-stamp for pre-release bundle in ISO format DK_EPOCH="-`date "+%Y%m%dT%H%M%S"`" # Installer will include or not digiKam debug symbols DK_DEBUG=1 # Sign bundles with GPG. Passphrase must be hosted in ~/.gnupg/dkorg-gpg-pwd.txt DK_SIGN=0 # Upload automatically bundle to files.kde.org (pre-release only). DK_UPLOAD=1 DK_UPLOADURL="digikam@milonia.kde.org" DK_UPLOADDIR="/srv/archives/files/digikam/"