From 37a5da4e044b44c2970dc494aaf1503b23a27092 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Thu, 3 Oct 2019 00:03:34 +0200 Subject: [PATCH] Ref T731, AFV sample default value for user name --- samples/afvclient/main.cpp | 21 ++++++++++++++++++--- samples/afvclient/qml/main.qml | 5 ++++- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/samples/afvclient/main.cpp b/samples/afvclient/main.cpp index 52113bf7c..6f73b10b8 100644 --- a/samples/afvclient/main.cpp +++ b/samples/afvclient/main.cpp @@ -3,16 +3,22 @@ #include "blackcore/afv/model/atcstationmodel.h" #include "blackcore/afv/model/afvmapreader.h" #include "blackcore/afv/clients/afvclient.h" - #include "blackcore/application.h" +#include "blackmisc/network/user.h" +#include "blackmisc/obfuscation.h" +#include "blackconfig/buildconfig.h" #include #include #include #include #include +#include +using namespace BlackConfig; using namespace BlackMisc; +using namespace BlackMisc::Network; +using namespace BlackCore; using namespace BlackCore::Afv::Clients; using namespace BlackCore::Afv::Model; @@ -21,18 +27,27 @@ int main(int argc, char *argv[]) QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QGuiApplication qa(argc, argv); - BlackCore::CApplication a("sampleafvclient", CApplicationInfo::Sample); + CApplication a("sampleafvclient", CApplicationInfo::Sample); CAfvMapReader *afvMapReader = new CAfvMapReader(&a); afvMapReader->updateFromMap(); CAfvClient voiceClient("https://voice1.vatsim.uk"); + // default user name + QString defaultUserName("1234567"); + if (CBuildConfig::isLocalDeveloperDebugBuild()) + { + CUser user("OBF:AwLZ7f9hUmpSZhm4=", "Joe Doe"); + defaultUserName = user.getId(); + } + QQmlApplicationEngine engine; QQmlContext *ctxt = engine.rootContext(); ctxt->setContextProperty("afvMapReader", afvMapReader); ctxt->setContextProperty("voiceClient", &voiceClient); - engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); + ctxt->setContextProperty("userName", defaultUserName); + engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); return a.exec(); } diff --git a/samples/afvclient/qml/main.qml b/samples/afvclient/qml/main.qml index 71a569da4..71fbc75e1 100644 --- a/samples/afvclient/qml/main.qml +++ b/samples/afvclient/qml/main.qml @@ -38,15 +38,18 @@ ApplicationWindow { Layout.fillWidth: false } + property alias mapUsername: tfUsername.text TextField { id: tfUsername + objectName: "loginUsername" width: 350 height: 25 - text: qsTr("1234567") + text: userName selectByMouse: true enabled: voiceClient.connectionStatus == 0 // Disconnected horizontalAlignment: Text.AlignLeft renderType: Text.NativeRendering + // text: qsTr("1234567") } Label {