mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-16 10:25:36 +08:00
Improvements of swift GUI - pilot client
* support for headers, allow to load files when caches are outdated (refs #787) * display error when no model set is initialized * removed some unused members
This commit is contained in:
@@ -10,7 +10,9 @@
|
|||||||
#include "blackcore/context/contextapplication.h"
|
#include "blackcore/context/contextapplication.h"
|
||||||
#include "blackcore/context/contextaudio.h"
|
#include "blackcore/context/contextaudio.h"
|
||||||
#include "blackcore/context/contextnetwork.h"
|
#include "blackcore/context/contextnetwork.h"
|
||||||
|
#include "blackcore/context/contextsimulator.h"
|
||||||
#include "blackcore/network.h"
|
#include "blackcore/network.h"
|
||||||
|
#include "blackcore/webdataservices.h"
|
||||||
#include "blackgui/components/infobarstatuscomponent.h"
|
#include "blackgui/components/infobarstatuscomponent.h"
|
||||||
#include "blackgui/components/logcomponent.h"
|
#include "blackgui/components/logcomponent.h"
|
||||||
#include "blackgui/components/settingscomponent.h"
|
#include "blackgui/components/settingscomponent.h"
|
||||||
@@ -48,6 +50,7 @@ namespace BlackGui
|
|||||||
namespace BlackMisc { class CIdentifiable; }
|
namespace BlackMisc { class CIdentifiable; }
|
||||||
|
|
||||||
using namespace BlackCore;
|
using namespace BlackCore;
|
||||||
|
using namespace BlackCore::Context;
|
||||||
using namespace BlackMisc;
|
using namespace BlackMisc;
|
||||||
using namespace BlackGui;
|
using namespace BlackGui;
|
||||||
using namespace BlackGui::Components;
|
using namespace BlackGui::Components;
|
||||||
@@ -57,6 +60,7 @@ using namespace BlackMisc::PhysicalQuantities;
|
|||||||
using namespace BlackMisc::Geo;
|
using namespace BlackMisc::Geo;
|
||||||
using namespace BlackMisc::Audio;
|
using namespace BlackMisc::Audio;
|
||||||
using namespace BlackMisc::Input;
|
using namespace BlackMisc::Input;
|
||||||
|
using namespace BlackMisc::Simulation;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Constructor
|
* Constructor
|
||||||
@@ -153,7 +157,7 @@ void SwiftGuiStd::changeEvent(QEvent *event)
|
|||||||
|
|
||||||
QAction *SwiftGuiStd::getWindowMinimizeAction(QObject *parent)
|
QAction *SwiftGuiStd::getWindowMinimizeAction(QObject *parent)
|
||||||
{
|
{
|
||||||
QIcon i(CIcons::changeIconBackgroundColor(this->style()->standardIcon(QStyle::SP_TitleBarMinButton), Qt::white, QSize(16, 16)));
|
const QIcon i(CIcons::changeIconBackgroundColor(this->style()->standardIcon(QStyle::SP_TitleBarMinButton), Qt::white, QSize(16, 16)));
|
||||||
QAction *a = new QAction(i, "Window minimized", parent);
|
QAction *a = new QAction(i, "Window minimized", parent);
|
||||||
connect(a, &QAction::triggered, this, &SwiftGuiStd::ps_showMinimized);
|
connect(a, &QAction::triggered, this, &SwiftGuiStd::ps_showMinimized);
|
||||||
return a;
|
return a;
|
||||||
@@ -287,7 +291,6 @@ void SwiftGuiStd::ps_handleTimerBasedUpdates()
|
|||||||
void SwiftGuiStd::setContextAvailability()
|
void SwiftGuiStd::setContextAvailability()
|
||||||
{
|
{
|
||||||
bool corePreviouslyAvailable = this->m_coreAvailable;
|
bool corePreviouslyAvailable = this->m_coreAvailable;
|
||||||
|
|
||||||
if (sGui && sGui->getIContextApplication()->isUsingImplementingObject())
|
if (sGui && sGui->getIContextApplication()->isUsingImplementingObject())
|
||||||
{
|
{
|
||||||
this->m_coreAvailable = true;
|
this->m_coreAvailable = true;
|
||||||
@@ -295,9 +298,8 @@ void SwiftGuiStd::setContextAvailability()
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
// ping to check if core is still alive
|
// ping to check if core is still alive
|
||||||
this->m_coreAvailable =
|
this->m_coreAvailable = sGui &&
|
||||||
sGui &&
|
this->isMyIdentifier(sGui->getIContextApplication()->registerApplication(getCurrentTimestampIdentifier()));
|
||||||
this->isMyIdentifier(sGui->getIContextApplication()->registerApplication(getCurrentTimestampIdentifier()));
|
|
||||||
}
|
}
|
||||||
this->m_contextNetworkAvailable = this->m_coreAvailable || (sGui && sGui->getIContextNetwork()->isUsingImplementingObject());
|
this->m_contextNetworkAvailable = this->m_coreAvailable || (sGui && sGui->getIContextNetwork()->isUsingImplementingObject());
|
||||||
this->m_contextAudioAvailable = this->m_coreAvailable || (sGui && sGui->getIContextAudio()->isUsingImplementingObject());
|
this->m_contextAudioAvailable = this->m_coreAvailable || (sGui && sGui->getIContextAudio()->isUsingImplementingObject());
|
||||||
@@ -388,6 +390,35 @@ void SwiftGuiStd::ps_navigatorClosed()
|
|||||||
this->showNormal();
|
this->showNormal();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SwiftGuiStd::ps_verifyDataAvailability()
|
||||||
|
{
|
||||||
|
const CSimulatorInfo sims = sGui->getIContextSimulator()->simulatorsWithInitializedModelSet();
|
||||||
|
if (sims.isNoSimulator())
|
||||||
|
{
|
||||||
|
CLogMessage(this).error("No model set so far, you need at least one model set");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SwiftGuiStd::ps_sharedFilesHeadersLoaded()
|
||||||
|
{
|
||||||
|
Q_ASSERT_X(sGui && sGui->hasWebDataServices(), Q_FUNC_INFO, "Missing web services");
|
||||||
|
const CEntityFlags::Entity newEntities = sGui->getWebDataServices()->getEntitiesWithNewerHeaderTimestamp(CEntityFlags::AllDbEntities);
|
||||||
|
if (newEntities == CEntityFlags::NoEntity) { return; }
|
||||||
|
CStatusMessage sm = CStatusMessage(this).info("New data for shared files:");
|
||||||
|
CStatusMessageList sms({sm});
|
||||||
|
const QSet<CEntityFlags::Entity> newSingleEntities = CEntityFlags::asSingleEntities(newEntities);
|
||||||
|
for (CEntityFlags::Entity newSingleEntity : newSingleEntities)
|
||||||
|
{
|
||||||
|
sm = CStatusMessage(this).info("Load data for '%1'?") << CEntityFlags::flagToString(newSingleEntity);
|
||||||
|
sms.push_back(sm);
|
||||||
|
}
|
||||||
|
auto lambda = [this, newEntities]()
|
||||||
|
{
|
||||||
|
sGui->getWebDataServices()->triggerLoadingDirectlyFromSharedFiles(newEntities, false);
|
||||||
|
};
|
||||||
|
ui->fr_CentralFrameInside->showOverlayMessagesWithConfirmation(sms, "Load data?", lambda);
|
||||||
|
}
|
||||||
|
|
||||||
void SwiftGuiStd::playNotifcationSound(CNotificationSounds::Notification notification) const
|
void SwiftGuiStd::playNotifcationSound(CNotificationSounds::Notification notification) const
|
||||||
{
|
{
|
||||||
if (!this->m_contextAudioAvailable) { return; }
|
if (!this->m_contextAudioAvailable) { return; }
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ public:
|
|||||||
SwiftGuiStd(WindowMode windowMode, QWidget *parent = nullptr);
|
SwiftGuiStd(WindowMode windowMode, QWidget *parent = nullptr);
|
||||||
|
|
||||||
//! Destructor
|
//! Destructor
|
||||||
~SwiftGuiStd();
|
virtual ~SwiftGuiStd();
|
||||||
|
|
||||||
//! Log message category
|
//! Log message category
|
||||||
static QString getLogCategory() { return "swift.gui.stdgui"; }
|
static QString getLogCategory() { return "swift.gui.stdgui"; }
|
||||||
@@ -103,8 +103,7 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
QScopedPointer<Ui::SwiftGuiStd> ui;
|
QScopedPointer<Ui::SwiftGuiStd> ui;
|
||||||
// if I pass the parent, the dialog is always center over the parent
|
QScopedPointer<BlackGui::Components::CNavigatorDialog> m_navigator{new BlackGui::Components::CNavigatorDialog()}; // if I pass the parent, the dialog is always centered over the parent
|
||||||
QScopedPointer<BlackGui::Components::CNavigatorDialog> m_navigator{new BlackGui::Components::CNavigatorDialog()};
|
|
||||||
bool m_init = false;
|
bool m_init = false;
|
||||||
BlackGui::CManagedStatusBar m_statusBar;
|
BlackGui::CManagedStatusBar m_statusBar;
|
||||||
BlackMisc::CLogSubscriber m_logSubscriber { this, &SwiftGuiStd::ps_displayStatusMessageInGui };
|
BlackMisc::CLogSubscriber m_logSubscriber { this, &SwiftGuiStd::ps_displayStatusMessageInGui };
|
||||||
@@ -115,16 +114,6 @@ private:
|
|||||||
bool m_contextAudioAvailable = false;
|
bool m_contextAudioAvailable = false;
|
||||||
QTimer *m_timerContextWatchdog = nullptr; //!< core available?
|
QTimer *m_timerContextWatchdog = nullptr; //!< core available?
|
||||||
BlackMisc::Simulation::CSimulatedAircraft m_ownAircraft; //!< own aircraft's state
|
BlackMisc::Simulation::CSimulatedAircraft m_ownAircraft; //!< own aircraft's state
|
||||||
QSize m_windowMinSizeWithMainPageShown;
|
|
||||||
QSize m_windowMinSizeWithMainPageHidden;
|
|
||||||
|
|
||||||
// cockpit
|
|
||||||
QString m_transponderResetValue; //!< Temp. storage of XPdr mode to reset, req. until timer allows singleShoot with Lambdas
|
|
||||||
QWidget *m_inputFocusedWidget = nullptr; //!< currently used widget for input, mainly used with cockpit
|
|
||||||
|
|
||||||
// actions
|
|
||||||
BlackCore::CActionBind m_action50 { "/swiftGui/Change opacity to 50%", this, &SwiftGuiStd::ps_onChangedWindowOpacityTo50 };
|
|
||||||
BlackCore::CActionBind m_action100 { "/swiftGui/Change opacity to 100%", this, &SwiftGuiStd::ps_onChangedWindowOpacityTo100 };
|
|
||||||
|
|
||||||
//! GUI status update
|
//! GUI status update
|
||||||
void updateGuiStatusInformation();
|
void updateGuiStatusInformation();
|
||||||
@@ -255,6 +244,12 @@ private slots:
|
|||||||
|
|
||||||
//! Navigator dialog has been closed
|
//! Navigator dialog has been closed
|
||||||
void ps_navigatorClosed();
|
void ps_navigatorClosed();
|
||||||
|
|
||||||
|
//! Checks if data such as model set etc. are available
|
||||||
|
void ps_verifyDataAvailability();
|
||||||
|
|
||||||
|
//! The shared headers have been loaded
|
||||||
|
void ps_sharedFilesHeadersLoaded();
|
||||||
};
|
};
|
||||||
|
|
||||||
#pragma pop_macro("interface")
|
#pragma pop_macro("interface")
|
||||||
|
|||||||
@@ -8,6 +8,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "blackconfig/buildconfig.h"
|
#include "blackconfig/buildconfig.h"
|
||||||
|
#include "blackcore/webdataservices.h"
|
||||||
#include "blackcore/context/contextnetwork.h"
|
#include "blackcore/context/contextnetwork.h"
|
||||||
#include "blackgui/components/aircraftcomponent.h"
|
#include "blackgui/components/aircraftcomponent.h"
|
||||||
#include "blackgui/components/atcstationcomponent.h"
|
#include "blackgui/components/atcstationcomponent.h"
|
||||||
@@ -58,6 +59,8 @@ using namespace BlackGui::Components;
|
|||||||
void SwiftGuiStd::init()
|
void SwiftGuiStd::init()
|
||||||
{
|
{
|
||||||
// POST(!) GUI init
|
// POST(!) GUI init
|
||||||
|
Q_ASSERT_X(sGui, Q_FUNC_INFO, "Missing sGui");
|
||||||
|
Q_ASSERT_X(sGui->getWebDataServices(), Q_FUNC_INFO, "Missing web services");
|
||||||
|
|
||||||
if (this->m_init) { return; }
|
if (this->m_init) { return; }
|
||||||
|
|
||||||
@@ -118,6 +121,7 @@ void SwiftGuiStd::init()
|
|||||||
this->initGuiSignals();
|
this->initGuiSignals();
|
||||||
|
|
||||||
// signal / slots contexts / timers
|
// signal / slots contexts / timers
|
||||||
|
connect(sGui->getWebDataServices(), &CWebDataServices::allSwiftSharedAllHeadersReceived, this, &SwiftGuiStd::ps_sharedFilesHeadersLoaded);
|
||||||
connect(sGui->getIContextNetwork(), &IContextNetwork::connectionTerminated, this, &SwiftGuiStd::ps_onConnectionTerminated);
|
connect(sGui->getIContextNetwork(), &IContextNetwork::connectionTerminated, this, &SwiftGuiStd::ps_onConnectionTerminated);
|
||||||
connect(sGui->getIContextNetwork(), &IContextNetwork::connectionStatusChanged, this, &SwiftGuiStd::ps_onConnectionStatusChanged);
|
connect(sGui->getIContextNetwork(), &IContextNetwork::connectionStatusChanged, this, &SwiftGuiStd::ps_onConnectionStatusChanged);
|
||||||
connect(sGui->getIContextNetwork(), &IContextNetwork::textMessagesReceived, ui->comp_MainInfoArea->getTextMessageComponent(), &CTextMessageComponent::onTextMessageReceived);
|
connect(sGui->getIContextNetwork(), &IContextNetwork::textMessagesReceived, ui->comp_MainInfoArea->getTextMessageComponent(), &CTextMessageComponent::onTextMessageReceived);
|
||||||
@@ -147,6 +151,7 @@ void SwiftGuiStd::init()
|
|||||||
|
|
||||||
sGui->startUpCompleted(true);
|
sGui->startUpCompleted(true);
|
||||||
this->m_init = true;
|
this->m_init = true;
|
||||||
|
QTimer::singleShot(2500, this, &SwiftGuiStd::ps_verifyDataAvailability);
|
||||||
|
|
||||||
if (!CNetworkUtils::hasConnectedInterface())
|
if (!CNetworkUtils::hasConnectedInterface())
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user