mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-27 02:55:44 +08:00
Issue #15 [GUI] Use CLogHistoryReplica in CLogComponent and swift applications
This commit is contained in:
@@ -272,27 +272,6 @@ void SwiftGuiStd::loginRequested()
|
||||
}
|
||||
}
|
||||
|
||||
void SwiftGuiStd::displayStatusMessageInGui(const CStatusMessage &statusMessage)
|
||||
{
|
||||
if (!m_init) { return; }
|
||||
// used with log subscriber
|
||||
if (statusMessage.wasHandledBy(this)) { return; }
|
||||
statusMessage.markAsHandledBy(this);
|
||||
m_statusBar.displayStatusMessage(statusMessage);
|
||||
|
||||
// main info areas
|
||||
ui->comp_MainInfoArea->displayStatusMessage(statusMessage);
|
||||
|
||||
// list
|
||||
ui->comp_MainInfoArea->getLogComponent()->appendStatusMessageToList(statusMessage);
|
||||
|
||||
// display overlay for errors, but not for validation
|
||||
if (statusMessage.getSeverity() == CStatusMessage::SeverityError && ! statusMessage.getCategories().contains(CLogCategory::validation()))
|
||||
{
|
||||
ui->fr_CentralFrameInside->showOverlayMessage(statusMessage);
|
||||
}
|
||||
}
|
||||
|
||||
void SwiftGuiStd::onKickedFromNetwork(const QString &kickMessage)
|
||||
{
|
||||
this->updateGuiStatusInformation();
|
||||
@@ -363,7 +342,6 @@ void SwiftGuiStd::setContextAvailability()
|
||||
{
|
||||
// core has just become available (startup)
|
||||
// this HERE is called with and without DBus
|
||||
sGui->getIContextApplication()->synchronizeLogSubscriptions();
|
||||
sGui->getIContextApplication()->synchronizeLocalSettings();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include "blackmisc/identifiable.h"
|
||||
#include "blackmisc/variant.h"
|
||||
#include "blackmisc/loghandler.h"
|
||||
#include "blackmisc/loghistory.h"
|
||||
#include "blackmisc/statusmessage.h"
|
||||
#include "blackmisc/icons.h"
|
||||
|
||||
@@ -127,7 +128,8 @@ private:
|
||||
BlackCore::CActionBind m_actionPtt2 { BlackMisc::Input::pttCom2HotkeyAction(), BlackMisc::CIcons::StandardIconRadio16, this, &SwiftGuiStd::onPttChanged };
|
||||
BlackCore::CActionBindings m_menuHotkeyHandlers;
|
||||
BlackGui::CManagedStatusBar m_statusBar;
|
||||
BlackMisc::CLogSubscriber m_logSubscriber { this, &SwiftGuiStd::displayStatusMessageInGui };
|
||||
BlackMisc::CLogHistoryReplica m_logHistoryForStatus { this };
|
||||
BlackMisc::CLogHistoryReplica m_logHistoryForOverlay { this };
|
||||
|
||||
// contexts
|
||||
static constexpr int MaxCoreFailures = 5; //!< Failures counted before reconnecting
|
||||
@@ -207,9 +209,6 @@ private:
|
||||
//! Reload own aircraft
|
||||
bool reloadOwnAircraft();
|
||||
|
||||
//! Display status message
|
||||
void displayStatusMessageInGui(const BlackMisc::CStatusMessage &statusMessage);
|
||||
|
||||
//! Connection status changed
|
||||
//! \param from old status
|
||||
//! \param to new status
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include "blackcore/context/contextaudio.h"
|
||||
#include "blacksound/audioutilities.h"
|
||||
#include "blackmisc/network/networkutils.h"
|
||||
#include "blackmisc/sharedstate/datalinkdbus.h"
|
||||
#include "blackmisc/loghandler.h"
|
||||
#include "blackmisc/logmessage.h"
|
||||
#include "blackmisc/logpattern.h"
|
||||
@@ -83,7 +84,20 @@ void SwiftGuiStd::init()
|
||||
// if (CBuildConfig::isLocalDeveloperDebugBuild()) { BlackSound::occupyAudioInputDevice(); }
|
||||
|
||||
// log messages
|
||||
m_logSubscriber.changeSubscription(CLogPattern().withSeverityAtOrAbove(CStatusMessage::SeverityInfo));
|
||||
m_logHistoryForStatus.setFilter(CLogPattern().withSeverityAtOrAbove(CStatusMessage::SeverityInfo));
|
||||
m_logHistoryForOverlay.setFilter(CLogPattern().withSeverityAtOrAbove(CStatusMessage::SeverityError));
|
||||
connect(&m_logHistoryForStatus, &CLogHistoryReplica::elementAdded, this, [this](const CStatusMessage& message)
|
||||
{
|
||||
m_statusBar.displayStatusMessage(message);
|
||||
ui->comp_MainInfoArea->displayStatusMessage(message);
|
||||
});
|
||||
connect(&m_logHistoryForOverlay, &CLogHistoryReplica::elementAdded, this, [this](const CStatusMessage& message)
|
||||
{
|
||||
//! \todo filter out validation messages at CLogPattern level
|
||||
if (!message.getCategories().contains(CLogCategory::validation())) { ui->fr_CentralFrameInside->showOverlayMessage(message); }
|
||||
});
|
||||
m_logHistoryForStatus.initialize(sApp->getDataLinkDBus());
|
||||
m_logHistoryForOverlay.initialize(sApp->getDataLinkDBus());
|
||||
|
||||
// style
|
||||
this->initStyleSheet();
|
||||
|
||||
Reference in New Issue
Block a user