mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-20 04:25:42 +08:00
Ref T125, X-Plan utility functions and moved XSwiftBus settings in own file
This commit is contained in:
committed by
Mathew Sutcliffe
parent
104d869c19
commit
65bd2d20ad
43
src/blackmisc/simulation/settings/xswiftbussettings.h
Normal file
43
src/blackmisc/simulation/settings/xswiftbussettings.h
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
/* Copyright (C) 2017
|
||||||
|
* 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 BLACKMISC_SIMULATION_SETTINGS_XSWIFTBUSSETTINGS_H
|
||||||
|
#define BLACKMISC_SIMULATION_SETTINGS_XSWIFTBUSSETTINGS_H
|
||||||
|
|
||||||
|
#include <QString>
|
||||||
|
#include "blackmisc/settingscache.h"
|
||||||
|
#include "blackmisc/dbusserver.h"
|
||||||
|
|
||||||
|
namespace BlackMisc
|
||||||
|
{
|
||||||
|
namespace Simulation
|
||||||
|
{
|
||||||
|
namespace Settings
|
||||||
|
{
|
||||||
|
/*!
|
||||||
|
* 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 BlackMisc::CDBusServer::sessionBusAddress(); }
|
||||||
|
|
||||||
|
//! \copydoc BlackMisc::TSettingTrait::defaultValue
|
||||||
|
static bool isValid(const QString &dBusAddress) { return BlackMisc::CDBusServer::isSessionOrSystemAddress(dBusAddress); }
|
||||||
|
};
|
||||||
|
} // ns
|
||||||
|
} // ns
|
||||||
|
} // ns
|
||||||
|
|
||||||
|
#endif // guard
|
||||||
@@ -89,6 +89,7 @@ namespace BlackMisc
|
|||||||
|
|
||||||
QString CXPlaneUtil::xplaneDir(const QString &xplaneInstallFile)
|
QString CXPlaneUtil::xplaneDir(const QString &xplaneInstallFile)
|
||||||
{
|
{
|
||||||
|
//! \fixme KB 8/17 we could also use the runtime CBuildConfig decision here, which looks nicer (I personally always try to avoid ifdef)
|
||||||
#if defined(Q_OS_WIN)
|
#if defined(Q_OS_WIN)
|
||||||
return CFileUtils::appendFilePaths(getWindowsLocalAppDataPath(), xplaneInstallFile);
|
return CFileUtils::appendFilePaths(getWindowsLocalAppDataPath(), xplaneInstallFile);
|
||||||
#elif defined (Q_OS_LINUX)
|
#elif defined (Q_OS_LINUX)
|
||||||
@@ -108,6 +109,25 @@ namespace BlackMisc
|
|||||||
else { return {}; }
|
else { return {}; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CXPlaneUtil::isXplaneRootDirExisting()
|
||||||
|
{
|
||||||
|
const QDir dir(xplaneRootDir());
|
||||||
|
return dir.exists();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString CXPlaneUtil::xplanePluginDir()
|
||||||
|
{
|
||||||
|
const QString xp = xplaneRootDir();
|
||||||
|
if (xp.isEmpty()) { return xp; }
|
||||||
|
return CFileUtils::appendFilePaths(xp, "/Resources/plugins");
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CXPlaneUtil::isXplanePluginDirDirExisting()
|
||||||
|
{
|
||||||
|
const QDir dir(xplanePluginDir());
|
||||||
|
return dir.exists();
|
||||||
|
}
|
||||||
|
|
||||||
QStringList CXPlaneUtil::xplaneModelDirectories()
|
QStringList CXPlaneUtil::xplaneModelDirectories()
|
||||||
{
|
{
|
||||||
if (xplaneRootDir().isEmpty()) { return QStringList(); }
|
if (xplaneRootDir().isEmpty()) { return QStringList(); }
|
||||||
@@ -142,7 +162,6 @@ namespace BlackMisc
|
|||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace
|
} // namespace
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|||||||
@@ -42,6 +42,16 @@ namespace BlackMisc
|
|||||||
//! In case more then one XPlane version is found, the path to the highest version is used
|
//! In case more then one XPlane version is found, the path to the highest version is used
|
||||||
static QString xplaneRootDir();
|
static QString xplaneRootDir();
|
||||||
|
|
||||||
|
//! Is the xplaneRootDir existing?
|
||||||
|
static bool isXplaneRootDirExisting();
|
||||||
|
|
||||||
|
//! XPlane root directory
|
||||||
|
//! In case more then one XPlane version is found, the path to the highest version is used
|
||||||
|
static QString xplanePluginDir();
|
||||||
|
|
||||||
|
//! Is the xplanePluginDir existing?
|
||||||
|
static bool isXplanePluginDirDirExisting();
|
||||||
|
|
||||||
//! Directories with models
|
//! Directories with models
|
||||||
static QStringList xplaneModelDirectories();
|
static QStringList xplaneModelDirectories();
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,7 @@
|
|||||||
#include "blackmisc/simulation/aircraftmodellist.h"
|
#include "blackmisc/simulation/aircraftmodellist.h"
|
||||||
#include "blackmisc/simulation/data/modelcaches.h"
|
#include "blackmisc/simulation/data/modelcaches.h"
|
||||||
#include "blackmisc/simulation/settings/simulatorsettings.h"
|
#include "blackmisc/simulation/settings/simulatorsettings.h"
|
||||||
|
#include "blackmisc/simulation/settings/xswiftbussettings.h"
|
||||||
#include "blackmisc/weather/weathergrid.h"
|
#include "blackmisc/weather/weathergrid.h"
|
||||||
#include "blackmisc/settingscache.h"
|
#include "blackmisc/settingscache.h"
|
||||||
#include "blackmisc/statusmessage.h"
|
#include "blackmisc/statusmessage.h"
|
||||||
@@ -224,7 +225,7 @@ namespace BlackSimPlugin
|
|||||||
private:
|
private:
|
||||||
QDBusConnection m_conn { "default" };
|
QDBusConnection m_conn { "default" };
|
||||||
QDBusServiceWatcher *m_watcher { nullptr };
|
QDBusServiceWatcher *m_watcher { nullptr };
|
||||||
BlackMisc::CSetting<TXSwiftBusServer> m_xswiftbusServerSetting { this, &CSimulatorXPlaneListener::ps_xswiftbusServerSettingChanged };
|
BlackMisc::CSettingReadOnly<BlackMisc::Simulation::Settings::TXSwiftBusServer> m_xswiftbusServerSetting { this, &CSimulatorXPlaneListener::ps_xswiftbusServerSettingChanged };
|
||||||
};
|
};
|
||||||
|
|
||||||
//! Factory for creating CSimulatorXPlane instance
|
//! Factory for creating CSimulatorXPlane instance
|
||||||
|
|||||||
Reference in New Issue
Block a user