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