diff --git a/nymea-app/main.cpp b/nymea-app/main.cpp index a113ee0e..7c394a40 100644 --- a/nymea-app/main.cpp +++ b/nymea-app/main.cpp @@ -26,7 +26,6 @@ #include #include #include -#include #ifdef Q_OS_ANDROID #include @@ -71,7 +70,6 @@ int main(int argc, char *argv[]) QApplication application(argc, argv); application.setApplicationName("nymea-app"); application.setOrganizationName("nymea"); - QtWebView::initialize(); QCommandLineParser parser; parser.addHelpOption(); diff --git a/nymea-app/nymea-app.pro b/nymea-app/nymea-app.pro index 58317024..4505458f 100644 --- a/nymea-app/nymea-app.pro +++ b/nymea-app/nymea-app.pro @@ -2,7 +2,7 @@ TEMPLATE=app TARGET=nymea-app include(../config.pri) -QT += network qml quick quickcontrols2 svg websockets bluetooth charts gui-private webview +QT += network qml quick quickcontrols2 svg websockets bluetooth charts gui-private INCLUDEPATH += $$top_srcdir/libnymea-common \ $$top_srcdir/libnymea-app-core @@ -44,6 +44,10 @@ equals(STYLES_PATH, "") { RESOURCES += $${STYLES_PATH}/styles.qrc } +win32 { + QT += webview +} + android { ANDROID_PACKAGE_SOURCE_DIR = $$PWD/../packaging/android @@ -60,7 +64,7 @@ android { INCLUDEPATH += /opt/firebase_cpp_sdk/include LIBS += -L/opt/firebase_cpp_sdk/libs/android/$$ANDROID_TARGET_ARCH/$$FIREBASE_STL_VARIANT/ -lfirebase_messaging -lfirebase_app - QT += androidextras + QT += androidextras webview HEADERS += platformintegration/android/platformhelperandroid.h SOURCES += platformintegration/android/platformhelperandroid.cpp @@ -80,6 +84,7 @@ android { } macx: { + QT += webview PRODUCT_NAME=$$TARGET plist.input = ../packaging/osx/Info.plist.in plist.output = $$OUT_PWD/Info.plist @@ -91,6 +96,7 @@ macx: { ios: { message("iOS build") + QT += webview HEADERS += platformintegration/ios/platformhelperios.h SOURCES += platformintegration/ios/platformhelperios.cpp OBJECTIVE_SOURCES += $$PWD/../packaging/ios/pushnotifications.mm \ diff --git a/nymea-app/platformintegration/ios/platformhelperios.cpp b/nymea-app/platformintegration/ios/platformhelperios.cpp index 7b41b420..f9b5bff0 100644 --- a/nymea-app/platformintegration/ios/platformhelperios.cpp +++ b/nymea-app/platformintegration/ios/platformhelperios.cpp @@ -3,15 +3,19 @@ #include #include #include +#include PlatformHelperIOS::PlatformHelperIOS(QObject *parent) : PlatformHelper(parent) { + QtWebView::initialize(); + QScreen *screen = qApp->primaryScreen(); screen->setOrientationUpdateMask(Qt::PortraitOrientation | Qt::LandscapeOrientation | Qt::InvertedPortraitOrientation | Qt::InvertedLandscapeOrientation); QObject::connect(screen, &QScreen::orientationChanged, qApp, [this](Qt::ScreenOrientation) { setBottomPanelColor(bottomPanelColor()); }); + } void PlatformHelperIOS::requestPermissions() diff --git a/nymea-app/resources.qrc b/nymea-app/resources.qrc index d9575e88..f49a7e82 100644 --- a/nymea-app/resources.qrc +++ b/nymea-app/resources.qrc @@ -195,5 +195,6 @@ ui/components/KeypadButton.qml ui/devicepages/DoorbellDevicePage.qml ui/magic/NewMagicPage.qml + ui/components/WebViewWrapper.qml diff --git a/nymea-app/ui/components/WebViewWrapper.qml b/nymea-app/ui/components/WebViewWrapper.qml new file mode 100644 index 00000000..0d6388fc --- /dev/null +++ b/nymea-app/ui/components/WebViewWrapper.qml @@ -0,0 +1,9 @@ +import QtQuick 2.0 +import QtWebView 1.1 + +// This is needed because we can only load this on-demand but +// *deployqt will not include the module if there isn't a actual qml file importing it + +WebView { + +} diff --git a/nymea-app/ui/thingconfiguration/SetupWizard.qml b/nymea-app/ui/thingconfiguration/SetupWizard.qml index 401c0f81..799a4a7c 100644 --- a/nymea-app/ui/thingconfiguration/SetupWizard.qml +++ b/nymea-app/ui/thingconfiguration/SetupWizard.qml @@ -3,7 +3,6 @@ import QtQuick.Layouts 1.1 import QtQuick.Controls 2.1 import QtQuick.Controls.Material 2.1 import Nymea 1.0 -import QtWebView 1.1 import "../components" import "../delegates" @@ -464,19 +463,56 @@ Page { id: oAuthPageComponent Page { id: oAuthPage - property alias oAuthUrl: oAuthWebView.url + property string oAuthUrl - WebView { - id: oAuthWebView + ColumnLayout { + anchors.centerIn: parent + width: parent.width - app.margins * 2 + spacing: app.margins * 2 + + Label { + Layout.fillWidth: true + text: qsTr("OAuth is not supported on this platform. Please use this app on a different device to set up this thing.") + wrapMode: Text.WordWrap + horizontalAlignment: Text.AlignHCenter + } + + Label { + Layout.fillWidth: true + text: qsTr("In order to use OAuth on this platform, make sure qml-module-qtwebview is installed.") + wrapMode: Text.WordWrap + font.pixelSize: app.smallFont + horizontalAlignment: Text.AlignHCenter + } + } + + Item { + id: webViewContainer anchors.fill: parent - onUrlChanged: { - print("OAUTH URL changed", url) - if (url.toString().indexOf("https://127.0.0.1") == 0) { - print("Redirect URL detected!"); - engine.deviceManager.confirmPairing(d.pairingTransactionId, url) - } + Component.onCompleted: { + // This might fail if qml-module-qtwebview isn't around + Qt.createQmlObject(webViewString, webViewContainer); } + + property string webViewString: + ' + import QtQuick 2.8; + import QtWebView 1.1; + WebView { + id: oAuthWebView + anchors.fill: parent + url: oAuthPage.oAuthUrl + + onUrlChanged: { + print("OAUTH URL changed", url) + if (url.toString().indexOf("https://127.0.0.1") == 0) { + print("Redirect URL detected!"); + engine.deviceManager.confirmPairing(d.pairingTransactionId, url) + } + } + } + ' } } } diff --git a/packaging/ubuntu/debian/control b/packaging/ubuntu/debian/control index 22535cad..ec83c7e7 100644 --- a/packaging/ubuntu/debian/control +++ b/packaging/ubuntu/debian/control @@ -16,7 +16,6 @@ Build-Depends: debhelper (>= 9.0.0), qtconnectivity5-dev, qtdeclarative5-dev, qtquickcontrols2-5-dev, - libqt5webview5-dev, Package: nymea-app Architecture: any @@ -28,6 +27,7 @@ Depends: ${shlibs:Depends}, libqt5gui5, libqt5websockets5, libqt5bluetooth5, + qml-module-qt-labs-folderlistmodel, qml-module-qt-labs-settings, qml-module-qtcharts, qml-module-qtgraphicaleffects, @@ -35,8 +35,7 @@ Depends: ${shlibs:Depends}, qml-module-qtquick-layouts, qml-module-qtquick-window2, qml-module-qtquick2, - qml-module-qtwebview, - xinit, +Recommends: qml-module-qtwebview, Suggests: nymea, network-manager Description: An open source IoT server - daemon @@ -56,7 +55,7 @@ Depends: nymea-app, openbox, lightdm, qtvirtualkeyboard-plugin, - qtdeclarative5-folderlistmodel-plugin, + xinit, Provides: lightdm-greeter Description: Run nymea:app in kiosk mode This package will install nymea:app in kiosk mode on your machine.