From f1482558fb0b484f25e3e3a6d95208a2913f0445 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Wed, 15 Jan 2014 17:27:17 +0100 Subject: [PATCH] New signal / slot syntax #88 Not all calls can be replaced by new sytnax (e.g. cannot handle default value arguments) --- samples/blackgui/mainwindow_init.cpp | 48 +++++++--------------------- 1 file changed, 11 insertions(+), 37 deletions(-) diff --git a/samples/blackgui/mainwindow_init.cpp b/samples/blackgui/mainwindow_init.cpp index d3549bd70..51ae104c3 100644 --- a/samples/blackgui/mainwindow_init.cpp +++ b/samples/blackgui/mainwindow_init.cpp @@ -114,44 +114,18 @@ void MainWindow::init(GuiModes::CoreMode coreMode) this->m_resPixmapVoiceHigh = QPixmap(":/blackgui/icons/audiovolumehigh.png"); this->m_resPixmapVoiceMuted = QPixmap(":/blackgui/icons/audiovolumemuted.png"); - // relay status messages + // signal / slots bool connect; - connect = this->connect(this->m_contextNetwork, SIGNAL(statusMessage(BlackMisc::CStatusMessage)), - this, SLOT(displayStatusMessage(BlackMisc::CStatusMessage))); - Q_ASSERT_X(connect, "init", "cannot connect status message"); - - connect = this->connect(this->m_contextNetwork, SIGNAL(connectionTerminated()), - this, SLOT(connectionTerminated())); - Q_ASSERT_X(connect, "init", "cannot connect terminating"); - - connect = this->connect(this->m_contextNetwork, SIGNAL(connectionStatusChanged(uint, uint)), - this, SLOT(connectionStatusChanged(uint, uint))); - Q_ASSERT_X(connect, "init", "cannot connect change connection status"); - - connect = this->connect(this->m_contextSettings, SIGNAL(changedNetworkSettings()), - this, SLOT(changedNetworkSettings())); - Q_ASSERT_X(connect, "init", "cannot connect change network status"); - - connect = this->connect(this->m_contextNetwork, SIGNAL(textMessagesReceived(BlackMisc::Network::CTextMessageList)), - this, SLOT(appendTextMessagesToGui(BlackMisc::Network::CTextMessageList))); - Q_ASSERT_X(connect, "init", "cannot connect text message received"); - - connect = this->connect(this->m_timerUpdateAircraftsInRange, SIGNAL(timeout()), - this, SLOT(timerBasedUpdates())); - Q_ASSERT_X(connect, "init", "cannot connect timer"); - - connect = this->connect(this->m_timerUpdateAtcStationsOnline, SIGNAL(timeout()), - this, SLOT(timerBasedUpdates())); - Q_ASSERT_X(connect, "init", "cannot connect timer"); - - connect = this->connect(this->m_timerContextWatchdog, SIGNAL(timeout()), - this, SLOT(timerBasedUpdates())); - Q_ASSERT_X(connect, "init", "cannot connect timer (watchdog)"); - - connect = this->connect(this->m_timerCollectedCockpitUpdates, SIGNAL(timeout()), - this, SLOT(sendCockpitUpdates())); - Q_ASSERT_X(connect, "init", "cannot connect timer (cockpit updates)"); - Q_UNUSED(connect); + this->connect(this->m_contextNetwork, &IContextNetwork::statusMessage, this, &MainWindow::displayStatusMessage); + this->connect(this->m_contextNetwork, &IContextNetwork::connectionTerminated, this, &MainWindow::connectionTerminated); + this->connect(this->m_contextNetwork, &IContextNetwork::connectionStatusChanged, this, &MainWindow::connectionStatusChanged); + this->connect(this->m_contextSettings, &IContextSettings::changedNetworkSettings, this, &MainWindow::changedNetworkSettings); + connect = this->connect(this->m_contextNetwork, SIGNAL(textMessagesReceived(BlackMisc::Network::CTextMessageList)), this, SLOT(appendTextMessagesToGui(BlackMisc::Network::CTextMessageList))); + Q_ASSERT(connect); + this->connect(this->m_timerUpdateAircraftsInRange, &QTimer::timeout, this, &MainWindow::timerBasedUpdates); + this->connect(this->m_timerUpdateAtcStationsOnline, &QTimer::timeout, this, &MainWindow::timerBasedUpdates); + this->connect(this->m_timerContextWatchdog, &QTimer::timeout, this, &MainWindow::timerBasedUpdates); + this->connect(this->m_timerCollectedCockpitUpdates, &QTimer::timeout, this, &MainWindow::sendCockpitUpdates); // start timers this->m_timerUpdateAircraftsInRange->start(10 * 1000);