refs #212, flightplan GUI

* similar to http://www.vatsim.net/fp/
* own form, own widget class as a trial to further modularize GUI components
* removed all view models (now encapsulated)
* tweaked style sheet
This commit is contained in:
Klaus Basan
2014-04-21 17:40:01 +02:00
parent c7ae163002
commit f967ed40ba
15 changed files with 408 additions and 126 deletions

View File

@@ -0,0 +1,17 @@
#include "flightplanwidget.h"
#include "ui_flightplanwidget.h"
namespace BlackGui
{
CFlightplanWidget::CFlightplanWidget(QWidget *parent) :
QFrame(parent),
ui(new Ui::CFlightplanWidget)
{
ui->setupUi(this);
}
CFlightplanWidget::~CFlightplanWidget()
{
delete ui;
}
}

View File

@@ -0,0 +1,26 @@
#ifndef BLACKGUI_FLIGHTPLANWIDGET_H
#define BLACKGUI_FLIGHTPLANWIDGET_H
#include <QFrame>
namespace Ui
{
class CFlightplanWidget;
}
namespace BlackGui
{
class CFlightplanWidget : public QFrame
{
Q_OBJECT
public:
explicit CFlightplanWidget(QWidget *parent = nullptr);
~CFlightplanWidget();
private:
Ui::CFlightplanWidget *ui;
};
}
#endif // guard

View File

@@ -0,0 +1,217 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>CFlightplanWidget</class>
<widget class="QFrame" name="CFlightplanWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>380</height>
</rect>
</property>
<property name="windowTitle">
<string>Frame</string>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QGridLayout" name="gl_Flightplan">
<item row="7" column="3">
<widget class="QLineEdit" name="le_FuelOnBoard"/>
</item>
<item row="6" column="3">
<widget class="QLabel" name="lbl_FuelOnBorad">
<property name="text">
<string>12.Fuel on board</string>
</property>
</widget>
</item>
<item row="2" column="4">
<widget class="QLabel" name="lbl_CrusingAltitude">
<property name="text">
<string>7.Cruising alt</string>
</property>
</widget>
</item>
<item row="9" column="1">
<widget class="QLabel" name="lbl_Remarks">
<property name="text">
<string>11.Remarks</string>
</property>
</widget>
</item>
<item row="9" column="2" colspan="3">
<widget class="QPlainTextEdit" name="pte_Remarks"/>
</item>
<item row="7" column="4">
<widget class="QLineEdit" name="le_AlternateAirport"/>
</item>
<item row="0" column="1" rowspan="4">
<widget class="QGroupBox" name="gb_Type">
<property name="title">
<string>1. Type</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QRadioButton" name="rb_Vfr">
<property name="text">
<string>VFR</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="rb_TypeIfr">
<property name="text">
<string>IFR</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="8" column="1" colspan="4">
<widget class="QGroupBox" name="gb_VoiceCapabilities">
<property name="title">
<string>11.Voice capabilities</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QRadioButton" name="rb_VoiceCapabilitiesTextOnly">
<property name="text">
<string>Text only</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="rb_VoiceCapabilitiesReceiveOnly">
<property name="text">
<string>Receive only</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="rb_VoiceCapabilitiesFull">
<property name="text">
<string>Full voice</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="2" column="2">
<widget class="QLabel" name="lbl_Departure">
<property name="text">
<string>5.Departure</string>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QLabel" name="lbl_DepartureTIme">
<property name="text">
<string>6.Dep.time</string>
</property>
</widget>
</item>
<item row="3" column="4">
<widget class="QLineEdit" name="le_CrusingAltitude"/>
</item>
<item row="6" column="4">
<widget class="QLabel" name="lbl_AlternateAirport">
<property name="text">
<string>13.Alternate airport</string>
</property>
</widget>
</item>
<item row="3" column="2">
<widget class="QLineEdit" name="le_Departure"/>
</item>
<item row="3" column="3">
<widget class="QLineEdit" name="le_DepartureTime"/>
</item>
<item row="1" column="4">
<widget class="QLineEdit" name="le_TrueAirspeed"/>
</item>
<item row="1" column="3">
<widget class="QLineEdit" name="le_AircraftType"/>
</item>
<item row="0" column="4">
<widget class="QLabel" name="lbl_TrueAirspeed">
<property name="text">
<string>4.True airspeed</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QLabel" name="lbl_Aircraft_Type">
<property name="text">
<string>3.Aircraft Type</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLabel" name="lbl_Callsign">
<property name="text">
<string>2.Callsign</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLineEdit" name="le_Callsign"/>
</item>
<item row="6" column="1">
<widget class="QLabel" name="lbl_Destination">
<property name="text">
<string>9.Destination</string>
</property>
</widget>
</item>
<item row="6" column="2">
<widget class="QLabel" name="lbl_EstimatedTimeEnroute">
<property name="text">
<string>10.Est.time enroute</string>
</property>
</widget>
</item>
<item row="7" column="2">
<widget class="QLineEdit" name="le_EstimatedTimeEnroute"/>
</item>
<item row="7" column="1">
<widget class="QLineEdit" name="le_Destination"/>
</item>
<item row="4" column="1">
<widget class="QLabel" name="lbl_Route">
<property name="text">
<string>8.Route</string>
</property>
</widget>
</item>
<item row="5" column="1" colspan="4">
<widget class="QPlainTextEdit" name="pte_Route"/>
</item>
<item row="10" column="1" colspan="2">
<widget class="QLabel" name="lbl_PilotsNameAndHomebase">
<property name="text">
<string>14.Pilots name / homebase</string>
</property>
</widget>
</item>
<item row="10" column="3" colspan="2">
<widget class="QLineEdit" name="le_PilotsNameAndHomebase"/>
</item>
</layout>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>

View File

