mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 14:55:36 +08:00
Ref T715, setting for "night texture"
* settings class * UI
This commit is contained in:
committed by
Mat Sutcliffe
parent
0605c2d139
commit
e62aa6fb2f
@@ -30,6 +30,7 @@ namespace BlackMisc
|
||||
{
|
||||
case IndexMaxPlanes: return CVariant::fromValue(m_maxPlanes);
|
||||
case IndexDBusServerAddress: return CVariant::fromValue(QString::fromStdString(m_dBusServerAddress));
|
||||
case IndexNightTextureMode: return CVariant::fromValue(QString::fromStdString(m_nightTextureMode));
|
||||
case IndexDrawingLabels: return CVariant::fromValue(m_drawingLabels);
|
||||
case IndexMaxDrawingDistance: return CVariant::fromValue(m_maxDrawDistanceNM);
|
||||
case IndexFollowAircraftDistance: return CVariant::fromValue(m_followAircraftDistanceM);
|
||||
@@ -48,6 +49,7 @@ namespace BlackMisc
|
||||
{
|
||||
case IndexMaxPlanes: m_maxPlanes = variant.toInt(); break;
|
||||
case IndexDBusServerAddress: m_dBusServerAddress = variant.toStdString(); break;
|
||||
case IndexNightTextureMode: m_nightTextureMode = variant.toStdString(); break;
|
||||
case IndexDrawingLabels: m_drawingLabels = variant.toBool(); break;
|
||||
case IndexMaxDrawingDistance: m_maxDrawDistanceNM = variant.toDouble(); break;
|
||||
case IndexFollowAircraftDistance: m_followAircraftDistanceM = variant.toInt(); break;
|
||||
|
||||
@@ -40,7 +40,8 @@ namespace BlackMisc
|
||||
IndexMaxPlanes,
|
||||
IndexDrawingLabels,
|
||||
IndexMaxDrawingDistance,
|
||||
IndexFollowAircraftDistance
|
||||
IndexFollowAircraftDistance,
|
||||
IndexNightTextureMode
|
||||
};
|
||||
|
||||
//! Default constructor
|
||||
@@ -64,6 +65,12 @@ namespace BlackMisc
|
||||
//! \copydoc CXSwiftBusSettingsQtFree::setDBusServerAddress
|
||||
void setDBusServerAddressQt(const QString &dBusAddress) { this->setDBusServerAddress(dBusAddress.toStdString()); }
|
||||
|
||||
//! \copydoc CXSwiftBusSettingsQtFree::getNightTextureMode
|
||||
QString getNightTextureModeQt() const { return QString::fromStdString(this->getNightTextureMode()); }
|
||||
|
||||
//! \copydoc CXSwiftBusSettingsQtFree::setNightTextureMode
|
||||
void setNightTextureModeQt(const QString &nightTexture) { this->setNightTextureMode(nightTexture.toStdString()); }
|
||||
|
||||
//! \copydoc CXSwiftBusSettingsQtFree::toXSwiftBusJsonString
|
||||
QString toXSwiftBusJsonStringQt() const { return QString::fromStdString(this->toXSwiftBusJsonString()); }
|
||||
|
||||
@@ -87,6 +94,7 @@ namespace BlackMisc
|
||||
BLACK_METACLASS(
|
||||
CXSwiftBusSettings,
|
||||
BLACK_METAMEMBER(dBusServerAddress),
|
||||
BLACK_METAMEMBER(nightTextureMode),
|
||||
BLACK_METAMEMBER(maxPlanes),
|
||||
BLACK_METAMEMBER(drawingLabels),
|
||||
BLACK_METAMEMBER(maxDrawDistanceNM),
|
||||
|
||||
@@ -25,6 +25,7 @@ constexpr char BlackMisc::Simulation::Settings::CXSwiftBusSettingsQtFree::JsonDr
|
||||
constexpr char BlackMisc::Simulation::Settings::CXSwiftBusSettingsQtFree::JsonMaxPlanes[];
|
||||
constexpr char BlackMisc::Simulation::Settings::CXSwiftBusSettingsQtFree::JsonMaxDrawDistance[];
|
||||
constexpr char BlackMisc::Simulation::Settings::CXSwiftBusSettingsQtFree::JsonFollowAircraftDistanceM[];
|
||||
constexpr char BlackMisc::Simulation::Settings::CXSwiftBusSettingsQtFree::JsonNightTextureMode[];
|
||||
constexpr char BlackMisc::Simulation::Settings::CXSwiftBusSettingsQtFree::JsonTimestamp[];
|
||||
//! @endcond
|
||||
|
||||
@@ -56,6 +57,10 @@ namespace BlackMisc
|
||||
{
|
||||
m_dBusServerAddress = settingsDoc[CXSwiftBusSettingsQtFree::JsonDBusServerAddress].GetString(); c++;
|
||||
}
|
||||
if (settingsDoc.HasMember(CXSwiftBusSettingsQtFree::JsonNightTextureMode) && settingsDoc[CXSwiftBusSettingsQtFree::JsonNightTextureMode].IsString())
|
||||
{
|
||||
m_nightTextureMode = settingsDoc[CXSwiftBusSettingsQtFree::JsonNightTextureMode].GetString(); c++;
|
||||
}
|
||||
if (settingsDoc.HasMember(CXSwiftBusSettingsQtFree::JsonDrawingLabels) && settingsDoc[CXSwiftBusSettingsQtFree::JsonDrawingLabels].IsBool())
|
||||
{
|
||||
m_drawingLabels = settingsDoc[CXSwiftBusSettingsQtFree::JsonDrawingLabels].GetBool(); c++;
|
||||
@@ -77,7 +82,7 @@ namespace BlackMisc
|
||||
m_msSinceEpochQtFree = settingsDoc[CXSwiftBusSettingsQtFree::JsonTimestamp].GetInt64(); c++;
|
||||
}
|
||||
this->objectUpdated(); // post processing
|
||||
return c == 6;
|
||||
return c == 7;
|
||||
}
|
||||
|
||||
std::string CXSwiftBusSettingsQtFree::toXSwiftBusJsonString() const
|
||||
@@ -91,10 +96,11 @@ namespace BlackMisc
|
||||
// Value k1(JsonDBusServerAddress, a);
|
||||
// Value v1(m_dBusServerAddress, a);
|
||||
document.AddMember(JsonDBusServerAddress, StringRef(m_dBusServerAddress.c_str()), a);
|
||||
document.AddMember(JsonDrawingLabels, m_drawingLabels, a);
|
||||
document.AddMember(JsonNightTextureMode, StringRef(m_nightTextureMode.c_str()), a);
|
||||
document.AddMember(JsonMaxPlanes, m_maxPlanes, a);
|
||||
document.AddMember(JsonMaxDrawDistance, m_maxDrawDistanceNM, a);
|
||||
document.AddMember(JsonTimestamp, m_msSinceEpochQtFree, a);
|
||||
document.AddMember(JsonDrawingLabels, m_drawingLabels, a);
|
||||
document.AddMember(JsonFollowAircraftDistanceM, m_followAircraftDistanceM, a);
|
||||
|
||||
// document[CXSwiftBusSettingsQtFree::JsonDBusServerAddress].SetString(StringRef(m_dBusServerAddress.c_str(), m_dBusServerAddress.size()));
|
||||
@@ -113,6 +119,7 @@ namespace BlackMisc
|
||||
{
|
||||
return "DBusServer: " + m_dBusServerAddress +
|
||||
", drawLabels: " + QtFreeUtils::boolToYesNo(m_drawingLabels) +
|
||||
", night t.: " + m_nightTextureMode +
|
||||
", max planes: " + std::to_string(m_maxPlanes) +
|
||||
", max distance NM: " + std::to_string(m_maxDrawDistanceNM) +
|
||||
", follow dist m: " + std::to_string(m_followAircraftDistanceM) +
|
||||
@@ -124,6 +131,7 @@ namespace BlackMisc
|
||||
int changed = 0;
|
||||
if (m_dBusServerAddress != newValues.m_dBusServerAddress) { m_dBusServerAddress = newValues.m_dBusServerAddress; changed++; }
|
||||
if (m_drawingLabels != newValues.m_drawingLabels) { m_drawingLabels = newValues.m_drawingLabels; changed++; }
|
||||
if (m_nightTextureMode != newValues.m_nightTextureMode) { m_nightTextureMode = newValues.m_nightTextureMode; changed++; }
|
||||
if (m_maxPlanes != newValues.m_maxPlanes) { m_maxPlanes = newValues.m_maxPlanes; changed++; }
|
||||
if (m_msSinceEpochQtFree != newValues.m_msSinceEpochQtFree) { m_msSinceEpochQtFree = newValues.m_msSinceEpochQtFree; changed++; }
|
||||
if (m_followAircraftDistanceM != newValues.m_followAircraftDistanceM) { m_followAircraftDistanceM = newValues.m_followAircraftDistanceM; changed++; }
|
||||
|
||||
@@ -46,6 +46,12 @@ namespace BlackMisc
|
||||
//! Get whether the plugin draws type and callsign labels above aircraft
|
||||
bool isDrawingLabels() const { return m_drawingLabels; }
|
||||
|
||||
//! The the night texture mode
|
||||
void setNightTextureMode(const std::string &mode) { m_nightTextureMode = XPlane::QtFreeUtils::toLower(mode); }
|
||||
|
||||
//! The the night texture mode
|
||||
const std::string &getNightTextureMode() const { return m_nightTextureMode; }
|
||||
|
||||
//! Set the maximum number of aircraft.
|
||||
bool setMaxPlanes(int planes)
|
||||
{
|
||||
@@ -100,6 +106,7 @@ namespace BlackMisc
|
||||
static constexpr char JsonDrawingLabels[] = "drawinglabels";
|
||||
static constexpr char JsonMaxPlanes[] = "maxplanes";
|
||||
static constexpr char JsonMaxDrawDistance[] = "maxDrawDistance";
|
||||
static constexpr char JsonNightTextureMode[] = "nighttexture";
|
||||
static constexpr char JsonTimestamp[] = "timestamp";
|
||||
static constexpr char JsonFollowAircraftDistanceM[] = "followAircraftDistance";
|
||||
//! @}
|
||||
@@ -108,6 +115,7 @@ namespace BlackMisc
|
||||
virtual void objectUpdated();
|
||||
|
||||
std::string m_dBusServerAddress { "tcp:host=127.0.0.1,port=45001" }; //!< DBus server
|
||||
std::string m_nightTextureMode { "auto" }; //!< night texture mode
|
||||
int m_maxPlanes = 100; //!< max. planes in XPlane
|
||||
int m_followAircraftDistanceM = 200; //!< follow aircraft in distance
|
||||
bool m_drawingLabels = true; //!< labels in XPlane
|
||||
|
||||
@@ -67,6 +67,7 @@ namespace BlackSimPlugin
|
||||
s.setMaxPlanes(ui->sb_MaxAircraft->value());
|
||||
s.setFollowAircraftDistanceM(ui->sb_FollowAircraftDistanceM->value());
|
||||
s.setDrawingLabels(ui->cb_DrawLabels->isChecked());
|
||||
s.setNightTextureModeQt(ui->cb_NightTextureMode->currentText());
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -77,6 +78,19 @@ namespace BlackSimPlugin
|
||||
ui->sb_FollowAircraftDistanceM->setValue(settings.getFollowAircraftDistanceM());
|
||||
ui->cb_DrawLabels->setChecked(settings.isDrawingLabels());
|
||||
ui->ds_MaxDrawDistanceNM->setValue(settings.getMaxDrawDistanceNM());
|
||||
|
||||
const QString s = settings.getNightTextureModeQt().left(1);
|
||||
if (!s.isEmpty())
|
||||
{
|
||||
for (int i = 0; i < ui->cb_NightTextureMode->count(); i++)
|
||||
{
|
||||
if (ui->cb_NightTextureMode->itemText(i).startsWith(s, Qt::CaseInsensitive))
|
||||
{
|
||||
ui->cb_NightTextureMode->setCurrentIndex(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CSimulatorXPlaneConfigWindow::onSettingsChanged()
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>300</width>
|
||||
<height>298</height>
|
||||
<height>325</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
@@ -144,6 +144,32 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<widget class="QComboBox" name="cb_NightTextureMode">
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>auto</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>daylight texture only</string>
|
||||
</property>
|
||||
</item>
|
||||
<item>
|
||||
<property name="text">
|
||||
<string>night texture only</string>
|
||||
</property>
|
||||
</item>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="lbl_NightTextureMode">
|
||||
<property name="text">
|
||||
<string>Night texture</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
||||
@@ -108,9 +108,11 @@ namespace BlackMiscTest
|
||||
s.setMaxDrawDistanceNM(11.11);
|
||||
s.setDrawingLabels(false);
|
||||
s.setFollowAircraftDistanceM(123);
|
||||
s.setNightTextureModeQt("FOO");
|
||||
s.setCurrentUtcTime();
|
||||
QString json = s.toXSwiftBusJsonStringQt();
|
||||
|
||||
QVERIFY2(s.getNightTextureModeQt() == "foo", "Expect lower case");
|
||||
QString json = s.toXSwiftBusJsonStringQt();
|
||||
qDebug() << json;
|
||||
qDebug() << s.toQString();
|
||||
|
||||
@@ -121,6 +123,7 @@ namespace BlackMiscTest
|
||||
QCOMPARE(s.getDBusServerAddressQt(), s2.getDBusServerAddressQt());
|
||||
QCOMPARE(s.getFollowAircraftDistanceM(), s2.getFollowAircraftDistanceM());
|
||||
QCOMPARE(s.getMSecsSinceEpoch(), s2.getMSecsSinceEpoch());
|
||||
QVERIFY2(s2.getNightTextureModeQt() == "foo", "Expect lower case foo");
|
||||
|
||||
s.setDBusServerAddressQt(CDBusServer::sessionBusAddress());
|
||||
json = s.toXSwiftBusJsonStringQt();
|
||||
@@ -136,6 +139,7 @@ namespace BlackMiscTest
|
||||
QCOMPARE(s.getMaxPlanes(), s2.getMaxPlanes());
|
||||
QCOMPARE(s.isDrawingLabels(), s2.isDrawingLabels());
|
||||
QCOMPARE(s.getDBusServerAddressQt(), s2.getDBusServerAddressQt());
|
||||
QVERIFY2(s2.getNightTextureModeQt() == "foo", "Expect lower case foo");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user