mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 20:15:35 +08:00
refs #316 Swiftgui using CLogMessage to emit messages.
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
#include "blackcore/context_application.h"
|
||||
#include "blackcore/network.h"
|
||||
#include "blackmisc/avaircraft.h"
|
||||
#include "blackmisc/logmessage.h"
|
||||
#include <QMouseEvent>
|
||||
|
||||
using namespace BlackCore;
|
||||
@@ -229,7 +230,6 @@ bool MainWindow::isMainPageSelected(MainWindow::MainPageIndex mainPage) const
|
||||
*/
|
||||
void MainWindow::ps_toggleNetworkConnection()
|
||||
{
|
||||
CStatusMessageList msgs;
|
||||
if (!this->isContextNetworkAvailableCheck()) return;
|
||||
if (!this->getIContextNetwork()->isConnected())
|
||||
{
|
||||
@@ -251,14 +251,15 @@ void MainWindow::ps_toggleNetworkConnection()
|
||||
if (this->ui->comp_MainInfoArea->getSettingsComponent()->loginStealth())
|
||||
{
|
||||
mode = INetwork::LoginStealth;
|
||||
this->ps_displayStatusMessageInGui(CStatusMessage::getInfoMessage("login in stealth mode"));
|
||||
this->ps_displayStatusMessageInGui(CLogMessage().info(this, "login in stealth mode"));
|
||||
}
|
||||
else if (this->ui->comp_MainInfoArea->getSettingsComponent()->loginAsObserver())
|
||||
{
|
||||
mode = INetwork::LoginAsObserver;
|
||||
this->ps_displayStatusMessageInGui(CStatusMessage::getInfoMessage("login in observer mode"));
|
||||
this->ps_displayStatusMessageInGui(CLogMessage().info(this, "login in observer mode"));
|
||||
}
|
||||
msgs = this->getIContextNetwork()->connectToNetwork(static_cast<uint>(mode));
|
||||
CStatusMessage msg = this->getIContextNetwork()->connectToNetwork(static_cast<uint>(mode));
|
||||
this->ps_displayStatusMessageInGui(msg);
|
||||
this->startUpdateTimersWhenConnected();
|
||||
}
|
||||
else
|
||||
@@ -266,9 +267,9 @@ void MainWindow::ps_toggleNetworkConnection()
|
||||
// disconnect from network
|
||||
this->stopUpdateTimersWhenDisconnected(); // stop update timers, to avoid updates during disconnecting (a short time frame)
|
||||
if (this->m_contextAudioAvailable) this->getIContextAudio()->leaveAllVoiceRooms();
|
||||
msgs = this->getIContextNetwork()->disconnectFromNetwork();
|
||||
CStatusMessage msg = this->getIContextNetwork()->disconnectFromNetwork();
|
||||
this->ps_displayStatusMessageInGui(msg);
|
||||
}
|
||||
if (!msgs.isEmpty()) this->ps_displayStatusMessagesInGui(msgs);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -277,7 +278,7 @@ void MainWindow::ps_toggleNetworkConnection()
|
||||
bool MainWindow::isContextNetworkAvailableCheck()
|
||||
{
|
||||
if (this->m_contextNetworkAvailable) return true;
|
||||
this->ps_displayStatusMessageInGui(CStatusMessage(CStatusMessage::TypeCore, CStatusMessage::SeverityError, "Network context not available, no updates this time"));
|
||||
this->ps_displayStatusMessageInGui(CLogMessage().error(this, "Network context not available, no updates this time"));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -287,7 +288,7 @@ bool MainWindow::isContextNetworkAvailableCheck()
|
||||
bool MainWindow::isContextAudioAvailableCheck()
|
||||
{
|
||||
if (this->m_contextAudioAvailable) return true;
|
||||
this->ps_displayStatusMessageInGui(CStatusMessage(CStatusMessage::TypeCore, CStatusMessage::SeverityError, "Voice context not available"));
|
||||
this->ps_displayStatusMessageInGui(CLogMessage().error(this, "Voice context not available"));
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -507,13 +508,13 @@ void MainWindow::ps_toogleWindowStayOnTop()
|
||||
{
|
||||
flags ^= Qt::WindowStaysOnTopHint;
|
||||
flags |= Qt::WindowStaysOnBottomHint;
|
||||
this->ps_displayStatusMessageInGui(CStatusMessage(CStatusMessage::TypeGui, CStatusMessage::SeverityInfo, "Window on bottom"));
|
||||
this->ps_displayStatusMessageInGui(CLogMessage().info(this, "Window on bottom"));
|
||||
}
|
||||
else
|
||||
{
|
||||
flags ^= Qt::WindowStaysOnBottomHint;
|
||||
flags |= Qt::WindowStaysOnTopHint;
|
||||
this->ps_displayStatusMessageInGui(CStatusMessage(CStatusMessage::TypeGui, CStatusMessage::SeverityInfo, "Window on top"));
|
||||
this->ps_displayStatusMessageInGui(CLogMessage().info(this, "Window on top"));
|
||||
}
|
||||
this->setWindowFlags(flags);
|
||||
this->show();
|
||||
|
||||
@@ -60,6 +60,9 @@ public:
|
||||
//! Graceful shutdown
|
||||
void gracefulShutdown();
|
||||
|
||||
//! Log message category
|
||||
static QString getMessageCategory() { return "swift.gui.component.mainwindow"; }
|
||||
|
||||
protected:
|
||||
//! Close event, e.g. when window is closed
|
||||
void closeEvent(QCloseEvent *event);
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "blackmisc/avselcal.h"
|
||||
#include "blackmisc/project.h"
|
||||
#include "blackmisc/hotkeyfunction.h"
|
||||
#include "blackmisc/logmessage.h"
|
||||
#include <QSortFilterProxyModel>
|
||||
#include <QSizeGrip>
|
||||
#include <QHBoxLayout>
|
||||
@@ -233,14 +234,13 @@ void MainWindow::initialDataReads()
|
||||
this->m_coreAvailable = (this->getIContextNetwork()->usingLocalObjects() || (this->getIContextApplication()->ping(t) == t));
|
||||
if (!this->m_coreAvailable)
|
||||
{
|
||||
this->ps_displayStatusMessageInGui(CStatusMessage(CStatusMessage::TypeGui, CStatusMessage::SeverityError,
|
||||
"no initial data read as network context is not available"));
|
||||
this->ps_displayStatusMessageInGui(CLogMessage().error(this, "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
|
||||
this->ps_displayStatusMessageInGui(CStatusMessage(CStatusMessage::TypeGui, CStatusMessage::SeverityInfo, "initial data read"));
|
||||
this->ps_displayStatusMessageInGui(CLogMessage().info(this, "initial data read"));
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include "blackgui/stylesheetutility.h"
|
||||
#include "blackmisc/statusmessagelist.h"
|
||||
#include "blackmisc/avaltitude.h"
|
||||
#include "blackmisc/logmessage.h"
|
||||
#include <QPoint>
|
||||
#include <QMenu>
|
||||
#include <QDesktopServices>
|
||||
@@ -20,7 +21,6 @@ using namespace BlackMisc::Aviation;
|
||||
void MainWindow::ps_onMenuClicked()
|
||||
{
|
||||
QObject *sender = QObject::sender();
|
||||
CStatusMessageList msgs;
|
||||
|
||||
if (sender == this->ui->menu_TestLocationsEDRY)
|
||||
{
|
||||
@@ -41,7 +41,7 @@ void MainWindow::ps_onMenuClicked()
|
||||
else if (sender == this->ui->menu_ReloadSettings)
|
||||
{
|
||||
this->ui->comp_MainInfoArea->getSettingsComponent()->reloadSettings();
|
||||
msgs.insert(CStatusMessage::getInfoMessage("Settings reloaded"));
|
||||
this->ps_displayStatusMessageInGui(CLogMessage().info(this, "Settings reloaded"));
|
||||
}
|
||||
else if (sender == this->ui->menu_FileReloadStyleSheets)
|
||||
{
|
||||
@@ -54,7 +54,7 @@ void MainWindow::ps_onMenuClicked()
|
||||
}
|
||||
else if (sender == this->ui->menu_FileClose)
|
||||
{
|
||||
msgs.insert(CStatusMessage::getInfoMessage("Closing"));
|
||||
this->ps_displayStatusMessageInGui(CLogMessage().info(this, "Closing"));
|
||||
this->close();
|
||||
}
|
||||
else if (sender == this->ui->menu_FileSettingsDirectory)
|
||||
@@ -65,7 +65,6 @@ void MainWindow::ps_onMenuClicked()
|
||||
else if (sender == this->ui->menu_FileResetSettings)
|
||||
{
|
||||
Q_ASSERT(this->getIContextSettings());
|
||||
msgs.insert(this->getIContextSettings()->reset(true));
|
||||
this->getIContextSettings()->reset(true);
|
||||
}
|
||||
if (!msgs.isEmpty()) this->ps_displayStatusMessagesInGui(msgs);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user