mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-25 10:15:43 +08:00
Ref T167, in swift GUI
* removed isContextNetworkAvailableCheck / isContextAudioAvailableCheck * replaced those by displayDBusReconnectDialog * using a counter to ignore some errors before showing re-connect dialog
This commit is contained in:
committed by
Mathew Sutcliffe
parent
ed51d3c5dd
commit
8b1ef20146
@@ -36,6 +36,7 @@
|
|||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <Qt>
|
#include <Qt>
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
|
#include <QMessageBox>
|
||||||
|
|
||||||
class QCloseEvent;
|
class QCloseEvent;
|
||||||
class QEvent;
|
class QEvent;
|
||||||
@@ -214,20 +215,6 @@ void SwiftGuiStd::ps_loginRequested()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SwiftGuiStd::isContextNetworkAvailableCheck()
|
|
||||||
{
|
|
||||||
if (m_contextNetworkAvailable) return true;
|
|
||||||
CLogMessage(this).error("Network context not available, no updates this time");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool SwiftGuiStd::isContextAudioAvailableCheck()
|
|
||||||
{
|
|
||||||
if (m_contextAudioAvailable) return true;
|
|
||||||
CLogMessage(this).error("Audio context not available");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void SwiftGuiStd::ps_displayStatusMessageInGui(const CStatusMessage &statusMessage)
|
void SwiftGuiStd::ps_displayStatusMessageInGui(const CStatusMessage &statusMessage)
|
||||||
{
|
{
|
||||||
if (!m_init) { return; }
|
if (!m_init) { return; }
|
||||||
@@ -288,10 +275,8 @@ void SwiftGuiStd::ps_handleTimerBasedUpdates()
|
|||||||
void SwiftGuiStd::setContextAvailability()
|
void SwiftGuiStd::setContextAvailability()
|
||||||
{
|
{
|
||||||
const bool corePreviouslyAvailable = m_coreAvailable;
|
const bool corePreviouslyAvailable = m_coreAvailable;
|
||||||
if (sGui &&
|
const bool isShuttingDown = !sGui || sGui->isShuttingDown();
|
||||||
sGui->getIContextApplication() &&
|
if (!isShuttingDown && sGui->getIContextApplication() && !sGui->getIContextApplication()->isEmptyObject())
|
||||||
!sGui->isShuttingDown() &&
|
|
||||||
!sGui->getIContextApplication()->isEmptyObject())
|
|
||||||
{
|
{
|
||||||
// ping to check if core is still alive
|
// ping to check if core is still alive
|
||||||
m_coreAvailable = this->isMyIdentifier(sGui->getIContextApplication()->registerApplication(getCurrentTimestampIdentifier()));
|
m_coreAvailable = this->isMyIdentifier(sGui->getIContextApplication()->registerApplication(getCurrentTimestampIdentifier()));
|
||||||
@@ -300,7 +285,19 @@ void SwiftGuiStd::setContextAvailability()
|
|||||||
{
|
{
|
||||||
m_coreAvailable = false;
|
m_coreAvailable = false;
|
||||||
}
|
}
|
||||||
|
if (isShuttingDown) { return; }
|
||||||
|
if (m_coreAvailable && m_coreFailures > 0)
|
||||||
|
{
|
||||||
|
m_coreFailures--;
|
||||||
|
}
|
||||||
|
else if (!m_coreAvailable && m_coreFailures < MaxCoreFailures)
|
||||||
|
{
|
||||||
|
m_coreFailures++;
|
||||||
|
}
|
||||||
|
else if (!m_coreAvailable && !m_displayingDBusReconnect)
|
||||||
|
{
|
||||||
|
this->displayDBusReconnectDialog();
|
||||||
|
}
|
||||||
m_contextNetworkAvailable = m_coreAvailable && sGui->getIContextNetwork() && !sGui->getIContextNetwork()->isEmptyObject();
|
m_contextNetworkAvailable = m_coreAvailable && sGui->getIContextNetwork() && !sGui->getIContextNetwork()->isEmptyObject();
|
||||||
m_contextAudioAvailable = m_coreAvailable && sGui->getIContextAudio() && !sGui->getIContextAudio()->isEmptyObject();
|
m_contextAudioAvailable = m_coreAvailable && sGui->getIContextAudio() && !sGui->getIContextAudio()->isEmptyObject();
|
||||||
|
|
||||||
@@ -443,3 +440,26 @@ void SwiftGuiStd::displayLog()
|
|||||||
{
|
{
|
||||||
ui->comp_MainInfoArea->displayLog();
|
ui->comp_MainInfoArea->displayLog();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SwiftGuiStd::displayDBusReconnectDialog()
|
||||||
|
{
|
||||||
|
if (!sGui || sGui->isShuttingDown()) { return; }
|
||||||
|
if (!sGui->getCoreFacade()) { return; }
|
||||||
|
if (m_displayingDBusReconnect) { return; }
|
||||||
|
m_displayingDBusReconnect = true;
|
||||||
|
QMessageBox msgBox(this);
|
||||||
|
msgBox.setIcon(QMessageBox::Critical);
|
||||||
|
msgBox.setText("swift core not reachable.");
|
||||||
|
msgBox.setInformativeText("Do you want to try to reconnect? 'Abort' will close the GUI.");
|
||||||
|
msgBox.setStandardButtons(QMessageBox::Retry | QMessageBox::Abort);
|
||||||
|
msgBox.setDefaultButton(QMessageBox::Retry);
|
||||||
|
const int ret = msgBox.exec();
|
||||||
|
m_displayingDBusReconnect = false;
|
||||||
|
m_coreFailures = 0;
|
||||||
|
if (ret == QMessageBox::Abort)
|
||||||
|
{
|
||||||
|
this->close();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
sGui->getCoreFacade()->tryToReconnectWithDBus();
|
||||||
|
}
|
||||||
|
|||||||
@@ -111,10 +111,13 @@ private:
|
|||||||
bool m_init = false;
|
bool m_init = false;
|
||||||
|
|
||||||
// contexts
|
// contexts
|
||||||
bool m_coreAvailable = false;
|
static constexpr int MaxCoreFailures = 5; //!< Failures counted before reconnecting
|
||||||
bool m_contextNetworkAvailable = false;
|
int m_coreFailures = 0; //!< failed access to core
|
||||||
bool m_contextAudioAvailable = false;
|
bool m_coreAvailable = false; //!< core already available?
|
||||||
QTimer *m_timerContextWatchdog = nullptr; //!< core available?
|
bool m_contextNetworkAvailable = false; //!< network context available?
|
||||||
|
bool m_contextAudioAvailable = false; //!< audio context available?
|
||||||
|
bool m_displayingDBusReconnect = false; //!< currently displaying reconnect dialog
|
||||||
|
QTimer *m_timerContextWatchdog = nullptr; //!< core available?
|
||||||
BlackMisc::Simulation::CSimulatedAircraft m_ownAircraft; //!< own aircraft's state
|
BlackMisc::Simulation::CSimulatedAircraft m_ownAircraft; //!< own aircraft's state
|
||||||
|
|
||||||
//! GUI status update
|
//! GUI status update
|
||||||
@@ -138,12 +141,6 @@ private:
|
|||||||
//! Graceful shutdown
|
//! Graceful shutdown
|
||||||
void performGracefulShutdown();
|
void performGracefulShutdown();
|
||||||
|
|
||||||
//! Context network availability check, otherwise status message
|
|
||||||
bool isContextNetworkAvailableCheck();
|
|
||||||
|
|
||||||
//! Context voice availability check, otherwise status message
|
|
||||||
bool isContextAudioAvailableCheck();
|
|
||||||
|
|
||||||
//! Audio device lists
|
//! Audio device lists
|
||||||
void setAudioDeviceLists();
|
void setAudioDeviceLists();
|
||||||
|
|
||||||
@@ -173,6 +170,9 @@ private:
|
|||||||
//! Display log
|
//! Display log
|
||||||
void displayLog();
|
void displayLog();
|
||||||
|
|
||||||
|
//! Display a reconnect dialog
|
||||||
|
void displayDBusReconnectDialog();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
//
|
//
|
||||||
// Data received related slots
|
// Data received related slots
|
||||||
@@ -185,8 +185,8 @@ private slots:
|
|||||||
void ps_displayStatusMessageInGui(const BlackMisc::CStatusMessage &statusMessage);
|
void ps_displayStatusMessageInGui(const BlackMisc::CStatusMessage &statusMessage);
|
||||||
|
|
||||||
//! Connection status changed
|
//! Connection status changed
|
||||||
//! \param from old status, as int so it is compliant with DBus
|
//! \param from old status
|
||||||
//! \param to new status, as int so it is compliant with DBus
|
//! \param to new status
|
||||||
void ps_onConnectionStatusChanged(BlackCore::INetwork::ConnectionStatus from, BlackCore::INetwork::ConnectionStatus to);
|
void ps_onConnectionStatusChanged(BlackCore::INetwork::ConnectionStatus from, BlackCore::INetwork::ConnectionStatus to);
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ using namespace BlackMisc::Audio;
|
|||||||
|
|
||||||
bool SwiftGuiStd::ps_reloadOwnAircraft()
|
bool SwiftGuiStd::ps_reloadOwnAircraft()
|
||||||
{
|
{
|
||||||
if (!this->isContextNetworkAvailableCheck()) { return false; }
|
if (!this->m_contextNetworkAvailable) { return false; }
|
||||||
|
|
||||||
// check for changed aircraft
|
// check for changed aircraft
|
||||||
bool changed = false;
|
bool changed = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user