Re-check bearers when app resumes from standby
This commit is contained in:
parent
a0834a0dc6
commit
ffc4d64ae6
@ -11,6 +11,7 @@
|
||||
#include <QFile>
|
||||
#include <QDir>
|
||||
#include <QTimer>
|
||||
#include <QGuiApplication>
|
||||
|
||||
#include "nymeatransportinterface.h"
|
||||
|
||||
@ -29,6 +30,12 @@ NymeaConnection::NymeaConnection(QObject *parent) : QObject(parent)
|
||||
updateActiveBearers();
|
||||
});
|
||||
|
||||
QGuiApplication *app = static_cast<QGuiApplication*>(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);
|
||||
}
|
||||
});
|
||||
|
||||
@ -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
|
||||
|
||||
@ -1,8 +1,22 @@
|
||||
#include "platformhelper.h"
|
||||
|
||||
#include <QtGui/qpa/qplatformwindow.h>
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
#define PLATFORMHELPER_H
|
||||
|
||||
#include <QObject>
|
||||
#include <QQuickWindow>
|
||||
|
||||
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();
|
||||
};
|
||||
|
||||
@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user