Add info about Qt versions in about pages

This commit is contained in:
Michael Zanetti 2020-01-21 23:27:18 +01:00
parent c89bb56e0c
commit 1e89663021
6 changed files with 49 additions and 4 deletions

View File

@ -391,9 +391,9 @@ void NymeaConnection::updateActiveBearers()
{
NymeaConnection::BearerTypes availableBearerTypes;
QList<QNetworkConfiguration> configs = m_networkConfigManager->allConfigurations(QNetworkConfiguration::Active);
qDebug() << "Network configuations:" << configs.count();
// qDebug() << "Network configuations:" << configs.count();
foreach (const QNetworkConfiguration &config, configs) {
qDebug() << "Active network config:" << config.name() << config.bearerTypeFamily() << config.bearerTypeName();
// qDebug() << "Active network config:" << config.name() << config.bearerTypeFamily() << config.bearerTypeName();
// NOTE: iOS doesn't correctly report bearer types. It'll be Unknown all the time. Let's hardcode it to WiFi for that...
#if defined(Q_OS_IOS)

View File

@ -150,6 +150,15 @@ void JsonRpcClient::deployCertificateReply(const QVariantMap &data)
qDebug() << "deploy certificate reply:" << data;
}
void JsonRpcClient::getVersionsReply(const QVariantMap &data)
{
m_serverQtVersion = data.value("params").toMap().value("qtVersion").toString();
m_serverQtBuildVersion = data.value("params").toMap().value("qtBuildVersion").toString();
if (!m_serverQtVersion.isEmpty()) {
emit serverQtVersionChanged();
}
}
bool JsonRpcClient::connected() const
{
return m_connected;
@ -202,6 +211,22 @@ QString JsonRpcClient::serverUuid() const
return m_serverUuid;
}
QString JsonRpcClient::serverQtVersion()
{
if (!m_serverQtVersion.isEmpty()) {
return m_serverQtVersion;
}
if (ensureServerVersion("4.0")) {
sendCommand("JSONRPC.Version", QVariantMap(), this, "getVersionsReply");
}
return QString();
}
QString JsonRpcClient::serverQtBuildVersion()
{
return m_serverQtBuildVersion;
}
int JsonRpcClient::createUser(const QString &username, const QString &password)
{
QVariantMap params;
@ -336,10 +361,13 @@ void JsonRpcClient::sendRequest(const QVariantMap &request)
void JsonRpcClient::onInterfaceConnectedChanged(bool connected)
{
if (!connected) {
qDebug() << "JsonRpcClient: Transport disconnected.";
m_initialSetupRequired = false;
m_authenticationRequired = false;
m_serverQtVersion.clear();
m_serverQtBuildVersion.clear();
if (m_connected) {
m_connected = false;
emit connectedChanged(false);

View File

@ -44,6 +44,8 @@ class JsonRpcClient : public JsonHandler
Q_PROPERTY(QString serverVersion READ serverVersion NOTIFY handshakeReceived)
Q_PROPERTY(QString jsonRpcVersion READ jsonRpcVersion NOTIFY handshakeReceived)
Q_PROPERTY(QString serverUuid READ serverUuid NOTIFY handshakeReceived)
Q_PROPERTY(QString serverQtVersion READ serverQtVersion NOTIFY serverQtVersionChanged)
Q_PROPERTY(QString serverQtBuildVersion READ serverQtBuildVersion NOTIFY serverQtVersionChanged)
public:
enum CloudConnectionState {
@ -75,6 +77,8 @@ public:
QString serverVersion() const;
QString jsonRpcVersion() const;
QString serverUuid() const;
QString serverQtVersion();
QString serverQtBuildVersion();
// ui methods
Q_INVOKABLE int createUser(const QString &username, const QString &password);
@ -97,6 +101,7 @@ signals:
void createUserSucceeded();
void createUserFailed(const QString &error);
void cloudConnectionStateChanged();
void serverQtVersionChanged();
void responseReceived(const int &commandId, const QVariantMap &response);
@ -125,6 +130,8 @@ private:
QString m_serverUuid;
QVersionNumber m_jsonRpcVersion;
QString m_serverVersion;
QString m_serverQtVersion;
QString m_serverQtBuildVersion;
QByteArray m_token;
QByteArray m_receiveBuffer;
@ -141,6 +148,7 @@ private:
Q_INVOKABLE void isCloudConnectedReply(const QVariantMap &data);
Q_INVOKABLE void setupRemoteAccessReply(const QVariantMap &data);
Q_INVOKABLE void deployCertificateReply(const QVariantMap &data);
Q_INVOKABLE void getVersionsReply(const QVariantMap &data);
void sendRequest(const QVariantMap &request);

View File

@ -124,7 +124,8 @@ int main(int argc, char *argv[])
engine->rootContext()->setContextProperty("appBranding", "");
#endif
engine->rootContext()->setContextProperty("appVersion", APP_VERSION);
engine->rootContext()->setContextProperty("qtVersion", QT_VERSION_STR);
engine->rootContext()->setContextProperty("qtBuildVersion", QT_VERSION_STR);
engine->rootContext()->setContextProperty("qtVersion", qVersion());
StyleController styleController;
engine->rootContext()->setContextProperty("styleController", &styleController);

View File

@ -33,7 +33,7 @@ Page {
NymeaListItemDelegate {
Layout.fillWidth: true
text: qsTr("Qt version:")
subText: qtVersion
subText: qtVersion + (qtBuildVersion !== qtVersion ? " (" + qsTr("Built with %1").arg(qtBuildVersion) + ")" : "")
progressive: false
prominentSubText: false
}

View File

@ -50,6 +50,14 @@ Page {
progressive: false
prominentSubText: false
}
NymeaListItemDelegate {
Layout.fillWidth: true
text: qsTr("Qt version:")
visible: engine.jsonRpcClient.ensureServerVersion("4.1")
subText: engine.jsonRpcClient.serverQtVersion + (engine.jsonRpcClient.serverQtVersion !== engine.jsonRpcClient.serverQtBuildVersion ? + " (" + qsTr("Built with %1").arg(engine.jsonRpcClient.serverQtBuildVersion) + ")" : "")
progressive: false
prominentSubText: false
}
}
}
}