mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-05 17:35:34 +08:00
refs #273, own settings component (GUI)
This commit is contained in:
@@ -527,7 +527,7 @@
|
|||||||
</attribute>
|
</attribute>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
<item>
|
<item>
|
||||||
<widget class="BlackGui::CSettingsFsxComponent" name="comp_SettingsSimulatorFsx">
|
<widget class="BlackGui::CSettingsSimulatorComponent" name="comp_SettingsSimulator">
|
||||||
<property name="frameShape">
|
<property name="frameShape">
|
||||||
<enum>QFrame::StyledPanel</enum>
|
<enum>QFrame::StyledPanel</enum>
|
||||||
</property>
|
</property>
|
||||||
@@ -743,9 +743,9 @@
|
|||||||
<header>blackgui/serverview.h</header>
|
<header>blackgui/serverview.h</header>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
<class>BlackGui::CSettingsFsxComponent</class>
|
<class>BlackGui::CSettingsSimulatorComponent</class>
|
||||||
<extends>QFrame</extends>
|
<extends>QFrame</extends>
|
||||||
<header>blackgui/settingsfsxcomponent.h</header>
|
<header>blackgui/settingssimulatorcomponent.h</header>
|
||||||
<container>1</container>
|
<container>1</container>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>400</width>
|
<width>400</width>
|
||||||
<height>300</height>
|
<height>150</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@@ -40,35 +40,35 @@
|
|||||||
<property name="fieldGrowthPolicy">
|
<property name="fieldGrowthPolicy">
|
||||||
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
|
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
|
||||||
</property>
|
</property>
|
||||||
<item row="0" column="0">
|
<item row="1" column="0">
|
||||||
<widget class="QLabel" name="lbl_SettingsFsxAddress">
|
<widget class="QLabel" name="lbl_SettingsFsxAddress">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>FSX address</string>
|
<string>FSX address</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1">
|
<item row="1" column="1">
|
||||||
<widget class="QLineEdit" name="le_SettingsFsxAddress">
|
<widget class="QLineEdit" name="le_SettingsFsxAddress">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>127.0.0.1</string>
|
<string>127.0.0.1</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="2" column="0">
|
||||||
<widget class="QLabel" name="lbl_SettingsFsxPort">
|
<widget class="QLabel" name="lbl_SettingsFsxPort">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>FSX port</string>
|
<string>FSX port</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1">
|
<item row="2" column="1">
|
||||||
<widget class="QLineEdit" name="le_SettingsFsxPort">
|
<widget class="QLineEdit" name="le_SettingsFsxPort">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>500</string>
|
<string>500</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="0" colspan="2">
|
<item row="4" column="0" colspan="2">
|
||||||
<layout class="QHBoxLayout" name="hl_SettingsSimconnectCfgButtons">
|
<layout class="QHBoxLayout" name="hl_SettingsSimconnectCfgButtons">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="pb_SettingsFsxOpenSimconnectCfg">
|
<widget class="QPushButton" name="pb_SettingsFsxOpenSimconnectCfg">
|
||||||
@@ -100,14 +100,14 @@
|
|||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="3" column="0">
|
||||||
<widget class="QLabel" name="lbl_SettingsFsxExistsSimconncetCfg">
|
<widget class="QLabel" name="lbl_SettingsFsxExistsSimconncetCfg">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>"simconnect.cfg" exists?</string>
|
<string>"simconnect.cfg" exists?</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="1">
|
<item row="3" column="1">
|
||||||
<widget class="QWidget" name="wi_SettingsFsxExistsSimconncetCfg" native="true">
|
<widget class="QWidget" name="wi_SettingsFsxExistsSimconncetCfg" native="true">
|
||||||
<layout class="QHBoxLayout" name="hl_SettingsFsxExistsSimconncetCfg">
|
<layout class="QHBoxLayout" name="hl_SettingsFsxExistsSimconncetCfg">
|
||||||
<property name="spacing">
|
<property name="spacing">
|
||||||
@@ -142,6 +142,13 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="0" column="0" colspan="2">
|
||||||
|
<widget class="QLabel" name="lbl_HeaderFsxSimConnect">
|
||||||
|
<property name="text">
|
||||||
|
<string><html><head/><body><p><span style=" font-size:10pt; font-weight:600;">FSX simconnect config files</span></p></body></html></string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
|||||||
74
src/blackgui/settingssimulatorcomponent.cpp
Normal file
74
src/blackgui/settingssimulatorcomponent.cpp
Normal file
@@ -0,0 +1,74 @@
|
|||||||
|
#include "settingssimulatorcomponent.h"
|
||||||
|
#include "ui_settingssimulatorcomponent.h"
|
||||||
|
|
||||||
|
#include "blackcore/context_settings.h"
|
||||||
|
#include "blacksim/simulatorinfolist.h"
|
||||||
|
#include "blacksim/setsimulator.h"
|
||||||
|
#include "blackmisc/settingutilities.h"
|
||||||
|
|
||||||
|
#include <QComboBox>
|
||||||
|
|
||||||
|
using namespace BlackMisc;
|
||||||
|
using namespace BlackMisc::Settings;
|
||||||
|
using namespace BlackSim;
|
||||||
|
using namespace BlackSim::Settings;
|
||||||
|
using namespace BlackCore;
|
||||||
|
|
||||||
|
namespace BlackGui
|
||||||
|
{
|
||||||
|
CSettingsSimulatorComponent::CSettingsSimulatorComponent(QWidget *parent) :
|
||||||
|
QFrame(parent), CRuntimeBasedComponent(nullptr, false),
|
||||||
|
ui(new Ui::CSettingsSimulatorComponent)
|
||||||
|
{
|
||||||
|
ui->setupUi(this);
|
||||||
|
bool connected = this->connect(this->ui->cb_SimulatorDriver, SIGNAL(currentIndexChanged(int)), this, SLOT(driverHasChanged(int)));
|
||||||
|
Q_ASSERT(connected);
|
||||||
|
Q_UNUSED(connected);
|
||||||
|
}
|
||||||
|
|
||||||
|
CSettingsSimulatorComponent::~CSettingsSimulatorComponent()
|
||||||
|
{
|
||||||
|
delete ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSettingsSimulatorComponent::runtimeHasBeenSet()
|
||||||
|
{
|
||||||
|
Q_ASSERT(this->getIContextSimulator());
|
||||||
|
if (this->getIContextSimulator())
|
||||||
|
{
|
||||||
|
QStringList drivers = this->getIContextSimulator()->getAvailableSimulatorPlugins().toStringList(true);
|
||||||
|
this->ui->cb_SimulatorDriver->addItems(drivers);
|
||||||
|
|
||||||
|
bool fsxDriver =
|
||||||
|
this->getIContextSimulator()->getAvailableSimulatorPlugins().supportsSimulator(CSimulatorInfo::FSX());
|
||||||
|
this->ui->comp_SettingsSimulatorFsx->setVisible(fsxDriver);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CSettingsSimulatorComponent::driverHasChanged(int index)
|
||||||
|
{
|
||||||
|
Q_ASSERT(this->getIContextSimulator());
|
||||||
|
Q_ASSERT(this->getIContextSettings());
|
||||||
|
if (!this->getIContextSimulator() || !this->getIContextSettings()) return;
|
||||||
|
|
||||||
|
CSimulatorInfoList simDrivers = this->getIContextSimulator()->getAvailableSimulatorPlugins();
|
||||||
|
if (simDrivers.isEmpty())
|
||||||
|
{
|
||||||
|
this->sendStatusMessage(CStatusMessage::getErrorMessage("No drivers available", CStatusMessage::TypeSimulator));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (simDrivers.size() <= index)
|
||||||
|
{
|
||||||
|
this->sendStatusMessage(CStatusMessage::getErrorMessage("Wrong driver index", CStatusMessage::TypeSimulator));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// update
|
||||||
|
CSimulatorInfo currentDriver = simDrivers[index];
|
||||||
|
const QString path = CSettingUtilities::appendPaths(IContextSettings::PathSimulatorSettings(), CSettingsSimulator::ValueSelectedDriver());
|
||||||
|
this->sendStatusMessages(
|
||||||
|
this->getIContextSettings()->value(path, CSettingUtilities::CmdUpdate(), currentDriver.toCVariant())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace
|
||||||
38
src/blackgui/settingssimulatorcomponent.h
Normal file
38
src/blackgui/settingssimulatorcomponent.h
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
#ifndef BLACKGUI_SETTINGSSIMULATORCOMPONENT_H
|
||||||
|
#define BLACKGUI_SETTINGSSIMULATORCOMPONENT_H
|
||||||
|
|
||||||
|
#include "runtimebasedcomponent.h"
|
||||||
|
#include <QFrame>
|
||||||
|
|
||||||
|
namespace Ui { class CSettingsSimulatorComponent; }
|
||||||
|
|
||||||
|
namespace BlackGui
|
||||||
|
{
|
||||||
|
/*!
|
||||||
|
* All simulator settings component (GUI)
|
||||||
|
*/
|
||||||
|
class CSettingsSimulatorComponent : public QFrame, public CRuntimeBasedComponent
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
//! Constructor
|
||||||
|
explicit CSettingsSimulatorComponent(QWidget *parent = nullptr);
|
||||||
|
|
||||||
|
//! Destructor
|
||||||
|
~CSettingsSimulatorComponent();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
//! \copydoc CRuntimeBasedComponent::runtimeHasBeenSet()
|
||||||
|
virtual void runtimeHasBeenSet() override;
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
//! Driver changed
|
||||||
|
void driverHasChanged(int index);
|
||||||
|
|
||||||
|
private:
|
||||||
|
Ui::CSettingsSimulatorComponent *ui; //!< UI
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace
|
||||||
|
#endif // guard
|
||||||
89
src/blackgui/settingssimulatorcomponent.ui
Normal file
89
src/blackgui/settingssimulatorcomponent.ui
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>CSettingsSimulatorComponent</class>
|
||||||
|
<widget class="QFrame" name="CSettingsSimulatorComponent">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>424</width>
|
||||||
|
<height>318</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_SettingsSimulatorComponent">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>2</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="QGridLayout" name="ql_SettingsSimulatorsAll">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<layout class="QFormLayout" name="fl_SettingsSimulatorsAll">
|
||||||
|
<item row="1" column="0">
|
||||||
|
<widget class="QLabel" name="lbl_SimulatorDriver">
|
||||||
|
<property name="text">
|
||||||
|
<string>Driver</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="QComboBox" name="cb_SimulatorDriver"/>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="0" colspan="2">
|
||||||
|
<widget class="QLabel" name="lbl_SettingsSimulatorAllHeader">
|
||||||
|
<property name="text">
|
||||||
|
<string><html><head/><body><p><span style=" font-size:10pt; font-weight:600;">All simulators</span></p></body></html></string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QGridLayout" name="gl_SettingsSimulatorsSpecific">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="BlackGui::CSettingsFsxComponent" name="comp_SettingsSimulatorFsx">
|
||||||
|
<property name="frameShape">
|
||||||
|
<enum>QFrame::StyledPanel</enum>
|
||||||
|
</property>
|
||||||
|
<property name="frameShadow">
|
||||||
|
<enum>QFrame::Raised</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<customwidgets>
|
||||||
|
<customwidget>
|
||||||
|
<class>BlackGui::CSettingsFsxComponent</class>
|
||||||
|
<extends>QFrame</extends>
|
||||||
|
<header>blackgui/settingsfsxcomponent.h</header>
|
||||||
|
<container>1</container>
|
||||||
|
</customwidget>
|
||||||
|
</customwidgets>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
||||||
Reference in New Issue
Block a user