mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 11:55:35 +08:00
As a follow up of refs #217, moved FSX settings into GUI component
This commit is contained in:
@@ -408,14 +408,6 @@ private slots:
|
||||
//! Clear single hotkey
|
||||
void clearHotkey();
|
||||
|
||||
//! Test the SIM connect connectivity
|
||||
void testSimConnectConnection();
|
||||
|
||||
//! Save a simconnect.cfg file for FSX
|
||||
void saveSimConnectCfg();
|
||||
|
||||
//! simConnect.cfg: open, exists? delete
|
||||
void simConnectCfgFile();
|
||||
};
|
||||
|
||||
#pragma pop_macro("interface")
|
||||
|
||||
@@ -461,7 +461,7 @@ QStatusBar QLabel {
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>4</number>
|
||||
<number>7</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="pg_StatusPage">
|
||||
<property name="sizePolicy">
|
||||
@@ -571,8 +571,8 @@ QStatusBar QLabel {
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>326</width>
|
||||
<height>267</height>
|
||||
<width>86</width>
|
||||
<height>59</height>
|
||||
</rect>
|
||||
</property>
|
||||
<attribute name="label">
|
||||
@@ -1801,9 +1801,9 @@ QStatusBar QLabel {
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QTabWidget" name="Simulator">
|
||||
<widget class="QTabWidget" name="tw_Settings">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
<number>3</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tb_SettingsTrafficNetwork">
|
||||
<attribute name="title">
|
||||
@@ -2292,119 +2292,20 @@ QStatusBar QLabel {
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tb_SettingsSimulator">
|
||||
<widget class="QWidget" name="tb_SettingsSimulatorFsx">
|
||||
<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>
|
||||
<widget class="BlackGui::CSettingsFsxComponent" name="comp_SettingsSimulatorFsx">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</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="3" column="0" colspan="2">
|
||||
<layout class="QHBoxLayout" name="hl_SettingsSimulatorSimconnectCfgButtons">
|
||||
<item>
|
||||
<widget class="QPushButton" name="pb_SettingsSimulatorFsxOpenSimconnectCfg">
|
||||
<property name="text">
|
||||
<string>Open</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pb_SettingsSimulatorFsxDeleteSimconnectCfg">
|
||||
<property name="text">
|
||||
<string>Delete</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>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="lbl_SettingsSimulatorFsxExistsSimconncetCfg">
|
||||
<property name="text">
|
||||
<string>"simconnect.cfg" exists?</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QWidget" name="wi_SettingsSimulatorFsxExistsSimconncetCfg" native="true">
|
||||
<layout class="QHBoxLayout" name="hl_SettingsSimulatorFsxExistsSimconncetCfg">
|
||||
<property name="spacing">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="le_SettingsSimulatorFsxExistsSimconncetCfg">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pb_SettingsSimulatorFsxExistsSimconncetCfg">
|
||||
<property name="text">
|
||||
<string>Check</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
@@ -3302,6 +3203,12 @@ QStatusBar QLabel {
|
||||
<header>blackgui/flightplancomponent.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>BlackGui::CSettingsFsxComponent</class>
|
||||
<extends>QFrame</extends>
|
||||
<header>blackgui/settingsfsxcomponent.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>cb_StatusWithDBus</tabstop>
|
||||
@@ -3343,7 +3250,7 @@ QStatusBar QLabel {
|
||||
<tabstop>te_TextMessagesUnicom</tabstop>
|
||||
<tabstop>te_TextMessagesCOM1</tabstop>
|
||||
<tabstop>te_TextMessagesCOM2</tabstop>
|
||||
<tabstop>Simulator</tabstop>
|
||||
<tabstop>tw_Settings</tabstop>
|
||||
<tabstop>tvp_SettingsTnServers</tabstop>
|
||||
<tabstop>le_SettingsTnCsName</tabstop>
|
||||
<tabstop>le_SettingsTnCsDescription</tabstop>
|
||||
|
||||
@@ -273,13 +273,6 @@ 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);
|
||||
this->connect(this->ui->pb_SettingsSimulatorFsxOpenSimconnectCfg, &QPushButton::clicked, this, &MainWindow::simConnectCfgFile);
|
||||
this->connect(this->ui->pb_SettingsSimulatorFsxDeleteSimconnectCfg, &QPushButton::clicked, this, &MainWindow::simConnectCfgFile);
|
||||
this->connect(this->ui->pb_SettingsSimulatorFsxExistsSimconncetCfg, &QPushButton::clicked, this, &MainWindow::simConnectCfgFile);
|
||||
|
||||
// no warnings in release build
|
||||
Q_UNUSED(connected);
|
||||
}
|
||||
|
||||
@@ -4,10 +4,6 @@
|
||||
#include "blackcore/dbus_server.h"
|
||||
#include "blackcore/context_network.h"
|
||||
#include "blackmisc/hwkeyboardkey.h"
|
||||
#include "blackmisc/networkutils.h"
|
||||
#include "blacksim/fsx/fsxsimulatorsetup.h"
|
||||
#include "blacksim/fsx/simconnectutilities.h"
|
||||
#include <QDesktopServices>
|
||||
|
||||
using namespace BlackCore;
|
||||
using namespace BlackMisc;
|
||||
@@ -17,7 +13,6 @@ using namespace BlackMisc::Aviation;
|
||||
using namespace BlackMisc::PhysicalQuantities;
|
||||
using namespace BlackMisc::Geo;
|
||||
using namespace BlackMisc::Settings;
|
||||
using namespace BlackSim::Fsx;
|
||||
|
||||
/*
|
||||
* Reload settings
|
||||
@@ -150,136 +145,3 @@ void MainWindow::clearHotkey()
|
||||
defaultKey.setFunction(key.getFunction());
|
||||
this->ui->tvp_SettingsMiscHotkeys->derivedModel()->update(i, defaultKey);
|
||||
}
|
||||
|
||||
/*
|
||||
* SimConnect working?
|
||||
*/
|
||||
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 (!CNetworkUtils::isValidIPv4Address(address))
|
||||
{
|
||||
this->displayStatusMessage(CStatusMessage(CStatusMessage::TypeTrafficNetwork, CStatusMessage::SeverityWarning, "IPv4 address invalid"));
|
||||
return;
|
||||
}
|
||||
if (!CNetworkUtils::isValidPort(port))
|
||||
{
|
||||
this->displayStatusMessage(CStatusMessage(CStatusMessage::TypeTrafficNetwork, CStatusMessage::SeverityWarning, "invalid port"));
|
||||
return;
|
||||
}
|
||||
quint16 p = port.toUInt();
|
||||
QString msg;
|
||||
if (!CNetworkUtils::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));
|
||||
}
|
||||
|
||||
/*
|
||||
* Save simconnect.cfg
|
||||
*/
|
||||
void MainWindow::saveSimConnectCfg()
|
||||
{
|
||||
if (!this->getIContextSimulator()) return;
|
||||
if (!this->getIContextSimulator()->isSimulatorAvailable()) return;
|
||||
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 (!CNetworkUtils::isValidIPv4Address(address))
|
||||
{
|
||||
this->displayStatusMessage(CStatusMessage(CStatusMessage::TypeTrafficNetwork, CStatusMessage::SeverityWarning, "IPv4 address invalid"));
|
||||
return;
|
||||
}
|
||||
if (!CNetworkUtils::isValidPort(port))
|
||||
{
|
||||
this->displayStatusMessage(CStatusMessage(CStatusMessage::TypeTrafficNetwork, CStatusMessage::SeverityWarning, "invalid port"));
|
||||
return;
|
||||
}
|
||||
quint16 p = port.toUInt();
|
||||
QString fileName = this->getIContextSimulator()->getSimulatorInfo().getSimulatorSetupValueAsString(CFsxSimulatorSetup::SetupSimConnectCfgFile);
|
||||
Q_ASSERT(!fileName.isEmpty());
|
||||
// write either local or remote file
|
||||
bool local = this->getIContextSimulator()->usingLocalObjects();
|
||||
bool success = local ?
|
||||
BlackSim::Fsx::CSimConnectUtilities::writeSimConnectCfg(fileName, address, p) :
|
||||
this->getIContextApplication()->writeToFile(fileName, CSimConnectUtilities::simConnectCfg(address, p));
|
||||
if (success)
|
||||
{
|
||||
QString m = QString("Written ").append(local ? " local " : "remote ").append(fileName);
|
||||
this->displayStatusMessage(CStatusMessage(CStatusMessage::TypeTrafficNetwork, CStatusMessage::SeverityInfo, m));
|
||||
}
|
||||
else
|
||||
{
|
||||
QString m = QString("Cannot write ").append(fileName);
|
||||
this->displayStatusMessage(CStatusMessage(CStatusMessage::TypeTrafficNetwork, CStatusMessage::SeverityError, m));
|
||||
}
|
||||
this->ui->pb_SettingsSimulatorFsxExistsSimconncetCfg->click(); // update status
|
||||
}
|
||||
|
||||
/*
|
||||
* simconnect.cfg: open, delete, exists?
|
||||
*/
|
||||
void MainWindow::simConnectCfgFile()
|
||||
{
|
||||
if (!this->getIContextSimulator()) return;
|
||||
if (!this->getIContextSimulator()->isSimulatorAvailable()) return;
|
||||
|
||||
QObject *sender = QObject::sender();
|
||||
if (sender == this->ui->pb_SettingsSimulatorFsxOpenSimconnectCfg)
|
||||
{
|
||||
QFileInfo fi(CSimConnectUtilities::getLocalSimConnectCfgFilename());
|
||||
QString path = QDir::toNativeSeparators(fi.absolutePath());
|
||||
QDesktopServices::openUrl(QUrl("file:///" + path));
|
||||
}
|
||||
else if (sender == this->ui->pb_SettingsSimulatorFsxDeleteSimconnectCfg)
|
||||
{
|
||||
if (!this->getIContextSimulator()) return;
|
||||
QString fileName = BlackSim::Fsx::CSimConnectUtilities::getLocalSimConnectCfgFilename();
|
||||
QString m = QString("Deleted %1 ").append(fileName);
|
||||
if (this->getIContextSimulator()->usingLocalObjects())
|
||||
{
|
||||
QFile f(fileName);
|
||||
f.remove();
|
||||
m = m.arg("locally");
|
||||
}
|
||||
else
|
||||
{
|
||||
this->getIContextApplication()->removeFile(fileName);
|
||||
m = m.arg("remotely");
|
||||
}
|
||||
this->displayStatusMessage(CStatusMessage(CStatusMessage::TypeSimulator, CStatusMessage::SeverityInfo, m));
|
||||
this->ui->pb_SettingsSimulatorFsxExistsSimconncetCfg->click(); // update status
|
||||
}
|
||||
else if (sender == this->ui->pb_SettingsSimulatorFsxExistsSimconncetCfg)
|
||||
{
|
||||
if (!this->getIContextSimulator()) return;
|
||||
QString fileName = BlackSim::Fsx::CSimConnectUtilities::getLocalSimConnectCfgFilename();
|
||||
bool exists = this->getIContextSimulator()->usingLocalObjects() ?
|
||||
QFile::exists(fileName) :
|
||||
this->getIContextApplication()->existsFile(fileName);
|
||||
if (exists)
|
||||
{
|
||||
this->ui->le_SettingsSimulatorFsxExistsSimconncetCfg->setText(fileName);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->ui->le_SettingsSimulatorFsxExistsSimconncetCfg->setText("no file");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
176
src/blackgui/settingsfsxcomponent.cpp
Normal file
176
src/blackgui/settingsfsxcomponent.cpp
Normal file
@@ -0,0 +1,176 @@
|
||||
#include "settingsfsxcomponent.h"
|
||||
#include "ui_settingsfsxcomponent.h"
|
||||
#include <QDesktopServices>
|
||||
#include <QFile>
|
||||
#include <QDir>
|
||||
#include <QFileInfo>
|
||||
|
||||
#include "blackmisc/networkutils.h"
|
||||
#include "blackmisc/statusmessage.h"
|
||||
#include "blacksim/fsx/fsxsimulatorsetup.h"
|
||||
#include "blacksim/fsx/simconnectutilities.h"
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackSim::Fsx;
|
||||
using namespace BlackMisc::Network;
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
|
||||
CSettingsFsxComponent::CSettingsFsxComponent(QWidget *parent) :
|
||||
QFrame(parent), CRuntimeBasedComponent(nullptr, false), ui(new Ui::CSettingsFsxComponent)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
this->connect(this->ui->pb_SettingsFsxTestConnection, &QPushButton::clicked, this, &CSettingsFsxComponent::testSimConnectConnection);
|
||||
this->connect(this->ui->pb_SettingsFsxSaveSimconnectCfg, &QPushButton::clicked, this, &CSettingsFsxComponent::saveSimConnectCfg);
|
||||
this->connect(this->ui->pb_SettingsFsxOpenSimconnectCfg, &QPushButton::clicked, this, &CSettingsFsxComponent::simConnectCfgFile);
|
||||
this->connect(this->ui->pb_SettingsFsxDeleteSimconnectCfg, &QPushButton::clicked, this, &CSettingsFsxComponent::simConnectCfgFile);
|
||||
this->connect(this->ui->pb_SettingsFsxExistsSimconncetCfg, &QPushButton::clicked, this, &CSettingsFsxComponent::simConnectCfgFile);
|
||||
|
||||
}
|
||||
|
||||
CSettingsFsxComponent::~CSettingsFsxComponent()
|
||||
{
|
||||
delete ui;
|
||||
}
|
||||
|
||||
/*
|
||||
* SimConnect working?
|
||||
*/
|
||||
void CSettingsFsxComponent::testSimConnectConnection()
|
||||
{
|
||||
QString address = this->ui->le_SettingsFsxAddress->text().trimmed();
|
||||
QString port = this->ui->le_SettingsFsxPort->text().trimmed();
|
||||
|
||||
if (address.isEmpty() || port.isEmpty())
|
||||
{
|
||||
this->sendStatusMessage(CStatusMessage(CStatusMessage::TypeTrafficNetwork, CStatusMessage::SeverityWarning, "no address or port"));
|
||||
return;
|
||||
}
|
||||
if (!CNetworkUtils::isValidIPv4Address(address))
|
||||
{
|
||||
this->sendStatusMessage(CStatusMessage(CStatusMessage::TypeTrafficNetwork, CStatusMessage::SeverityWarning, "IPv4 address invalid"));
|
||||
return;
|
||||
}
|
||||
if (!CNetworkUtils::isValidPort(port))
|
||||
{
|
||||
this->sendStatusMessage(CStatusMessage(CStatusMessage::TypeTrafficNetwork, CStatusMessage::SeverityWarning, "invalid port"));
|
||||
return;
|
||||
}
|
||||
quint16 p = port.toUInt();
|
||||
QString msg;
|
||||
if (!CNetworkUtils::canConnect(address, p, msg))
|
||||
{
|
||||
this->sendStatusMessage(CStatusMessage(CStatusMessage::TypeTrafficNetwork, CStatusMessage::SeverityWarning, msg));
|
||||
return;
|
||||
}
|
||||
|
||||
msg = QString("Connected to %1:%2").arg(address).arg(port);
|
||||
this->sendStatusMessage(CStatusMessage(CStatusMessage::TypeTrafficNetwork, CStatusMessage::SeverityInfo, msg));
|
||||
}
|
||||
|
||||
/*
|
||||
* Save simconnect.cfg
|
||||
*/
|
||||
void CSettingsFsxComponent::saveSimConnectCfg()
|
||||
{
|
||||
if (!this->getIContextSimulator() || !this->getIContextSimulator()->isSimulatorAvailable())
|
||||
{
|
||||
this->sendStatusMessage(CStatusMessage::getErrorMessage("Simulator not available", CStatusMessage::TypeSimulator));
|
||||
return;
|
||||
}
|
||||
QString address = this->ui->le_SettingsFsxAddress->text().trimmed();
|
||||
QString port = this->ui->le_SettingsFsxPort->text().trimmed();
|
||||
|
||||
if (address.isEmpty() || port.isEmpty())
|
||||
{
|
||||
this->sendStatusMessage(CStatusMessage(CStatusMessage::TypeTrafficNetwork, CStatusMessage::SeverityWarning, "no address or port"));
|
||||
return;
|
||||
}
|
||||
if (!CNetworkUtils::isValidIPv4Address(address))
|
||||
{
|
||||
this->sendStatusMessage(CStatusMessage(CStatusMessage::TypeTrafficNetwork, CStatusMessage::SeverityWarning, "IPv4 address invalid"));
|
||||
return;
|
||||
}
|
||||
if (!CNetworkUtils::isValidPort(port))
|
||||
{
|
||||
this->sendStatusMessage(CStatusMessage(CStatusMessage::TypeTrafficNetwork, CStatusMessage::SeverityWarning, "invalid port"));
|
||||
return;
|
||||
}
|
||||
quint16 p = port.toUInt();
|
||||
QString fileName = this->getIContextSimulator()->getSimulatorInfo().getSimulatorSetupValueAsString(CFsxSimulatorSetup::SetupSimConnectCfgFile);
|
||||
Q_ASSERT(!fileName.isEmpty());
|
||||
// write either local or remote file
|
||||
bool local = this->getIContextSimulator()->usingLocalObjects();
|
||||
bool success = local ?
|
||||
BlackSim::Fsx::CSimConnectUtilities::writeSimConnectCfg(fileName, address, p) :
|
||||
this->getIContextApplication()->writeToFile(fileName, CSimConnectUtilities::simConnectCfg(address, p));
|
||||
if (success)
|
||||
{
|
||||
QString m = QString("Written ").append(local ? " local " : "remote ").append(fileName);
|
||||
this->sendStatusMessage(CStatusMessage(CStatusMessage::TypeTrafficNetwork, CStatusMessage::SeverityInfo, m));
|
||||
}
|
||||
else
|
||||
{
|
||||
QString m = QString("Cannot write ").append(fileName);
|
||||
this->sendStatusMessage(CStatusMessage(CStatusMessage::TypeTrafficNetwork, CStatusMessage::SeverityError, m));
|
||||
}
|
||||
this->ui->pb_SettingsFsxExistsSimconncetCfg->click(); // update status
|
||||
}
|
||||
|
||||
/*
|
||||
* simconnect.cfg: open, delete, exists?
|
||||
*/
|
||||
void CSettingsFsxComponent::simConnectCfgFile()
|
||||
{
|
||||
if (!this->getIContextSimulator() || !this->getIContextSimulator()->isSimulatorAvailable())
|
||||
{
|
||||
this->sendStatusMessage(CStatusMessage::getErrorMessage("Simulator not available", CStatusMessage::TypeSimulator));
|
||||
return;
|
||||
}
|
||||
|
||||
QObject *sender = QObject::sender();
|
||||
if (sender == this->ui->pb_SettingsFsxOpenSimconnectCfg)
|
||||
{
|
||||
QFileInfo fi(CSimConnectUtilities::getLocalSimConnectCfgFilename());
|
||||
QString path = QDir::toNativeSeparators(fi.absolutePath());
|
||||
QDesktopServices::openUrl(QUrl("file:///" + path));
|
||||
}
|
||||
else if (sender == this->ui->pb_SettingsFsxDeleteSimconnectCfg)
|
||||
{
|
||||
if (!this->getIContextSimulator()) return;
|
||||
QString fileName = BlackSim::Fsx::CSimConnectUtilities::getLocalSimConnectCfgFilename();
|
||||
QString m = QString("Deleted %1 ").append(fileName);
|
||||
if (this->getIContextSimulator()->usingLocalObjects())
|
||||
{
|
||||
QFile f(fileName);
|
||||
f.remove();
|
||||
m = m.arg("locally");
|
||||
}
|
||||
else
|
||||
{
|
||||
this->getIContextApplication()->removeFile(fileName);
|
||||
m = m.arg("remotely");
|
||||
}
|
||||
this->sendStatusMessage(CStatusMessage(CStatusMessage::TypeSimulator, CStatusMessage::SeverityInfo, m));
|
||||
this->ui->pb_SettingsFsxExistsSimconncetCfg->click(); // update status
|
||||
}
|
||||
else if (sender == this->ui->pb_SettingsFsxExistsSimconncetCfg)
|
||||
{
|
||||
if (!this->getIContextSimulator()) return;
|
||||
QString fileName = BlackSim::Fsx::CSimConnectUtilities::getLocalSimConnectCfgFilename();
|
||||
bool exists = this->getIContextSimulator()->usingLocalObjects() ?
|
||||
QFile::exists(fileName) :
|
||||
this->getIContextApplication()->existsFile(fileName);
|
||||
if (exists)
|
||||
{
|
||||
this->ui->le_SettingsFsxExistsSimconncetCfg->setText(fileName);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->ui->le_SettingsFsxExistsSimconncetCfg->setText("no file");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
41
src/blackgui/settingsfsxcomponent.h
Normal file
41
src/blackgui/settingsfsxcomponent.h
Normal file
@@ -0,0 +1,41 @@
|
||||
#ifndef BLACKGUI_SETTINGSFSXCOMPONENT_H
|
||||
#define BLACKGUI_SETTINGSFSXCOMPONENT_H
|
||||
|
||||
#include "blackgui/runtimebasedcomponent.h"
|
||||
#include <QFrame>
|
||||
|
||||
namespace Ui { class CSettingsFsxComponent; }
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
|
||||
/*!
|
||||
* \brief Settings for FSX
|
||||
*/
|
||||
class CSettingsFsxComponent : public QFrame, public CRuntimeBasedComponent
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Constructor
|
||||
explicit CSettingsFsxComponent(QWidget *parent = nullptr);
|
||||
|
||||
//! Destructor
|
||||
~CSettingsFsxComponent();
|
||||
|
||||
private slots:
|
||||
//! Test the SIM connect connectivity
|
||||
void testSimConnectConnection();
|
||||
|
||||
//! Save a simconnect.cfg file for FSX
|
||||
void saveSimConnectCfg();
|
||||
|
||||
//! simConnect.cfg: open, exists? delete
|
||||
void simConnectCfgFile();
|
||||
|
||||
private:
|
||||
Ui::CSettingsFsxComponent *ui;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // guard
|
||||
161
src/blackgui/settingsfsxcomponent.ui
Normal file
161
src/blackgui/settingsfsxcomponent.ui
Normal file
@@ -0,0 +1,161 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CSettingsFsxComponent</class>
|
||||
<widget class="QFrame" name="CSettingsFsxComponent">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Frame</string>
|
||||
</property>
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="vl_SettingsFsxComponent">
|
||||
<property name="spacing">
|
||||
<number>6</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<layout class="QFormLayout" name="fl_Settings">
|
||||
<property name="fieldGrowthPolicy">
|
||||
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lbl_SettingsFsxAddress">
|
||||
<property name="text">
|
||||
<string>FSX address</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="le_SettingsFsxAddress">
|
||||
<property name="text">
|
||||
<string>127.0.0.1</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lbl_SettingsFsxPort">
|
||||
<property name="text">
|
||||
<string>FSX port</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QLineEdit" name="le_SettingsFsxPort">
|
||||
<property name="text">
|
||||
<string>500</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0" colspan="2">
|
||||
<layout class="QHBoxLayout" name="hl_SettingsSimconnectCfgButtons">
|
||||
<item>
|
||||
<widget class="QPushButton" name="pb_SettingsFsxOpenSimconnectCfg">
|
||||
<property name="text">
|
||||
<string>Open</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pb_SettingsFsxDeleteSimconnectCfg">
|
||||
<property name="text">
|
||||
<string>Delete</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pb_SettingsFsxSaveSimconnectCfg">
|
||||
<property name="text">
|
||||
<string>Save</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pb_SettingsFsxTestConnection">
|
||||
<property name="text">
|
||||
<string>Test connection</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="lbl_SettingsFsxExistsSimconncetCfg">
|
||||
<property name="text">
|
||||
<string>"simconnect.cfg" exists?</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QWidget" name="wi_SettingsFsxExistsSimconncetCfg" native="true">
|
||||
<layout class="QHBoxLayout" name="hl_SettingsFsxExistsSimconncetCfg">
|
||||
<property name="spacing">
|
||||
<number>4</number>
|
||||
</property>
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="le_SettingsFsxExistsSimconncetCfg">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="pb_SettingsFsxExistsSimconncetCfg">
|
||||
<property name="text">
|
||||
<string>Check</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<tabstops>
|
||||
<tabstop>le_SettingsFsxAddress</tabstop>
|
||||
<tabstop>le_SettingsFsxPort</tabstop>
|
||||
<tabstop>le_SettingsFsxExistsSimconncetCfg</tabstop>
|
||||
<tabstop>pb_SettingsFsxExistsSimconncetCfg</tabstop>
|
||||
<tabstop>pb_SettingsFsxOpenSimconnectCfg</tabstop>
|
||||
<tabstop>pb_SettingsFsxDeleteSimconnectCfg</tabstop>
|
||||
<tabstop>pb_SettingsFsxSaveSimconnectCfg</tabstop>
|
||||
<tabstop>pb_SettingsFsxTestConnection</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
Reference in New Issue
Block a user