From 35b489d89a997c78a6d91fec92e4d2922e206d35 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Tue, 8 Apr 2014 18:17:52 +0200 Subject: [PATCH] refs #199, console redirection enabled for GUI # hooked up with siganls # changed widget to courier font --- samples/blackgui/mainwindow.cpp | 24 ++++++++++++++++++------ samples/blackgui/mainwindow.ui | 11 ++++++++++- samples/blackgui/mainwindow_init.cpp | 12 +++++++----- 3 files changed, 35 insertions(+), 12 deletions(-) diff --git a/samples/blackgui/mainwindow.cpp b/samples/blackgui/mainwindow.cpp index c4d034655..8d4ffae97 100644 --- a/samples/blackgui/mainwindow.cpp +++ b/samples/blackgui/mainwindow.cpp @@ -67,6 +67,7 @@ void MainWindow::gracefulShutdown() { if (!this->m_init) return; this->m_init = false; + if (this->m_rt->getIContextApplication()) emit this->m_rt->getIContextApplication()->widgetGuiTerminating(); // close info window if (this->m_infoWindow) @@ -280,6 +281,13 @@ 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 + this->ui->te_StatusPageConsole->appendHtml(statusMessage.toHtml()); +} + /* * Connection terminated */ @@ -317,11 +325,6 @@ void MainWindow::connectionStatusChanged(uint /** from **/, uint to) } } -void MainWindow::simulatorAvailable() -{ - m_timerSimulator->start(500); -} - /* * Timer event */ @@ -353,7 +356,7 @@ void MainWindow::timerBasedUpdates() } else if (sender == this->m_timerSimulator) { - updateSimulatorData(); + this->updateSimulatorData(); } // own aircraft @@ -525,3 +528,12 @@ void MainWindow::updateSimulatorData() ui->le_SimulatorCom2Standby->setText(ownAircraft.getCom2System().getFrequencyStandby().toFormattedQString()); ui->le_SimulatorTransponder->setText(ownAircraft.getTransponderCodeFormatted()); } + +void MainWindow::simulatorConnectionChanged(bool isAvailable) +{ + // Simulator timer, TODO remove later + if (isAvailable) + this->m_timerSimulator->start(500); + else + this->m_timerSimulator->stop(); +} diff --git a/samples/blackgui/mainwindow.ui b/samples/blackgui/mainwindow.ui index 0386bbf86..3ac9dc08f 100644 --- a/samples/blackgui/mainwindow.ui +++ b/samples/blackgui/mainwindow.ui @@ -554,7 +554,7 @@ QStatusBar QLabel { - 0 + 1 3 @@ -638,6 +638,15 @@ QStatusBar QLabel { 0 + + + Courier New + -1 + 75 + false + true + + QPlainTextEdit::NoWrap diff --git a/samples/blackgui/mainwindow_init.cpp b/samples/blackgui/mainwindow_init.cpp index c50821572..8c8b4733c 100644 --- a/samples/blackgui/mainwindow_init.cpp +++ b/samples/blackgui/mainwindow_init.cpp @@ -201,14 +201,15 @@ void MainWindow::init(GuiModes::CoreMode coreMode) // signal / slots contexts / timers bool connect; - this->connect(this->m_rt->getIContextNetwork(), &IContextNetwork::statusMessage, this, &MainWindow::displayStatusMessage); - this->connect(this->m_rt->getIContextNetwork(), &IContextNetwork::statusMessages, this, &MainWindow::displayStatusMessages); + 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))); Q_ASSERT(connect); - this->connect(this->m_rt->getIContextSimulator(), &IContextSimulator::connectionChanged, this, &MainWindow::simulatorAvailable); + this->connect(this->m_rt->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); @@ -239,12 +240,13 @@ void MainWindow::init(GuiModes::CoreMode coreMode) // init context menus this->initContextMenus(); + // starting + emit this->m_rt->getIContextApplication()->widgetGuiStarting(); + // do this as last statement, so it can be used as flag // whether init has been completed this->m_init = true; - // TODO remove later - simulatorAvailable(); } //