Improved status bar, connection handling, displaying ATC station as tooltip

when it matches a frequency
This commit is contained in:
Klaus Basan
2014-02-05 21:46:01 +00:00
committed by Mathew Sutcliffe
parent 6aa6058c57
commit 431b347cfd
5 changed files with 96 additions and 28 deletions

View File

@@ -23,21 +23,23 @@ MainWindow::MainWindow(GuiModes::WindowMode windowMode, QWidget *parent) :
ui(new Ui::MainWindow),
m_infoWindow(nullptr),
m_init(false), m_windowMode(windowMode),
// core
m_coreMode(GuiModes::CoreExternal), m_coreAvailable(false),
// misc
m_contextNetworkAvailable(false), m_contextVoiceAvailable(false), m_dBusConnection("dummy"), m_coreRuntime(nullptr),
m_dBusConnection("dummy"),
// table view models
m_statusMessageList(nullptr),
m_atcListOnline(nullptr), m_atcListBooked(nullptr), m_trafficServerList(nullptr), m_aircraftsInRange(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),
// timers
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
m_contextMenuAudio(nullptr), m_contextMenuStatusMessageList(nullptr)
m_contextMenuAudio(nullptr), m_contextMenuStatusMessageList(nullptr),
// status bar
m_statusBarIcon(nullptr), m_statusBarLabel(nullptr)
{
if (windowMode == GuiModes::WindowFrameless)
{
@@ -211,6 +213,8 @@ void MainWindow::toggleNetworkConnection()
}
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();
msgs = this->m_contextNetwork->disconnectFromNetwork();
}
@@ -240,13 +244,18 @@ bool MainWindow::isContextVoiceAvailableCheck()
/*
* 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->m_statusMessageList->insert(message);
this->ui->sb_MainStatusBar->show();
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->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);
if (newStatus == INetwork::Connected)
this->startUpdateTimers();
else if (newStatus == INetwork::Disconnected || newStatus == INetwork::DisconnectedError)
else if (newStatus == INetwork::Disconnecting || newStatus == INetwork::Disconnected || newStatus == INetwork::DisconnectedError)
this->stopUpdateTimers();
}
@@ -352,7 +361,7 @@ void MainWindow::middlePanelChanged(int /* index */)
*/
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");
if (this->m_contextNetworkAvailable)
{

View File

@@ -27,6 +27,7 @@
#include <QTextEdit>
#include <QTableView>
#include <QItemSelection>
#include <QLabel>
#include <QTimer>
namespace Ui
@@ -99,12 +100,8 @@ private:
CInfoWindow *m_infoWindow;
bool m_init;
GuiModes::WindowMode m_windowMode;
GuiModes::CoreMode m_coreMode;
bool m_coreAvailable;
bool m_contextNetworkAvailable;
bool m_contextVoiceAvailable;
QDBusConnection m_dBusConnection;
QScopedPointer<BlackCore::CCoreRuntime> m_coreRuntime; /*!< runtime, if working with local core */
// the table view models
// normal pointers, as these will be deleted by parent
BlackGui::CStatusMessageListModel *m_statusMessageList;
@@ -117,6 +114,11 @@ private:
BlackGui::CUserListModel *m_usersVoiceCom2;
// 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::IContextNetwork *m_contextNetwork;
BlackCore::IContextVoice *m_contextVoice;
@@ -127,16 +129,29 @@ private:
QTimer *m_timerUpdateUsers; /*!< timer for update of users */
QTimer *m_timerCollectedCockpitUpdates; /*!< collect cockpit updates over a short period before sending */
QTimer *m_timerContextWatchdog; /*!< core available? */
QTimer *m_timerStatusBar;
// pixmaps
QPixmap m_resPixmapConnectionConnected;
QPixmap m_resPixmapConnectionDisconnected;
QPixmap m_resPixmapConnectionConnecting;
QPixmap m_resPixmapVoiceHigh;
QPixmap m_resPixmapVoiceLow;
QPixmap m_resPixmapVoiceMuted;
// 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 */
QString m_transponderResetValue; /*! Temp. storage of XPdr mode to reset, req. until timer allows singleShoot with Lambdas */
// context menus
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

View File

@@ -338,7 +338,19 @@ QSizeGrip {
image: url(:/blackgui/icons/resize.png);
width: 16px;
height: 16px;
}</string>
}
QStatusBar {
background: darkslategray;
}
QStatusBar::item {
border: none;
}
QStatusBar QLabel {
border: none;
}</string>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonIconOnly</enum>
@@ -584,8 +596,8 @@ QSizeGrip {
<rect>
<x>0</x>
<y>0</y>
<width>326</width>
<height>267</height>
<width>90</width>
<height>55</height>
</rect>
</property>
<attribute name="label">

View File

@@ -77,7 +77,7 @@ void MainWindow::updateCockpitFromContext()
{
// update GUI elements
// 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 CTransponder transponder = this->m_ownAircraft.getTransponder();
@@ -106,6 +106,21 @@ void MainWindow::updateCockpitFromContext()
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
//
@@ -117,8 +132,11 @@ void MainWindow::updateCockpitFromContext()
Q_ASSERT(rooms.size() == 2);
Q_ASSERT(this->m_usersVoiceCom1);
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
this->m_usersVoiceCom1->update(this->m_contextVoice->getCom1RoomUsers());
@@ -136,7 +154,7 @@ void MainWindow::updateCockpitFromContext()
{
// no override
QString s = com1Connected ?
QString("*%1").arg(rooms[0].getVoiceRoomUrl()) :
QString("*%1").arg(room1.getVoiceRoomUrl()) :
"";
this->ui->le_CockpitVoiceRoomCom1->setText(s);
}
@@ -146,7 +164,7 @@ void MainWindow::updateCockpitFromContext()
{
// no overrride
QString s = com2Connected ?
QString("*%1").arg(rooms[0].getVoiceRoomUrl()) :
QString("*%1").arg(room2.getVoiceRoomUrl()) :
"";
this->ui->le_CockpitVoiceRoomCom2->setText(s);
}

View File

@@ -170,6 +170,20 @@ void MainWindow::init(GuiModes::CoreMode coreMode)
this->m_resPixmapVoiceHigh = QPixmap(":/blackgui/icons/audiovolumehigh.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
bool connect;
this->connect(this->m_contextNetwork, &IContextNetwork::statusMessage, this, &MainWindow::displayStatusMessage);