mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 14:55:36 +08:00
Ref T709, UI for XPlane settings (plugin config window)
This commit is contained in:
committed by
Mat Sutcliffe
parent
49a9a767a3
commit
dd6e14e2c8
@@ -16,6 +16,7 @@
|
||||
|
||||
using namespace BlackGui;
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Simulation::Settings;
|
||||
using namespace BlackMisc::Simulation::XPlane;
|
||||
|
||||
namespace BlackSimPlugin
|
||||
@@ -27,8 +28,15 @@ namespace BlackSimPlugin
|
||||
ui(new Ui::CSimulatorXPlaneConfigWindow)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
ui->comp_SettingsXSwiftBus->setDefaultP2PAddress(m_xswiftbusServerSetting.getDefault());
|
||||
ui->comp_SettingsXSwiftBus->set(m_xswiftbusServerSetting.getThreadLocal());
|
||||
ui->comp_SettingsXSwiftBus->setDefaultP2PAddress(m_xSwiftBusServerSettings.getDefault().getDBusServerAddressQt());
|
||||
|
||||
const CXSwiftBusSettings defaultSettings = TXSwiftBusSettings::defaultValue();
|
||||
ui->sb_MaxAircraft->setMaximum(defaultSettings.getMaxPlanes() * 2);
|
||||
ui->sb_FollowAircraftDistanceM->setMaximum(defaultSettings.getFollowAircraftDistanceM() * 5);
|
||||
ui->ds_MaxDrawDistanceNM->setMaximum(qRound(defaultSettings.getMaxDrawDistanceNM() * 3));
|
||||
|
||||
const CXSwiftBusSettings s = m_xSwiftBusServerSettings.getThreadLocal();
|
||||
this->setUiValues(s);
|
||||
|
||||
connect(ui->bb_OkCancel, &QDialogButtonBox::accepted, this, &CSimulatorXPlaneConfigWindow::onSettingsAccepted);
|
||||
connect(ui->bb_OkCancel, &QDialogButtonBox::rejected, this, &CSimulatorXPlaneConfigWindow::close);
|
||||
@@ -39,16 +47,39 @@ namespace BlackSimPlugin
|
||||
|
||||
void CSimulatorXPlaneConfigWindow::onSettingsAccepted()
|
||||
{
|
||||
const QString currentAddress = m_xswiftbusServerSetting.getThreadLocal();
|
||||
const QString updatedAddress = ui->comp_SettingsXSwiftBus->getDBusAddress();
|
||||
if (currentAddress != ui->comp_SettingsXSwiftBus->getDBusAddress())
|
||||
const CXSwiftBusSettings s = m_xSwiftBusServerSettings.getThreadLocal();
|
||||
const CXSwiftBusSettings changed = this->getSettingsFromUI();
|
||||
if (s != changed)
|
||||
{
|
||||
m_xswiftbusServerSetting.set(updatedAddress);
|
||||
m_xSwiftBusServerSettings.set(changed);
|
||||
CXSwiftBusConfigWriter xswiftbusConfigWriter;
|
||||
xswiftbusConfigWriter.setDBusAddress(updatedAddress);
|
||||
xswiftbusConfigWriter.setDBusAddress(changed.getDBusServerAddressQt());
|
||||
xswiftbusConfigWriter.updateInAllXPlaneVersions();
|
||||
}
|
||||
close();
|
||||
this->close();
|
||||
}
|
||||
|
||||
CXSwiftBusSettings CSimulatorXPlaneConfigWindow::getSettingsFromUI() const
|
||||
{
|
||||
CXSwiftBusSettings s = m_xSwiftBusServerSettings.getThreadLocal();
|
||||
s.setDBusServerAddressQt(ui->comp_SettingsXSwiftBus->getDBusAddress());
|
||||
s.setMaxDrawDistanceNM(ui->ds_MaxDrawDistanceNM->value());
|
||||
s.setMaxPlanes(ui->sb_MaxAircraft->value());
|
||||
s.setDrawingLabels(ui->cb_DrawLabels->isChecked());
|
||||
return s;
|
||||
}
|
||||
|
||||
void CSimulatorXPlaneConfigWindow::setUiValues(const CXSwiftBusSettings &settings)
|
||||
{
|
||||
ui->comp_SettingsXSwiftBus->set(settings.getDBusServerAddressQt());
|
||||
ui->sb_MaxAircraft->setValue(settings.getMaxPlanes());
|
||||
ui->cb_DrawLabels->setChecked(settings.isDrawingLabels());
|
||||
ui->ds_MaxDrawDistanceNM->setValue(settings.getMaxDrawDistanceNM());
|
||||
}
|
||||
|
||||
void CSimulatorXPlaneConfigWindow::onSettingsChanged()
|
||||
{
|
||||
this->setUiValues(m_xSwiftBusServerSettings.get());
|
||||
}
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
@@ -34,14 +34,23 @@ namespace BlackSimPlugin
|
||||
CSimulatorXPlaneConfigWindow(QWidget *parent);
|
||||
|
||||
//! Dtor.
|
||||
virtual ~CSimulatorXPlaneConfigWindow();
|
||||
virtual ~CSimulatorXPlaneConfigWindow() override;
|
||||
|
||||
private:
|
||||
//! Settings have been accepted
|
||||
void onSettingsAccepted();
|
||||
|
||||
//! Settings from UI
|
||||
BlackMisc::Simulation::Settings::CXSwiftBusSettings getSettingsFromUI() const;
|
||||
|
||||
//! Set settings
|
||||
void setUiValues(const BlackMisc::Simulation::Settings::CXSwiftBusSettings &settings);
|
||||
|
||||
//! Settings changed
|
||||
void onSettingsChanged();
|
||||
|
||||
QScopedPointer<Ui::CSimulatorXPlaneConfigWindow> ui;
|
||||
BlackMisc::CSetting<BlackMisc::Simulation::Settings::TXSwiftBusServer> m_xswiftbusServerSetting { this };
|
||||
BlackMisc::CSetting<BlackMisc::Simulation::Settings::TXSwiftBusSettings> m_xSwiftBusServerSettings { this, &CSimulatorXPlaneConfigWindow::onSettingsChanged };
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>275</width>
|
||||
<height>175</height>
|
||||
<width>250</width>
|
||||
<height>272</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
@@ -35,7 +35,38 @@
|
||||
<property name="horizontalSpacing">
|
||||
<number>2</number>
|
||||
</property>
|
||||
<item row="1" column="0">
|
||||
<item row="0" column="0">
|
||||
<widget class="QGroupBox" name="gb_DBus">
|
||||
<property name="title">
|
||||
<string>XSwiftBus DBus</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="vl_DBus">
|
||||
<property name="leftMargin">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>3</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="BlackGui::Components::CDBusServerAddressSelector" name="comp_SettingsXSwiftBus">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>100</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QDialogButtonBox" name="bb_OkCancel">
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
@@ -45,14 +76,58 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" alignment="Qt::AlignTop">
|
||||
<widget class="BlackGui::Components::CDBusServerAddressSelector" name="comp_SettingsXSwiftBus">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>100</height>
|
||||
</size>
|
||||
<item row="1" column="0">
|
||||
<widget class="QGroupBox" name="gb_XPSettings">
|
||||
<property name="title">
|
||||
<string>Settings</string>
|
||||
</property>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="1" column="0">
|
||||
<widget class="QLabel" name="lbl_MaxAircraft">
|
||||
<property name="text">
|
||||
<string>Max.aircraft</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QSpinBox" name="sb_MaxAircraft">
|
||||
<property name="maximum">
|
||||
<number>250</number>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="lbl_MaxDistance">
|
||||
<property name="text">
|
||||
<string>Max.distance</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QDoubleSpinBox" name="ds_MaxDrawDistanceNM">
|
||||
<property name="suffix">
|
||||
<string>NM</string>
|
||||
</property>
|
||||
<property name="maximum">
|
||||
<double>250.000000000000000</double>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="lbl_Labels">
|
||||
<property name="text">
|
||||
<string>Labels</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QCheckBox" name="cb_DrawLabels">
|
||||
<property name="text">
|
||||
<string>draw labels</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
@@ -65,6 +140,11 @@
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<tabstops>
|
||||
<tabstop>sb_MaxAircraft</tabstop>
|
||||
<tabstop>ds_MaxDrawDistanceNM</tabstop>
|
||||
<tabstop>cb_DrawLabels</tabstop>
|
||||
</tabstops>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
||||
Reference in New Issue
Block a user