mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-19 20:25:29 +08:00
Improved status bar, connection handling, displaying ATC station as tooltip
when it matches a frequency
This commit is contained in:
committed by
Mathew Sutcliffe
parent
6aa6058c57
commit
431b347cfd
@@ -23,21 +23,23 @@ MainWindow::MainWindow(GuiModes::WindowMode windowMode, QWidget *parent) :
|
|||||||
ui(new Ui::MainWindow),
|
ui(new Ui::MainWindow),
|
||||||
m_infoWindow(nullptr),
|
m_infoWindow(nullptr),
|
||||||
m_init(false), m_windowMode(windowMode),
|
m_init(false), m_windowMode(windowMode),
|
||||||
// core
|
|
||||||
m_coreMode(GuiModes::CoreExternal), m_coreAvailable(false),
|
|
||||||
// misc
|
// misc
|
||||||
m_contextNetworkAvailable(false), m_contextVoiceAvailable(false), m_dBusConnection("dummy"), m_coreRuntime(nullptr),
|
m_dBusConnection("dummy"),
|
||||||
// table view models
|
// table view models
|
||||||
m_statusMessageList(nullptr),
|
m_statusMessageList(nullptr),
|
||||||
m_atcListOnline(nullptr), m_atcListBooked(nullptr), m_trafficServerList(nullptr), m_aircraftsInRange(nullptr),
|
m_atcListOnline(nullptr), m_atcListBooked(nullptr), m_trafficServerList(nullptr), m_aircraftsInRange(nullptr),
|
||||||
m_allUsers(nullptr), m_usersVoiceCom1(nullptr), m_usersVoiceCom2(nullptr),
|
m_allUsers(nullptr), m_usersVoiceCom1(nullptr), m_usersVoiceCom2(nullptr),
|
||||||
// contexts
|
// contexts and runtime
|
||||||
|
m_coreMode(GuiModes::CoreExternal),
|
||||||
|
m_coreAvailable(false), m_contextNetworkAvailable(false), m_contextVoiceAvailable(false),
|
||||||
m_contextApplication(nullptr), m_contextNetwork(nullptr), m_contextVoice(nullptr), m_contextSettings(nullptr),
|
m_contextApplication(nullptr), m_contextNetwork(nullptr), m_contextVoice(nullptr), m_contextSettings(nullptr),
|
||||||
// timers
|
// timers
|
||||||
m_timerUpdateAtcStationsOnline(nullptr), m_timerUpdateAircraftsInRange(nullptr), m_timerUpdateUsers(nullptr),
|
m_timerUpdateAtcStationsOnline(nullptr), m_timerUpdateAircraftsInRange(nullptr), m_timerUpdateUsers(nullptr),
|
||||||
m_timerCollectedCockpitUpdates(nullptr), m_timerContextWatchdog(nullptr),
|
m_timerCollectedCockpitUpdates(nullptr), m_timerContextWatchdog(nullptr), m_timerStatusBar(nullptr),
|
||||||
// context menus
|
// context menus
|
||||||
m_contextMenuAudio(nullptr), m_contextMenuStatusMessageList(nullptr)
|
m_contextMenuAudio(nullptr), m_contextMenuStatusMessageList(nullptr),
|
||||||
|
// status bar
|
||||||
|
m_statusBarIcon(nullptr), m_statusBarLabel(nullptr)
|
||||||
{
|
{
|
||||||
if (windowMode == GuiModes::WindowFrameless)
|
if (windowMode == GuiModes::WindowFrameless)
|
||||||
{
|
{
|
||||||
@@ -211,6 +213,8 @@ void MainWindow::toggleNetworkConnection()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
// disconnect from network
|
||||||
|
this->stopUpdateTimers(); // stop update timers, to avoid updates during disconnecting (a short time frame)
|
||||||
if (this->m_contextVoiceAvailable) this->m_contextVoice->leaveAllVoiceRooms();
|
if (this->m_contextVoiceAvailable) this->m_contextVoice->leaveAllVoiceRooms();
|
||||||
msgs = this->m_contextNetwork->disconnectFromNetwork();
|
msgs = this->m_contextNetwork->disconnectFromNetwork();
|
||||||
}
|
}
|
||||||
@@ -240,13 +244,18 @@ bool MainWindow::isContextVoiceAvailableCheck()
|
|||||||
/*
|
/*
|
||||||
* Display a status message
|
* Display a status message
|
||||||
*/
|
*/
|
||||||
void MainWindow::displayStatusMessage(const CStatusMessage &message)
|
void MainWindow::displayStatusMessage(const CStatusMessage &statusMessage)
|
||||||
{
|
{
|
||||||
this->ui->sb_MainStatusBar->showMessage(message.getMessage(), 3000);
|
this->ui->sb_MainStatusBar->show();
|
||||||
this->m_statusMessageList->insert(message);
|
this->m_timerStatusBar->start(3000);
|
||||||
|
this->m_statusBarIcon->setPixmap(statusMessage.toIcon());
|
||||||
|
this->m_statusBarLabel->setText(statusMessage.getMessage());
|
||||||
|
|
||||||
|
// list
|
||||||
|
this->m_statusMessageList->insert(statusMessage);
|
||||||
this->ui->tv_StatusMessages->resizeColumnsToContents();
|
this->ui->tv_StatusMessages->resizeColumnsToContents();
|
||||||
this->ui->tv_StatusMessages->resizeRowsToContents();
|
this->ui->tv_StatusMessages->resizeRowsToContents();
|
||||||
if (message.getSeverity() == CStatusMessage::SeverityError) this->displayOverlayInfo(message);
|
if (statusMessage.getSeverity() == CStatusMessage::SeverityError) this->displayOverlayInfo(statusMessage);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -278,7 +287,7 @@ void MainWindow::connectionStatusChanged(uint /** from **/, uint to)
|
|||||||
INetwork::ConnectionStatus newStatus = static_cast<INetwork::ConnectionStatus>(to);
|
INetwork::ConnectionStatus newStatus = static_cast<INetwork::ConnectionStatus>(to);
|
||||||
if (newStatus == INetwork::Connected)
|
if (newStatus == INetwork::Connected)
|
||||||
this->startUpdateTimers();
|
this->startUpdateTimers();
|
||||||
else if (newStatus == INetwork::Disconnected || newStatus == INetwork::DisconnectedError)
|
else if (newStatus == INetwork::Disconnecting || newStatus == INetwork::Disconnected || newStatus == INetwork::DisconnectedError)
|
||||||
this->stopUpdateTimers();
|
this->stopUpdateTimers();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -352,7 +361,7 @@ void MainWindow::middlePanelChanged(int /* index */)
|
|||||||
*/
|
*/
|
||||||
void MainWindow::updateGuiStatusInformation()
|
void MainWindow::updateGuiStatusInformation()
|
||||||
{
|
{
|
||||||
const QString now = QDateTime::currentDateTimeUtc().toString("yyyy - MM - dd HH: mm: ss");
|
const QString now = QDateTime::currentDateTimeUtc().toString("yyyy-MM-dd HH:mm:ss");
|
||||||
QString network("unavailable");
|
QString network("unavailable");
|
||||||
if (this->m_contextNetworkAvailable)
|
if (this->m_contextNetworkAvailable)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -27,6 +27,7 @@
|
|||||||
#include <QTextEdit>
|
#include <QTextEdit>
|
||||||
#include <QTableView>
|
#include <QTableView>
|
||||||
#include <QItemSelection>
|
#include <QItemSelection>
|
||||||
|
#include <QLabel>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
|
|
||||||
namespace Ui
|
namespace Ui
|
||||||
@@ -99,12 +100,8 @@ private:
|
|||||||
CInfoWindow *m_infoWindow;
|
CInfoWindow *m_infoWindow;
|
||||||
bool m_init;
|
bool m_init;
|
||||||
GuiModes::WindowMode m_windowMode;
|
GuiModes::WindowMode m_windowMode;
|
||||||
GuiModes::CoreMode m_coreMode;
|
|
||||||
bool m_coreAvailable;
|
|
||||||
bool m_contextNetworkAvailable;
|
|
||||||
bool m_contextVoiceAvailable;
|
|
||||||
QDBusConnection m_dBusConnection;
|
QDBusConnection m_dBusConnection;
|
||||||
QScopedPointer<BlackCore::CCoreRuntime> m_coreRuntime; /*!< runtime, if working with local core */
|
|
||||||
// the table view models
|
// the table view models
|
||||||
// normal pointers, as these will be deleted by parent
|
// normal pointers, as these will be deleted by parent
|
||||||
BlackGui::CStatusMessageListModel *m_statusMessageList;
|
BlackGui::CStatusMessageListModel *m_statusMessageList;
|
||||||
@@ -117,6 +114,11 @@ private:
|
|||||||
BlackGui::CUserListModel *m_usersVoiceCom2;
|
BlackGui::CUserListModel *m_usersVoiceCom2;
|
||||||
|
|
||||||
// contexts
|
// contexts
|
||||||
|
GuiModes::CoreMode m_coreMode;
|
||||||
|
bool m_coreAvailable;
|
||||||
|
bool m_contextNetworkAvailable;
|
||||||
|
bool m_contextVoiceAvailable;
|
||||||
|
QScopedPointer<BlackCore::CCoreRuntime> m_coreRuntime; /*!< runtime, if working with local core */
|
||||||
BlackCore::IContextApplication *m_contextApplication; /*!< overall application state */
|
BlackCore::IContextApplication *m_contextApplication; /*!< overall application state */
|
||||||
BlackCore::IContextNetwork *m_contextNetwork;
|
BlackCore::IContextNetwork *m_contextNetwork;
|
||||||
BlackCore::IContextVoice *m_contextVoice;
|
BlackCore::IContextVoice *m_contextVoice;
|
||||||
@@ -127,16 +129,29 @@ private:
|
|||||||
QTimer *m_timerUpdateUsers; /*!< timer for update of users */
|
QTimer *m_timerUpdateUsers; /*!< timer for update of users */
|
||||||
QTimer *m_timerCollectedCockpitUpdates; /*!< collect cockpit updates over a short period before sending */
|
QTimer *m_timerCollectedCockpitUpdates; /*!< collect cockpit updates over a short period before sending */
|
||||||
QTimer *m_timerContextWatchdog; /*!< core available? */
|
QTimer *m_timerContextWatchdog; /*!< core available? */
|
||||||
|
QTimer *m_timerStatusBar;
|
||||||
|
|
||||||
|
// pixmaps
|
||||||
QPixmap m_resPixmapConnectionConnected;
|
QPixmap m_resPixmapConnectionConnected;
|
||||||
QPixmap m_resPixmapConnectionDisconnected;
|
QPixmap m_resPixmapConnectionDisconnected;
|
||||||
QPixmap m_resPixmapConnectionConnecting;
|
QPixmap m_resPixmapConnectionConnecting;
|
||||||
QPixmap m_resPixmapVoiceHigh;
|
QPixmap m_resPixmapVoiceHigh;
|
||||||
QPixmap m_resPixmapVoiceLow;
|
QPixmap m_resPixmapVoiceLow;
|
||||||
QPixmap m_resPixmapVoiceMuted;
|
QPixmap m_resPixmapVoiceMuted;
|
||||||
|
|
||||||
|
// frameless window
|
||||||
QPoint m_dragPosition; /*!< position, if moving is handled with frameless window */
|
QPoint m_dragPosition; /*!< position, if moving is handled with frameless window */
|
||||||
QMenu *m_contextMenuAudio; /*! audio context menu */
|
|
||||||
QMenu *m_contextMenuStatusMessageList; /*! context menu for status message list */
|
// context menus
|
||||||
QString m_transponderResetValue; /*! Temp. storage of XPdr mode to reset, req. until timer allows singleShoot with Lambdas */
|
QMenu *m_contextMenuAudio; /*!< audio context menu */
|
||||||
|
QMenu *m_contextMenuStatusMessageList; /*!< context menu for status message list */
|
||||||
|
|
||||||
|
// cockpit
|
||||||
|
QString m_transponderResetValue; /*!< Temp. storage of XPdr mode to reset, req. until timer allows singleShoot with Lambdas */
|
||||||
|
|
||||||
|
// status bar
|
||||||
|
QLabel *m_statusBarIcon; /*!< status bar icon */
|
||||||
|
QLabel *m_statusBarLabel; /*!< status bar label */
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief GUI status update
|
* \brief GUI status update
|
||||||
|
|||||||
@@ -338,7 +338,19 @@ QSizeGrip {
|
|||||||
image: url(:/blackgui/icons/resize.png);
|
image: url(:/blackgui/icons/resize.png);
|
||||||
width: 16px;
|
width: 16px;
|
||||||
height: 16px;
|
height: 16px;
|
||||||
}</string>
|
}
|
||||||
|
|
||||||
|
QStatusBar {
|
||||||
|
background: darkslategray;
|
||||||
|
}
|
||||||
|
|
||||||
|
QStatusBar::item {
|
||||||
|
border: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
QStatusBar QLabel {
|
||||||
|
border: none;
|
||||||
|
}</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="toolButtonStyle">
|
<property name="toolButtonStyle">
|
||||||
<enum>Qt::ToolButtonIconOnly</enum>
|
<enum>Qt::ToolButtonIconOnly</enum>
|
||||||
@@ -584,8 +596,8 @@ QSizeGrip {
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>326</width>
|
<width>90</width>
|
||||||
<height>267</height>
|
<height>55</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<attribute name="label">
|
<attribute name="label">
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ void MainWindow::updateCockpitFromContext()
|
|||||||
{
|
{
|
||||||
// update GUI elements
|
// update GUI elements
|
||||||
// avoid unnecessary change events as far as possible
|
// avoid unnecessary change events as far as possible
|
||||||
const CComSystem com1 = this->m_ownAircraft.getCom1System();
|
const CComSystem com1 = this->m_ownAircraft.getCom1System(); // aircraft just updated or set from context
|
||||||
const CComSystem com2 = this->m_ownAircraft.getCom2System();
|
const CComSystem com2 = this->m_ownAircraft.getCom2System();
|
||||||
const CTransponder transponder = this->m_ownAircraft.getTransponder();
|
const CTransponder transponder = this->m_ownAircraft.getTransponder();
|
||||||
|
|
||||||
@@ -106,6 +106,21 @@ void MainWindow::updateCockpitFromContext()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this->m_contextNetworkAvailable)
|
||||||
|
{
|
||||||
|
CAtcStationList selectedStations = this->m_contextNetwork->getSelectedAtcStations();
|
||||||
|
CAtcStation com1Station = selectedStations[0];
|
||||||
|
CAtcStation com2Station = selectedStations[1];
|
||||||
|
if (com1Station.getCallsign().isEmpty())
|
||||||
|
this->ui->lbl_CockpitCom1->setToolTip("");
|
||||||
|
else
|
||||||
|
this->ui->lbl_CockpitCom1->setToolTip(com1Station.getCallsign().getStringAsSet());
|
||||||
|
if (com2Station.getCallsign().isEmpty())
|
||||||
|
this->ui->lbl_CockpitCom2->setToolTip("");
|
||||||
|
else
|
||||||
|
this->ui->lbl_CockpitCom2->setToolTip(com2Station.getCallsign().getStringAsSet());
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Voice room override
|
// Voice room override
|
||||||
//
|
//
|
||||||
@@ -117,8 +132,11 @@ void MainWindow::updateCockpitFromContext()
|
|||||||
Q_ASSERT(rooms.size() == 2);
|
Q_ASSERT(rooms.size() == 2);
|
||||||
Q_ASSERT(this->m_usersVoiceCom1);
|
Q_ASSERT(this->m_usersVoiceCom1);
|
||||||
Q_ASSERT(this->m_usersVoiceCom2);
|
Q_ASSERT(this->m_usersVoiceCom2);
|
||||||
bool com1Connected = rooms[0].isConnected();
|
|
||||||
bool com2Connected = rooms[1].isConnected();
|
CVoiceRoom room1 = rooms[0];
|
||||||
|
CVoiceRoom room2 = rooms[1];
|
||||||
|
bool com1Connected = room1.isConnected();
|
||||||
|
bool com2Connected = room2.isConnected();
|
||||||
|
|
||||||
// update views
|
// update views
|
||||||
this->m_usersVoiceCom1->update(this->m_contextVoice->getCom1RoomUsers());
|
this->m_usersVoiceCom1->update(this->m_contextVoice->getCom1RoomUsers());
|
||||||
@@ -136,7 +154,7 @@ void MainWindow::updateCockpitFromContext()
|
|||||||
{
|
{
|
||||||
// no override
|
// no override
|
||||||
QString s = com1Connected ?
|
QString s = com1Connected ?
|
||||||
QString("*%1").arg(rooms[0].getVoiceRoomUrl()) :
|
QString("*%1").arg(room1.getVoiceRoomUrl()) :
|
||||||
"";
|
"";
|
||||||
this->ui->le_CockpitVoiceRoomCom1->setText(s);
|
this->ui->le_CockpitVoiceRoomCom1->setText(s);
|
||||||
}
|
}
|
||||||
@@ -146,7 +164,7 @@ void MainWindow::updateCockpitFromContext()
|
|||||||
{
|
{
|
||||||
// no overrride
|
// no overrride
|
||||||
QString s = com2Connected ?
|
QString s = com2Connected ?
|
||||||
QString("*%1").arg(rooms[0].getVoiceRoomUrl()) :
|
QString("*%1").arg(room2.getVoiceRoomUrl()) :
|
||||||
"";
|
"";
|
||||||
this->ui->le_CockpitVoiceRoomCom2->setText(s);
|
this->ui->le_CockpitVoiceRoomCom2->setText(s);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -170,6 +170,20 @@ void MainWindow::init(GuiModes::CoreMode coreMode)
|
|||||||
this->m_resPixmapVoiceHigh = QPixmap(":/blackgui/icons/audiovolumehigh.png");
|
this->m_resPixmapVoiceHigh = QPixmap(":/blackgui/icons/audiovolumehigh.png");
|
||||||
this->m_resPixmapVoiceMuted = QPixmap(":/blackgui/icons/audiovolumemuted.png");
|
this->m_resPixmapVoiceMuted = QPixmap(":/blackgui/icons/audiovolumemuted.png");
|
||||||
|
|
||||||
|
// status bar
|
||||||
|
if (!this->m_statusBarLabel)
|
||||||
|
{
|
||||||
|
// also subject of style sheet
|
||||||
|
this->m_statusBarIcon = new QLabel(this);
|
||||||
|
this->m_statusBarLabel = new QLabel(this);
|
||||||
|
this->m_timerStatusBar = new QTimer(this);
|
||||||
|
this->m_statusBarLabel->setMinimumHeight(16);
|
||||||
|
connect(this->m_timerStatusBar, &QTimer::timeout, this->m_statusBarIcon, &QLabel::clear);
|
||||||
|
connect(this->m_timerStatusBar, &QTimer::timeout, this->m_statusBarLabel, &QLabel::clear);
|
||||||
|
this->ui->sb_MainStatusBar->addWidget(this->m_statusBarIcon, 0);
|
||||||
|
this->ui->sb_MainStatusBar->addWidget(this->m_statusBarLabel, 1);
|
||||||
|
}
|
||||||
|
|
||||||
// signal / slots
|
// signal / slots
|
||||||
bool connect;
|
bool connect;
|
||||||
this->connect(this->m_contextNetwork, &IContextNetwork::statusMessage, this, &MainWindow::displayStatusMessage);
|
this->connect(this->m_contextNetwork, &IContextNetwork::statusMessage, this, &MainWindow::displayStatusMessage);
|
||||||
|
|||||||
Reference in New Issue
Block a user