From 3781cf209546909664b93c7a4e5728e321cac304 Mon Sep 17 00:00:00 2001 From: Michal Garapich Date: Tue, 6 Oct 2015 19:35:23 +0200 Subject: [PATCH] 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 --- .../components/settingsfsxcomponent.cpp | 190 ------------------ .../components/settingsfsxcomponent.h | 54 ----- .../components/settingssimulatorcomponent.cpp | 5 +- .../components/settingssimulatorcomponent.ui | 18 +- src/blackgui/pluginselector.cpp | 10 +- src/plugins/simulator/fsx/plugin_fsx.pro | 1 + src/plugins/simulator/fsx/simulator_fsx.json | 3 +- .../fsx_config/plugin_fsx_config.pro | 20 ++ .../simconnectsettingscomponent.cpp | 166 +++++++++++++++ .../fsx_config/simconnectsettingscomponent.h | 65 ++++++ .../simconnectsettingscomponent.ui} | 43 +--- .../fsx_config/simulator_fsx_config.json | 3 + .../fsx_config/simulatorfsxconfig.cpp | 19 ++ .../simulator/fsx_config/simulatorfsxconfig.h | 43 ++++ .../fsx_config/simulatorfsxconfigwindow.cpp | 27 +++ .../fsx_config/simulatorfsxconfigwindow.h | 48 +++++ .../fsx_config/simulatorfsxconfigwindow.ui | 46 +++++ .../xplane_config/plugin_xplane_config.pro | 8 +- .../simulatorxplaneconfigwindow.cpp | 2 + .../simulatorxplaneconfigwindow.h | 1 - swift.pro | 1 + 21 files changed, 460 insertions(+), 313 deletions(-) delete mode 100644 src/blackgui/components/settingsfsxcomponent.cpp delete mode 100644 src/blackgui/components/settingsfsxcomponent.h create mode 100644 src/plugins/simulator/fsx_config/plugin_fsx_config.pro create mode 100644 src/plugins/simulator/fsx_config/simconnectsettingscomponent.cpp create mode 100644 src/plugins/simulator/fsx_config/simconnectsettingscomponent.h rename src/{blackgui/components/settingsfsxcomponent.ui => plugins/simulator/fsx_config/simconnectsettingscomponent.ui} (86%) create mode 100644 src/plugins/simulator/fsx_config/simulator_fsx_config.json create mode 100644 src/plugins/simulator/fsx_config/simulatorfsxconfig.cpp create mode 100644 src/plugins/simulator/fsx_config/simulatorfsxconfig.h create mode 100644 src/plugins/simulator/fsx_config/simulatorfsxconfigwindow.cpp create mode 100644 src/plugins/simulator/fsx_config/simulatorfsxconfigwindow.h create mode 100644 src/plugins/simulator/fsx_config/simulatorfsxconfigwindow.ui diff --git a/src/blackgui/components/settingsfsxcomponent.cpp b/src/blackgui/components/settingsfsxcomponent.cpp deleted file mode 100644 index a046e4b2a..000000000 --- a/src/blackgui/components/settingsfsxcomponent.cpp +++ /dev/null @@ -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 -#include -#include -#include -#include - -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 diff --git a/src/blackgui/components/settingsfsxcomponent.h b/src/blackgui/components/settingsfsxcomponent.h deleted file mode 100644 index e8df770b2..000000000 --- a/src/blackgui/components/settingsfsxcomponent.h +++ /dev/null @@ -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 -#include - -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; - }; - } -} - -#endif // guard diff --git a/src/blackgui/components/settingssimulatorcomponent.cpp b/src/blackgui/components/settingssimulatorcomponent.cpp index a53130aab..6d05aaade 100644 --- a/src/blackgui/components/settingssimulatorcomponent.cpp +++ b/src/blackgui/components/settingssimulatorcomponent.cpp @@ -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(configId); CPluginConfigWindow *window = config->createConfigWindow(qApp->activeWindow()); + CEnableForRuntime::setRuntimeForComponents(getRuntime(), window); window->setAttribute(Qt::WA_DeleteOnClose); window->show(); } diff --git a/src/blackgui/components/settingssimulatorcomponent.ui b/src/blackgui/components/settingssimulatorcomponent.ui index e8caf06a5..65e747b5d 100644 --- a/src/blackgui/components/settingssimulatorcomponent.ui +++ b/src/blackgui/components/settingssimulatorcomponent.ui @@ -22,7 +22,7 @@ 0 - + 2 @@ -366,16 +366,6 @@ - - - - - 0 - 0 - - - - @@ -395,12 +385,6 @@ - - BlackGui::Components::CSettingsFsxComponent - QFrame -
blackgui/components/settingsfsxcomponent.h
- 1 -
BlackGui::CLedWidget QWidget diff --git a/src/blackgui/pluginselector.cpp b/src/blackgui/pluginselector.cpp index d0e51a984..733ab51ed 100644 --- a/src/blackgui/pluginselector.cpp +++ b/src/blackgui/pluginselector.cpp @@ -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(&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(&QSignalMapper::map)); + pw->layout()->addWidget(details); + layout->setStretch(0, 1); layout->setStretch(1, 0); layout->setStretch(2, 0); diff --git a/src/plugins/simulator/fsx/plugin_fsx.pro b/src/plugins/simulator/fsx/plugin_fsx.pro index 74d1c9502..ec02178ab 100644 --- a/src/plugins/simulator/fsx/plugin_fsx.pro +++ b/src/plugins/simulator/fsx/plugin_fsx.pro @@ -20,6 +20,7 @@ LIBS += -ldxguid -lole32 SOURCES += *.cpp HEADERS += *.h +DISTFILES += simulator_fsx.json DESTDIR = $$DestRoot/bin/plugins/simulator diff --git a/src/plugins/simulator/fsx/simulator_fsx.json b/src/plugins/simulator/fsx/simulator_fsx.json index e089531b9..da893b9b7 100644 --- a/src/plugins/simulator/fsx/simulator_fsx.json +++ b/src/plugins/simulator/fsx/simulator_fsx.json @@ -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" } diff --git a/src/plugins/simulator/fsx_config/plugin_fsx_config.pro b/src/plugins/simulator/fsx_config/plugin_fsx_config.pro new file mode 100644 index 000000000..449c17d8b --- /dev/null +++ b/src/plugins/simulator/fsx_config/plugin_fsx_config.pro @@ -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) diff --git a/src/plugins/simulator/fsx_config/simconnectsettingscomponent.cpp b/src/plugins/simulator/fsx_config/simconnectsettingscomponent.cpp new file mode 100644 index 000000000..d995a00fd --- /dev/null +++ b/src/plugins/simulator/fsx_config/simconnectsettingscomponent.cpp @@ -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 +#include +#include + +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)); + } + } + + } +} diff --git a/src/plugins/simulator/fsx_config/simconnectsettingscomponent.h b/src/plugins/simulator/fsx_config/simconnectsettingscomponent.h new file mode 100644 index 000000000..8c1ab2545 --- /dev/null +++ b/src/plugins/simulator/fsx_config/simconnectsettingscomponent.h @@ -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 +#include +#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; + + }; + + } +} + +#endif // guard diff --git a/src/blackgui/components/settingsfsxcomponent.ui b/src/plugins/simulator/fsx_config/simconnectsettingscomponent.ui similarity index 86% rename from src/blackgui/components/settingsfsxcomponent.ui rename to src/plugins/simulator/fsx_config/simconnectsettingscomponent.ui index 751ac0fba..8a7d8c1a4 100644 --- a/src/blackgui/components/settingsfsxcomponent.ui +++ b/src/plugins/simulator/fsx_config/simconnectsettingscomponent.ui @@ -1,40 +1,19 @@ - CSettingsFsxComponent - + CSimConnectSettingsComponent + 0 0 - 317 - 141 + 400 + 158 - FSX SimConnect Settings + Form - - QFrame::StyledPanel - - - QFrame::Raised - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - + @@ -262,16 +241,6 @@ - - le_SettingsFsxAddress - le_SettingsFsxPort - le_SettingsFsxExistsSimconncetCfg - pb_SettingsFsxExistsSimconncetCfg - pb_SettingsFsxOpenSimconnectCfg - pb_SettingsFsxDeleteSimconnectCfg - pb_SettingsFsxSaveSimconnectCfg - pb_SettingsFsxTestConnection - diff --git a/src/plugins/simulator/fsx_config/simulator_fsx_config.json b/src/plugins/simulator/fsx_config/simulator_fsx_config.json new file mode 100644 index 000000000..f597c8d88 --- /dev/null +++ b/src/plugins/simulator/fsx_config/simulator_fsx_config.json @@ -0,0 +1,3 @@ +{ + "identifier" : "org.swift-project.plugins.simulator.fsx.config" +} diff --git a/src/plugins/simulator/fsx_config/simulatorfsxconfig.cpp b/src/plugins/simulator/fsx_config/simulatorfsxconfig.cpp new file mode 100644 index 000000000..ab893d259 --- /dev/null +++ b/src/plugins/simulator/fsx_config/simulatorfsxconfig.cpp @@ -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); + } + } +} diff --git a/src/plugins/simulator/fsx_config/simulatorfsxconfig.h b/src/plugins/simulator/fsx_config/simulatorfsxconfig.h new file mode 100644 index 000000000..dd6d2f407 --- /dev/null +++ b/src/plugins/simulator/fsx_config/simulatorfsxconfig.h @@ -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 diff --git a/src/plugins/simulator/fsx_config/simulatorfsxconfigwindow.cpp b/src/plugins/simulator/fsx_config/simulatorfsxconfigwindow.cpp new file mode 100644 index 000000000..cea7bd81d --- /dev/null +++ b/src/plugins/simulator/fsx_config/simulatorfsxconfigwindow.cpp @@ -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() + { + + } + + } +} diff --git a/src/plugins/simulator/fsx_config/simulatorfsxconfigwindow.h b/src/plugins/simulator/fsx_config/simulatorfsxconfigwindow.h new file mode 100644 index 000000000..2ad0fad46 --- /dev/null +++ b/src/plugins/simulator/fsx_config/simulatorfsxconfigwindow.h @@ -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 + +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; + }; + } +} + +#endif // guard diff --git a/src/plugins/simulator/fsx_config/simulatorfsxconfigwindow.ui b/src/plugins/simulator/fsx_config/simulatorfsxconfigwindow.ui new file mode 100644 index 000000000..5fc5d17fd --- /dev/null +++ b/src/plugins/simulator/fsx_config/simulatorfsxconfigwindow.ui @@ -0,0 +1,46 @@ + + + CSimulatorFsxConfigWindow + + + + 0 + 0 + 400 + 300 + + + + FSX plugin settings + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + QDialogButtonBox::Close + + + + + + + + BlackSimPlugin::Fsx::CSimConnectSettingsComponent + QFrame +
simconnectsettingscomponent.h
+ 1 +
+
+ + +
diff --git a/src/plugins/simulator/xplane_config/plugin_xplane_config.pro b/src/plugins/simulator/xplane_config/plugin_xplane_config.pro index 2e2e5948a..e7d09acd2 100644 --- a/src/plugins/simulator/xplane_config/plugin_xplane_config.pro +++ b/src/plugins/simulator/xplane_config/plugin_xplane_config.pro @@ -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) diff --git a/src/plugins/simulator/xplane_config/simulatorxplaneconfigwindow.cpp b/src/plugins/simulator/xplane_config/simulatorxplaneconfigwindow.cpp index 9d04abb35..13d361c2b 100644 --- a/src/plugins/simulator/xplane_config/simulatorxplaneconfigwindow.cpp +++ b/src/plugins/simulator/xplane_config/simulatorxplaneconfigwindow.cpp @@ -5,6 +5,8 @@ #include #include #include +#include +#include using namespace BlackGui; diff --git a/src/plugins/simulator/xplane_config/simulatorxplaneconfigwindow.h b/src/plugins/simulator/xplane_config/simulatorxplaneconfigwindow.h index 8dc62b92e..ac7a43b62 100644 --- a/src/plugins/simulator/xplane_config/simulatorxplaneconfigwindow.h +++ b/src/plugins/simulator/xplane_config/simulatorxplaneconfigwindow.h @@ -14,7 +14,6 @@ #include "simulatorxplaneconfig.h" #include "blackgui/pluginconfigwindow.h" -#include #include namespace Ui { diff --git a/swift.pro b/swift.pro index 0bfd5d95a..71f19c99d 100644 --- a/swift.pro +++ b/swift.pro @@ -42,6 +42,7 @@ win32 { contains(BLACK_CONFIG, FSX) { SUBDIRS += src/plugins/simulator/fsx/plugin_fsx.pro + SUBDIRS += src/plugins/simulator/fsx_config/plugin_fsx_config.pro } contains(BLACK_CONFIG, FS9) { SUBDIRS += src/plugins/simulator/fs9/plugin_fs9.pro