mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-07 19:35:32 +08:00
refs #392 Added BlackGui::CPluginConfigWindow
* CPluginConfigWindow is now base class for all plugin config windows * CPluginConfigWindow is styled properly * Fixed behaviour in CSimulatorXPlaneConfigWindow
This commit is contained in:
committed by
Mathew Sutcliffe
parent
a0b4d47736
commit
06c17d7d09
@@ -11,6 +11,7 @@
|
||||
#include "xbus_service_proxy.h"
|
||||
#include "xbus_traffic_proxy.h"
|
||||
#include "xbus_weather_proxy.h"
|
||||
#include "blackcore/dbus_server.h"
|
||||
#include "blackmisc/logmessage.h"
|
||||
#include "blackmisc/blackmiscfreefunctions.h"
|
||||
#include "blackmisc/simulation/modelmappingsprovider.h"
|
||||
@@ -351,6 +352,22 @@ namespace BlackSimPlugin
|
||||
return CPixmap();
|
||||
}
|
||||
|
||||
QDBusConnection CSimulatorXPlane::connectionFromString(const QString &str)
|
||||
{
|
||||
if (str == BlackCore::CDBusServer::sessionDBusServer())
|
||||
{
|
||||
return QDBusConnection::sessionBus();
|
||||
}
|
||||
else if (str == BlackCore::CDBusServer::systemDBusServer())
|
||||
{
|
||||
return QDBusConnection::systemBus();
|
||||
}
|
||||
else
|
||||
{
|
||||
Q_UNREACHABLE();
|
||||
}
|
||||
}
|
||||
|
||||
bool CSimulatorXPlane::isPhysicallyRenderedAircraft(const CCallsign &callsign) const
|
||||
{
|
||||
//! \todo XP implement isRenderedAircraft correctly. This work around, but not really telling me if callsign is really(!) visible in SIM
|
||||
@@ -510,7 +527,7 @@ namespace BlackSimPlugin
|
||||
}
|
||||
else
|
||||
{
|
||||
m_conn = QDBusConnection::sessionBus(); // TODO make this configurable
|
||||
m_conn = CSimulatorXPlane::connectionFromString(m_xbusServerSetting.get());
|
||||
m_watcher = new QDBusServiceWatcher(xbusServiceName(), m_conn, QDBusServiceWatcher::WatchForRegistration, this);
|
||||
connect(m_watcher, &QDBusServiceWatcher::serviceRegistered, this, &CSimulatorXPlaneListener::ps_serviceRegistered);
|
||||
}
|
||||
@@ -527,7 +544,7 @@ namespace BlackSimPlugin
|
||||
|
||||
bool CSimulatorXPlaneListener::isXBusRunning() const
|
||||
{
|
||||
QDBusConnection conn = QDBusConnection::sessionBus(); // TODO make this configurable
|
||||
QDBusConnection conn = CSimulatorXPlane::connectionFromString(m_xbusServerSetting.get());
|
||||
CXBusServiceProxy *service = new CXBusServiceProxy(conn);
|
||||
CXBusTrafficProxy *traffic = new CXBusTrafficProxy(conn);
|
||||
|
||||
@@ -547,5 +564,15 @@ namespace BlackSimPlugin
|
||||
}
|
||||
}
|
||||
|
||||
void CSimulatorXPlaneListener::ps_xbusServerSettingChanged()
|
||||
{
|
||||
// user changed settings, restart the listener
|
||||
if (m_watcher) {
|
||||
CLogMessage(this).debug() << "XP: Restarting listener";
|
||||
stop();
|
||||
start();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
} // namespace
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "blackmisc/simulation/ownaircraftprovider.h"
|
||||
#include "blackmisc/simulation/aircraftmodellist.h"
|
||||
#include "blackmisc/pixmap.h"
|
||||
#include "plugins/simulator/xplane_config/simulatorxplaneconfig.h"
|
||||
#include <QDBusConnection>
|
||||
|
||||
class QDBusServiceWatcher;
|
||||
@@ -99,6 +100,9 @@ namespace BlackSimPlugin
|
||||
//! \copydoc ISimulator::iconForModel
|
||||
virtual BlackMisc::CPixmap iconForModel(const QString &modelString) const override;
|
||||
|
||||
//! Creates an appropriate dbus connection from the string describing it
|
||||
static QDBusConnection connectionFromString(const QString &str);
|
||||
|
||||
protected slots:
|
||||
//! \copydoc CSimulatorCommon::ps_remoteProviderAddAircraftSituation
|
||||
virtual void ps_remoteProviderAddAircraftSituation(const BlackMisc::Aviation::CAircraftSituation &situation) override;
|
||||
@@ -205,10 +209,13 @@ namespace BlackSimPlugin
|
||||
|
||||
private slots:
|
||||
void ps_serviceRegistered(const QString &serviceName);
|
||||
void ps_xbusServerSettingChanged();
|
||||
|
||||
private:
|
||||
QDBusConnection m_conn { "default" };
|
||||
QDBusServiceWatcher *m_watcher { nullptr };
|
||||
BlackCore::CSetting<XBusServer> m_xbusServerSetting { this, &CSimulatorXPlaneListener::ps_xbusServerSettingChanged };
|
||||
|
||||
};
|
||||
|
||||
//! Factory for creating CSimulatorXPlane instance
|
||||
|
||||
Reference in New Issue
Block a user