mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-05 17:35:34 +08:00
Issue #15 [GUI] Use CLogHistoryReplica in CLogComponent and swift applications
This commit is contained in:
@@ -35,6 +35,7 @@ int main(int argc, char *argv[])
|
||||
a.splashScreen(CIcons::swiftDatabase256());
|
||||
if (!a.parseAndSynchronizeSetup()) { return EXIT_FAILURE; }
|
||||
a.useWebDataServices(BlackCore::CWebReaderFlags::AllSwiftDbReaders, CDatabaseReaderConfigList::forMappingTool());
|
||||
a.useFacadeNoContexts();
|
||||
if (!a.start())
|
||||
{
|
||||
a.gracefulShutdown();
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
#include "blackcore/data/globalsetup.h"
|
||||
#include "blackmisc/simulation/autopublishdata.h"
|
||||
#include "blackmisc/simulation/distributorlist.h"
|
||||
#include "blackmisc/sharedstate/datalinkdbus.h"
|
||||
#include "blackmisc/loghandler.h"
|
||||
#include "blackmisc/statusmessage.h"
|
||||
#include "blackmisc/logmessage.h"
|
||||
@@ -80,17 +81,6 @@ void CSwiftData::closeEvent(QCloseEvent *event)
|
||||
this->performGracefulShutdown();
|
||||
}
|
||||
|
||||
void CSwiftData::appendLogMessage(const CStatusMessage &message)
|
||||
{
|
||||
if (!ui->comp_MainInfoArea) { return; } // not initialized yet
|
||||
CLogComponent *logComponent = ui->comp_MainInfoArea->getLogComponent();
|
||||
Q_ASSERT_X(logComponent, Q_FUNC_INFO, "missing log component");
|
||||
logComponent->appendStatusMessageToList(message);
|
||||
|
||||
// status bar
|
||||
m_statusBar.displayStatusMessage(message);
|
||||
}
|
||||
|
||||
void CSwiftData::onStyleSheetsChanged()
|
||||
{
|
||||
this->initStyleSheet();
|
||||
@@ -134,12 +124,15 @@ void CSwiftData::initLogDisplay()
|
||||
m_statusBar.initStatusBar(ui->sb_SwiftData);
|
||||
// m_statusBar.setSizeGripEnabled(false);
|
||||
|
||||
connect(&m_logHistory, &CLogHistoryReplica::elementAdded, this, [this](const CStatusMessage &message)
|
||||
{
|
||||
m_statusBar.displayStatusMessage(message);
|
||||
});
|
||||
m_logHistory.setFilter(CLogPattern().withSeverityAtOrAbove(CStatusMessage::SeverityInfo));
|
||||
m_logHistory.initialize(sApp->getDataLinkDBus());
|
||||
|
||||
CLogHandler::instance()->install(true);
|
||||
CLogHandler::instance()->enableConsoleOutput(false); // default disable
|
||||
auto logHandler = CLogHandler::instance()->handlerForPattern(
|
||||
CLogPattern().withSeverityAtOrAbove(CStatusMessage::SeverityInfo)
|
||||
);
|
||||
logHandler->subscribe(this, &CSwiftData::appendLogMessage);
|
||||
}
|
||||
|
||||
void CSwiftData::initMenu()
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
#include "blackgui/mainwindowaccess.h"
|
||||
#include "blackgui/managedstatusbar.h"
|
||||
#include "blackcore/db/backgrounddataupdater.h"
|
||||
#include "blackmisc/loghistory.h"
|
||||
#include "blackmisc/identifiable.h"
|
||||
#include "blackmisc/statusmessage.h"
|
||||
|
||||
@@ -50,9 +51,6 @@ protected:
|
||||
//! @}
|
||||
|
||||
private:
|
||||
//! Append log message
|
||||
void appendLogMessage(const BlackMisc::CStatusMessage &message);
|
||||
|
||||
//! Style sheet has changed
|
||||
void onStyleSheetsChanged();
|
||||
|
||||
@@ -83,6 +81,7 @@ private:
|
||||
BlackGui::CManagedStatusBar m_statusBar;
|
||||
BlackCore::Db::CBackgroundDataUpdater *m_updater = nullptr; //!< consolidate with DB data
|
||||
BlackMisc::CSettingReadOnly<BlackGui::Settings::TBackgroundConsolidation> m_consolidationSettings { this, &CSwiftData::consolidationSettingChanged }; //!< consolidation time
|
||||
BlackMisc::CLogHistoryReplica m_logHistory { this };
|
||||
|
||||
// auto update
|
||||
BlackGui::Components::CAutoPublishDialog *m_autoPublishDialog = nullptr; //!< auto publishing dialog
|
||||
|
||||
Reference in New Issue
Block a user