diff --git a/samples/blackgui/flightplanwidget.cpp b/samples/blackgui/flightplanwidget.cpp new file mode 100644 index 000000000..7471c94b9 --- /dev/null +++ b/samples/blackgui/flightplanwidget.cpp @@ -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; + } +} diff --git a/samples/blackgui/flightplanwidget.h b/samples/blackgui/flightplanwidget.h new file mode 100644 index 000000000..ca7af9ceb --- /dev/null +++ b/samples/blackgui/flightplanwidget.h @@ -0,0 +1,26 @@ +#ifndef BLACKGUI_FLIGHTPLANWIDGET_H +#define BLACKGUI_FLIGHTPLANWIDGET_H + +#include + +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 diff --git a/samples/blackgui/flightplanwidget.ui b/samples/blackgui/flightplanwidget.ui new file mode 100644 index 000000000..1af10fdd7 --- /dev/null +++ b/samples/blackgui/flightplanwidget.ui @@ -0,0 +1,217 @@ + + + CFlightplanWidget + + + + 0 + 0 + 400 + 380 + + + + Frame + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + + + + + 12.Fuel on board + + + + + + + 7.Cruising alt + + + + + + + 11.Remarks + + + + + + + + + + + + + 1. Type + + + + + + VFR + + + + + + + IFR + + + true + + + + + + + + + + 11.Voice capabilities + + + + + + Text only + + + + + + + Receive only + + + + + + + Full voice + + + + + + + + + + 5.Departure + + + + + + + 6.Dep.time + + + + + + + + + + 13.Alternate airport + + + + + + + + + + + + + + + + + + + 4.True airspeed + + + + + + + 3.Aircraft Type + + + + + + + 2.Callsign + + + + + + + + + + 9.Destination + + + + + + + 10.Est.time enroute + + + + + + + + + + + + + 8.Route + + + + + + + + + + 14.Pilots name / homebase + + + + + + + + + + + + + diff --git a/samples/blackgui/mainwindow.cpp b/samples/blackgui/mainwindow.cpp index 429d62ff2..1d2ea6cb5 100644 --- a/samples/blackgui/mainwindow.cpp +++ b/samples/blackgui/mainwindow.cpp @@ -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(mode)); + msgs = this->getIContextNetwork()->connectToNetwork(static_cast(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()); diff --git a/samples/blackgui/mainwindow.h b/samples/blackgui/mainwindow.h index 65415d79f..c86568f13 100644 --- a/samples/blackgui/mainwindow.h +++ b/samples/blackgui/mainwindow.h @@ -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 #include -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 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 diff --git a/samples/blackgui/mainwindow.ui b/samples/blackgui/mainwindow.ui index 3f5f7dd10..b206ae637 100644 --- a/samples/blackgui/mainwindow.ui +++ b/samples/blackgui/mainwindow.ui @@ -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 { QFrame::NoFrame - 7 + 4 @@ -564,8 +571,8 @@ QStatusBar QLabel { 0 0 - 90 - 59 + 326 + 267 @@ -1771,6 +1778,9 @@ QStatusBar QLabel { 0 + + + @@ -3286,6 +3296,12 @@ QStatusBar QLabel { QTableView
blackgui/serverview.h
+ + BlackGui::CFlightPlanComponent + QTabWidget +
blackgui/flightplancomponent.h
+ 1 +
cb_StatusWithDBus diff --git a/samples/blackgui/mainwindow_aircraft.cpp b/samples/blackgui/mainwindow_aircraft.cpp index 4dc6e07e5..d69aab877 100644 --- a/samples/blackgui/mainwindow_aircraft.cpp +++ b/samples/blackgui/mainwindow_aircraft.cpp @@ -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 ); diff --git a/samples/blackgui/mainwindow_atc.cpp b/samples/blackgui/mainwindow_atc.cpp index 8c815423f..65f825e9c 100644 --- a/samples/blackgui/mainwindow_atc.cpp +++ b/samples/blackgui/mainwindow_atc.cpp @@ -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(); } /* diff --git a/samples/blackgui/mainwindow_cockpit.cpp b/samples/blackgui/mainwindow_cockpit.cpp index 7d4b5a133..2e351bee1 100644 --- a/samples/blackgui/mainwindow_cockpit.cpp +++ b/samples/blackgui/mainwindow_cockpit.cpp @@ -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 { diff --git a/samples/blackgui/mainwindow_init.cpp b/samples/blackgui/mainwindow_init.cpp index 4962d7f30..d66fa3288 100644 --- a/samples/blackgui/mainwindow_init.cpp +++ b/samples/blackgui/mainwindow_init.cpp @@ -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); } diff --git a/samples/blackgui/mainwindow_menus.cpp b/samples/blackgui/mainwindow_menus.cpp index 6dcf0209e..9314b2ea7 100644 --- a/samples/blackgui/mainwindow_menus.cpp +++ b/samples/blackgui/mainwindow_menus.cpp @@ -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); } diff --git a/samples/blackgui/mainwindow_settings.cpp b/samples/blackgui/mainwindow_settings.cpp index 37ee6a667..fe4b54079 100644 --- a/samples/blackgui/mainwindow_settings.cpp +++ b/samples/blackgui/mainwindow_settings.cpp @@ -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); diff --git a/samples/blackgui/mainwindow_textmessages.cpp b/samples/blackgui/mainwindow_textmessages.cpp index d287b784e..c7512c264 100644 --- a/samples/blackgui/mainwindow_textmessages.cpp +++ b/samples/blackgui/mainwindow_textmessages.cpp @@ -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(""); } diff --git a/samples/blackgui/mainwindow_voice.cpp b/samples/blackgui/mainwindow_voice.cpp index d940fc0b6..5fadf68f5 100644 --- a/samples/blackgui/mainwindow_voice.cpp +++ b/samples/blackgui/mainwindow_voice.cpp @@ -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(notification)); + this->getIContextAudio()->playNotification(static_cast(notification)); } diff --git a/samples/blackgui/stylesheetmain.qss b/samples/blackgui/stylesheetmain.qss index acfc52b8f..883a22d18 100644 --- a/samples/blackgui/stylesheetmain.qss +++ b/samples/blackgui/stylesheetmain.qss @@ -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 {