mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-03 07:35:48 +08:00
Refactor qmake SUBDIRS structure
The big swift.pro is refactored by the correct usage of SUBDIRS template. The following additional changes are made: - Removed '_' from all targets and folder names - Aligned parent folder and target name refs #461
This commit is contained in:
20
src/plugins/simulator/xplaneconfig/simulatorxplaneconfig.cpp
Normal file
20
src/plugins/simulator/xplaneconfig/simulatorxplaneconfig.cpp
Normal file
@@ -0,0 +1,20 @@
|
||||
#include "simulatorxplaneconfig.h"
|
||||
#include "simulatorxplaneconfigwindow.h"
|
||||
|
||||
namespace BlackSimPlugin
|
||||
{
|
||||
namespace XPlane
|
||||
{
|
||||
|
||||
CSimulatorXPlaneConfig::CSimulatorXPlaneConfig(QObject *parent) : QObject(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
BlackGui::CPluginConfigWindow *CSimulatorXPlaneConfig::createConfigWindow(QWidget *parent)
|
||||
{
|
||||
CSimulatorXPlaneConfigWindow* w = new CSimulatorXPlaneConfigWindow(parent);
|
||||
return w;
|
||||
}
|
||||
}
|
||||
}
|
||||
58
src/plugins/simulator/xplaneconfig/simulatorxplaneconfig.h
Normal file
58
src/plugins/simulator/xplaneconfig/simulatorxplaneconfig.h
Normal file
@@ -0,0 +1,58 @@
|
||||
/* 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 BLACKSIMPLUGIN_SIMULATOR_XPLANE_CONFIG_H
|
||||
#define BLACKSIMPLUGIN_SIMULATOR_XPLANE_CONFIG_H
|
||||
|
||||
#include "blackgui/pluginconfig.h"
|
||||
#include "blackcore/settingscache.h"
|
||||
|
||||
namespace BlackSimPlugin
|
||||
{
|
||||
namespace XPlane
|
||||
{
|
||||
|
||||
/*!
|
||||
* Setting for XBus.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
class CSimulatorXPlaneConfig : public QObject, public BlackGui::IPluginConfig
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PLUGIN_METADATA(IID "org.swift-project.blackgui.pluginconfiginterface" FILE "simulatorxplaneconfig.json")
|
||||
Q_INTERFACES(BlackGui::IPluginConfig)
|
||||
|
||||
public:
|
||||
//! Ctor
|
||||
CSimulatorXPlaneConfig(QObject *parent = nullptr);
|
||||
|
||||
//! Dtor
|
||||
virtual ~CSimulatorXPlaneConfig() {}
|
||||
|
||||
//! \copydoc BlackGui::IPluginConfig::createConfigWindow()
|
||||
BlackGui::CPluginConfigWindow *createConfigWindow(QWidget *parent) override;
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif // guard
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"identifier" : "org.swift-project.plugins.simulator.xplane.config"
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
#include "simulatorxplaneconfigwindow.h"
|
||||
#include "ui_simulatorxplaneconfigwindow.h"
|
||||
#include "blackcore/dbusserver.h"
|
||||
#include "blackmisc/simulation/xplane/xplaneutil.h"
|
||||
#include "blackmisc/fileutils.h"
|
||||
#include <QStringBuilder>
|
||||
#include <QFileDialog>
|
||||
#include <QMessageBox>
|
||||
#include <QStandardPaths>
|
||||
#include <QStringBuilder>
|
||||
|
||||
using namespace BlackGui;
|
||||
|
||||
namespace
|
||||
{
|
||||
QString xBusOriginDir()
|
||||
{
|
||||
return QCoreApplication::applicationDirPath() % QStringLiteral("/../xbus");
|
||||
}
|
||||
}
|
||||
|
||||
namespace BlackSimPlugin
|
||||
{
|
||||
namespace XPlane
|
||||
{
|
||||
|
||||
CSimulatorXPlaneConfigWindow::CSimulatorXPlaneConfigWindow(QWidget *parent) :
|
||||
CPluginConfigWindow(parent),
|
||||
ui(new Ui::CSimulatorXPlaneConfigWindow)
|
||||
{
|
||||
ui->setupUi(this);
|
||||
|
||||
ui->cp_XBusServer->addItem(BlackCore::CDBusServer::sessionDBusServer());
|
||||
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);
|
||||
|
||||
ui->cp_XBusServer->setCurrentText(m_xbusServerSetting.get());
|
||||
|
||||
if (xBusAvailable())
|
||||
connect(ui->pb_InstallXBus, &QPushButton::clicked, this, &CSimulatorXPlaneConfigWindow::ps_installXBus);
|
||||
else
|
||||
ui->pb_InstallXBus->setEnabled(false);
|
||||
}
|
||||
|
||||
CSimulatorXPlaneConfigWindow::~CSimulatorXPlaneConfigWindow()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool CSimulatorXPlaneConfigWindow::xBusAvailable()
|
||||
{
|
||||
return QDir(xBusOriginDir()).exists();
|
||||
}
|
||||
|
||||
void CSimulatorXPlaneConfigWindow::ps_storeSettings()
|
||||
{
|
||||
if (ui->cp_XBusServer->currentText() != m_xbusServerSetting.get())
|
||||
{
|
||||
m_xbusServerSetting.set(ui->cp_XBusServer->currentText());
|
||||
}
|
||||
}
|
||||
|
||||
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 | 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("/xbus");
|
||||
|
||||
// TODO Use QtConcurrent here, maybe?
|
||||
bool result = BlackMisc::CFileUtils::copyRecursively(xBusOriginDir(), path);
|
||||
if (result)
|
||||
{
|
||||
QMessageBox::information(this, tr("XBus installed"), tr("You may now launch your X-Plane and start using XBus!"));
|
||||
}
|
||||
else
|
||||
{
|
||||
QMessageBox::warning(this, tr("Failed installing XBus"), tr("Failed installing the XBus plugin in your X-Plane installation directory; try installing it manually."));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/* 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 BLACKSIMPLUGIN_SIMULATOR_XPLANE_CONFIG_WINDOW_H
|
||||
#define BLACKSIMPLUGIN_SIMULATOR_XPLANE_CONFIG_WINDOW_H
|
||||
|
||||
#include "simulatorxplaneconfig.h"
|
||||
#include "blackgui/pluginconfigwindow.h"
|
||||
#include <QScopedPointer>
|
||||
|
||||
namespace Ui {
|
||||
class CSimulatorXPlaneConfigWindow;
|
||||
}
|
||||
|
||||
namespace BlackSimPlugin
|
||||
{
|
||||
namespace XPlane
|
||||
{
|
||||
/**
|
||||
* A window that shows all the X-Plane plugin options.
|
||||
*/
|
||||
class CSimulatorXPlaneConfigWindow : public BlackGui::CPluginConfigWindow
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
//! Ctor.
|
||||
CSimulatorXPlaneConfigWindow(QWidget *parent);
|
||||
|
||||
//! Dtor.
|
||||
virtual ~CSimulatorXPlaneConfigWindow();
|
||||
|
||||
private:
|
||||
//! Checks whether xbus is present in the distributed directory.
|
||||
bool xBusAvailable();
|
||||
|
||||
private slots:
|
||||
void ps_storeSettings();
|
||||
void ps_installXBus();
|
||||
|
||||
private:
|
||||
QScopedPointer<Ui::CSimulatorXPlaneConfigWindow> ui;
|
||||
BlackCore::CSetting<XBusServer> m_xbusServerSetting { this };
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif // guard
|
||||
@@ -0,0 +1,61 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>CSimulatorXPlaneConfigWindow</class>
|
||||
<widget class="QWidget" name="CSimulatorXPlaneConfigWindow">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>400</width>
|
||||
<height>136</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>X-Plane plugin settings</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="1">
|
||||
<widget class="QComboBox" name="cp_XBusServer"/>
|
||||
</item>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="lbl_XBusServer">
|
||||
<property name="text">
|
||||
<string>XBus server:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<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>
|
||||
</property>
|
||||
<property name="centerButtons">
|
||||
<bool>false</bool>
|
||||
</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/>
|
||||
<connections/>
|
||||
</ui>
|
||||
29
src/plugins/simulator/xplaneconfig/xplaneconfig.pro
Normal file
29
src/plugins/simulator/xplaneconfig/xplaneconfig.pro
Normal file
@@ -0,0 +1,29 @@
|
||||
load(common_pre)
|
||||
|
||||
QT += core widgets dbus
|
||||
|
||||
TARGET = simulatorxplaneconfig
|
||||
TEMPLATE = lib
|
||||
|
||||
CONFIG += plugin shared
|
||||
CONFIG += blackmisc blackcore blackgui
|
||||
|
||||
DEPENDPATH += . $$SourceRoot/src
|
||||
INCLUDEPATH += . $$SourceRoot/src
|
||||
|
||||
SOURCES += *.cpp
|
||||
HEADERS += *.h
|
||||
FORMS += *.ui
|
||||
DISTFILES += simulatorxplaneconfig.json
|
||||
|
||||
DESTDIR = $$DestRoot/bin/plugins/simulator
|
||||
|
||||
win32 {
|
||||
dlltarget.path = $$PREFIX/bin/plugins/simulator
|
||||
INSTALLS += dlltarget
|
||||
} else {
|
||||
target.path = $$PREFIX/bin/plugins/simulator
|
||||
INSTALLS += target
|
||||
}
|
||||
|
||||
load(common_post)
|
||||
Reference in New Issue
Block a user