mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 23:05:36 +08:00
Ref T167, utility functions in CCoreFacadeConfig and better check in SwiftGuiStd::displayDBusReconnectDialog
This commit is contained in:
committed by
Mathew Sutcliffe
parent
7a87f986e2
commit
2aa5ed431f
@@ -343,6 +343,9 @@ namespace BlackCore
|
||||
//! \sa m_useContexts we use or we will use contexts
|
||||
bool supportsContexts() const;
|
||||
|
||||
//! The core facade config
|
||||
const CCoreFacadeConfig &getCoreFacadeConfig() const { return m_coreFacadeConfig; }
|
||||
|
||||
//! Init the contexts part and start core facade
|
||||
//! \sa coreFacadeStarted
|
||||
//! \remark requires setup loaded
|
||||
|
||||
@@ -26,22 +26,37 @@ namespace BlackCore
|
||||
|
||||
bool CCoreFacadeConfig::requiresDBusConnection() const
|
||||
{
|
||||
return (this->m_application == Remote ||
|
||||
this->m_audio == Remote ||
|
||||
this->m_network == Remote ||
|
||||
this->m_ownAircraft == Remote ||
|
||||
this->m_simulator == Remote);
|
||||
return this->any(Remote);
|
||||
}
|
||||
|
||||
bool CCoreFacadeConfig::any(CCoreFacadeConfig::ContextMode mode) const
|
||||
{
|
||||
return (this->m_application == mode ||
|
||||
this->m_audio == mode ||
|
||||
this->m_network == mode ||
|
||||
this->m_ownAircraft == mode ||
|
||||
this->m_simulator == mode);
|
||||
}
|
||||
|
||||
bool CCoreFacadeConfig::anyRemote() const
|
||||
{
|
||||
return this->any(Remote);
|
||||
}
|
||||
|
||||
bool CCoreFacadeConfig::anyLocalInDBusServer() const
|
||||
{
|
||||
return this->any(LocalInDBusServer);
|
||||
}
|
||||
|
||||
CCoreFacadeConfig CCoreFacadeConfig::forCoreAllLocalInDBus(const QString &dbusBootstrapAddress)
|
||||
{
|
||||
const CCoreFacadeConfig cfg(CCoreFacadeConfig::LocalInDbusServer, dbusBootstrapAddress);
|
||||
const CCoreFacadeConfig cfg(CCoreFacadeConfig::LocalInDBusServer, dbusBootstrapAddress);
|
||||
return cfg;
|
||||
}
|
||||
|
||||
CCoreFacadeConfig CCoreFacadeConfig::forCoreAllLocalInDBusNoAudio(const QString &dbusBootstrapAddress)
|
||||
{
|
||||
CCoreFacadeConfig cfg(CCoreFacadeConfig::LocalInDbusServer, dbusBootstrapAddress);
|
||||
CCoreFacadeConfig cfg(CCoreFacadeConfig::LocalInDBusServer, dbusBootstrapAddress);
|
||||
cfg.m_audio = CCoreFacadeConfig::NotUsed;
|
||||
return cfg;
|
||||
}
|
||||
|
||||
@@ -86,6 +86,15 @@ namespace BlackCore
|
||||
//! DBus address?
|
||||
bool hasDBusAddress() const { return !this->m_dbusAddress.isEmpty(); }
|
||||
|
||||
//! Any context in given mode
|
||||
bool any(ContextMode mode) const;
|
||||
|
||||
//! Any remote context?
|
||||
bool anyRemote() const;
|
||||
|
||||
//! Any local in DBus context?
|
||||
bool anyLocalInDBusServer() const;
|
||||
|
||||
//! Predefined for Core
|
||||
static CCoreFacadeConfig forCoreAllLocalInDBus(const QString &dbusBootstrapAddress = "");
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "blackcore/context/contextsimulator.h"
|
||||
#include "blackcore/network.h"
|
||||
#include "blackcore/webdataservices.h"
|
||||
#include "blackcore/corefacadeconfig.h"
|
||||
#include "blackgui/components/infobarstatuscomponent.h"
|
||||
#include "blackgui/components/logcomponent.h"
|
||||
#include "blackgui/components/settingscomponent.h"
|
||||
@@ -447,12 +448,13 @@ void SwiftGuiStd::displayLog()
|
||||
|
||||
void SwiftGuiStd::displayDBusReconnectDialog()
|
||||
{
|
||||
if (m_displayingDBusReconnect) { return; }
|
||||
if (!sGui || sGui->isShuttingDown()) { return; }
|
||||
if (!sGui->getCoreFacade()) { return; }
|
||||
if (m_displayingDBusReconnect) { return; }
|
||||
if (!sGui->getCoreFacadeConfig().requiresDBusConnection()) { return; }
|
||||
m_displayingDBusReconnect = true;
|
||||
const QString dBusAddress = sGui->getCoreFacade()->getDBusAddress();
|
||||
static const QString informativeText("Do you want to try to reconnect? 'Abort' will close the GUI. DBus: '%1'");
|
||||
static const QString informativeText("Do you want to try to reconnect? 'Abort' will close the GUI.\n\nDBus: '%1'");
|
||||
QMessageBox msgBox(this);
|
||||
msgBox.setIcon(QMessageBox::Critical);
|
||||
msgBox.setText("swift core not reachable!");
|
||||
|
||||
Reference in New Issue
Block a user