Re-check bearers when app resumes from standby
This commit is contained in:
parent
a0834a0dc6
commit
ffc4d64ae6
@ -11,6 +11,7 @@
|
|||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
#include <QGuiApplication>
|
||||||
|
|
||||||
#include "nymeatransportinterface.h"
|
#include "nymeatransportinterface.h"
|
||||||
|
|
||||||
@ -29,6 +30,12 @@ NymeaConnection::NymeaConnection(QObject *parent) : QObject(parent)
|
|||||||
updateActiveBearers();
|
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();
|
updateActiveBearers();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,7 +137,7 @@ Connection *NymeaConnection::currentConnection() const
|
|||||||
void NymeaConnection::sendData(const QByteArray &data)
|
void NymeaConnection::sendData(const QByteArray &data)
|
||||||
{
|
{
|
||||||
if (connected()) {
|
if (connected()) {
|
||||||
// qDebug() << "sending data:" << data;
|
qDebug() << "sending data:" << data;
|
||||||
m_currentTransport->sendData(data);
|
m_currentTransport->sendData(data);
|
||||||
} else {
|
} else {
|
||||||
qWarning() << "Connection: Not connected. Cannot send.";
|
qWarning() << "Connection: Not connected. Cannot send.";
|
||||||
@ -328,9 +335,10 @@ void NymeaConnection::onDisconnected()
|
|||||||
t->deleteLater();
|
t->deleteLater();
|
||||||
|
|
||||||
if (!m_currentTransport && m_transportCandidates.isEmpty()) {
|
if (!m_currentTransport && m_transportCandidates.isEmpty()) {
|
||||||
qDebug() << "Last connection dropped. Trying to reconnect..";
|
qDebug() << "Last connection dropped.";
|
||||||
QTimer::singleShot(1000, this, [this](){
|
QTimer::singleShot(1000, this, [this](){
|
||||||
if (m_currentHost) {
|
if (m_currentHost) {
|
||||||
|
qDebug() << "Trying to reconnect..";
|
||||||
connectInternal(m_currentHost);
|
connectInternal(m_currentHost);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -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
|
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
|
||||||
|
|||||||
@ -1,8 +1,22 @@
|
|||||||
#include "platformhelper.h"
|
#include "platformhelper.h"
|
||||||
|
|
||||||
|
#include <QtGui/qpa/qplatformwindow.h>
|
||||||
|
|
||||||
PlatformHelper::PlatformHelper(QObject *parent) : QObject(parent)
|
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
|
#define PLATFORMHELPER_H
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
#include <QQuickWindow>
|
||||||
|
|
||||||
class PlatformHelper : public QObject
|
class PlatformHelper : public QObject
|
||||||
{
|
{
|
||||||
@ -35,6 +36,7 @@ public:
|
|||||||
|
|
||||||
Q_INVOKABLE virtual void vibrate(HapticsFeedback feedbackType) = 0;
|
Q_INVOKABLE virtual void vibrate(HapticsFeedback feedbackType) = 0;
|
||||||
|
|
||||||
|
Q_INVOKABLE QVariantMap getSafeAreaMargins(QQuickWindow *window);
|
||||||
signals:
|
signals:
|
||||||
void permissionsRequestFinished();
|
void permissionsRequestFinished();
|
||||||
};
|
};
|
||||||
|
|||||||
@ -16,6 +16,7 @@ ApplicationWindow {
|
|||||||
visibility: ApplicationWindow.AutomaticVisibility
|
visibility: ApplicationWindow.AutomaticVisibility
|
||||||
font: Qt.application.font
|
font: Qt.application.font
|
||||||
|
|
||||||
|
|
||||||
// Those variables must be present in the Style
|
// Those variables must be present in the Style
|
||||||
title: appName
|
title: appName
|
||||||
Material.primary: primaryColor
|
Material.primary: primaryColor
|
||||||
@ -49,6 +50,7 @@ ApplicationWindow {
|
|||||||
RootItem {
|
RootItem {
|
||||||
id: rootItem
|
id: rootItem
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
|
anchors.topMargin: PlatformHelper.getSafeAreaMargins(app)
|
||||||
}
|
}
|
||||||
|
|
||||||
NymeaDiscovery {
|
NymeaDiscovery {
|
||||||
|
|||||||
Reference in New Issue
Block a user