mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 23:05:36 +08:00
refs #185 , added config panel for FSX to GUI. Allows to write a simconnect.cfg, if FSX is running remotely.
This commit is contained in:
@@ -5,9 +5,7 @@
|
||||
#include "blackcore/context_network.h"
|
||||
#include "blackcore/context_application.h"
|
||||
#include "blackcore/network.h"
|
||||
|
||||
#include "blackmisc/avaircraft.h"
|
||||
|
||||
#include <QMouseEvent>
|
||||
|
||||
using namespace BlackCore;
|
||||
|
||||
@@ -318,8 +318,8 @@ private:
|
||||
* \brief Play notifcation sound
|
||||
*/
|
||||
void playNotifcationSound(BlackSound::CSoundGenerator::Notification notification) const;
|
||||
|
||||
//! \brief Update simulator page with latest user aircraft data
|
||||
|
||||
//! \brief Update simulator page with latest user aircraft data
|
||||
void updateSimulatorData();
|
||||
|
||||
private slots:
|
||||
@@ -405,14 +405,10 @@ private slots:
|
||||
*/
|
||||
void toggleNetworkConnection();
|
||||
|
||||
/*!
|
||||
* \brief Menu item clicked
|
||||
*/
|
||||
//! \brief Menu item clicked
|
||||
void menuClicked();
|
||||
|
||||
/*!
|
||||
* \brief Terminated connection
|
||||
*/
|
||||
//! \brief Terminated connection
|
||||
void connectionTerminated();
|
||||
|
||||
/*!
|
||||
@@ -432,9 +428,7 @@ private slots:
|
||||
*/
|
||||
void alterTrafficServer();
|
||||
|
||||
/*!
|
||||
* \brief Network settings have been changed
|
||||
*/
|
||||
//! \brief Network settings have been changed
|
||||
void changedSettings();
|
||||
|
||||
/*!
|
||||
@@ -454,28 +448,19 @@ private slots:
|
||||
*/
|
||||
void middlePanelChanged(int index);
|
||||
|
||||
/*!
|
||||
* \brief Command entered
|
||||
*/
|
||||
//! \brief Command entered
|
||||
void commandEntered();
|
||||
|
||||
/*!
|
||||
* \brief Get METAR
|
||||
* \param airportIcaoCode
|
||||
*/
|
||||
//! \brief Get METAR for given ICAO airport code
|
||||
void getMetar(const QString &airportIcaoCode = "");
|
||||
|
||||
//! \brief Request new ATIS
|
||||
void requestAtis();
|
||||
|
||||
/*!
|
||||
* \brief Close text message tab
|
||||
*/
|
||||
//! \brief Close text message tab
|
||||
void closeTextMessageTab();
|
||||
|
||||
/*!
|
||||
* \brief Cockpit values changed
|
||||
*/
|
||||
//! \brief Cockpit values changed
|
||||
void cockpitValuesChanged();
|
||||
|
||||
/*!
|
||||
@@ -484,9 +469,7 @@ private slots:
|
||||
*/
|
||||
void audioDeviceSelected(int index);
|
||||
|
||||
/*!
|
||||
* \brief Reset transponder to Standby / Charly
|
||||
*/
|
||||
//! \brief Reset transponder to Standby / Charly
|
||||
void resetTransponderMode();
|
||||
|
||||
/*!
|
||||
@@ -525,6 +508,13 @@ private slots:
|
||||
|
||||
//! Clear single hotkey
|
||||
void clearHotkey();
|
||||
|
||||
//! Test the SIM connect connectivity
|
||||
void testSimConnectConnection();
|
||||
|
||||
//! Save a simconnect.cfg file for FSX
|
||||
void saveSimConnectCfg();
|
||||
|
||||
};
|
||||
|
||||
#pragma pop_macro("interface")
|
||||
|
||||
@@ -1798,9 +1798,9 @@ QStatusBar QLabel {
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QTabWidget" name="tb_Settings">
|
||||
<widget class="QTabWidget" name="Simulator">
|
||||
<property name="currentIndex">
|
||||
<number>4</number>
|
||||
<number>3</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tb_SettingsTrafficNetwork">
|
||||
<attribute name="title">
|
||||
@@ -2289,6 +2289,73 @@ QStatusBar QLabel {
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tb_SettingsSimulator">
|
||||
<attribute name="title">
|
||||
<string>Simulator</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<layout class="QFormLayout" name="fl_SettingsSimulator">
|
||||
<property name="fieldGrowthPolicy">
|
||||
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lbl_SettingsSimulatorFsxAddress">
|
||||
<property name="text">
|
||||
<string>FSX address</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="le_SettingsSimulatorFsxAddress">
|
||||
<property name="text">
|
||||
<string>127.0.0.1</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lbl_SettingsSimulatorFsxPort">
|
||||
<property name="text">
|
||||
<string>FSX port</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="le_SettingsSimulatorFsxPort">
|
||||
<property name="text">
|
||||
<string>500</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
<item>
|
||||
<widget class="QPushButton" name="pb_SettingsSimulatorFsxOpenSimconnectCfg">
|
||||
<property name="text">
|
||||
<string>Open</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pb_SettingsSimulatorFsxSaveSimconnectCfg">
|
||||
<property name="text">
|
||||
<string>Save</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pb_SettingsSimulatorFsxTestConnection">
|
||||
<property name="text">
|
||||
<string>Test connection</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tb_SettingsGui">
|
||||
<attribute name="title">
|
||||
<string>GUI</string>
|
||||
@@ -3168,7 +3235,7 @@ QStatusBar QLabel {
|
||||
<tabstop>te_TextMessagesUnicom</tabstop>
|
||||
<tabstop>te_TextMessagesCOM1</tabstop>
|
||||
<tabstop>te_TextMessagesCOM2</tabstop>
|
||||
<tabstop>tb_Settings</tabstop>
|
||||
<tabstop>Simulator</tabstop>
|
||||
<tabstop>tv_SettingsTnServers</tabstop>
|
||||
<tabstop>le_SettingsTnCsName</tabstop>
|
||||
<tabstop>le_SettingsTnCsDescription</tabstop>
|
||||
|
||||
@@ -367,6 +367,10 @@ void MainWindow::initGuiSignals()
|
||||
this->connect(this->ui->pb_SettingsMiscSave, &QPushButton::clicked, this, &MainWindow::saveHotkeys);
|
||||
this->connect(this->ui->pb_SettingsMiscRemove, &QPushButton::clicked, this, &MainWindow::clearHotkey);
|
||||
|
||||
// Settings simulator
|
||||
this->connect(this->ui->pb_SettingsSimulatorFsxTestConnection, &QPushButton::clicked, this, &MainWindow::testSimConnectConnection);
|
||||
this->connect(this->ui->pb_SettingsSimulatorFsxSaveSimconnectCfg, &QPushButton::clicked, this, &MainWindow::saveSimConnectCfg);
|
||||
|
||||
// no warnings in release build
|
||||
Q_UNUSED(connected);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
#include "blackcore/dbus_server.h"
|
||||
#include "blackcore/context_network.h"
|
||||
#include "blackmisc/hwkeyboardkey.h"
|
||||
#include "blackmisc/networkchecks.h"
|
||||
#include "blacksim/fsx/simconnectutilities.h"
|
||||
|
||||
using namespace BlackCore;
|
||||
using namespace BlackMisc;
|
||||
@@ -13,6 +15,7 @@ using namespace BlackMisc::Aviation;
|
||||
using namespace BlackMisc::PhysicalQuantities;
|
||||
using namespace BlackMisc::Geo;
|
||||
using namespace BlackMisc::Settings;
|
||||
using namespace BlackSim::Fsx;
|
||||
|
||||
/*
|
||||
* Reload settings
|
||||
@@ -146,3 +149,69 @@ void MainWindow::clearHotkey()
|
||||
defKey.setFunction(key.getFunction());
|
||||
this->m_modelSettingsHotKeys->update(i, defKey);
|
||||
}
|
||||
|
||||
void MainWindow::testSimConnectConnection()
|
||||
{
|
||||
QString address = this->ui->le_SettingsSimulatorFsxAddress->text().trimmed();
|
||||
QString port = this->ui->le_SettingsSimulatorFsxPort->text().trimmed();
|
||||
|
||||
if (address.isEmpty() || port.isEmpty())
|
||||
{
|
||||
this->displayStatusMessage(CStatusMessage(CStatusMessage::TypeTrafficNetwork, CStatusMessage::SeverityWarning, "no address or port"));
|
||||
return;
|
||||
}
|
||||
if (!CNetworkChecks::isValidIPv4Address(address))
|
||||
{
|
||||
this->displayStatusMessage(CStatusMessage(CStatusMessage::TypeTrafficNetwork, CStatusMessage::SeverityWarning, "IPv4 address invalid"));
|
||||
return;
|
||||
}
|
||||
if (!CNetworkChecks::isValidPort(port))
|
||||
{
|
||||
this->displayStatusMessage(CStatusMessage(CStatusMessage::TypeTrafficNetwork, CStatusMessage::SeverityWarning, "invalid port"));
|
||||
return;
|
||||
}
|
||||
quint16 p = port.toUInt();
|
||||
QString msg;
|
||||
if (!CNetworkChecks::canConnect(address, p, msg))
|
||||
{
|
||||
this->displayStatusMessage(CStatusMessage(CStatusMessage::TypeTrafficNetwork, CStatusMessage::SeverityWarning, msg));
|
||||
return;
|
||||
}
|
||||
|
||||
msg = QString("Connected to %1:%2").arg(address).arg(port);
|
||||
this->displayStatusMessage(CStatusMessage(CStatusMessage::TypeTrafficNetwork, CStatusMessage::SeverityInfo, msg));
|
||||
}
|
||||
|
||||
void MainWindow::saveSimConnectCfg()
|
||||
{
|
||||
QString address = this->ui->le_SettingsSimulatorFsxAddress->text().trimmed();
|
||||
QString port = this->ui->le_SettingsSimulatorFsxPort->text().trimmed();
|
||||
|
||||
if (address.isEmpty() || port.isEmpty())
|
||||
{
|
||||
this->displayStatusMessage(CStatusMessage(CStatusMessage::TypeTrafficNetwork, CStatusMessage::SeverityWarning, "no address or port"));
|
||||
return;
|
||||
}
|
||||
if (!CNetworkChecks::isValidIPv4Address(address))
|
||||
{
|
||||
this->displayStatusMessage(CStatusMessage(CStatusMessage::TypeTrafficNetwork, CStatusMessage::SeverityWarning, "IPv4 address invalid"));
|
||||
return;
|
||||
}
|
||||
if (!CNetworkChecks::isValidPort(port))
|
||||
{
|
||||
this->displayStatusMessage(CStatusMessage(CStatusMessage::TypeTrafficNetwork, CStatusMessage::SeverityWarning, "invalid port"));
|
||||
return;
|
||||
}
|
||||
quint16 p = port.toUInt();
|
||||
QString file = CSimConnectUtilities::getLocalSimConnectCfgFilename();
|
||||
if (CSimConnectUtilities::writeSimConnectCfg(file, address, p))
|
||||
{
|
||||
QString m = QString("Written ").append(file);
|
||||
this->displayStatusMessage(CStatusMessage(CStatusMessage::TypeTrafficNetwork, CStatusMessage::SeverityInfo, m));
|
||||
}
|
||||
else
|
||||
{
|
||||
QString m = QString("Cannot write ").append(file);
|
||||
this->displayStatusMessage(CStatusMessage(CStatusMessage::TypeTrafficNetwork, CStatusMessage::SeverityError, m));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,20 +10,22 @@ TEMPLATE = app
|
||||
SOURCES += *.cpp
|
||||
HEADERS += *.h
|
||||
FORMS += *.ui
|
||||
CONFIG += blackmisc blacksound blackcore blackgui
|
||||
CONFIG += blackmisc blacksound blackcore blackgui blacksim
|
||||
|
||||
DEPENDPATH += . ../../src/blackmisc ../../src/blackgui ../../src/blacksound ../../src/blackcore
|
||||
DEPENDPATH += . ../../src/blackmisc ../../src/blackgui ../../src/blacksound ../../src/blacksim ../../src/blackcore
|
||||
INCLUDEPATH += . ../../src
|
||||
|
||||
DESTDIR = ../../bin
|
||||
|
||||
win32:!win32-g++*: PRE_TARGETDEPS += ../../lib/blackmisc.lib \
|
||||
../../lib/blackgui.lib \
|
||||
../../lib/blacksim.lib \
|
||||
../../lib/blacksound.lib \
|
||||
../../lib/blackcore.lib
|
||||
|
||||
else: PRE_TARGETDEPS += ../../lib/libblackmisc.a \
|
||||
../../lib/libblackgui.a \
|
||||
../../lib/libblacksim.a \
|
||||
../../lib/libblacksound.a \
|
||||
../../lib/libblackcore.a
|
||||
|
||||
|
||||
Reference in New Issue
Block a user