Make the webview optional
This commit is contained in:
parent
bf24f169d6
commit
69f959befe
@ -26,7 +26,6 @@
|
|||||||
#include <QSysInfo>
|
#include <QSysInfo>
|
||||||
#include <QCommandLineParser>
|
#include <QCommandLineParser>
|
||||||
#include <QCommandLineOption>
|
#include <QCommandLineOption>
|
||||||
#include <QtWebView>
|
|
||||||
|
|
||||||
#ifdef Q_OS_ANDROID
|
#ifdef Q_OS_ANDROID
|
||||||
#include <QtAndroidExtras/QtAndroid>
|
#include <QtAndroidExtras/QtAndroid>
|
||||||
@ -71,7 +70,6 @@ int main(int argc, char *argv[])
|
|||||||
QApplication application(argc, argv);
|
QApplication application(argc, argv);
|
||||||
application.setApplicationName("nymea-app");
|
application.setApplicationName("nymea-app");
|
||||||
application.setOrganizationName("nymea");
|
application.setOrganizationName("nymea");
|
||||||
QtWebView::initialize();
|
|
||||||
|
|
||||||
QCommandLineParser parser;
|
QCommandLineParser parser;
|
||||||
parser.addHelpOption();
|
parser.addHelpOption();
|
||||||
|
|||||||
@ -2,7 +2,7 @@ TEMPLATE=app
|
|||||||
TARGET=nymea-app
|
TARGET=nymea-app
|
||||||
include(../config.pri)
|
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 \
|
INCLUDEPATH += $$top_srcdir/libnymea-common \
|
||||||
$$top_srcdir/libnymea-app-core
|
$$top_srcdir/libnymea-app-core
|
||||||
@ -44,6 +44,10 @@ equals(STYLES_PATH, "") {
|
|||||||
RESOURCES += $${STYLES_PATH}/styles.qrc
|
RESOURCES += $${STYLES_PATH}/styles.qrc
|
||||||
}
|
}
|
||||||
|
|
||||||
|
win32 {
|
||||||
|
QT += webview
|
||||||
|
}
|
||||||
|
|
||||||
android {
|
android {
|
||||||
ANDROID_PACKAGE_SOURCE_DIR = $$PWD/../packaging/android
|
ANDROID_PACKAGE_SOURCE_DIR = $$PWD/../packaging/android
|
||||||
|
|
||||||
@ -60,7 +64,7 @@ android {
|
|||||||
INCLUDEPATH += /opt/firebase_cpp_sdk/include
|
INCLUDEPATH += /opt/firebase_cpp_sdk/include
|
||||||
LIBS += -L/opt/firebase_cpp_sdk/libs/android/$$ANDROID_TARGET_ARCH/$$FIREBASE_STL_VARIANT/ -lfirebase_messaging -lfirebase_app
|
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
|
HEADERS += platformintegration/android/platformhelperandroid.h
|
||||||
SOURCES += platformintegration/android/platformhelperandroid.cpp
|
SOURCES += platformintegration/android/platformhelperandroid.cpp
|
||||||
|
|
||||||
@ -80,6 +84,7 @@ android {
|
|||||||
}
|
}
|
||||||
|
|
||||||
macx: {
|
macx: {
|
||||||
|
QT += webview
|
||||||
PRODUCT_NAME=$$TARGET
|
PRODUCT_NAME=$$TARGET
|
||||||
plist.input = ../packaging/osx/Info.plist.in
|
plist.input = ../packaging/osx/Info.plist.in
|
||||||
plist.output = $$OUT_PWD/Info.plist
|
plist.output = $$OUT_PWD/Info.plist
|
||||||
@ -91,6 +96,7 @@ macx: {
|
|||||||
|
|
||||||
ios: {
|
ios: {
|
||||||
message("iOS build")
|
message("iOS build")
|
||||||
|
QT += webview
|
||||||
HEADERS += platformintegration/ios/platformhelperios.h
|
HEADERS += platformintegration/ios/platformhelperios.h
|
||||||
SOURCES += platformintegration/ios/platformhelperios.cpp
|
SOURCES += platformintegration/ios/platformhelperios.cpp
|
||||||
OBJECTIVE_SOURCES += $$PWD/../packaging/ios/pushnotifications.mm \
|
OBJECTIVE_SOURCES += $$PWD/../packaging/ios/pushnotifications.mm \
|
||||||
|
|||||||
@ -3,15 +3,19 @@
|
|||||||
#include <QUuid>
|
#include <QUuid>
|
||||||
#include <QScreen>
|
#include <QScreen>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
#include <QtWebView>
|
||||||
|
|
||||||
PlatformHelperIOS::PlatformHelperIOS(QObject *parent) : PlatformHelper(parent)
|
PlatformHelperIOS::PlatformHelperIOS(QObject *parent) : PlatformHelper(parent)
|
||||||
{
|
{
|
||||||
|
QtWebView::initialize();
|
||||||
|
|
||||||
QScreen *screen = qApp->primaryScreen();
|
QScreen *screen = qApp->primaryScreen();
|
||||||
screen->setOrientationUpdateMask(Qt::PortraitOrientation | Qt::LandscapeOrientation | Qt::InvertedPortraitOrientation | Qt::InvertedLandscapeOrientation);
|
screen->setOrientationUpdateMask(Qt::PortraitOrientation | Qt::LandscapeOrientation | Qt::InvertedPortraitOrientation | Qt::InvertedLandscapeOrientation);
|
||||||
QObject::connect(screen, &QScreen::orientationChanged, qApp, [this](Qt::ScreenOrientation) {
|
QObject::connect(screen, &QScreen::orientationChanged, qApp, [this](Qt::ScreenOrientation) {
|
||||||
setBottomPanelColor(bottomPanelColor());
|
setBottomPanelColor(bottomPanelColor());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlatformHelperIOS::requestPermissions()
|
void PlatformHelperIOS::requestPermissions()
|
||||||
|
|||||||
@ -195,5 +195,6 @@
|
|||||||
<file>ui/components/KeypadButton.qml</file>
|
<file>ui/components/KeypadButton.qml</file>
|
||||||
<file>ui/devicepages/DoorbellDevicePage.qml</file>
|
<file>ui/devicepages/DoorbellDevicePage.qml</file>
|
||||||
<file>ui/magic/NewMagicPage.qml</file>
|
<file>ui/magic/NewMagicPage.qml</file>
|
||||||
|
<file>ui/components/WebViewWrapper.qml</file>
|
||||||
</qresource>
|
</qresource>
|
||||||
</RCC>
|
</RCC>
|
||||||
|
|||||||
9
nymea-app/ui/components/WebViewWrapper.qml
Normal file
9
nymea-app/ui/components/WebViewWrapper.qml
Normal file
@ -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 {
|
||||||
|
|
||||||
|
}
|
||||||
@ -3,7 +3,6 @@ import QtQuick.Layouts 1.1
|
|||||||
import QtQuick.Controls 2.1
|
import QtQuick.Controls 2.1
|
||||||
import QtQuick.Controls.Material 2.1
|
import QtQuick.Controls.Material 2.1
|
||||||
import Nymea 1.0
|
import Nymea 1.0
|
||||||
import QtWebView 1.1
|
|
||||||
|
|
||||||
import "../components"
|
import "../components"
|
||||||
import "../delegates"
|
import "../delegates"
|
||||||
@ -464,19 +463,56 @@ Page {
|
|||||||
id: oAuthPageComponent
|
id: oAuthPageComponent
|
||||||
Page {
|
Page {
|
||||||
id: oAuthPage
|
id: oAuthPage
|
||||||
property alias oAuthUrl: oAuthWebView.url
|
property string oAuthUrl
|
||||||
|
|
||||||
WebView {
|
ColumnLayout {
|
||||||
id: oAuthWebView
|
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
|
anchors.fill: parent
|
||||||
|
|
||||||
onUrlChanged: {
|
Component.onCompleted: {
|
||||||
print("OAUTH URL changed", url)
|
// This might fail if qml-module-qtwebview isn't around
|
||||||
if (url.toString().indexOf("https://127.0.0.1") == 0) {
|
Qt.createQmlObject(webViewString, webViewContainer);
|
||||||
print("Redirect URL detected!");
|
|
||||||
engine.deviceManager.confirmPairing(d.pairingTransactionId, url)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,7 +16,6 @@ Build-Depends: debhelper (>= 9.0.0),
|
|||||||
qtconnectivity5-dev,
|
qtconnectivity5-dev,
|
||||||
qtdeclarative5-dev,
|
qtdeclarative5-dev,
|
||||||
qtquickcontrols2-5-dev,
|
qtquickcontrols2-5-dev,
|
||||||
libqt5webview5-dev,
|
|
||||||
|
|
||||||
Package: nymea-app
|
Package: nymea-app
|
||||||
Architecture: any
|
Architecture: any
|
||||||
@ -28,6 +27,7 @@ Depends: ${shlibs:Depends},
|
|||||||
libqt5gui5,
|
libqt5gui5,
|
||||||
libqt5websockets5,
|
libqt5websockets5,
|
||||||
libqt5bluetooth5,
|
libqt5bluetooth5,
|
||||||
|
qml-module-qt-labs-folderlistmodel,
|
||||||
qml-module-qt-labs-settings,
|
qml-module-qt-labs-settings,
|
||||||
qml-module-qtcharts,
|
qml-module-qtcharts,
|
||||||
qml-module-qtgraphicaleffects,
|
qml-module-qtgraphicaleffects,
|
||||||
@ -35,8 +35,7 @@ Depends: ${shlibs:Depends},
|
|||||||
qml-module-qtquick-layouts,
|
qml-module-qtquick-layouts,
|
||||||
qml-module-qtquick-window2,
|
qml-module-qtquick-window2,
|
||||||
qml-module-qtquick2,
|
qml-module-qtquick2,
|
||||||
qml-module-qtwebview,
|
Recommends: qml-module-qtwebview,
|
||||||
xinit,
|
|
||||||
Suggests: nymea,
|
Suggests: nymea,
|
||||||
network-manager
|
network-manager
|
||||||
Description: An open source IoT server - daemon
|
Description: An open source IoT server - daemon
|
||||||
@ -56,7 +55,7 @@ Depends: nymea-app,
|
|||||||
openbox,
|
openbox,
|
||||||
lightdm,
|
lightdm,
|
||||||
qtvirtualkeyboard-plugin,
|
qtvirtualkeyboard-plugin,
|
||||||
qtdeclarative5-folderlistmodel-plugin,
|
xinit,
|
||||||
Provides: lightdm-greeter
|
Provides: lightdm-greeter
|
||||||
Description: Run nymea:app in kiosk mode
|
Description: Run nymea:app in kiosk mode
|
||||||
This package will install nymea:app in kiosk mode on your machine.
|
This package will install nymea:app in kiosk mode on your machine.
|
||||||
|
|||||||
Reference in New Issue
Block a user