refs #432, adjusted GUI

* register / unregister with application contexts
* adjusted originator
This commit is contained in:
Klaus Basan
2015-05-27 04:12:35 +02:00
parent c25f8b6429
commit a21a42c167
4 changed files with 27 additions and 30 deletions

View File

@@ -12,6 +12,8 @@
#include "blackmisc/icon.h"
#include "blackgui/stylesheetutility.h"
#include "blackgui/models/atcstationlistmodel.h"
#include "blackgui/components/logcomponent.h"
#include "blackgui/components/settingscomponent.h"
#include "blackcore/dbus_server.h"
#include "blackcore/context_network.h"
#include "blackcore/context_application.h"
@@ -41,6 +43,7 @@ using namespace BlackMisc::Hardware;
*/
SwiftGuiStd::SwiftGuiStd(BlackGui::CEnableForFramelessWindow::WindowMode windowMode, QWidget *parent) :
QMainWindow(parent, CEnableForFramelessWindow::modeToWindowFlags(windowMode)),
COriginatorAware(this),
CEnableForFramelessWindow(windowMode, true, "framelessMainWindow", this),
ui(new Ui::SwiftGuiStd)
{
@@ -112,7 +115,7 @@ void SwiftGuiStd::performGracefulShutdown()
// tell context GUI is going down
if (this->getIContextApplication())
{
this->getIContextApplication()->notifyAboutComponentChange(IContextApplication::ApplicationGui, IContextApplication::ApplicationStops);
this->getIContextApplication()->unregisterApplication(originator());
}
// allow some other parts to react
@@ -304,8 +307,14 @@ void SwiftGuiStd::ps_handleTimerBasedUpdates()
void SwiftGuiStd::setContextAvailability()
{
qint64 t = QDateTime::currentMSecsSinceEpoch();
this->m_coreAvailable = (this->getIContextApplication()->ping(t) == t);
if (this->getIContextApplication()->isUsingImplementingObject())
{
this->m_coreAvailable = true;
}
else
{
this->m_coreAvailable = isMyOriginator(this->getIContextApplication()->registerApplication(getCurrentTimestampOriginator()));
}
this->m_contextNetworkAvailable = this->m_coreAvailable || this->getIContextNetwork()->isUsingImplementingObject();
this->m_contextAudioAvailable = this->m_coreAvailable || this->getIContextAudio()->isUsingImplementingObject();
}
@@ -406,6 +415,7 @@ void SwiftGuiStd::ps_onCurrentMainWidgetChanged(int currentIndex)
void SwiftGuiStd::ps_onChangedMainInfoAreaFloating(bool floating)
{
// code for whole floating area goes here
Q_UNUSED(floating);
}
@@ -423,7 +433,7 @@ void SwiftGuiStd::ps_showNormal()
void SwiftGuiStd::playNotifcationSound(CNotificationSounds::Notification notification) const
{
if (!this->m_contextAudioAvailable) return;
if (!this->ui->comp_MainInfoArea->getSettingsComponent()->playNotificationSounds()) return;
if (!this->m_contextAudioAvailable) { return; }
if (!this->ui->comp_MainInfoArea->getSettingsComponent()->playNotificationSounds()) { return; }
this->getIContextAudio()->playNotification(static_cast<uint>(notification), true);
}

View File

@@ -30,9 +30,9 @@
#include "blackgui/models/keyboardkeylistmodel.h"
#include "blackgui/enableforframelesswindow.h"
#include "blackgui/managedstatusbar.h"
#include "blackmisc/originator.h"
#include "blackmisc/network/textmessage.h"
#include "blackmisc/loghandler.h"
#include "blackmisc/originatoraware.h"
#include "blacksound/soundgenerator.h"
#include <QMainWindow>
#include <QTextEdit>
@@ -46,6 +46,7 @@ namespace Ui { class SwiftGuiStd; }
//! swift GUI
class SwiftGuiStd :
public QMainWindow,
public BlackMisc::COriginatorAware,
public BlackGui::CEnableForFramelessWindow,
public BlackGui::Components::CEnableForRuntime
{
@@ -112,9 +113,9 @@ private:
QScopedPointer<Ui::SwiftGuiStd> ui;
bool m_init = false;
BlackGui::Components::CInfoWindowComponent *m_compInfoWindow = nullptr; //!< the info window (popup
BlackGui::CManagedStatusBar m_statusBar;
BlackInput::IKeyboard *m_keyboard = nullptr; //!< hotkeys
BlackMisc::CLogSubscriber m_logSubscriber { this, &SwiftGuiStd::ps_displayStatusMessageInGui };
BlackGui::CManagedStatusBar m_statusBar;
BlackInput::IKeyboard *m_keyboard = nullptr; //!< hotkeys
BlackMisc::CLogSubscriber m_logSubscriber { this, &SwiftGuiStd::ps_displayStatusMessageInGui };
// contexts
bool m_coreAvailable = false;
@@ -129,8 +130,6 @@ private:
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
BlackMisc::COriginator m_originator;
//! GUI status update
void updateGuiStatusInformation();
@@ -177,22 +176,13 @@ private:
//! Stop all update timers
void stopUpdateTimersWhenDisconnected();
//! \brief Stop all timers
//! Stop all timers
//! \param disconnect also disconnect signal/slots
void stopAllTimers(bool disconnectSignalSlots);
//! Play notifcation sound
void playNotifcationSound(BlackSound::CNotificationSounds::Notification notification) const;
//! Originator for aircraft context
BlackMisc::COriginator swiftGuiStandardOriginator()
{
if (m_originator.getName().isEmpty())
m_originator = BlackMisc::COriginator(QStringLiteral("SWIFTGUISTANDARD"));
return m_originator;
}
private slots:
//

View File

@@ -13,9 +13,7 @@
#include "blackcore/context_all_interfaces.h"
#include "blackgui/stylesheetutility.h"
#include "blackgui/guiutility.h"
#include "blackgui/components/textmessagecomponent.h"
#include "blackgui/components/cockpitcomponent.h"
#include "blackgui/components/navigatordockwidget.h"
#include "blackgui/components/allmaininfoareacomponents.h"
#include "blackgui/models/atcstationlistmodel.h"
#include "blackgui/models/keyboardkeylistmodel.h"
#include "blackmisc/icons.h"
@@ -125,8 +123,6 @@ void SwiftGuiStd::init(const CRuntimeConfig &runtimeConfig)
this->initDynamicMenus();
this->initMenuIcons();
// starting
this->getIContextApplication()->notifyAboutComponentChange(IContextApplication::ApplicationGui, IContextApplication::ApplicationStarts);
// info
this->ui->comp_MainInfoArea->getLogComponent()->appendPlainTextToConsole(CProject::systemNameAndVersion());
@@ -218,17 +214,16 @@ void SwiftGuiStd::initGuiSignals()
*/
void SwiftGuiStd::initialDataReads()
{
qint64 t = QDateTime::currentMSecsSinceEpoch();
this->m_coreAvailable = (this->getIContextNetwork()->isUsingImplementingObject() || (this->getIContextApplication()->ping(t) == t));
this->setContextAvailability();
if (!this->m_coreAvailable)
{
CLogMessage(this).error("no initial data read as network context is not available");
CLogMessage(this).error("No initial data read as network context is not available");
return;
}
this->ui->comp_MainInfoArea->getSettingsComponent()->reloadSettings(); // init read
this->ps_reloadOwnAircraft(); // init read, independent of traffic network
CLogMessage(this).info("initial data read");
CLogMessage(this).info("Initial data read");
}
/*

View File

@@ -10,6 +10,8 @@
#include "swiftguistd.h"
#include "ui_swiftguistd.h"
#include "blackgui/stylesheetutility.h"
#include "blackgui/components/settingscomponent.h"
#include "blackgui/components/logcomponent.h"
#include "blackmisc/statusmessagelist.h"
#include "blackmisc/aviation/altitude.h"
#include "blackmisc/logmessage.h"