diff --git a/libnymea-app-core/connection/nymeaconnection.cpp b/libnymea-app-core/connection/nymeaconnection.cpp index 730cc100..a191ac52 100644 --- a/libnymea-app-core/connection/nymeaconnection.cpp +++ b/libnymea-app-core/connection/nymeaconnection.cpp @@ -11,6 +11,7 @@ #include #include #include +#include #include "nymeatransportinterface.h" @@ -29,6 +30,12 @@ NymeaConnection::NymeaConnection(QObject *parent) : QObject(parent) updateActiveBearers(); }); + QGuiApplication *app = static_cast(QGuiApplication::instance()); + QObject::connect(app, &QGuiApplication::applicationStateChanged, this, [this](Qt::ApplicationState state) { + qDebug() << "Application state changed to:" << state; + updateActiveBearers(); + }); + updateActiveBearers(); } @@ -130,7 +137,7 @@ Connection *NymeaConnection::currentConnection() const void NymeaConnection::sendData(const QByteArray &data) { if (connected()) { -// qDebug() << "sending data:" << data; + qDebug() << "sending data:" << data; m_currentTransport->sendData(data); } else { qWarning() << "Connection: Not connected. Cannot send."; @@ -328,9 +335,10 @@ void NymeaConnection::onDisconnected() t->deleteLater(); if (!m_currentTransport && m_transportCandidates.isEmpty()) { - qDebug() << "Last connection dropped. Trying to reconnect.."; + qDebug() << "Last connection dropped."; QTimer::singleShot(1000, this, [this](){ if (m_currentHost) { + qDebug() << "Trying to reconnect.."; connectInternal(m_currentHost); } }); diff --git a/nymea-app/nymea-app.pro b/nymea-app/nymea-app.pro index 67564987..b3e84269 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 +QT += network qml quick quickcontrols2 svg websockets bluetooth charts gui-private INCLUDEPATH += $$top_srcdir/libnymea-common \ $$top_srcdir/libnymea-app-core diff --git a/nymea-app/platformhelper.cpp b/nymea-app/platformhelper.cpp index de4fd04f..2e4f0089 100644 --- a/nymea-app/platformhelper.cpp +++ b/nymea-app/platformhelper.cpp @@ -1,8 +1,22 @@ #include "platformhelper.h" +#include PlatformHelper::PlatformHelper(QObject *parent) : QObject(parent) { } + + +QVariantMap PlatformHelper::getSafeAreaMargins(QQuickWindow *window) +{ +// QPlatformWindow *platformWindow = window->handle(); +// QMargins margins = platformWindow->safeAreaMargins(); + QVariantMap map; +// map["top"] = margins.top(); +// map["right"] = margins.right(); +// map["bottom"] = margins.bottom(); +// map["left"] = margins.left(); + return map; +} diff --git a/nymea-app/platformhelper.h b/nymea-app/platformhelper.h index d5bbbef4..0f943c5b 100644 --- a/nymea-app/platformhelper.h +++ b/nymea-app/platformhelper.h @@ -2,6 +2,7 @@ #define PLATFORMHELPER_H #include +#include class PlatformHelper : public QObject { @@ -35,6 +36,7 @@ public: Q_INVOKABLE virtual void vibrate(HapticsFeedback feedbackType) = 0; + Q_INVOKABLE QVariantMap getSafeAreaMargins(QQuickWindow *window); signals: void permissionsRequestFinished(); }; diff --git a/nymea-app/ui/Nymea.qml b/nymea-app/ui/Nymea.qml index c40b307d..b1eacadd 100644 --- a/nymea-app/ui/Nymea.qml +++ b/nymea-app/ui/Nymea.qml @@ -16,6 +16,7 @@ ApplicationWindow { visibility: ApplicationWindow.AutomaticVisibility font: Qt.application.font + // Those variables must be present in the Style title: appName Material.primary: primaryColor @@ -49,6 +50,7 @@ ApplicationWindow { RootItem { id: rootItem anchors.fill: parent + anchors.topMargin: PlatformHelper.getSafeAreaMargins(app) } NymeaDiscovery {