@@ -62,8 +62,8 @@ void MainWindow::gracefulShutdown()
{
if (!this->m_init) return;
this->m_init = false;
if (this->m_rt->getIContextApplication())
this->m_rt->getIContextApplication()->notifyAboutComponentChange(IContextApplication::ComponentGui, IContextApplication::ActionStops);
if (this->getIContextApplication())
this->getIContextApplication()->notifyAboutComponentChange(IContextApplication::ComponentGui, IContextApplication::ActionStops);
// close info window
if (this->m_infoWindow)
@@ -88,15 +88,15 @@ void MainWindow::gracefulShutdown()
// if we have a context, we shut some things down
if (this->m_contextNetworkAvailable)
{
if (this->m_rt->getIContextNetwork()->isConnected())
if (this->getIContextNetwork()->isConnected())
{
if (this->m_contextAudioAvailable)
{
this->m_rt->getIContextAudio()->leaveAllVoiceRooms();
this->m_rt->getIContextAudio()->disconnect(this); // break down signal / slots
this->getIContextAudio()->leaveAllVoiceRooms();
this->getIContextAudio()->disconnect(this); // break down signal / slots
}
this->m_rt->getIContextNetwork()->disconnectFromNetwork();
this->m_rt->getIContextNetwork()->disconnect(this); // avoid any status update signals, etc.
this->getIContextNetwork()->disconnectFromNetwork();
this->getIContextNetwork()->disconnect(this); // avoid any status update signals, etc.
}
}
}
@@ -192,7 +192,7 @@ void MainWindow::toggleNetworkConnection()
if (!this->isContextNetworkAvailableCheck()) return;
this->ui->lbl_StatusNetworkConnectedIcon->setPixmap(this->m_resPixmapConnectionConnecting);
if (!this->m_rt->getIContextNetwork()->isConnected())
if (!this->getIContextNetwork()->isConnected())
{
if (this->m_ownAircraft.getCallsign().isEmpty())
{
@@ -201,8 +201,8 @@ void MainWindow::toggleNetworkConnection()
}
// send latest aircraft to network/voice
this->m_rt->getIContextNetwork()->setOwnAircraft(this->m_ownAircraft);
if (this->m_contextAudioAvailable) this->m_rt->getIContextAudio()->setOwnAircraft(this->m_ownAircraft);
this->getIContextNetwork()->setOwnAircraft(this->m_ownAircraft);
if (this->m_contextAudioAvailable) this->getIContextAudio()->setOwnAircraft(this->m_ownAircraft);
// Login is based on setting current server
INetwork::LoginMode mode = INetwork::LoginNormal;
@@ -216,14 +216,14 @@ void MainWindow::toggleNetworkConnection()
mode = INetwork::LoginAsObserver;
this->displayStatusMessage(CStatusMessage::getInfoMessage("login in observer mode"));
}
msgs = this->m_rt->getIContextNetwork()->connectToNetwork(static_cast<uint>(mode));
msgs = this->getIContextNetwork()->connectToNetwork(static_cast<uint>(mode));
}
else
{
// disconnect from network
this->stopUpdateTimers(); // stop update timers, to avoid updates during disconnecting (a short time frame)
if (this->m_contextAudioAvailable) this->m_rt->getIContextAudio()->leaveAllVoiceRooms();
msgs = this->m_rt->getIContextNetwork()->disconnectFromNetwork();
if (this->m_contextAudioAvailable) this->getIContextAudio()->leaveAllVoiceRooms();
msgs = this->getIContextNetwork()->disconnectFromNetwork();
}
if (!msgs.isEmpty()) this->displayStatusMessages(msgs);
}
@@ -260,7 +260,10 @@ void MainWindow::displayStatusMessage(const CStatusMessage &statusMessage)
// list
this->ui->tvp_StatusMessages->insert(statusMessage);
if (statusMessage.getSeverity() == CStatusMessage::SeverityError) this->displayOverlayInfo(statusMessage);
// display overlay for errors, but not for validation
if (statusMessage.getSeverity() == CStatusMessage::SeverityError && statusMessage.getType() != CStatusMessage::TypeValidation)
this->displayOverlayInfo(statusMessage);
}
/*
@@ -277,8 +280,8 @@ void MainWindow::displayStatusMessages(const CStatusMessageList &messages)
void MainWindow::displayRedirectedOutput(const CStatusMessage &statusMessage, qint64 contextId)
{
if (!this->m_rt->getIContextApplication()) return;
if (this->m_rt->getIContextApplication()->getUniqueId() == contextId) return; //self triggered
if (!this->getIContextApplication()) return;
if (this->getIContextApplication()->getUniqueId() == contextId) return; //self triggered
this->ui->te_StatusPageConsole->appendHtml(statusMessage.toHtml());
}
@@ -366,9 +369,9 @@ void MainWindow::timerBasedUpdates()
void MainWindow::setContextAvailability()
{
qint64 t = QDateTime::currentMSecsSinceEpoch();
this->m_coreAvailable = this->m_rt->getIContextApplication()->ping(t) == t;
this->m_contextNetworkAvailable = this->m_coreAvailable || this->m_rt->getIContextNetwork()->usingLocalObjects();
this->m_contextAudioAvailable = this->m_coreAvailable || this->m_rt->getIContextAudio()->usingLocalObjects();
this->m_coreAvailable = this->getIContextApplication()->ping(t) == t;
this->m_contextNetworkAvailable = this->m_coreAvailable || this->getIContextNetwork()->usingLocalObjects();
this->m_contextAudioAvailable = this->m_coreAvailable || this->getIContextAudio()->usingLocalObjects();
}
/*
@@ -397,7 +400,7 @@ void MainWindow::updateGuiStatusInformation()
QString network("unavailable");
if (this->m_contextNetworkAvailable)
{
bool dbus = !this->m_rt->getIContextNetwork()->usingLocalObjects();
bool dbus = !this->getIContextNetwork()->usingLocalObjects();
network = dbus ? now : "local";
this->ui->cb_StatusWithDBus->setChecked(dbus);
}
@@ -406,7 +409,7 @@ void MainWindow::updateGuiStatusInformation()
QString voice("unavailable");
if (this->m_contextAudioAvailable)
{
voice = this->m_rt->getIContextAudio()->usingLocalObjects() ? "local" : now;
voice = this->getIContextAudio()->usingLocalObjects() ? "local" : now;
this->ui->pb_SoundMute->setEnabled(true);
}
else
@@ -420,7 +423,7 @@ void MainWindow::updateGuiStatusInformation()
this->ui->le_StatusAudioContext->setText(voice);
// Connected button
if (this->m_contextNetworkAvailable && this->m_rt->getIContextNetwork()->isConnected())
if (this->m_contextNetworkAvailable && this->getIContextNetwork()->isConnected())
{
if (this->ui->lbl_StatusNetworkConnectedIcon->toolTip().startsWith("dis", Qt::CaseInsensitive))
this->ui->lbl_StatusNetworkConnectedIcon->setToolTip(now);
@@ -494,17 +497,17 @@ void MainWindow::displayOverlayInfo(const CStatusMessage &message)
void MainWindow::reloadAllUsers()
{
if (!this->isContextNetworkAvailableCheck()) return;
this->ui->tvp_AllUsers->update(this->m_rt->getIContextNetwork()->getUsers());
this->ui->tvp_AllUsers->update(this->getIContextNetwork()->getUsers());
}
void MainWindow::updateSimulatorData()
{
if (this->m_rt->getIContextSimulator()->isConnected())
if (this->getIContextSimulator()->isConnected())
ui->le_SimulatorStatus->setText("Connected");
else
ui->le_SimulatorStatus->setText("Not connected");
CAircraft ownAircraft = this->m_rt->getIContextSimulator()->getOwnAircraft();
CAircraft ownAircraft = this->getIContextSimulator()->getOwnAircraft();
ui->le_SimulatorLatitude->setText(ownAircraft.getSituation().latitude().toFormattedQString());
ui->le_SimulatorLongitude->setText(ownAircraft.getSituation().longitude().toFormattedQString());
ui->le_SimulatorAltitude->setText(ownAircraft.getSituation().getAltitude().toFormattedQString());

View File

@@ -18,6 +18,7 @@
#include "blackcore/context_application.h"
#include "blackcore/context_simulator.h"
#include "blackcore/context_runtime.h"
#include "blackgui/runtimebasedcomponent.h"
#include "blackgui/transpondermodeselector.h"
#include "blackgui/atcstationlistmodel.h"
#include "blackgui/serverlistmodel.h"
@@ -34,15 +35,12 @@
#include <QLabel>
#include <QTimer>
namespace Ui
{
class MainWindow;
}
namespace Ui { class MainWindow; }
/*!
* \brief GUI
*/
class MainWindow : public QMainWindow
class MainWindow : public QMainWindow, public BlackGui::CRuntimeBasedComponent
{
Q_OBJECT
@@ -103,7 +101,6 @@ private:
bool m_coreAvailable;
bool m_contextNetworkAvailable;
bool m_contextAudioAvailable;
QScopedPointer<BlackCore::CRuntime> m_rt; /*!< runtime */
BlackMisc::Aviation::CAircraft m_ownAircraft; /*!< own aircraft's state */
QTimer *m_timerUpdateAtcStationsOnline; /*!< timer for update of stations */
QTimer *m_timerUpdateAircraftsInRange; /*!< timer for update of aircrafts */
@@ -111,7 +108,7 @@ private:
QTimer *m_timerCollectedCockpitUpdates; /*!< collect cockpit updates over a short period before sending */
QTimer *m_timerContextWatchdog; /*!< core available? */
QTimer *m_timerStatusBar; /*!< cleaning up status bar */
QTimer *m_timerAudioTests; /*!< cleaning up status bar */
QTimer *m_timerAudioTests; /*!< audio tests: progress bar, disable/enable buttons */
QTimer *m_timerSimulator; /*!< update simulator data */
// pixmaps
@@ -155,6 +152,9 @@ private:
//! Init GUI signals
void initGuiSignals();
//! Init the context menus
void initContextMenus();
//! Context network availability check, otherwise status message
bool isContextNetworkAvailableCheck();
@@ -223,9 +223,6 @@ private:
//! For this text message's recepient, is the current tab selected?
bool isCorrespondingTextMessageTabSelected(BlackMisc::Network::CTextMessage textMessage) const;
//! Init the context menus
void initContextMenus();
//! Start all update timers
void startUpdateTimers();
@@ -247,6 +244,7 @@ private:
//! Update simulator page with latest user aircraft data
void updateSimulatorData();
private slots:
//
@@ -346,16 +344,10 @@ private slots:
//! Update timer
void timerBasedUpdates();
/*!
* \brief ATC station, tab changed, reload data
* \param tabIndex
*/
//! ATC station, tab changed, reload data
void atcStationTabChanged(int tabIndex);
/*!
* \brief Middle panel has changed, reload data
* \param index
*/
//! Middle panel has changed, reload data
void middlePanelChanged(int index);
//! Command entered

View File

@@ -175,10 +175,17 @@ QPlainTextEdit {
QGroupBox {
border: 1px solid green;
margin-top: 2ex; /* leave space at the top for the title */
}
QGroupBox::title {
subcontrol-origin: margin;
subcontrol-position: middle center; /* position at the top center */
padding: 0 3px;
}
QToolBox {
border: none;
border: none;
}
QToolBox::tab {
@@ -228,8 +235,8 @@ QMenu::item {
}
QMenu::item:selected {
border-color: darkblue;
background: black;
border-color: darkblue;
background: black;
}
QMenu::indicator {
@@ -454,7 +461,7 @@ QStatusBar QLabel {
<enum>QFrame::NoFrame</enum>
</property>
<property name="currentIndex">
<number>7</number>
<number>4</number>
</property>
<widget class="QWidget" name="pg_StatusPage">
<property name="sizePolicy">
@@ -564,8 +571,8 @@ QStatusBar QLabel {
<rect>
<x>0</x>
<y>0</y>
<width>90</width>
<height>59</height>
<width>326</width>
<height>267</height>
</rect>
</property>
<attribute name="label">
@@ -1771,6 +1778,9 @@ QStatusBar QLabel {
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="BlackGui::CFlightPlanComponent" name="comp_Flightplan"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="pg_Settings">
@@ -3286,6 +3296,12 @@ QStatusBar QLabel {
<extends>QTableView</extends>
<header>blackgui/serverview.h</header>
</customwidget>
<customwidget>
<class>BlackGui::CFlightPlanComponent</class>
<extends>QTabWidget</extends>
<header>blackgui/flightplancomponent.h</header>
<container>1</container>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>cb_StatusWithDBus</tabstop>

View File

@@ -20,7 +20,7 @@ using namespace BlackMisc::Audio;
void MainWindow::reloadAircraftsInRange()
{
if (!this->isContextNetworkAvailableCheck()) return;
this->ui->tvp_AircraftsInRange->update(this->m_rt->getIContextNetwork()->getAircraftsInRange());
this->ui->tvp_AircraftsInRange->update(this->getIContextNetwork()->getAircraftsInRange());
}
/*
@@ -33,11 +33,12 @@ bool MainWindow::reloadOwnAircraft()
// check for changed aircraft
bool changed = false;
CAircraft loadedAircraft = this->m_rt->getIContextNetwork()->getOwnAircraft();
CAircraft loadedAircraft = this->getIContextNetwork()->getOwnAircraft();
if (loadedAircraft != this->m_ownAircraft)
{
this->m_ownAircraft = loadedAircraft;
this->updateCockpitFromContext();
this->ui->comp_Flightplan->prefillWithAircraftData(this->m_ownAircraft);
changed = true;
}
return changed;
@@ -55,7 +56,7 @@ void MainWindow::setTestPosition(const QString &wgsLatitude, const QString &wgsL
this->m_ownAircraft.setPosition(coordinate);
this->m_ownAircraft.setAltitude(altitude);
this->m_rt->getIContextNetwork()->updateOwnPosition(
this->getIContextNetwork()->updateOwnPosition(
coordinate,
altitude
);

View File

@@ -20,7 +20,7 @@ using namespace BlackMisc::Settings;
void MainWindow::reloadAtcStationsBooked()
{
if (!this->isContextNetworkAvailableCheck()) return;
this->ui->tvp_AtcStationsBooked->update(this->m_rt->getIContextNetwork()->getAtcStationsBooked());
this->ui->tvp_AtcStationsBooked->update(this->getIContextNetwork()->getAtcStationsBooked());
}
/*
@@ -29,8 +29,8 @@ void MainWindow::reloadAtcStationsBooked()
void MainWindow::reloadAtcStationsOnline()
{
if (!this->isContextNetworkAvailableCheck()) return;
this->ui->tvp_AtcStationsOnline->update(this->m_rt->getIContextNetwork()->getAtcStationsOnline());
if (!this->m_rt->getIContextNetwork()->isConnected())
this->ui->tvp_AtcStationsOnline->update(this->getIContextNetwork()->getAtcStationsOnline());
if (!this->getIContextNetwork()->isConnected())
{
// clear metar/ATIS
this->ui->te_AtcStationsOnlineInfo->clear();
@@ -67,11 +67,11 @@ void MainWindow::onlineAtcStationSelected(QModelIndex index)
void MainWindow::getMetar(const QString &airportIcaoCode)
{
if (!this->isContextNetworkAvailableCheck()) return;
if (!this->m_rt->getIContextNetwork()->isConnected()) return;
if (!this->getIContextNetwork()->isConnected()) return;
QString icao = airportIcaoCode.isEmpty() ? this->ui->le_AtcStationsOnlineMetar->text().trimmed().toUpper() : airportIcaoCode.trimmed().toUpper();
this->ui->le_AtcStationsOnlineMetar->setText(icao);
if (icao.length() != 4) return;
CInformationMessage metar = this->m_rt->getIContextNetwork()->getMetar(icao);
CInformationMessage metar = this->getIContextNetwork()->getMetar(icao);
if (metar.getType() != CInformationMessage::METAR) return;
if (metar.isEmpty()) return;
this->ui->te_AtcStationsOnlineInfo->setText(metar.getMessage());
@@ -83,8 +83,8 @@ void MainWindow::getMetar(const QString &airportIcaoCode)
void MainWindow::requestAtis()
{
if (!this->isContextNetworkAvailableCheck()) return;
if (!this->m_rt->getIContextNetwork()->isConnected()) return;
this->m_rt->getIContextNetwork()->requestAtisUpdates();
if (!this->getIContextNetwork()->isConnected()) return;
this->getIContextNetwork()->requestAtisUpdates();
}
/*

View File

@@ -96,7 +96,7 @@ void MainWindow::updateCockpitFromContext()
if (this->m_contextNetworkAvailable)
{
CAtcStationList selectedStations = this->m_rt->getIContextNetwork()->getSelectedAtcStations();
CAtcStationList selectedStations = this->getIContextNetwork()->getSelectedAtcStations();
CAtcStation com1Station = selectedStations[0];
CAtcStation com2Station = selectedStations[1];
if (com1Station.getCallsign().isEmpty())
@@ -116,7 +116,7 @@ void MainWindow::updateCockpitFromContext()
{
// get all rooms, it is important to get the rooms from voice context here
// these are the ones featuring the real audio status
CVoiceRoomList rooms = this->m_rt->getIContextAudio()->getComVoiceRoomsWithAudioStatus();
CVoiceRoomList rooms = this->getIContextAudio()->getComVoiceRoomsWithAudioStatus();
Q_ASSERT(rooms.size() == 2);
CVoiceRoom room1 = rooms[0];
@@ -125,8 +125,8 @@ void MainWindow::updateCockpitFromContext()
bool com2Connected = room2.isConnected();
// update views
this->ui->tvp_CockpitVoiceRoom1->update(this->m_rt->getIContextAudio()->getCom1RoomUsers());
this->ui->tvp_CockpitVoiceRoom1->update(this->m_rt->getIContextAudio()->getCom1RoomUsers());
this->ui->tvp_CockpitVoiceRoom1->update(this->getIContextAudio()->getCom1RoomUsers());
this->ui->tvp_CockpitVoiceRoom1->update(this->getIContextAudio()->getCom1RoomUsers());
// highlite voice room according to status
QString vrStyle1;
@@ -252,7 +252,7 @@ void MainWindow::sendCockpitUpdates()
this->m_ownAircraft.getCom2System() != com2 ||
this->m_ownAircraft.getTransponder() != transponder)
{
this->m_rt->getIContextNetwork()->updateOwnCockpit(com1, com2, transponder);
this->getIContextNetwork()->updateOwnCockpit(com1, com2, transponder);
this->reloadOwnAircraft(); // also loads resolved voice rooms
changedCockpit = true;
}
@@ -279,7 +279,7 @@ void MainWindow::setAudioVoiceRooms()
CVoiceRoom room1;
CVoiceRoom room2;
CVoiceRoomList selectedVoiceRooms = this->m_rt->getIContextNetwork()->getSelectedVoiceRooms();
CVoiceRoomList selectedVoiceRooms = this->getIContextNetwork()->getSelectedVoiceRooms();
Q_ASSERT(selectedVoiceRooms.size() == 2);
if (this->ui->cb_CockpitVoiceRoom1Override->isChecked())
@@ -301,7 +301,7 @@ void MainWindow::setAudioVoiceRooms()
}
// set the real voice rooms for audio output
this->m_rt->getIContextAudio()->setComVoiceRooms(room1, room2);
this->getIContextAudio()->setComVoiceRooms(room1, room2);
}
/*
@@ -319,7 +319,7 @@ void MainWindow::testSelcal()
if (this->m_contextAudioAvailable)
{
CSelcal selcal(selcalCode);
this->m_rt->getIContextAudio()->playSelcalTone(selcal);
this->getIContextAudio()->playSelcalTone(selcal);
}
else
{

View File

@@ -55,7 +55,7 @@ void MainWindow::init(const CRuntimeConfig &runtimeConfig)
this->ui->sb_MainStatusBar->addPermanentWidget(grip);
}
// init models
// init encapsulated table views / models
this->ui->tvp_AtcStationsBooked->setStationMode(CAtcStationListModel::StationsBooked);
this->ui->tvp_CockpitVoiceRoom1->setUserMode(CUserListModel::UserShort);
this->ui->tvp_CockpitVoiceRoom2->setUserMode(CUserListModel::UserShort);
@@ -76,7 +76,8 @@ void MainWindow::init(const CRuntimeConfig &runtimeConfig)
if (this->m_timerSimulator == nullptr) this->m_timerSimulator = new QTimer(this);
// context
this->m_rt.reset(new CRuntime(runtimeConfig, this));
this->createRuntime(runtimeConfig, this);
this->ui->comp_Flightplan->setRuntime(this->getRuntime());
// wire GUI signals
this->initGuiSignals();
@@ -105,15 +106,15 @@ void MainWindow::init(const CRuntimeConfig &runtimeConfig)
// signal / slots contexts / timers
bool connect;
this->connect(this->m_rt->getIContextApplication(), &IContextApplication::statusMessage, this, &MainWindow::displayStatusMessage);
this->connect(this->m_rt->getIContextApplication(), &IContextApplication::statusMessages, this, &MainWindow::displayStatusMessages);
this->connect(this->m_rt->getIContextApplication(), &IContextApplication::redirectedOutput, this, &MainWindow::displayRedirectedOutput);
this->connect(this->m_rt->getIContextNetwork(), &IContextNetwork::connectionTerminated, this, &MainWindow::connectionTerminated);
this->connect(this->m_rt->getIContextNetwork(), &IContextNetwork::connectionStatusChanged, this, &MainWindow::connectionStatusChanged);
this->connect(this->m_rt->getIContextSettings(), &IContextSettings::changedSettings, this, &MainWindow::changedSettings);
connect = this->connect(this->m_rt->getIContextNetwork(), SIGNAL(textMessagesReceived(BlackMisc::Network::CTextMessageList)), this, SLOT(appendTextMessagesToGui(BlackMisc::Network::CTextMessageList)));
this->connect(this->getIContextApplication(), &IContextApplication::statusMessage, this, &MainWindow::displayStatusMessage);
this->connect(this->getIContextApplication(), &IContextApplication::statusMessages, this, &MainWindow::displayStatusMessages);
this->connect(this->getIContextApplication(), &IContextApplication::redirectedOutput, this, &MainWindow::displayRedirectedOutput);
this->connect(this->getIContextNetwork(), &IContextNetwork::connectionTerminated, this, &MainWindow::connectionTerminated);
this->connect(this->getIContextNetwork(), &IContextNetwork::connectionStatusChanged, this, &MainWindow::connectionStatusChanged);
this->connect(this->getIContextSettings(), &IContextSettings::changedSettings, this, &MainWindow::changedSettings);
connect = this->connect(this->getIContextNetwork(), SIGNAL(textMessagesReceived(BlackMisc::Network::CTextMessageList)), this, SLOT(appendTextMessagesToGui(BlackMisc::Network::CTextMessageList)));
Q_ASSERT(connect);
this->connect(this->m_rt->getIContextSimulator(), &IContextSimulator::connectionChanged, this, &MainWindow::simulatorConnectionChanged);
this->connect(this->getIContextSimulator(), &IContextSimulator::connectionChanged, this, &MainWindow::simulatorConnectionChanged);
this->connect(this->m_timerUpdateAircraftsInRange, &QTimer::timeout, this, &MainWindow::timerBasedUpdates);
this->connect(this->m_timerUpdateAtcStationsOnline, &QTimer::timeout, this, &MainWindow::timerBasedUpdates);
this->connect(this->m_timerUpdateUsers, &QTimer::timeout, this, &MainWindow::timerBasedUpdates);
@@ -121,7 +122,7 @@ void MainWindow::init(const CRuntimeConfig &runtimeConfig)
this->connect(this->m_timerCollectedCockpitUpdates, &QTimer::timeout, this, &MainWindow::sendCockpitUpdates);
this->connect(this->m_timerAudioTests, &QTimer::timeout, this, &MainWindow::audioTestUpdate);
this->connect(this->m_timerSimulator, &QTimer::timeout, this, &MainWindow::timerBasedUpdates);
connect = this->connect(this->m_rt->getIContextAudio(), &IContextAudio::audioTestCompleted, this, &MainWindow::audioTestUpdate);
connect = this->connect(this->getIContextAudio(), &IContextAudio::audioTestCompleted, this, &MainWindow::audioTestUpdate);
Q_ASSERT(connect);
Q_UNUSED(connect); // suppress GCC warning in release build
@@ -145,18 +146,18 @@ void MainWindow::init(const CRuntimeConfig &runtimeConfig)
this->initContextMenus();
// starting
this->m_rt->getIContextApplication()->notifyAboutComponentChange(IContextApplication::ComponentGui, IContextApplication::ActionStarts);
this->getIContextApplication()->notifyAboutComponentChange(IContextApplication::ComponentGui, IContextApplication::ActionStarts);
// We don't receive signals from the past. So ask for it simulate an initial signal
simulatorConnectionChanged(this->getIContextSimulator()->isConnected());
// do this as last statement, so it can be used as flag
// whether init has been completed
this->m_init = true;
// We don't receive signals from the past. So ask for it simulate an initial signal
simulatorConnectionChanged(m_rt->getIContextSimulator()->isConnected());
}
//
// GUI
// GUI signals
//
void MainWindow::initGuiSignals()
{
@@ -284,7 +285,7 @@ void MainWindow::initGuiSignals()
void MainWindow::initialDataReads()
{
qint64 t = QDateTime::currentMSecsSinceEpoch();
this->m_coreAvailable = (this->m_rt->getIContextNetwork()->usingLocalObjects() || (this->m_rt->getIContextApplication()->ping(t) == t));
this->m_coreAvailable = (this->getIContextNetwork()->usingLocalObjects() || (this->getIContextApplication()->ping(t) == t));
if (!this->m_coreAvailable)
{
this->displayStatusMessage(CStatusMessage(CStatusMessage::TypeGui, CStatusMessage::SeverityError,
@@ -296,7 +297,7 @@ void MainWindow::initialDataReads()
this->reloadAtcStationsBooked(); // init read, to do this no traffic network required
this->reloadOwnAircraft(); // init read, independent of traffic network
if (this->m_rt->getIContextNetwork()->isConnected())
if (this->getIContextNetwork()->isConnected())
{
// connection is already established
this->reloadAircraftsInRange();
@@ -327,8 +328,11 @@ void MainWindow::stopUpdateTimers(bool disconnect)
this->m_timerUpdateAtcStationsOnline->stop();
this->m_timerUpdateUsers->stop();
this->m_timerAudioTests->stop();
this->m_timerSimulator->stop();
if (!disconnect) return;
this->disconnect(this->m_timerUpdateAircraftsInRange);
this->disconnect(this->m_timerUpdateAtcStationsOnline);
this->disconnect(this->m_timerUpdateUsers);
this->disconnect(this->m_timerAudioTests);
this->disconnect(this->m_timerSimulator);
}

View File

@@ -52,8 +52,8 @@ void MainWindow::menuClicked()
}
else if (sender == this->ui->menu_FileResetSettings)
{
Q_ASSERT(this->m_rt->getIContextSettings());
msgs.insert(this->m_rt->getIContextSettings()->reset(true));
Q_ASSERT(this->getIContextSettings());
msgs.insert(this->getIContextSettings()->reset(true));
}
if (!msgs.isEmpty()) this->displayStatusMessages(msgs);
}

View File

@@ -25,14 +25,14 @@ using namespace BlackSim::Fsx;
void MainWindow::reloadSettings()
{
// local copy
CSettingsNetwork nws = this->m_rt->getIContextSettings()->getNetworkSettings();
CSettingsNetwork nws = this->getIContextSettings()->getNetworkSettings();
// update servers
this->ui->tvp_SettingsTnServers->setSelectedServer(nws.getCurrentTrafficNetworkServer());
this->ui->tvp_SettingsTnServers->update(nws.getTrafficNetworkServers());
// update hot keys
this->ui->tvp_SettingsMiscHotkeys->update(this->m_rt->getIContextSettings()->getHotkeys());
this->ui->tvp_SettingsMiscHotkeys->update(this->getIContextSettings()->getHotkeys());
// fake setting for sound notifications
this->ui->cb_SettingsAudioPlayNotificationSounds->setChecked(true);
@@ -66,15 +66,15 @@ void MainWindow::alterTrafficServer()
CStatusMessageList msgs;
if (sender == this->ui->pb_SettingsTnCurrentServer)
{
msgs = this->m_rt->getIContextSettings()->value(path, CSettingsNetwork::CmdSetCurrentServer(), server.toQVariant());
msgs = this->getIContextSettings()->value(path, CSettingsNetwork::CmdSetCurrentServer(), server.toQVariant());
}
else if (sender == this->ui->pb_SettingsTnRemoveServer)
{
msgs = this->m_rt->getIContextSettings()->value(path, CSettingUtilities::CmdRemove(), server.toQVariant());
msgs = this->getIContextSettings()->value(path, CSettingUtilities::CmdRemove(), server.toQVariant());
}
else if (sender == this->ui->pb_SettingsTnSaveServer)
{
msgs = this->m_rt->getIContextSettings()->value(path, CSettingUtilities::CmdUpdate(), server.toQVariant());
msgs = this->getIContextSettings()->value(path, CSettingUtilities::CmdUpdate(), server.toQVariant());
}
// status messages
@@ -132,7 +132,7 @@ CServer MainWindow::selectedServerFromTextboxes() const
void MainWindow::saveHotkeys()
{
const QString path = CSettingUtilities::appendPaths(IContextSettings::PathRoot(), IContextSettings::PathHotkeys());
CStatusMessageList msgs = this->m_rt->getIContextSettings()->value(path, CSettingUtilities::CmdUpdate(), this->ui->tvp_SettingsMiscHotkeys->derivedModel()->getContainer().toQVariant());
CStatusMessageList msgs = this->getIContextSettings()->value(path, CSettingUtilities::CmdUpdate(), this->ui->tvp_SettingsMiscHotkeys->derivedModel()->getContainer().toQVariant());
// status messages
this->displayStatusMessages(msgs);
@@ -191,8 +191,8 @@ void MainWindow::testSimConnectConnection()
*/
void MainWindow::saveSimConnectCfg()
{
if (!this->m_rt->getIContextSimulator()) return;
if (!this->m_rt->getIContextSimulator()->isSimulatorAvailable()) return;
if (!this->getIContextSimulator()) return;
if (!this->getIContextSimulator()->isSimulatorAvailable()) return;
QString address = this->ui->le_SettingsSimulatorFsxAddress->text().trimmed();
QString port = this->ui->le_SettingsSimulatorFsxPort->text().trimmed();
@@ -212,13 +212,13 @@ void MainWindow::saveSimConnectCfg()
return;
}
quint16 p = port.toUInt();
QString fileName = this->m_rt->getIContextSimulator()->getSimulatorInfo().getSimulatorSetupValueAsString(CFsxSimulatorSetup::SetupSimConnectCfgFile);
QString fileName = this->getIContextSimulator()->getSimulatorInfo().getSimulatorSetupValueAsString(CFsxSimulatorSetup::SetupSimConnectCfgFile);
Q_ASSERT(!fileName.isEmpty());
// write either local or remote file
bool local = this->m_rt->getIContextSimulator()->usingLocalObjects();
bool local = this->getIContextSimulator()->usingLocalObjects();
bool success = local ?
BlackSim::Fsx::CSimConnectUtilities::writeSimConnectCfg(fileName, address, p) :
this->m_rt->getIContextApplication()->writeToFile(fileName, CSimConnectUtilities::simConnectCfg(address, p));
this->getIContextApplication()->writeToFile(fileName, CSimConnectUtilities::simConnectCfg(address, p));
if (success)
{
QString m = QString("Written ").append(local ? " local " : "remote ").append(fileName);
@@ -237,8 +237,8 @@ void MainWindow::saveSimConnectCfg()
*/
void MainWindow::simConnectCfgFile()
{
if (!this->m_rt->getIContextSimulator()) return;
if (!this->m_rt->getIContextSimulator()->isSimulatorAvailable()) return;
if (!this->getIContextSimulator()) return;
if (!this->getIContextSimulator()->isSimulatorAvailable()) return;
QObject *sender = QObject::sender();
if (sender == this->ui->pb_SettingsSimulatorFsxOpenSimconnectCfg)
@@ -249,10 +249,10 @@ void MainWindow::simConnectCfgFile()
}
else if (sender == this->ui->pb_SettingsSimulatorFsxDeleteSimconnectCfg)
{
if (!this->m_rt->getIContextSimulator()) return;
if (!this->getIContextSimulator()) return;
QString fileName = BlackSim::Fsx::CSimConnectUtilities::getLocalSimConnectCfgFilename();
QString m = QString("Deleted %1 ").append(fileName);
if (this->m_rt->getIContextSimulator()->usingLocalObjects())
if (this->getIContextSimulator()->usingLocalObjects())
{
QFile f(fileName);
f.remove();
@@ -260,7 +260,7 @@ void MainWindow::simConnectCfgFile()
}
else
{
this->m_rt->getIContextApplication()->removeFile(fileName);
this->getIContextApplication()->removeFile(fileName);
m = m.arg("remotely");
}
this->displayStatusMessage(CStatusMessage(CStatusMessage::TypeSimulator, CStatusMessage::SeverityInfo, m));
@@ -268,11 +268,11 @@ void MainWindow::simConnectCfgFile()
}
else if (sender == this->ui->pb_SettingsSimulatorFsxExistsSimconncetCfg)
{
if (!this->m_rt->getIContextSimulator()) return;
if (!this->getIContextSimulator()) return;
QString fileName = BlackSim::Fsx::CSimConnectUtilities::getLocalSimConnectCfgFilename();
bool exists = this->m_rt->getIContextSimulator()->usingLocalObjects() ?
bool exists = this->getIContextSimulator()->usingLocalObjects() ?
QFile::exists(fileName) :
this->m_rt->getIContextApplication()->existsFile(fileName);
this->getIContextApplication()->existsFile(fileName);
if (exists)
{
this->ui->le_SettingsSimulatorFsxExistsSimconncetCfg->setText(fileName);

View File

@@ -28,7 +28,7 @@ void MainWindow::appendTextMessagesToGui(const CTextMessageList &messages, bool
// this is SELCAL for me
if (this->m_contextAudioAvailable)
{
CAudioDevice dev = this->m_rt->getIContextAudio()->getCurrentAudioDevices().getOutputDevices()[0];
CAudioDevice dev = this->getIContextAudio()->getCurrentAudioDevices().getOutputDevices()[0];
BlackSound::CSoundGenerator::playSelcal(90, CSelcal(currentSelcal), dev);
}
else
@@ -261,7 +261,7 @@ void MainWindow::commandEntered()
QString cmd = parts[0].startsWith('.') ? parts[0].toLower() : "";
if (cmd == ".m" || cmd == ".msg")
{
if (!this->m_contextNetworkAvailable || !this->m_rt->getIContextNetwork()->isConnected())
if (!this->m_contextNetworkAvailable || !this->getIContextNetwork()->isConnected())
{
this->displayStatusMessage(CStatusMessage(CStatusMessage::TypeTrafficNetwork, CStatusMessage::SeverityError, "network needs to be connected"));
return;
@@ -308,7 +308,7 @@ void MainWindow::commandEntered()
if (tm.isEmpty()) return;
if (!this->isContextNetworkAvailableCheck()) return;
CTextMessageList tml(tm);
this->m_rt->getIContextNetwork()->sendTextMessages(tml);
this->getIContextNetwork()->sendTextMessages(tml);
this->appendTextMessagesToGui(tml, true);
this->ui->le_CommandLineInput->setText("");
}
@@ -320,7 +320,7 @@ void MainWindow::commandEntered()
{
// single line, no command
// line is considered to be a message to the selected channel, send
if (!this->m_rt->getIContextNetwork()->isConnected())
if (!this->getIContextNetwork()->isConnected())
{
this->displayStatusMessage(CStatusMessage(CStatusMessage::TypeTrafficNetwork, CStatusMessage::SeverityError, "network needs to be connected"));
return;
@@ -344,7 +344,7 @@ void MainWindow::commandEntered()
if (tm.isEmpty()) return;
if (!this->isContextNetworkAvailableCheck()) return;
CTextMessageList textMessageList(tm);
this->m_rt->getIContextNetwork()->sendTextMessages(textMessageList);
this->getIContextNetwork()->sendTextMessages(textMessageList);
this->appendTextMessagesToGui(textMessageList, true);
this->ui->le_CommandLineInput->setText("");
}

View File

@@ -27,7 +27,7 @@ void MainWindow::setAudioDeviceLists()
this->ui->cb_SettingsAudioOutputDevice->clear();
this->ui->cb_SettingsAudioInputDevice->clear();
foreach(CAudioDevice device, this->m_rt->getIContextAudio()->getAudioDevices())
foreach(CAudioDevice device, this->getIContextAudio()->getAudioDevices())
{
if (device.getType() == CAudioDevice::InputDevice)
{
@@ -39,7 +39,7 @@ void MainWindow::setAudioDeviceLists()
}
}
foreach(CAudioDevice device, this->m_rt->getIContextAudio()->getCurrentAudioDevices())
foreach(CAudioDevice device, this->getIContextAudio()->getCurrentAudioDevices())
{
if (device.getType() == CAudioDevice::InputDevice)
{
@@ -60,7 +60,7 @@ void MainWindow::audioDeviceSelected(int index)
if (!this->m_init) return; // not during init
if (!this->isContextAudioAvailableCheck()) return;
if (index < 0)return;
CAudioDeviceList devices = this->m_rt->getIContextAudio()->getAudioDevices();
CAudioDeviceList devices = this->getIContextAudio()->getAudioDevices();
if (devices.isEmpty()) return;
CAudioDevice selectedDevice;
QObject *sender = QObject::sender();
@@ -69,14 +69,14 @@ void MainWindow::audioDeviceSelected(int index)
CAudioDeviceList inputDevices = devices.getInputDevices();
if (index >= inputDevices.size()) return;
selectedDevice = inputDevices[index];
this->m_rt->getIContextAudio()->setCurrentAudioDevice(selectedDevice);
this->getIContextAudio()->setCurrentAudioDevice(selectedDevice);
}
else if (sender == this->ui->cb_SettingsAudioOutputDevice)
{
CAudioDeviceList outputDevices = devices.getOutputDevices();
if (index >= outputDevices.size()) return;
selectedDevice = outputDevices[index];
this->m_rt->getIContextAudio()->setCurrentAudioDevice(selectedDevice);
this->getIContextAudio()->setCurrentAudioDevice(selectedDevice);
}
}
@@ -103,7 +103,7 @@ void MainWindow::audioVolumes()
if (sender == this->ui->pb_SoundMute)
{
if (this->m_rt->getIContextAudio()->isMuted())
if (this->getIContextAudio()->isMuted())
{
// muted right now, now unmute
muted = false;
@@ -146,7 +146,7 @@ void MainWindow::audioVolumes()
// update own aircraft, also set volume/mute in voice
this->m_ownAircraft.setCom1System(com1);
this->m_ownAircraft.setCom2System(com2);
this->m_rt->getIContextAudio()->setVolumes(this->m_ownAircraft.getCom1System(), this->m_ownAircraft.getCom2System());
this->getIContextAudio()->setVolumes(this->m_ownAircraft.getCom1System(), this->m_ownAircraft.getCom2System());
}
/*
@@ -174,13 +174,13 @@ void MainWindow::startAudioTest()
if (sender == this->ui->pb_SettingsAudioMicrophoneTest)
{
this->m_audioTestRunning = MicrophoneTest;
this->m_rt->getIContextAudio()->runMicrophoneTest();
this->getIContextAudio()->runMicrophoneTest();
this->ui->pte_SettingsAudioTestActionAndResult->appendPlainText("Speak normally for 5 seconds");
}
else if (sender == this->ui->pb_SettingsAudioSquelchTest)
{
this->m_audioTestRunning = SquelchTest;
this->m_rt->getIContextAudio()->runSquelchTest();
this->getIContextAudio()->runSquelchTest();
this->ui->pte_SettingsAudioTestActionAndResult->appendPlainText("Silence for 5 seconds");
}
this->ui->prb_SettingsAudioTestProgress->setVisible(true);
@@ -214,12 +214,12 @@ void MainWindow::audioTestUpdate()
{
if (this->m_audioTestRunning == SquelchTest)
{
double s = this->m_rt->getIContextAudio()->getSquelchValue();
double s = this->getIContextAudio()->getSquelchValue();
this->ui->pte_SettingsAudioTestActionAndResult->appendPlainText(QString::number(s));
}
else if (this->m_audioTestRunning == MicrophoneTest)
{
QString m = this->m_rt->getIContextAudio()->getMicrophoneTestResult();
QString m = this->getIContextAudio()->getMicrophoneTestResult();
this->ui->pte_SettingsAudioTestActionAndResult->appendPlainText(m);
}
}
@@ -239,5 +239,5 @@ void MainWindow::playNotifcationSound(CSoundGenerator::Notification notification
if (!this->m_contextAudioAvailable) return;
if (!this->ui->cb_SettingsAudioPlayNotificationSounds->isChecked()) return;
if (notification == CSoundGenerator::NotificationTextMessage && !this->ui->cb_SettingsAudioNotificationTextMessage->isChecked()) return;
this->m_rt->getIContextAudio()->playNotification(static_cast<uint>(notification));
this->getIContextAudio()->playNotification(static_cast<uint>(notification));
}

View File

@@ -145,8 +145,14 @@ QGroupBox {
border: 1px solid green;
}
QGroupBox::title {
subcontrol-origin: margin;
subcontrol-position: top center; /* position at the top center */
padding: 0 3px;
}
QToolBox {
border: none;
border: none;
}
QToolBox::tab {
@@ -196,8 +202,8 @@ QMenu::item {
}
QMenu::item:selected {
border-color: darkblue;
background: black;
border-color: darkblue;
background: black;
}
QMenu::indicator {