mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 14:55:36 +08:00
refs #392 Add config window for FSX
* Added plugin_fsx_config subproject * Removed CSettingsFsxComponent from BlackGui * Added CSimConnectSettingsComponent * Add x-plane_install_10.txt path for Windows
This commit is contained in:
committed by
Mathew Sutcliffe
parent
cf3102333b
commit
3781cf2095
@@ -1,190 +0,0 @@
|
||||
/* Copyright (C) 2013
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* This file is part of swift Project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "settingsfsxcomponent.h"
|
||||
#include "ui_settingsfsxcomponent.h"
|
||||
#include "blackcore/context_simulator.h"
|
||||
#include "blackcore/context_application.h"
|
||||
#include "blackmisc/simulation/fsx/simconnectutilities.h"
|
||||
#include "blackmisc/network/networkutils.h"
|
||||
#include "blackmisc/statusmessage.h"
|
||||
#include "blackmisc/logmessage.h"
|
||||
#include "blackmisc/simulation/fsx/fsxsimulatorsetup.h"
|
||||
#include "blackmisc/simulation/fsx/simconnectutilities.h"
|
||||
#include <QDesktopServices>
|
||||
#include <QFile>
|
||||
#include <QDir>
|
||||
#include <QUrl>
|
||||
#include <QFileInfo>
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Simulation::Fsx;
|
||||
using namespace BlackMisc::Network;
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Components
|
||||
{
|
||||
CSettingsFsxComponent::CSettingsFsxComponent(QWidget *parent) :
|
||||
QFrame(parent), CEnableForRuntime(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()
|
||||
{ }
|
||||
|
||||
/*
|
||||
* 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())
|
||||
{
|
||||
CLogMessage(this).validationWarning("No address or port");
|
||||
return;
|
||||
}
|
||||
if (!CNetworkUtils::isValidIPv4Address(address))
|
||||
{
|
||||
CLogMessage(this).validationWarning("IPv4 address invalid");
|
||||
return;
|
||||
}
|
||||
if (!CNetworkUtils::isValidPort(port))
|
||||
{
|
||||
CLogMessage(this).validationWarning("Invalid port");
|
||||
return;
|
||||
}
|
||||
int p = port.toInt();
|
||||
QString msg;
|
||||
if (!CNetworkUtils::canConnect(address, p, msg))
|
||||
{
|
||||
CLogMessage(this).validationWarning(msg);
|
||||
return;
|
||||
}
|
||||
|
||||
CLogMessage(this).validationInfo("Connected to %1:%2") << address << port;
|
||||
}
|
||||
|
||||
/*
|
||||
* Save simconnect.cfg
|
||||
*/
|
||||
void CSettingsFsxComponent::saveSimConnectCfg()
|
||||
{
|
||||
if (!this->getIContextSimulator())
|
||||
{
|
||||
CLogMessage(this).validationError("Simulator driver not available");
|
||||
return;
|
||||
}
|
||||
QString address = this->ui->le_SettingsFsxAddress->text().trimmed();
|
||||
QString port = this->ui->le_SettingsFsxPort->text().trimmed();
|
||||
|
||||
if (address.isEmpty() || port.isEmpty())
|
||||
{
|
||||
CLogMessage(this).validationError("No address or port");
|
||||
return;
|
||||
}
|
||||
if (!CNetworkUtils::isValidIPv4Address(address))
|
||||
{
|
||||
CLogMessage(this).validationError("IPv4 address invalid");
|
||||
return;
|
||||
}
|
||||
if (!CNetworkUtils::isValidPort(port))
|
||||
{
|
||||
CLogMessage(this).validationError("Invalid port");
|
||||
return;
|
||||
}
|
||||
int p = port.toInt();
|
||||
|
||||
//! \todo filename is only available if driver has been loaded
|
||||
QString fileName = this->getIContextSimulator()->getSimulatorSetup().getStringValue(CFsxSimulatorSetup::KeyLocalSimConnectCfgFilename());
|
||||
if (fileName.isEmpty())
|
||||
{
|
||||
CLogMessage(this).validationError("Invalid or empty filename empty, driver loaded?");
|
||||
return;
|
||||
}
|
||||
|
||||
// write either local or remote file
|
||||
bool localSimulatorObject = this->getIContextSimulator()->isUsingImplementingObject();
|
||||
bool success = localSimulatorObject ?
|
||||
BlackMisc::Simulation::Fsx::CSimConnectUtilities::writeSimConnectCfg(fileName, address, p) :
|
||||
this->getIContextApplication()->writeToFile(fileName, CSimConnectUtilities::simConnectCfg(address, p));
|
||||
if (success)
|
||||
{
|
||||
CLogMessage(this).validationInfo(localSimulatorObject ? "Written local %1" : "Written remote %1") << fileName;
|
||||
}
|
||||
else
|
||||
{
|
||||
CLogMessage(this).validationError("Cannot write %1") << fileName;
|
||||
}
|
||||
this->ui->pb_SettingsFsxExistsSimconncetCfg->click(); // update status
|
||||
}
|
||||
|
||||
/*
|
||||
* simconnect.cfg: open, delete, exists?
|
||||
*/
|
||||
void CSettingsFsxComponent::simConnectCfgFile()
|
||||
{
|
||||
if (!this->getIContextSimulator())
|
||||
{
|
||||
CLogMessage(this).validationError("Simulator driver not available");
|
||||
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 = BlackMisc::Simulation::Fsx::CSimConnectUtilities::getLocalSimConnectCfgFilename();
|
||||
if (this->getIContextSimulator()->isUsingImplementingObject())
|
||||
{
|
||||
QFile f(fileName);
|
||||
f.remove();
|
||||
CLogMessage(this).info("Deleted locally %1") << fileName;
|
||||
}
|
||||
else
|
||||
{
|
||||
this->getIContextApplication()->removeFile(fileName);
|
||||
CLogMessage(this).info("Deleted remotely %1") << fileName;
|
||||
}
|
||||
this->ui->pb_SettingsFsxExistsSimconncetCfg->click(); // update status
|
||||
}
|
||||
else if (sender == this->ui->pb_SettingsFsxExistsSimconncetCfg)
|
||||
{
|
||||
if (!this->getIContextSimulator()) return;
|
||||
QString fileName = BlackMisc::Simulation::Fsx::CSimConnectUtilities::getLocalSimConnectCfgFilename();
|
||||
bool exists = this->getIContextSimulator()->isUsingImplementingObject() ?
|
||||
QFile::exists(fileName) :
|
||||
this->getIContextApplication()->existsFile(fileName);
|
||||
if (exists)
|
||||
{
|
||||
this->ui->le_SettingsFsxExistsSimconncetCfg->setText(fileName);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->ui->le_SettingsFsxExistsSimconncetCfg->setText("no file");
|
||||
}
|
||||
}
|
||||
}
|
||||
} // ns
|
||||
} // ns
|
||||
@@ -1,54 +0,0 @@
|
||||
/* Copyright (C) 2013
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* This file is part of swift Project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef BLACKGUI_SETTINGSFSXCOMPONENT_H
|
||||
#define BLACKGUI_SETTINGSFSXCOMPONENT_H
|
||||
|
||||
#include "blackgui/blackguiexport.h"
|
||||
#include "blackgui/components/enableforruntime.h"
|
||||
#include <QFrame>
|
||||
#include <QScopedPointer>
|
||||
|
||||
namespace Ui { class CSettingsFsxComponent; }
|
||||
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Components
|
||||
{
|
||||
//! Settings for FSX
|
||||
class BLACKGUI_EXPORT CSettingsFsxComponent : public QFrame, public CEnableForRuntime
|
||||
{
|
||||
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:
|
||||
QScopedPointer<Ui::CSettingsFsxComponent> ui;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif // guard
|
||||
@@ -228,10 +228,6 @@ namespace BlackGui
|
||||
|
||||
void CSettingsSimulatorComponent::ps_simulatorPluginChanged(const CSimulatorPluginInfo &info)
|
||||
{
|
||||
// disable / enable driver specific GUI parts
|
||||
bool hasFsxDriver = this->getIContextSimulator()->getAvailableSimulatorPlugins().supportsSimulator(QStringLiteral("fsx"));
|
||||
this->ui->comp_SettingsSimulatorFsx->setVisible(hasFsxDriver);
|
||||
|
||||
// I intentionally to not set the selected plugin combobox here
|
||||
// as this would cause undesired rountrips
|
||||
|
||||
@@ -281,6 +277,7 @@ namespace BlackGui
|
||||
QString configId = m_plugins->getPluginConfigId(selected->getIdentifier());
|
||||
IPluginConfig *config = m_plugins->getPluginById<IPluginConfig>(configId);
|
||||
CPluginConfigWindow *window = config->createConfigWindow(qApp->activeWindow());
|
||||
CEnableForRuntime::setRuntimeForComponents(getRuntime(), window);
|
||||
window->setAttribute(Qt::WA_DeleteOnClose);
|
||||
window->show();
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
<property name="lineWidth">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="vl_SettingsSimulatorComponent" stretch="0,0,1">
|
||||
<layout class="QVBoxLayout" name="vl_SettingsSimulatorComponent" stretch="0,1">
|
||||
<property name="leftMargin">
|
||||
<number>2</number>
|
||||
</property>
|
||||
@@ -366,16 +366,6 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="BlackGui::Components::CSettingsFsxComponent" name="comp_SettingsSimulatorFsx">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="vs_SettingsSimulator">
|
||||
<property name="orientation">
|
||||
@@ -395,12 +385,6 @@
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>BlackGui::Components::CSettingsFsxComponent</class>
|
||||
<extends>QFrame</extends>
|
||||
<header>blackgui/components/settingsfsxcomponent.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>BlackGui::CLedWidget</class>
|
||||
<extends>QWidget</extends>
|
||||
|
||||
@@ -52,11 +52,6 @@ namespace BlackGui
|
||||
|
||||
pw->layout()->addWidget(cb);
|
||||
|
||||
QPushButton *details = new QPushButton("?");
|
||||
m_detailsButtonMapper->setMapping(details, identifier);
|
||||
connect(details, &QPushButton::clicked, m_detailsButtonMapper, static_cast<void (QSignalMapper::*)()>(&QSignalMapper::map));
|
||||
pw->layout()->addWidget(details);
|
||||
|
||||
if (hasConfig) {
|
||||
QPushButton *config = new QPushButton("...");
|
||||
m_configButtonMapper->setMapping(config, identifier);
|
||||
@@ -64,6 +59,11 @@ namespace BlackGui
|
||||
pw->layout()->addWidget(config);
|
||||
}
|
||||
|
||||
QPushButton *details = new QPushButton("?");
|
||||
m_detailsButtonMapper->setMapping(details, identifier);
|
||||
connect(details, &QPushButton::clicked, m_detailsButtonMapper, static_cast<void (QSignalMapper::*)()>(&QSignalMapper::map));
|
||||
pw->layout()->addWidget(details);
|
||||
|
||||
layout->setStretch(0, 1);
|
||||
layout->setStretch(1, 0);
|
||||
layout->setStretch(2, 0);
|
||||
|
||||
@@ -20,6 +20,7 @@ LIBS += -ldxguid -lole32
|
||||
|
||||
SOURCES += *.cpp
|
||||
HEADERS += *.h
|
||||
DISTFILES += simulator_fsx.json
|
||||
|
||||
DESTDIR = $$DestRoot/bin/plugins/simulator
|
||||
|
||||
|
||||
@@ -2,5 +2,6 @@
|
||||
"identifier" : "org.swift-project.plugins.simulator.fsx",
|
||||
"name" : "Flight Simulator X",
|
||||
"simulator" : "fsx",
|
||||
"description" : "Microsoft Flight Simulator X (2006)"
|
||||
"description" : "Microsoft Flight Simulator X (2006)",
|
||||
"config" : "org.swift-project.plugins.simulator.fsx.config"
|
||||
}
|
||||
|
||||
20
src/plugins/simulator/fsx_config/plugin_fsx_config.pro
Normal file
20
src/plugins/simulator/fsx_config/plugin_fsx_config.pro
Normal file
@@ -0,0 +1,20 @@
|
||||
load(common_pre)
|
||||
|
||||
QT += core widgets dbus
|
||||
|
||||
TARGET = simulator_fsx_config
|
||||
TEMPLATE = lib
|
||||
CONFIG += plugin shared
|
||||
CONFIG += blackmisc blackcore blackgui
|
||||
|
||||
DEPENDPATH += . $$SourceRoot/src
|
||||
INCLUDEPATH += . $$SourceRoot/src
|
||||
|
||||
SOURCES += *.cpp
|
||||
HEADERS += *.h
|
||||
FORMS += *.ui
|
||||
DISTFILES += simulator_fsx_config.json
|
||||
|
||||
DESTDIR = $$BuildRoot/bin/plugins/simulator
|
||||
|
||||
load(common_post)
|
||||
166
src/plugins/simulator/fsx_config/simconnectsettingscomponent.cpp
Normal file
166
src/plugins/simulator/fsx_config/simconnectsettingscomponent.cpp
Normal file
@@ -0,0 +1,166 @@
|
||||
#include "simconnectsettingscomponent.h"
|
||||
#include "ui_simconnectsettingscomponent.h"
|
||||
#include "blackcore/context_application.h"
|
||||
#include "blackcore/context_simulator.h"
|
||||
#include "blackmisc/network/networkutils.h"
|
||||
#include "blackmisc/logmessage.h"
|
||||
#include "blackmisc/simulation/fsx/fsxsimulatorsetup.h"
|
||||
#include "blackmisc/simulation/fsx/simconnectutilities.h"
|
||||
#include <QFileInfo>
|
||||
#include <QDesktopServices>
|
||||
#include <QMessageBox>
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Simulation::Fsx;
|
||||
using namespace BlackMisc::Network;
|
||||
|
||||
namespace BlackSimPlugin
|
||||
{
|
||||
namespace Fsx
|
||||
{
|
||||
|
||||
CSimConnectSettingsComponent::CSimConnectSettingsComponent(QWidget *parent) :
|
||||
QFrame(parent),
|
||||
ui(new Ui::CSimConnectSettingsComponent)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
connect(ui->pb_SettingsFsxOpenSimconnectCfg, &QPushButton::clicked, this, &CSimConnectSettingsComponent::openSimConnectCfgFile);
|
||||
connect(ui->pb_SettingsFsxDeleteSimconnectCfg, &QPushButton::clicked, this, &CSimConnectSettingsComponent::deleteSimConnectCfgFile);
|
||||
connect(ui->pb_SettingsFsxExistsSimconncetCfg, &QPushButton::clicked, this, &CSimConnectSettingsComponent::checkSimConnectCfgFile);
|
||||
connect(ui->pb_SettingsFsxSaveSimconnectCfg, &QPushButton::clicked, this, &CSimConnectSettingsComponent::saveSimConnectCfgFile);
|
||||
connect(ui->pb_SettingsFsxTestConnection, &QPushButton::clicked, this, &CSimConnectSettingsComponent::testSimConnectConnection);
|
||||
}
|
||||
|
||||
CSimConnectSettingsComponent::~CSimConnectSettingsComponent()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CSimConnectSettingsComponent::openSimConnectCfgFile()
|
||||
{
|
||||
QFileInfo info(CSimConnectUtilities::getLocalSimConnectCfgFilename());
|
||||
QString path = QDir::toNativeSeparators(info.absolutePath());
|
||||
QDesktopServices::openUrl(QUrl(QStringLiteral("file:///") % path));
|
||||
}
|
||||
|
||||
void CSimConnectSettingsComponent::deleteSimConnectCfgFile()
|
||||
{
|
||||
QString fileName = CSimConnectUtilities::getLocalSimConnectCfgFilename();
|
||||
bool result = getIContextApplication()->removeFile(fileName);
|
||||
if (result)
|
||||
{
|
||||
QMessageBox::information(qApp->activeWindow(), tr("File deleted"),
|
||||
tr("File %1 deleted successfully.").arg(fileName));
|
||||
}
|
||||
|
||||
checkSimConnectCfgFile();
|
||||
}
|
||||
|
||||
void CSimConnectSettingsComponent::checkSimConnectCfgFile()
|
||||
{
|
||||
QString fileName = CSimConnectUtilities::getLocalSimConnectCfgFilename();
|
||||
if (getIContextApplication()->existsFile(fileName))
|
||||
{
|
||||
ui->le_SettingsFsxExistsSimconncetCfg->setText(fileName);
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->le_SettingsFsxExistsSimconncetCfg->setText("no file");
|
||||
}
|
||||
}
|
||||
|
||||
void CSimConnectSettingsComponent::testSimConnectConnection()
|
||||
{
|
||||
QString address = this->ui->le_SettingsFsxAddress->text().trimmed();
|
||||
QString port = this->ui->le_SettingsFsxPort->text().trimmed();
|
||||
|
||||
if (address.isEmpty() || port.isEmpty())
|
||||
{
|
||||
QMessageBox::warning(qApp->activeWindow(), tr("Connection invalid"),
|
||||
tr("Address and/or port not specified!"));
|
||||
return;
|
||||
}
|
||||
if (!CNetworkUtils::isValidIPv4Address(address))
|
||||
{
|
||||
QMessageBox::warning(qApp->activeWindow(), tr("Connection invalid"),
|
||||
tr("Wrong IPv4 address!"));
|
||||
return;
|
||||
}
|
||||
if (!CNetworkUtils::isValidPort(port))
|
||||
{
|
||||
QMessageBox::warning(qApp->activeWindow(), tr("Connection invalid"),
|
||||
tr("Invalid port!"));
|
||||
return;
|
||||
}
|
||||
int p = port.toInt();
|
||||
QString msg;
|
||||
if (!CNetworkUtils::canConnect(address, p, msg))
|
||||
{
|
||||
QMessageBox::warning(qApp->activeWindow(), tr("Connection invalid"), msg);
|
||||
return;
|
||||
}
|
||||
|
||||
QMessageBox::information(qApp->activeWindow(), tr("Connection successful"),
|
||||
tr("Connected to %1:%2.").arg(address, port));
|
||||
}
|
||||
|
||||
void CSimConnectSettingsComponent::saveSimConnectCfgFile()
|
||||
{
|
||||
QString address = ui->le_SettingsFsxAddress->text().trimmed();
|
||||
QString port = ui->le_SettingsFsxPort->text().trimmed();
|
||||
|
||||
if (address.isEmpty() || port.isEmpty())
|
||||
{
|
||||
QMessageBox::warning(qApp->activeWindow(), tr("Connection invalid"),
|
||||
tr("Address and/or port not specified!"));
|
||||
return;
|
||||
}
|
||||
if (!CNetworkUtils::isValidIPv4Address(address))
|
||||
{
|
||||
QMessageBox::warning(qApp->activeWindow(), tr("Connection invalid"),
|
||||
tr("Wrong IPv4 address!"));
|
||||
return;
|
||||
}
|
||||
if (!CNetworkUtils::isValidPort(port))
|
||||
{
|
||||
QMessageBox::warning(qApp->activeWindow(), tr("Connection invalid"),
|
||||
tr("Invalid port!"));
|
||||
return;
|
||||
}
|
||||
|
||||
int p = port.toInt();
|
||||
QString fileName;
|
||||
|
||||
if (getIContextSimulator())
|
||||
{
|
||||
fileName = getIContextSimulator()->getSimulatorSetup().getStringValue(CFsxSimulatorSetup::KeyLocalSimConnectCfgFilename());
|
||||
}
|
||||
|
||||
if (fileName.isEmpty())
|
||||
{
|
||||
fileName = CSimConnectUtilities::getLocalSimConnectCfgFilename();
|
||||
}
|
||||
|
||||
if (fileName.isEmpty())
|
||||
{
|
||||
QMessageBox::warning(qApp->activeWindow(), tr("Failed writing simConnect.cfg"),
|
||||
tr("No file name specified!"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (getIContextApplication()->writeToFile(fileName, CSimConnectUtilities::simConnectCfg(address, p)))
|
||||
{
|
||||
QMessageBox::information(qApp->activeWindow(), tr("File saved"),
|
||||
tr("File %1 saved.").arg(fileName));
|
||||
checkSimConnectCfgFile();
|
||||
}
|
||||
else
|
||||
{
|
||||
QMessageBox::warning(qApp->activeWindow(), tr("Failed writing simConnect.cfg"),
|
||||
tr("Failed writing %1!").arg(fileName));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
/* Copyright (C) 2015
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef BLACKSIMPLUGIN_SIMCONNECT_SETTINGS_COMPONENT_H
|
||||
#define BLACKSIMPLUGIN_SIMCONNECT_SETTINGS_COMPONENT_H
|
||||
|
||||
#include <QFrame>
|
||||
#include <QScopedPointer>
|
||||
#include "blackgui/components/enableforruntime.h"
|
||||
|
||||
namespace Ui {
|
||||
class CSimConnectSettingsComponent;
|
||||
}
|
||||
|
||||
namespace BlackSimPlugin
|
||||
{
|
||||
namespace Fsx
|
||||
{
|
||||
/**
|
||||
* A component that gathers all SimConnect-related settings.
|
||||
*/
|
||||
class CSimConnectSettingsComponent : public QFrame, public BlackGui::Components::CEnableForRuntime
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Ctor
|
||||
explicit CSimConnectSettingsComponent(QWidget *parent = nullptr);
|
||||
|
||||
//! Dtor
|
||||
~CSimConnectSettingsComponent();
|
||||
|
||||
private slots:
|
||||
//! Open simConnect.cfg using default application
|
||||
void openSimConnectCfgFile();
|
||||
|
||||
//! Delete simConnect.cfg file
|
||||
void deleteSimConnectCfgFile();
|
||||
|
||||
//! Check whether the simConnect.cfg file exists
|
||||
void checkSimConnectCfgFile();
|
||||
|
||||
//! Test the SimConnect connectivity
|
||||
void testSimConnectConnection();
|
||||
|
||||
//! Save a simconnect.cfg file for FSX
|
||||
void saveSimConnectCfgFile();
|
||||
|
||||
private:
|
||||
QScopedPointer<Ui::CSimConnectSettingsComponent> ui;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // guard
|
||||
@@ -1,40 +1,19 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CSettingsFsxComponent</class>
|
||||
<widget class="QFrame" name="CSettingsFsxComponent">
|
||||
<class>CSimConnectSettingsComponent</class>
|
||||
<widget class="QWidget" name="CSimConnectSettingsComponent">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>317</width>
|
||||
<height>141</height>
|
||||
<width>400</width>
|
||||
<height>158</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>FSX SimConnect Settings</string>
|
||||
<string>Form</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>0</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>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QGroupBox" name="gb_FsxSimConnectConfigFile">
|
||||
<property name="title">
|
||||
@@ -262,16 +241,6 @@
|
||||
</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>
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"identifier" : "org.swift-project.plugins.simulator.fsx.config"
|
||||
}
|
||||
19
src/plugins/simulator/fsx_config/simulatorfsxconfig.cpp
Normal file
19
src/plugins/simulator/fsx_config/simulatorfsxconfig.cpp
Normal file
@@ -0,0 +1,19 @@
|
||||
#include "simulatorfsxconfig.h"
|
||||
#include "simulatorfsxconfigwindow.h"
|
||||
|
||||
namespace BlackSimPlugin
|
||||
{
|
||||
namespace Fsx
|
||||
{
|
||||
|
||||
CSimulatorFsxConfig::CSimulatorFsxConfig(QObject *parent) : QObject(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
BlackGui::CPluginConfigWindow *CSimulatorFsxConfig::createConfigWindow(QWidget *parent)
|
||||
{
|
||||
return new CSimulatorFsxConfigWindow(parent);
|
||||
}
|
||||
}
|
||||
}
|
||||
43
src/plugins/simulator/fsx_config/simulatorfsxconfig.h
Normal file
43
src/plugins/simulator/fsx_config/simulatorfsxconfig.h
Normal file
@@ -0,0 +1,43 @@
|
||||
/* Copyright (C) 2015
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef BLACKSIMPLUGIN_SIMULATOR_FSX_CONFIG_H
|
||||
#define BLACKSIMPLUGIN_SIMULATOR_FSX_CONFIG_H
|
||||
|
||||
#include "blackgui/pluginconfig.h"
|
||||
#include "blackcore/settingscache.h"
|
||||
|
||||
namespace BlackSimPlugin
|
||||
{
|
||||
namespace Fsx
|
||||
{
|
||||
|
||||
class CSimulatorFsxConfig : public QObject, public BlackGui::IPluginConfig
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PLUGIN_METADATA(IID "org.swift-project.blackgui.pluginconfiginterface" FILE "simulator_fsx_config.json")
|
||||
Q_INTERFACES(BlackGui::IPluginConfig)
|
||||
|
||||
public:
|
||||
//! Ctor
|
||||
CSimulatorFsxConfig(QObject *parent = nullptr);
|
||||
|
||||
//! Dtor
|
||||
virtual ~CSimulatorFsxConfig() {}
|
||||
|
||||
//! \copydoc BlackGui::IPluginConfig::createConfigWindow()
|
||||
BlackGui::CPluginConfigWindow *createConfigWindow(QWidget *parent) override;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif // guard
|
||||
@@ -0,0 +1,27 @@
|
||||
#include "simulatorfsxconfigwindow.h"
|
||||
#include "ui_simulatorfsxconfigwindow.h"
|
||||
|
||||
|
||||
using namespace BlackGui;
|
||||
|
||||
namespace BlackSimPlugin
|
||||
{
|
||||
namespace Fsx
|
||||
{
|
||||
|
||||
CSimulatorFsxConfigWindow::CSimulatorFsxConfigWindow(QWidget *parent) :
|
||||
CPluginConfigWindow(parent),
|
||||
ui(new Ui::CSimulatorFsxConfigWindow)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
connect(ui->bb_OkCancel, &QDialogButtonBox::rejected, this, &QWidget::close);
|
||||
}
|
||||
|
||||
CSimulatorFsxConfigWindow::~CSimulatorFsxConfigWindow()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
48
src/plugins/simulator/fsx_config/simulatorfsxconfigwindow.h
Normal file
48
src/plugins/simulator/fsx_config/simulatorfsxconfigwindow.h
Normal file
@@ -0,0 +1,48 @@
|
||||
/* Copyright (C) 2015
|
||||
* swift project Community / Contributors
|
||||
*
|
||||
* This file is part of swift Project. It is subject to the license terms in the LICENSE file found in the top-level
|
||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
||||
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||
* contained in the LICENSE file.
|
||||
*/
|
||||
|
||||
//! \file
|
||||
|
||||
#ifndef BLACKSIMPLUGIN_SIMULATOR_FSX_CONFIG_WINDOW_H
|
||||
#define BLACKSIMPLUGIN_SIMULATOR_FSX_CONFIG_WINDOW_H
|
||||
|
||||
#include "simulatorfsxconfig.h"
|
||||
#include "blackgui/pluginconfigwindow.h"
|
||||
#include <QScopedPointer>
|
||||
|
||||
namespace Ui {
|
||||
class CSimulatorFsxConfigWindow;
|
||||
}
|
||||
|
||||
namespace BlackSimPlugin
|
||||
{
|
||||
namespace Fsx
|
||||
{
|
||||
|
||||
/**
|
||||
* A window the lets user set up the FSX plugin.
|
||||
*/
|
||||
class CSimulatorFsxConfigWindow : public BlackGui::CPluginConfigWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Ctor.
|
||||
CSimulatorFsxConfigWindow(QWidget *parent);
|
||||
|
||||
//! Dtor.
|
||||
virtual ~CSimulatorFsxConfigWindow();
|
||||
|
||||
private:
|
||||
QScopedPointer<Ui::CSimulatorFsxConfigWindow> ui;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif // guard
|
||||
46
src/plugins/simulator/fsx_config/simulatorfsxconfigwindow.ui
Normal file
46
src/plugins/simulator/fsx_config/simulatorfsxconfigwindow.ui
Normal file
@@ -0,0 +1,46 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CSimulatorFsxConfigWindow</class>
|
||||
<widget class="QWidget" name="CSimulatorFsxConfigWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>FSX plugin settings</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="BlackSimPlugin::Fsx::CSimConnectSettingsComponent" name="frame">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::StyledPanel</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Raised</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="bb_OkCancel">
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Close</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>BlackSimPlugin::Fsx::CSimConnectSettingsComponent</class>
|
||||
<extends>QFrame</extends>
|
||||
<header>simconnectsettingscomponent.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -1,12 +1,11 @@
|
||||
include ($$SourceRoot/config.pri)
|
||||
include ($$SourceRoot/build.pri)
|
||||
load(common_pre)
|
||||
|
||||
QT += core widgets dbus
|
||||
|
||||
TARGET = simulator_xplane_config
|
||||
TEMPLATE = lib
|
||||
CONFIG += plugin shared
|
||||
CONFIG += blackmisc blackcore
|
||||
CONFIG += blackmisc blackcore blackgui
|
||||
|
||||
DEPENDPATH += . $$SourceRoot/src
|
||||
INCLUDEPATH += . $$SourceRoot/src
|
||||
@@ -17,4 +16,5 @@ FORMS += *.ui
|
||||
DISTFILES += simulator_xplane_config.json
|
||||
|
||||
DESTDIR = $$BuildRoot/bin/plugins/simulator
|
||||
include ($$SourceRoot/libraries.pri)
|
||||
|
||||
load(common_post)
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
#include <QStringBuilder>
|
||||
#include <QFileDialog>
|
||||
#include <QMessageBox>
|
||||
#include <QStandardPaths>
|
||||
#include <QStringBuilder>
|
||||
|
||||
using namespace BlackGui;
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
|
||||
#include "simulatorxplaneconfig.h"
|
||||
#include "blackgui/pluginconfigwindow.h"
|
||||
#include <QWidget>
|
||||
#include <QScopedPointer>
|
||||
|
||||
namespace Ui {
|
||||
|
||||
Reference in New Issue
Block a user