mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-09 13:35:34 +08:00
Ref T125, X-Plane config now only XSwiftBus settings, no longer installation
This commit is contained in:
committed by
Mathew Sutcliffe
parent
329b0512eb
commit
d4b027b6bd
@@ -25,18 +25,6 @@ namespace BlackSimPlugin
|
|||||||
{
|
{
|
||||||
namespace XPlane
|
namespace XPlane
|
||||||
{
|
{
|
||||||
/*!
|
|
||||||
* Setting for XSwiftBus.
|
|
||||||
*/
|
|
||||||
struct TXSwiftBusServer : public BlackMisc::TSettingTrait<QString>
|
|
||||||
{
|
|
||||||
//! \copydoc BlackMisc::TSettingTrait::key
|
|
||||||
static const char *key() { return "xswiftbus/server"; }
|
|
||||||
|
|
||||||
//! \copydoc BlackMisc::TSettingTrait::defaultValue
|
|
||||||
static QString defaultValue() { return QStringLiteral("session"); }
|
|
||||||
};
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Config plugin for the X-Plane plugin.
|
* Config plugin for the X-Plane plugin.
|
||||||
*/
|
*/
|
||||||
@@ -56,7 +44,7 @@ namespace BlackSimPlugin
|
|||||||
//! \copydoc BlackGui::IPluginConfig::createConfigWindow()
|
//! \copydoc BlackGui::IPluginConfig::createConfigWindow()
|
||||||
BlackGui::CPluginConfigWindow *createConfigWindow(QWidget *parent) override;
|
BlackGui::CPluginConfigWindow *createConfigWindow(QWidget *parent) override;
|
||||||
};
|
};
|
||||||
}
|
} // ns
|
||||||
}
|
} // ns
|
||||||
|
|
||||||
#endif // guard
|
#endif // guard
|
||||||
|
|||||||
@@ -9,35 +9,14 @@
|
|||||||
|
|
||||||
#include "simulatorxplaneconfigwindow.h"
|
#include "simulatorxplaneconfigwindow.h"
|
||||||
#include "blackcore/application.h"
|
#include "blackcore/application.h"
|
||||||
#include "blackmisc/directoryutils.h"
|
|
||||||
#include "blackmisc/dbusserver.h"
|
|
||||||
#include "blackmisc/fileutils.h"
|
|
||||||
#include "blackmisc/simulation/xplane/xplaneutil.h"
|
|
||||||
#include "ui_simulatorxplaneconfigwindow.h"
|
#include "ui_simulatorxplaneconfigwindow.h"
|
||||||
|
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
#include <QDialogButtonBox>
|
#include <QDialogButtonBox>
|
||||||
#include <QDir>
|
|
||||||
#include <QFileDialog>
|
|
||||||
#include <QFlags>
|
|
||||||
#include <QMessageBox>
|
|
||||||
#include <QPushButton>
|
|
||||||
#include <QString>
|
|
||||||
#include <QStringBuilder>
|
|
||||||
|
|
||||||
class QWidget;
|
|
||||||
|
|
||||||
using namespace BlackGui;
|
using namespace BlackGui;
|
||||||
using namespace BlackMisc;
|
using namespace BlackMisc;
|
||||||
|
|
||||||
namespace
|
|
||||||
{
|
|
||||||
QString xSwiftBusOriginDir()
|
|
||||||
{
|
|
||||||
return CDirectoryUtils::binDirectory() % QStringLiteral("/../xswiftbus");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace BlackSimPlugin
|
namespace BlackSimPlugin
|
||||||
{
|
{
|
||||||
namespace XPlane
|
namespace XPlane
|
||||||
@@ -48,69 +27,11 @@ namespace BlackSimPlugin
|
|||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
ui->cp_XSwiftBusServer->addItem(BlackMisc::CDBusServer::sessionBusAddress());
|
|
||||||
ui->cp_XSwiftBusServer->addItem(BlackMisc::CDBusServer::systemBusAddress());
|
|
||||||
|
|
||||||
connect(ui->bb_OkCancel, &QDialogButtonBox::accepted, this, &CSimulatorXPlaneConfigWindow::ps_storeSettings);
|
|
||||||
connect(ui->bb_OkCancel, &QDialogButtonBox::accepted, this, &CSimulatorXPlaneConfigWindow::close);
|
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_XSwiftBusServer->setCurrentText(m_xswiftbusServerSetting.getThreadLocal());
|
|
||||||
|
|
||||||
if (xSwiftBusAvailable())
|
|
||||||
connect(ui->pb_InstallXSwiftBus, &QPushButton::clicked, this, &CSimulatorXPlaneConfigWindow::ps_installXSwiftBus);
|
|
||||||
else
|
|
||||||
ui->pb_InstallXSwiftBus->setEnabled(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CSimulatorXPlaneConfigWindow::~CSimulatorXPlaneConfigWindow()
|
CSimulatorXPlaneConfigWindow::~CSimulatorXPlaneConfigWindow()
|
||||||
{
|
{ }
|
||||||
|
} // ns
|
||||||
}
|
} // ns
|
||||||
|
|
||||||
bool CSimulatorXPlaneConfigWindow::xSwiftBusAvailable()
|
|
||||||
{
|
|
||||||
return QDir(xSwiftBusOriginDir()).exists();
|
|
||||||
}
|
|
||||||
|
|
||||||
void CSimulatorXPlaneConfigWindow::ps_storeSettings()
|
|
||||||
{
|
|
||||||
if (ui->cp_XSwiftBusServer->currentText() != m_xswiftbusServerSetting.getThreadLocal())
|
|
||||||
{
|
|
||||||
m_xswiftbusServerSetting.set(ui->cp_XSwiftBusServer->currentText());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void CSimulatorXPlaneConfigWindow::ps_installXSwiftBus()
|
|
||||||
{
|
|
||||||
const QString xPlaneLocation = BlackMisc::Simulation::XPlane::CXPlaneUtil::xplaneRootDir();
|
|
||||||
QString path = QFileDialog::getExistingDirectory(parentWidget(),
|
|
||||||
tr("Choose your X-Plane install directory"),
|
|
||||||
xPlaneLocation,
|
|
||||||
QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks | QFileDialog::DontUseNativeDialog);
|
|
||||||
|
|
||||||
if (path.isEmpty()) // canceled
|
|
||||||
return;
|
|
||||||
|
|
||||||
path.append("/Resources/plugins");
|
|
||||||
if (!QDir(path).exists())
|
|
||||||
{
|
|
||||||
QMessageBox::warning(this, tr("Invalid X-Plane directory"), tr("%1 is not a valid X-Plane installation.").arg(path));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
path.append("/xswiftbus");
|
|
||||||
|
|
||||||
// TODO Use QtConcurrent here, maybe?
|
|
||||||
const bool result = BlackMisc::CFileUtils::copyRecursively(xSwiftBusOriginDir(), path);
|
|
||||||
if (result)
|
|
||||||
{
|
|
||||||
QMessageBox::information(this, tr("XSwiftBus installed"), tr("You may now launch your X-Plane and start using XSwiftBus!"));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
QMessageBox::warning(this, tr("Failed installing XSwiftBus"), tr("Failed installing the XSwiftBus plugin in your X-Plane installation directory; try installing it manually."));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -13,16 +13,13 @@
|
|||||||
#define BLACKSIMPLUGIN_SIMULATOR_XPLANE_CONFIG_WINDOW_H
|
#define BLACKSIMPLUGIN_SIMULATOR_XPLANE_CONFIG_WINDOW_H
|
||||||
|
|
||||||
#include "blackgui/pluginconfigwindow.h"
|
#include "blackgui/pluginconfigwindow.h"
|
||||||
#include "blackmisc/settingscache.h"
|
|
||||||
#include "simulatorxplaneconfig.h"
|
#include "simulatorxplaneconfig.h"
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QScopedPointer>
|
#include <QScopedPointer>
|
||||||
|
|
||||||
class QWidget;
|
class QWidget;
|
||||||
|
|
||||||
namespace Ui { class CSimulatorXPlaneConfigWindow; }
|
namespace Ui { class CSimulatorXPlaneConfigWindow; }
|
||||||
|
|
||||||
namespace BlackSimPlugin
|
namespace BlackSimPlugin
|
||||||
{
|
{
|
||||||
namespace XPlane
|
namespace XPlane
|
||||||
@@ -41,19 +38,10 @@ namespace BlackSimPlugin
|
|||||||
//! Dtor.
|
//! Dtor.
|
||||||
virtual ~CSimulatorXPlaneConfigWindow();
|
virtual ~CSimulatorXPlaneConfigWindow();
|
||||||
|
|
||||||
private:
|
|
||||||
//! Checks whether xswiftbus is present in the distributed directory.
|
|
||||||
bool xSwiftBusAvailable();
|
|
||||||
|
|
||||||
private slots:
|
|
||||||
void ps_storeSettings();
|
|
||||||
void ps_installXSwiftBus();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QScopedPointer<Ui::CSimulatorXPlaneConfigWindow> ui;
|
QScopedPointer<Ui::CSimulatorXPlaneConfigWindow> ui;
|
||||||
BlackMisc::CSetting<TXSwiftBusServer> m_xswiftbusServerSetting { this };
|
|
||||||
};
|
};
|
||||||
}
|
} // ns
|
||||||
}
|
} // ns
|
||||||
|
|
||||||
#endif // guard
|
#endif // guard
|
||||||
|
|||||||
@@ -6,32 +6,15 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>400</width>
|
<width>184</width>
|
||||||
<height>136</height>
|
<height>66</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>X-Plane plugin settings</string>
|
<string>X-Plane plugin settings</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gl_ConfigWindow">
|
||||||
<item row="0" column="1">
|
<item row="1" column="0">
|
||||||
<widget class="QComboBox" name="cp_XSwiftBusServer"/>
|
|
||||||
</item>
|
|
||||||
<item row="0" column="0">
|
|
||||||
<widget class="QLabel" name="lbl_XSwiftBusServer">
|
|
||||||
<property name="text">
|
|
||||||
<string>XSwiftBus server:</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="3" column="1">
|
|
||||||
<widget class="QPushButton" name="pb_InstallXSwiftBus">
|
|
||||||
<property name="text">
|
|
||||||
<string>Install XSwiftBus in the X-Plane directory...</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="1" column="1">
|
|
||||||
<widget class="QDialogButtonBox" name="bb_OkCancel">
|
<widget class="QDialogButtonBox" name="bb_OkCancel">
|
||||||
<property name="standardButtons">
|
<property name="standardButtons">
|
||||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||||
@@ -41,21 +24,26 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="1">
|
<item row="0" column="0">
|
||||||
<spacer name="verticalSpacer">
|
<widget class="BlackGui::Components::CSettingsXSwiftBusComponent" name="comp_SettingsXSwiftBus">
|
||||||
<property name="orientation">
|
<property name="minimumSize">
|
||||||
<enum>Qt::Vertical</enum>
|
|
||||||
</property>
|
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
<size>
|
||||||
<width>20</width>
|
<width>0</width>
|
||||||
<height>40</height>
|
<height>20</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
</spacer>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
<customwidgets>
|
||||||
|
<customwidget>
|
||||||
|
<class>BlackGui::Components::CSettingsXSwiftBusComponent</class>
|
||||||
|
<extends>QFrame</extends>
|
||||||
|
<header>blackgui/components/settingsxswiftbuscomponent.h</header>
|
||||||
|
<container>1</container>
|
||||||
|
</customwidget>
|
||||||
|
</customwidgets>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
</ui>
|
</ui>
|
||||||
|
|||||||
Reference in New Issue
Block a user