From 840633749e21d917bd679442ed09c20fc83f6c88 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Thu, 26 Sep 2019 14:33:26 +0200 Subject: [PATCH] Ref T731, simplified form of ATC station map --- src/blackgui/components/afvmapdialog.cpp | 25 +- src/blackgui/components/afvmapdialog.ui | 11 +- src/blackgui/qml/AFVMap.qml | 328 ++--------------------- 3 files changed, 47 insertions(+), 317 deletions(-) diff --git a/src/blackgui/components/afvmapdialog.cpp b/src/blackgui/components/afvmapdialog.cpp index d94290829..16e9bb58f 100644 --- a/src/blackgui/components/afvmapdialog.cpp +++ b/src/blackgui/components/afvmapdialog.cpp @@ -6,14 +6,15 @@ * or distributed except according to the terms contained in the LICENSE file. */ -//! \file - +#include "blackgui/guiapplication.h" +#include "blackcore/context/contextaudioimpl.h" #include "blackcore/afv/clients/afvclient.h" #include "blackcore/afv/model/afvmapreader.h" #include "afvmapdialog.h" #include "ui_afvmapdialog.h" #include +#include using namespace BlackCore::Afv::Model; using namespace BlackCore::Afv::Clients; @@ -26,14 +27,28 @@ namespace BlackGui QDialog(parent), ui(new Ui::CAfvMapDialog) { - ui->setupUi(this); m_afvMapReader = new CAfvMapReader(this); m_afvMapReader->updateFromMap(); - m_afvClient = new CAfvClient("https://voice1.vatsim.uk"); + if (sGui && !sGui->isShuttingDown() && sGui->getIContextAudio()) + { + if (sGui->getIContextAudio()->isUsingImplementingObject()) + { + m_afvClient = &sGui->getCoreFacade()->getCContextAudio()->voiceClient(); + } + } + + ui->setupUi(this); QQmlContext *ctxt = ui->qw_AfvMap->rootContext(); ctxt->setContextProperty("afvMapReader", m_afvMapReader); - ctxt->setContextProperty("voiceClient", m_afvClient); + + if (m_afvClient) + { + ctxt->setContextProperty("voiceClient", m_afvClient); + } + + // ui->qw_AfvMap->engine()->setBaseUrl(":/blackgui/qml"); + ui->qw_AfvMap->setSource(QUrl("qrc:/blackgui/qml/AFVMap.qml")); } CAfvMapDialog::~CAfvMapDialog() { } diff --git a/src/blackgui/components/afvmapdialog.ui b/src/blackgui/components/afvmapdialog.ui index 067508f07..a9c384638 100644 --- a/src/blackgui/components/afvmapdialog.ui +++ b/src/blackgui/components/afvmapdialog.ui @@ -11,19 +11,14 @@ - Dialog + AFV map - + QQuickWidget::SizeRootObjectToView - - - qrc:/blackgui/qml/AFVMap.qml - - @@ -32,7 +27,7 @@ Qt::Horizontal - QDialogButtonBox::Cancel|QDialogButtonBox::Ok + QDialogButtonBox::Close diff --git a/src/blackgui/qml/AFVMap.qml b/src/blackgui/qml/AFVMap.qml index 50a5e1615..06df1516f 100644 --- a/src/blackgui/qml/AFVMap.qml +++ b/src/blackgui/qml/AFVMap.qml @@ -16,305 +16,16 @@ Rectangle { name: "osm" } - Grid { - id: leftGrid - columns: 2 - rows: 6 - spacing: 10 - padding: 10 - anchors.left: parent.left - anchors.top: parent.top - anchors.topMargin: 5 - anchors.leftMargin: 10 - - Label { - id: lblUsername - width: 100 - text: qsTr("Username") - verticalAlignment: Text.AlignVCenter - Layout.fillHeight: true - Layout.fillWidth: false - } - - TextField { - id: tfUsername - width: 350 - height: 25 - text: qsTr("1234567") - selectByMouse: true - enabled: voiceClient.connectionStatus == 0 // Disconnected - horizontalAlignment: Text.AlignLeft - renderType: Text.NativeRendering - } - - Label { - id: lblPassword - width: 100 - text: qsTr("Password") - Layout.fillWidth: false - Layout.fillHeight: false - verticalAlignment: Text.AlignVCenter - } - - TextField { - id: tfPassword - width: 350 - height: 25 - text: qsTr("123456") - selectByMouse: true - enabled: voiceClient.connectionStatus == 0 // Disconnected - echoMode: TextInput.PasswordEchoOnEdit - horizontalAlignment: Text.AlignLeft - renderType: Text.NativeRendering - } - - Label { - id: lblCallsign - width: 100 - text: qsTr("Callsign") - Layout.fillWidth: false - Layout.fillHeight: false - verticalAlignment: Text.AlignVCenter - } - - TextField { - id: tfCallsign - width: 350 - height: 25 - text: qsTr("DECHK") - selectByMouse: true - enabled: voiceClient.connectionStatus == 0 // Disconnected - horizontalAlignment: Text.AlignLeft - renderType: Text.NativeRendering - } - - Label { - id: lblInputDevice - width: 100 - text: qsTr("Input Device") - verticalAlignment: Text.AlignVCenter - Layout.fillHeight: false - Layout.fillWidth: false - } - - ComboBox { - id: cbInputDevices - width: 350 - height: 25 - model: voiceClient.availableInputDevices() - } - - Label { - id: lblOutputDevice - width: 100 - text: qsTr("Output Device") - verticalAlignment: Text.AlignVCenter - Layout.fillHeight: false - Layout.fillWidth: false - } - - ComboBox { - id: cbOutputDevices - width: 350 - height: 25 - model: voiceClient.availableOutputDevices() - } - - Frame { - background: Rectangle { - color: "transparent" - border.color: "transparent" - } - } - - Row { - spacing: 10 - - Button { - id: btConnect - width: 170 - height: 25 - text: voiceClient.connectionStatus == 0 ? "Connect" : "Disconnect" - onClicked: { - if (voiceClient.connectionStatus == 0) { - voiceClient.connectTo(tfUsername.text, tfPassword.text, tfCallsign.text) - afvMapReader.setOwnCallsign(tfCallsign.text) - } else if (voiceClient.connectionStatus == 1) { - voiceClient.disconnectFrom() - } - } - } - - Button { - id: btStartAudio - - property bool started: false - width: 170 - height: 25 - text: qsTr("Start Audio") - onClicked: { - btStartAudio.enabled = false - cbInputDevices.enabled = false - cbOutputDevices.enabled = false - voiceClient.start(cbInputDevices.currentText, cbOutputDevices.currentText) - } - } - } - } - - Grid { - id: rightGrid - padding: 10 - anchors.top: parent.top - anchors.left: leftGrid.right - anchors.right: parent.right - spacing: 10 - rows: 3 - columns: 3 - - Transceiver { - id: transceiver1 - transceiverId: 0 - onRxOnChanged: { - voiceClient.enableTransceiver(transceiverId, rxOn) - } - } - - SpinBox { - id: sbAltitude - width: 150 - height: 40 - stepSize: 500 - to: 50000 - from: 0 - value: 1000 - } - - Label { - id: lblReceivingCom1 - height: 40 - text: qsTr("Receiving: ") + voiceClient.receivingCallsignsCom1 - verticalAlignment: Text.AlignVCenter - } - - Transceiver { - id: transceiver2 - transceiverId: 1 - txOn: false - onRxOnChanged: { - voiceClient.enableTransceiver(transceiverId, rxOn) - } - } - - Button { - id: btUpdateStack - width: 150 - height: 40 - text: qsTr("Update Stack") - onClicked: { - voiceClient.updateComFrequency(0, transceiver1.frequency * 1000) - voiceClient.updateComFrequency(1, transceiver2.frequency * 1000) - voiceClient.updatePosition(map.center.latitude, map.center.longitude, sbAltitude.value) - } - } - - Label { - id: lblReceivingCom2 - height: 40 - text: qsTr("Receiving: ") + voiceClient.receivingCallsignsCom2 - verticalAlignment: Text.AlignVCenter - // anchors.verticalCenter: parent.verticalCenter - } - } - - Column { - id: column - spacing: 10 - anchors.top: rightGrid.bottom - anchors.left: leftGrid.right - anchors.right: parent.right - - ProgressBar { - id: pbAudioInput - width: 500 - height: 25 - anchors.left: parent.left - anchors.leftMargin: 10 - value: voiceClient.inputVolumePeakVU - } - - ProgressBar { - id: pbAudioOutput - width: 500 - height: 25 - anchors.left: parent.left - anchors.leftMargin: 10 - value: voiceClient.outputVolumePeakVU - } - } - - Row { - padding: 0 - spacing: 10 - anchors.top: column.bottom - anchors.left: leftGrid.right - anchors.right: parent.right - - CheckBox { - id: cbVhfEffects - text: qsTr("VHF Effects") - checked: true - anchors.verticalCenter: parent.verticalCenter - onClicked: voiceClient.setBypassEffects(!checked) - } - - CheckBox { - id: cbLoopback - text: qsTr("Loopback") - checked: false - anchors.verticalCenter: parent.verticalCenter - onClicked: voiceClient.setLoopBack(checked) - } - - Button { - id: btPtt - width: 150 - height: 40 - text: qsTr("PTT") - onPressed: voiceClient.setPtt(true) - onReleased: voiceClient.setPtt(false) - background: Rectangle { - implicitWidth: btPtt.width - implicitHeight: btPtt.height - color: btPtt.down ? "lightgreen" : "lightgrey" - border.width: 1 - radius: 2 - } - } - - Label { - function translateStatus(status) { - switch(status) { - case 0: return "Disconnected" - case 1: return "Connected" - default: return "Unknown" - } - } - - id: lblStatus - text: "Status: " + translateStatus(voiceClient.connectionStatus) - verticalAlignment: Text.AlignVCenter - anchors.verticalCenter: parent.verticalCenter - } - } - Map { id: map - anchors.topMargin: 5 - anchors.top: leftGrid.bottom - anchors.bottom: parent.bottom - anchors.left: parent.left - anchors.right: parent.right + anchors.fill: parent + /** + anchors.topMargin: 5 + anchors.top: leftGrid.bottom + anchors.bottom: parent.bottom + anchors.left: parent.left + anchors.right: parent.right + **/ plugin: mapPlugin center: QtPositioning.coordinate(48.50, 11.50) // Oslo zoomLevel: 3 @@ -339,10 +50,9 @@ Rectangle { onSelected: { map.center = QtPositioning.coordinate(latitude, longitude) transceiver1.frequency = frequency - voiceClient.updateComFrequency(0, transceiver1.frequency * 1000) - voiceClient.updateComFrequency(1, transceiver2.frequency * 1000) - voiceClient.updatePosition(map.center.latitude, map.center.longitude, sbAltitude.value) - + // voiceClient.updateComFrequency(0, transceiver1.frequency * 1000) + // voiceClient.updateComFrequency(1, transceiver2.frequency * 1000) + voiceClient.updatePosition(map.center.latitude, map.center.longitude, sbAltitude.value ) } } } @@ -386,14 +96,24 @@ Rectangle { anchors.bottomMargin: 20 onClicked: map.zoomLevel = map.zoomLevel - 1 } + + SpinBox { + id: sbAltitude + width: 150 + height: 40 + stepSize: 500 + to: 50000 + from: 0 + value: 1000 + } } Timer { interval: 5000; running: true; repeat: true onTriggered: { - voiceClient.updateComFrequency(0, transceiver1.frequency * 1000) - voiceClient.updateComFrequency(1, transceiver2.frequency * 1000) - voiceClient.updatePosition(map.center.latitude, map.center.longitude, sbAltitude.value) + // voiceClient.updateComFrequency(0, transceiver1.frequency * 1000) + // voiceClient.updateComFrequency(1, transceiver2.frequency * 1000) + voiceClient.updatePosition(map.center.latitude, map.center.longitude, sbAltitude.value ) } } }