mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 23:05:36 +08:00
refs #392 Added the "Install XBus" feature
* New "Install XBus" button in the CSimulatorXPlaneConfigWindow * CSettingsSimulatorComponent cleanup
This commit is contained in:
committed by
Mathew Sutcliffe
parent
06c17d7d09
commit
cf3102333b
@@ -280,9 +280,7 @@ namespace BlackGui
|
||||
|
||||
QString configId = m_plugins->getPluginConfigId(selected->getIdentifier());
|
||||
IPluginConfig *config = m_plugins->getPluginById<IPluginConfig>(configId);
|
||||
CPluginConfigWindow *window = config->createConfigWindow();
|
||||
window->setParent(qApp->activeWindow());
|
||||
window->setWindowFlags(Qt::Dialog);
|
||||
CPluginConfigWindow *window = config->createConfigWindow(qApp->activeWindow());
|
||||
window->setAttribute(Qt::WA_DeleteOnClose);
|
||||
window->show();
|
||||
}
|
||||
|
||||
@@ -32,10 +32,10 @@ namespace BlackGui
|
||||
|
||||
public:
|
||||
//! Dtor.
|
||||
virtual ~IPluginConfig() = default;
|
||||
virtual ~IPluginConfig() {}
|
||||
|
||||
//! Creates a new config window and returns its pointer.
|
||||
virtual CPluginConfigWindow *createConfigWindow() = 0;
|
||||
virtual CPluginConfigWindow *createConfigWindow(QWidget *parent) = 0;
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,10 +1,27 @@
|
||||
#include "pluginconfigwindow.h"
|
||||
#include <QDesktopWidget>
|
||||
#include <QApplication>
|
||||
#include <QStyle>
|
||||
|
||||
namespace BlackGui {
|
||||
|
||||
CPluginConfigWindow::CPluginConfigWindow() : QWidget(nullptr)
|
||||
CPluginConfigWindow::CPluginConfigWindow(QWidget *parent) : QWidget(parent, Qt::Window)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CPluginConfigWindow::showEvent(QShowEvent *event)
|
||||
{
|
||||
this->setGeometry(
|
||||
QStyle::alignedRect(
|
||||
Qt::LeftToRight,
|
||||
Qt::AlignCenter,
|
||||
this->size(),
|
||||
QDesktopWidget().screenGeometry(qApp->activeWindow())
|
||||
)
|
||||
);
|
||||
|
||||
Q_UNUSED(event);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -22,7 +22,10 @@ namespace BlackGui
|
||||
Q_OBJECT
|
||||
public:
|
||||
//! No parent
|
||||
explicit CPluginConfigWindow();
|
||||
explicit CPluginConfigWindow(QWidget *parent);
|
||||
|
||||
protected:
|
||||
virtual void showEvent(QShowEvent *event) override;
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
@@ -527,6 +527,7 @@ namespace BlackSimPlugin
|
||||
}
|
||||
else
|
||||
{
|
||||
CLogMessage(this).debug() << "Starting XBus on %1" << m_xbusServerSetting.get();
|
||||
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);
|
||||
@@ -568,7 +569,6 @@ namespace BlackSimPlugin
|
||||
{
|
||||
// user changed settings, restart the listener
|
||||
if (m_watcher) {
|
||||
CLogMessage(this).debug() << "XP: Restarting listener";
|
||||
stop();
|
||||
start();
|
||||
}
|
||||
|
||||
@@ -11,9 +11,9 @@ namespace BlackSimPlugin
|
||||
|
||||
}
|
||||
|
||||
BlackGui::CPluginConfigWindow *CSimulatorXPlaneConfig::createConfigWindow()
|
||||
BlackGui::CPluginConfigWindow *CSimulatorXPlaneConfig::createConfigWindow(QWidget *parent)
|
||||
{
|
||||
CSimulatorXPlaneConfigWindow* w = new CSimulatorXPlaneConfigWindow();
|
||||
CSimulatorXPlaneConfigWindow* w = new CSimulatorXPlaneConfigWindow(parent);
|
||||
return w;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,11 +41,14 @@ namespace BlackSimPlugin
|
||||
//! Ctor
|
||||
CSimulatorXPlaneConfig(QObject *parent = nullptr);
|
||||
|
||||
//! Dtor
|
||||
virtual ~CSimulatorXPlaneConfig() {}
|
||||
|
||||
//! \copydoc BlackGui::IPluginConfig::createConfigWindow()
|
||||
BlackGui::CPluginConfigWindow *createConfigWindow() override;
|
||||
BlackGui::CPluginConfigWindow *createConfigWindow(QWidget *parent) override;
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif // SIMULATORXPLANECONFIG_H
|
||||
#endif // guard
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
#include "simulatorxplaneconfigwindow.h"
|
||||
#include "ui_simulatorxplaneconfigwindow.h"
|
||||
#include "blackcore/dbus_server.h"
|
||||
#include "blackmisc/simulation/xplane/xplaneutil.h"
|
||||
#include <QStringBuilder>
|
||||
#include <QFileDialog>
|
||||
#include <QMessageBox>
|
||||
|
||||
using namespace BlackGui;
|
||||
|
||||
@@ -9,7 +13,8 @@ namespace BlackSimPlugin
|
||||
namespace XPlane
|
||||
{
|
||||
|
||||
CSimulatorXPlaneConfigWindow::CSimulatorXPlaneConfigWindow() :
|
||||
CSimulatorXPlaneConfigWindow::CSimulatorXPlaneConfigWindow(QWidget *parent) :
|
||||
CPluginConfigWindow(parent),
|
||||
ui(new Ui::CSimulatorXPlaneConfigWindow)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
@@ -22,6 +27,8 @@ namespace BlackSimPlugin
|
||||
connect(ui->bb_OkCancel, &QDialogButtonBox::rejected, this, &CSimulatorXPlaneConfigWindow::close);
|
||||
|
||||
ui->cp_XBusServer->setCurrentText(m_xbusServerSetting.get());
|
||||
|
||||
connect(ui->pb_InstallXBus, &QPushButton::clicked, this, &CSimulatorXPlaneConfigWindow::ps_installXBus);
|
||||
}
|
||||
|
||||
CSimulatorXPlaneConfigWindow::~CSimulatorXPlaneConfigWindow()
|
||||
@@ -37,5 +44,32 @@ namespace BlackSimPlugin
|
||||
}
|
||||
}
|
||||
|
||||
void CSimulatorXPlaneConfigWindow::ps_installXBus()
|
||||
{
|
||||
QString xPlaneLocation = BlackMisc::Simulation::XPlane::CXPlaneUtil::xplane10Dir();
|
||||
if (xPlaneLocation.isEmpty())
|
||||
xPlaneLocation = BlackMisc::Simulation::XPlane::CXPlaneUtil::xplane9Dir();
|
||||
|
||||
QString path = QFileDialog::getExistingDirectory(parentWidget(),
|
||||
tr("Choose your X-Plane install directory"),
|
||||
xPlaneLocation,
|
||||
QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
|
||||
|
||||
path.append("/Resources/plugins/xbus/64/");
|
||||
QDir xbusDir(path);
|
||||
if (!xbusDir.exists())
|
||||
{
|
||||
if (!xbusDir.mkpath("."))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
QString origin = QCoreApplication::applicationDirPath() % QStringLiteral("/../xbus/64/lin.xpl");
|
||||
QString destination = path % "/lin.xpl";
|
||||
QFile::copy(origin, destination);
|
||||
|
||||
QMessageBox::information(this, tr("XBus installed"), tr("You may now launch your X-Plane and start using XBus!"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,17 +34,17 @@ namespace BlackSimPlugin
|
||||
|
||||
public:
|
||||
//! Ctor.
|
||||
CSimulatorXPlaneConfigWindow();
|
||||
CSimulatorXPlaneConfigWindow(QWidget *parent);
|
||||
|
||||
//! Dtor.
|
||||
virtual ~CSimulatorXPlaneConfigWindow();
|
||||
|
||||
private slots:
|
||||
void ps_storeSettings();
|
||||
void ps_installXBus();
|
||||
|
||||
private:
|
||||
QScopedPointer<Ui::CSimulatorXPlaneConfigWindow> ui;
|
||||
|
||||
BlackCore::CSetting<XBusServer> m_xbusServerSetting { this };
|
||||
|
||||
};
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>74</height>
|
||||
<height>136</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@@ -24,7 +24,14 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<item row="3" column="1">
|
||||
<widget class="QPushButton" name="pb_InstallXBus">
|
||||
<property name="text">
|
||||
<string>Install XBus in the X-Plane directory...</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1">
|
||||
<widget class="QDialogButtonBox" name="bb_OkCancel">
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
@@ -34,6 +41,19 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
|
||||
Reference in New Issue
Block a user