mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-05-05 01:35:45 +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
@@ -4,6 +4,7 @@
|
|||||||
#include "blackcore/context_simulator.h"
|
#include "blackcore/context_simulator.h"
|
||||||
#include "blackcore/context_network.h"
|
#include "blackcore/context_network.h"
|
||||||
#include "blackgui/pluginconfig.h"
|
#include "blackgui/pluginconfig.h"
|
||||||
|
#include "blackgui/pluginconfigwindow.h"
|
||||||
#include "blackgui/plugindetailswindow.h"
|
#include "blackgui/plugindetailswindow.h"
|
||||||
#include "blackmisc/simulation/simulatorplugininfolist.h"
|
#include "blackmisc/simulation/simulatorplugininfolist.h"
|
||||||
#include "blackmisc/simulation/simulatedaircraftlist.h"
|
#include "blackmisc/simulation/simulatedaircraftlist.h"
|
||||||
@@ -279,8 +280,8 @@ namespace BlackGui
|
|||||||
|
|
||||||
QString configId = m_plugins->getPluginConfigId(selected->getIdentifier());
|
QString configId = m_plugins->getPluginConfigId(selected->getIdentifier());
|
||||||
IPluginConfig *config = m_plugins->getPluginById<IPluginConfig>(configId);
|
IPluginConfig *config = m_plugins->getPluginById<IPluginConfig>(configId);
|
||||||
QWidget *window = config->createConfigWindow();
|
CPluginConfigWindow *window = config->createConfigWindow();
|
||||||
// window->setParent(qApp->activeWindow());
|
window->setParent(qApp->activeWindow());
|
||||||
window->setWindowFlags(Qt::Dialog);
|
window->setWindowFlags(Qt::Dialog);
|
||||||
window->setAttribute(Qt::WA_DeleteOnClose);
|
window->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
window->show();
|
window->show();
|
||||||
|
|||||||
@@ -5,14 +5,12 @@
|
|||||||
* directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project,
|
* 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
|
* including this file, may be copied, modified, propagated, or distributed except according to the terms
|
||||||
* contained in the LICENSE file.
|
* contained in the LICENSE file.
|
||||||
*
|
|
||||||
* Class based on qLed: Copyright (C) 2010 by P. Sereno, http://www.sereno-online.com
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//! \file
|
//! \file
|
||||||
|
|
||||||
#ifndef BLACKGUI_PLUGINCONFIG_H
|
#ifndef BLACKGUI_PLUGINCONFIG_H
|
||||||
#define BCLAKGUI_PLUGINCONFIG_H
|
#define BLACKGUI_PLUGINCONFIG_H
|
||||||
|
|
||||||
#include "blackgui/blackguiexport.h"
|
#include "blackgui/blackguiexport.h"
|
||||||
#include <QtWidgets/QWidget>
|
#include <QtWidgets/QWidget>
|
||||||
@@ -20,13 +18,24 @@
|
|||||||
|
|
||||||
namespace BlackGui
|
namespace BlackGui
|
||||||
{
|
{
|
||||||
|
class CPluginConfigWindow;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The interface for the plugin config.
|
||||||
|
* The plugin config plugin is always called from the GUI process in order
|
||||||
|
* to make it possible to create a config window.
|
||||||
|
*
|
||||||
|
* \sa BlackCore::ISimulator.
|
||||||
|
*/
|
||||||
class BLACKGUI_EXPORT IPluginConfig
|
class BLACKGUI_EXPORT IPluginConfig
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
//! Dtor.
|
||||||
virtual ~IPluginConfig() = default;
|
virtual ~IPluginConfig() = default;
|
||||||
|
|
||||||
virtual QWidget *createConfigWindow() = 0;
|
//! Creates a new config window and returns its pointer.
|
||||||
|
virtual CPluginConfigWindow *createConfigWindow() = 0;
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
10
src/blackgui/pluginconfigwindow.cpp
Normal file
10
src/blackgui/pluginconfigwindow.cpp
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
#include "pluginconfigwindow.h"
|
||||||
|
|
||||||
|
namespace BlackGui {
|
||||||
|
|
||||||
|
CPluginConfigWindow::CPluginConfigWindow() : QWidget(nullptr)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
30
src/blackgui/pluginconfigwindow.h
Normal file
30
src/blackgui/pluginconfigwindow.h
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
/* 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 BLACKGUI_PLUGINCONFIGWINDOW_H
|
||||||
|
#define BLACKGUI_PLUGINCONFIGWINDOW_H
|
||||||
|
|
||||||
|
#include "blackgui/blackguiexport.h"
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
|
namespace BlackGui
|
||||||
|
{
|
||||||
|
class BLACKGUI_EXPORT CPluginConfigWindow : public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
//! No parent
|
||||||
|
explicit CPluginConfigWindow();
|
||||||
|
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // CPLUGINCONFIGWINDOW_H
|
||||||
@@ -111,9 +111,9 @@ BlackGui--Editors--CValidationIndicator {
|
|||||||
background-image: url(:/textures/icons/textures/texture-inner.jpg);
|
background-image: url(:/textures/icons/textures/texture-inner.jpg);
|
||||||
}
|
}
|
||||||
|
|
||||||
BlackGui--CPluginDetailsWindow {
|
BlackGui--CPluginDetailsWindow,
|
||||||
background-image: url(:/textures/icons/textures/texture-inner.jpg);
|
BlackGui--CPluginConfigWindow {
|
||||||
background-color: darkslategray;
|
background: black;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** default for buttons **/
|
/** default for buttons **/
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
#include "xbus_service_proxy.h"
|
#include "xbus_service_proxy.h"
|
||||||
#include "xbus_traffic_proxy.h"
|
#include "xbus_traffic_proxy.h"
|
||||||
#include "xbus_weather_proxy.h"
|
#include "xbus_weather_proxy.h"
|
||||||
|
#include "blackcore/dbus_server.h"
|
||||||
#include "blackmisc/logmessage.h"
|
#include "blackmisc/logmessage.h"
|
||||||
#include "blackmisc/blackmiscfreefunctions.h"
|
#include "blackmisc/blackmiscfreefunctions.h"
|
||||||
#include "blackmisc/simulation/modelmappingsprovider.h"
|
#include "blackmisc/simulation/modelmappingsprovider.h"
|
||||||
@@ -351,6 +352,22 @@ namespace BlackSimPlugin
|
|||||||
return CPixmap();
|
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
|
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
|
//! \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
|
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);
|
m_watcher = new QDBusServiceWatcher(xbusServiceName(), m_conn, QDBusServiceWatcher::WatchForRegistration, this);
|
||||||
connect(m_watcher, &QDBusServiceWatcher::serviceRegistered, this, &CSimulatorXPlaneListener::ps_serviceRegistered);
|
connect(m_watcher, &QDBusServiceWatcher::serviceRegistered, this, &CSimulatorXPlaneListener::ps_serviceRegistered);
|
||||||
}
|
}
|
||||||
@@ -527,7 +544,7 @@ namespace BlackSimPlugin
|
|||||||
|
|
||||||
bool CSimulatorXPlaneListener::isXBusRunning() const
|
bool CSimulatorXPlaneListener::isXBusRunning() const
|
||||||
{
|
{
|
||||||
QDBusConnection conn = QDBusConnection::sessionBus(); // TODO make this configurable
|
QDBusConnection conn = CSimulatorXPlane::connectionFromString(m_xbusServerSetting.get());
|
||||||
CXBusServiceProxy *service = new CXBusServiceProxy(conn);
|
CXBusServiceProxy *service = new CXBusServiceProxy(conn);
|
||||||
CXBusTrafficProxy *traffic = new CXBusTrafficProxy(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
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
#include "blackmisc/simulation/ownaircraftprovider.h"
|
#include "blackmisc/simulation/ownaircraftprovider.h"
|
||||||
#include "blackmisc/simulation/aircraftmodellist.h"
|
#include "blackmisc/simulation/aircraftmodellist.h"
|
||||||
#include "blackmisc/pixmap.h"
|
#include "blackmisc/pixmap.h"
|
||||||
|
#include "plugins/simulator/xplane_config/simulatorxplaneconfig.h"
|
||||||
#include <QDBusConnection>
|
#include <QDBusConnection>
|
||||||
|
|
||||||
class QDBusServiceWatcher;
|
class QDBusServiceWatcher;
|
||||||
@@ -99,6 +100,9 @@ namespace BlackSimPlugin
|
|||||||
//! \copydoc ISimulator::iconForModel
|
//! \copydoc ISimulator::iconForModel
|
||||||
virtual BlackMisc::CPixmap iconForModel(const QString &modelString) const override;
|
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:
|
protected slots:
|
||||||
//! \copydoc CSimulatorCommon::ps_remoteProviderAddAircraftSituation
|
//! \copydoc CSimulatorCommon::ps_remoteProviderAddAircraftSituation
|
||||||
virtual void ps_remoteProviderAddAircraftSituation(const BlackMisc::Aviation::CAircraftSituation &situation) override;
|
virtual void ps_remoteProviderAddAircraftSituation(const BlackMisc::Aviation::CAircraftSituation &situation) override;
|
||||||
@@ -205,10 +209,13 @@ namespace BlackSimPlugin
|
|||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void ps_serviceRegistered(const QString &serviceName);
|
void ps_serviceRegistered(const QString &serviceName);
|
||||||
|
void ps_xbusServerSettingChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QDBusConnection m_conn { "default" };
|
QDBusConnection m_conn { "default" };
|
||||||
QDBusServiceWatcher *m_watcher { nullptr };
|
QDBusServiceWatcher *m_watcher { nullptr };
|
||||||
|
BlackCore::CSetting<XBusServer> m_xbusServerSetting { this, &CSimulatorXPlaneListener::ps_xbusServerSettingChanged };
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//! Factory for creating CSimulatorXPlane instance
|
//! Factory for creating CSimulatorXPlane instance
|
||||||
|
|||||||
@@ -11,11 +11,10 @@ namespace BlackSimPlugin
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QWidget *CSimulatorXPlaneConfig::createConfigWindow()
|
BlackGui::CPluginConfigWindow *CSimulatorXPlaneConfig::createConfigWindow()
|
||||||
{
|
{
|
||||||
CSimulatorXPlaneConfigWindow* w = new CSimulatorXPlaneConfigWindow();
|
CSimulatorXPlaneConfigWindow* w = new CSimulatorXPlaneConfigWindow();
|
||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,12 +13,21 @@
|
|||||||
#define BLACKSIMPLUGIN_SIMULATOR_XPLANE_CONFIG_H
|
#define BLACKSIMPLUGIN_SIMULATOR_XPLANE_CONFIG_H
|
||||||
|
|
||||||
#include "blackgui/pluginconfig.h"
|
#include "blackgui/pluginconfig.h"
|
||||||
|
#include "blackcore/settingscache.h"
|
||||||
|
|
||||||
namespace BlackSimPlugin
|
namespace BlackSimPlugin
|
||||||
{
|
{
|
||||||
namespace XPlane
|
namespace XPlane
|
||||||
{
|
{
|
||||||
|
struct XBusServer : public BlackCore::CSettingTrait<QString>
|
||||||
|
{
|
||||||
|
//! \copydoc BlackCore::CSetting::key
|
||||||
|
static const char *key() { return "xbus/server"; }
|
||||||
|
|
||||||
|
//! \copydoc BlackCore::CSetting::defaultValue
|
||||||
|
static QString defaultValue() { return QStringLiteral("session"); }
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Config plugin for the X-Plane plugin.
|
* Config plugin for the X-Plane plugin.
|
||||||
*/
|
*/
|
||||||
@@ -33,7 +42,7 @@ namespace BlackSimPlugin
|
|||||||
CSimulatorXPlaneConfig(QObject *parent = nullptr);
|
CSimulatorXPlaneConfig(QObject *parent = nullptr);
|
||||||
|
|
||||||
//! \copydoc BlackGui::IPluginConfig::createConfigWindow()
|
//! \copydoc BlackGui::IPluginConfig::createConfigWindow()
|
||||||
QWidget *createConfigWindow() override;
|
BlackGui::CPluginConfigWindow *createConfigWindow() override;
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
#include "ui_simulatorxplaneconfigwindow.h"
|
#include "ui_simulatorxplaneconfigwindow.h"
|
||||||
#include "blackcore/dbus_server.h"
|
#include "blackcore/dbus_server.h"
|
||||||
|
|
||||||
|
using namespace BlackGui;
|
||||||
|
|
||||||
namespace BlackSimPlugin
|
namespace BlackSimPlugin
|
||||||
{
|
{
|
||||||
@@ -9,7 +10,6 @@ namespace BlackSimPlugin
|
|||||||
{
|
{
|
||||||
|
|
||||||
CSimulatorXPlaneConfigWindow::CSimulatorXPlaneConfigWindow() :
|
CSimulatorXPlaneConfigWindow::CSimulatorXPlaneConfigWindow() :
|
||||||
QWidget(nullptr),
|
|
||||||
ui(new Ui::CSimulatorXPlaneConfigWindow)
|
ui(new Ui::CSimulatorXPlaneConfigWindow)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
@@ -17,7 +17,11 @@ namespace BlackSimPlugin
|
|||||||
ui->cp_XBusServer->addItem(BlackCore::CDBusServer::sessionDBusServer());
|
ui->cp_XBusServer->addItem(BlackCore::CDBusServer::sessionDBusServer());
|
||||||
ui->cp_XBusServer->addItem(BlackCore::CDBusServer::systemDBusServer());
|
ui->cp_XBusServer->addItem(BlackCore::CDBusServer::systemDBusServer());
|
||||||
|
|
||||||
|
connect(ui->bb_OkCancel, &QDialogButtonBox::accepted, this, &CSimulatorXPlaneConfigWindow::ps_storeSettings);
|
||||||
|
connect(ui->bb_OkCancel, &QDialogButtonBox::accepted, this, &CSimulatorXPlaneConfigWindow::close);
|
||||||
connect(ui->bb_OkCancel, &QDialogButtonBox::rejected, this, &CSimulatorXPlaneConfigWindow::close);
|
connect(ui->bb_OkCancel, &QDialogButtonBox::rejected, this, &CSimulatorXPlaneConfigWindow::close);
|
||||||
|
|
||||||
|
ui->cp_XBusServer->setCurrentText(m_xbusServerSetting.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
CSimulatorXPlaneConfigWindow::~CSimulatorXPlaneConfigWindow()
|
CSimulatorXPlaneConfigWindow::~CSimulatorXPlaneConfigWindow()
|
||||||
@@ -25,5 +29,13 @@ namespace BlackSimPlugin
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSimulatorXPlaneConfigWindow::ps_storeSettings()
|
||||||
|
{
|
||||||
|
if (ui->cp_XBusServer->currentText() != m_xbusServerSetting.get())
|
||||||
|
{
|
||||||
|
m_xbusServerSetting.set(ui->cp_XBusServer->currentText());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,8 @@
|
|||||||
#ifndef BLACKSIMPLUGIN_SIMULATOR_XPLANE_CONFIG_WINDOW_H
|
#ifndef BLACKSIMPLUGIN_SIMULATOR_XPLANE_CONFIG_WINDOW_H
|
||||||
#define BLACKSIMPLUGIN_SIMULATOR_XPLANE_CONFIG_WINDOW_H
|
#define BLACKSIMPLUGIN_SIMULATOR_XPLANE_CONFIG_WINDOW_H
|
||||||
|
|
||||||
|
#include "simulatorxplaneconfig.h"
|
||||||
|
#include "blackgui/pluginconfigwindow.h"
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QScopedPointer>
|
#include <QScopedPointer>
|
||||||
|
|
||||||
@@ -26,7 +28,7 @@ namespace BlackSimPlugin
|
|||||||
/**
|
/**
|
||||||
* A window that shows all the X-Plane plugin options.
|
* A window that shows all the X-Plane plugin options.
|
||||||
*/
|
*/
|
||||||
class CSimulatorXPlaneConfigWindow : public QWidget
|
class CSimulatorXPlaneConfigWindow : public BlackGui::CPluginConfigWindow
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@@ -37,9 +39,14 @@ namespace BlackSimPlugin
|
|||||||
//! Dtor.
|
//! Dtor.
|
||||||
virtual ~CSimulatorXPlaneConfigWindow();
|
virtual ~CSimulatorXPlaneConfigWindow();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void ps_storeSettings();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QScopedPointer<Ui::CSimulatorXPlaneConfigWindow> ui;
|
QScopedPointer<Ui::CSimulatorXPlaneConfigWindow> ui;
|
||||||
|
|
||||||
|
BlackCore::CSetting<XBusServer> m_xbusServerSetting { this };
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user