mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-30 11:55:35 +08:00
Fix overriding cockpit values if a field is input focused.
Cockpit updates are a 2 way process, from context to GUI and vice versa. This fix checks if a widget is focused, and if so, updating is ignored.
This commit is contained in:
@@ -39,6 +39,8 @@ MainWindow::MainWindow(GuiModes::WindowMode windowMode, QWidget *parent) :
|
|||||||
m_timerStatusBar(nullptr), m_timerAudioTests(nullptr),
|
m_timerStatusBar(nullptr), m_timerAudioTests(nullptr),
|
||||||
// context menus
|
// context menus
|
||||||
m_contextMenuAudio(nullptr), m_contextMenuStatusMessageList(nullptr),
|
m_contextMenuAudio(nullptr), m_contextMenuStatusMessageList(nullptr),
|
||||||
|
// cockpit
|
||||||
|
m_inputFocusedWidget(nullptr),
|
||||||
// status bar
|
// status bar
|
||||||
m_statusBarIcon(nullptr), m_statusBarLabel(nullptr)
|
m_statusBarIcon(nullptr), m_statusBarLabel(nullptr)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -157,6 +157,7 @@ private:
|
|||||||
|
|
||||||
// cockpit
|
// cockpit
|
||||||
QString m_transponderResetValue; /*!< Temp. storage of XPdr mode to reset, req. until timer allows singleShoot with Lambdas */
|
QString m_transponderResetValue; /*!< Temp. storage of XPdr mode to reset, req. until timer allows singleShoot with Lambdas */
|
||||||
|
QWidget *m_inputFocusedWidget; /*!< currently used widget for input, mainly used with cockpit */
|
||||||
|
|
||||||
// status bar
|
// status bar
|
||||||
QLabel *m_statusBarIcon; /*!< status bar icon */
|
QLabel *m_statusBarIcon; /*!< status bar icon */
|
||||||
@@ -208,10 +209,8 @@ private:
|
|||||||
*/
|
*/
|
||||||
bool isCockpitUpdatePending() const;
|
bool isCockpitUpdatePending() const;
|
||||||
|
|
||||||
/*!
|
//! \brief Update the COM frequency displays
|
||||||
* \brief Round the COM frequency display
|
void updateComFrequencyDisplays(const BlackMisc::Aviation::CComSystem &com1, const BlackMisc::Aviation::CComSystem &com2);
|
||||||
*/
|
|
||||||
void roundComFrequencyDisplays(const BlackMisc::Aviation::CComSystem &com1, const BlackMisc::Aviation::CComSystem &com2);
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Add new text message tab
|
* \brief Add new text message tab
|
||||||
@@ -360,14 +359,10 @@ private slots:
|
|||||||
*/
|
*/
|
||||||
void appendTextMessagesToGui(const BlackMisc::Network::CTextMessageList &messages, bool sending = false);
|
void appendTextMessagesToGui(const BlackMisc::Network::CTextMessageList &messages, bool sending = false);
|
||||||
|
|
||||||
/*!
|
//!\brief Reload settings
|
||||||
* \brief Reload settings
|
|
||||||
*/
|
|
||||||
void reloadSettings();
|
void reloadSettings();
|
||||||
|
|
||||||
/*!
|
//! \brief Send cockpit updates
|
||||||
* \brief Send cockpit updates
|
|
||||||
*/
|
|
||||||
void sendCockpitUpdates();
|
void sendCockpitUpdates();
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -500,6 +495,11 @@ private slots:
|
|||||||
|
|
||||||
//! \brief start the MIC tests (Squelch)
|
//! \brief start the MIC tests (Squelch)
|
||||||
void startAudioTest();
|
void startAudioTest();
|
||||||
|
|
||||||
|
//! \brief inputFocusChanged
|
||||||
|
//! \sa QApplication::focusChanged
|
||||||
|
void inputFocusChanged(QWidget *oldWidget, QWidget *newWidget);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#pragma pop_macro("interface")
|
#pragma pop_macro("interface")
|
||||||
|
|||||||
@@ -454,7 +454,7 @@ QStatusBar QLabel {
|
|||||||
<enum>QFrame::NoFrame</enum>
|
<enum>QFrame::NoFrame</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>7</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="pg_StatusPage">
|
<widget class="QWidget" name="pg_StatusPage">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
@@ -564,8 +564,8 @@ QStatusBar QLabel {
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>86</width>
|
<width>326</width>
|
||||||
<height>59</height>
|
<height>267</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<attribute name="label">
|
<attribute name="label">
|
||||||
@@ -607,8 +607,8 @@ QStatusBar QLabel {
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>90</width>
|
<width>326</width>
|
||||||
<height>55</height>
|
<height>267</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<attribute name="label">
|
<attribute name="label">
|
||||||
@@ -2842,6 +2842,7 @@ QStatusBar QLabel {
|
|||||||
<tabstop>cb_StatusWithDBus</tabstop>
|
<tabstop>cb_StatusWithDBus</tabstop>
|
||||||
<tabstop>le_StatusNetworkContext</tabstop>
|
<tabstop>le_StatusNetworkContext</tabstop>
|
||||||
<tabstop>le_StatusVoiceContext</tabstop>
|
<tabstop>le_StatusVoiceContext</tabstop>
|
||||||
|
<tabstop>tv_StatusMessages</tabstop>
|
||||||
<tabstop>le_CommandLineInput</tabstop>
|
<tabstop>le_CommandLineInput</tabstop>
|
||||||
<tabstop>tw_AtcStations</tabstop>
|
<tabstop>tw_AtcStations</tabstop>
|
||||||
<tabstop>tv_AtcStationsOnline</tabstop>
|
<tabstop>tv_AtcStationsOnline</tabstop>
|
||||||
@@ -2852,6 +2853,7 @@ QStatusBar QLabel {
|
|||||||
<tabstop>tv_AtcStationsBooked</tabstop>
|
<tabstop>tv_AtcStationsBooked</tabstop>
|
||||||
<tabstop>pb_ReloadAtcStationsBooked</tabstop>
|
<tabstop>pb_ReloadAtcStationsBooked</tabstop>
|
||||||
<tabstop>tv_AircraftsInRange</tabstop>
|
<tabstop>tv_AircraftsInRange</tabstop>
|
||||||
|
<tabstop>tv_AllUsers</tabstop>
|
||||||
<tabstop>pb_CockpitToggleCom1</tabstop>
|
<tabstop>pb_CockpitToggleCom1</tabstop>
|
||||||
<tabstop>ds_CockpitCom1Active</tabstop>
|
<tabstop>ds_CockpitCom1Active</tabstop>
|
||||||
<tabstop>ds_CockpitCom1Standby</tabstop>
|
<tabstop>ds_CockpitCom1Standby</tabstop>
|
||||||
@@ -2913,6 +2915,14 @@ QStatusBar QLabel {
|
|||||||
<tabstop>pb_MainKeypadOpacity050</tabstop>
|
<tabstop>pb_MainKeypadOpacity050</tabstop>
|
||||||
<tabstop>pb_SoundMute</tabstop>
|
<tabstop>pb_SoundMute</tabstop>
|
||||||
<tabstop>pb_SoundMaxVolume</tabstop>
|
<tabstop>pb_SoundMaxVolume</tabstop>
|
||||||
|
<tabstop>te_StatusPageConsole</tabstop>
|
||||||
|
<tabstop>rb_SetttingsNormalLoginMode</tabstop>
|
||||||
|
<tabstop>rb_SettingsLoginStealthMode</tabstop>
|
||||||
|
<tabstop>rb_SettingsLoginObserver</tabstop>
|
||||||
|
<tabstop>pb_SettingsAudioSquelchTest</tabstop>
|
||||||
|
<tabstop>pb_SettingsAudioMicrophoneTest</tabstop>
|
||||||
|
<tabstop>pte_SettingsAudioTestActionAndResult</tabstop>
|
||||||
|
<tabstop>hs_SettingsGuiUserRefreshTime</tabstop>
|
||||||
</tabstops>
|
</tabstops>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="../../src/blackgui/blackgui.qrc"/>
|
<include location="../../src/blackgui/blackgui.qrc"/>
|
||||||
|
|||||||
@@ -81,10 +81,16 @@ void MainWindow::updateCockpitFromContext()
|
|||||||
const CComSystem com2 = this->m_ownAircraft.getCom2System();
|
const CComSystem com2 = this->m_ownAircraft.getCom2System();
|
||||||
const CTransponder transponder = this->m_ownAircraft.getTransponder();
|
const CTransponder transponder = this->m_ownAircraft.getTransponder();
|
||||||
|
|
||||||
this->roundComFrequencyDisplays(com1, com2);
|
// update the frequencies
|
||||||
qint32 tc = transponder.getTransponderCode();
|
this->updateComFrequencyDisplays(com1, com2);
|
||||||
if (tc != static_cast<qint32>(this->ui->ds_CockpitTransponder->value()))
|
|
||||||
this->ui->ds_CockpitTransponder->setValue(tc);
|
if (this->m_inputFocusedWidget != this->ui->ds_CockpitTransponder)
|
||||||
|
{
|
||||||
|
// update transponder if this is not input focused
|
||||||
|
qint32 tc = transponder.getTransponderCode();
|
||||||
|
if (tc != static_cast<qint32>(this->ui->ds_CockpitTransponder->value()))
|
||||||
|
this->ui->ds_CockpitTransponder->setValue(tc);
|
||||||
|
}
|
||||||
|
|
||||||
QString tm = this->ui->cb_CockpitTransponderMode->currentText().trimmed().toUpper();
|
QString tm = this->ui->cb_CockpitTransponderMode->currentText().trimmed().toUpper();
|
||||||
switch (transponder.getTransponderMode())
|
switch (transponder.getTransponderMode())
|
||||||
@@ -178,25 +184,38 @@ void MainWindow::updateCockpitFromContext()
|
|||||||
/*
|
/*
|
||||||
* Round the com frequency displays
|
* Round the com frequency displays
|
||||||
*/
|
*/
|
||||||
void MainWindow::roundComFrequencyDisplays(const CComSystem &com1, const CComSystem &com2)
|
void MainWindow::updateComFrequencyDisplays(const CComSystem &com1, const CComSystem &com2)
|
||||||
{
|
{
|
||||||
// do not just set! Leads to unwanted signals fired
|
// do not just set! Leads to unwanted signals fired
|
||||||
double freq = com1.getFrequencyActive().valueRounded(3);
|
// only update if not focused
|
||||||
if (freq != this->ui->ds_CockpitCom1Active->value())
|
|
||||||
this->ui->ds_CockpitCom1Active->setValue(freq);
|
|
||||||
|
|
||||||
freq = com2.getFrequencyActive().valueRounded(3);
|
if (this->m_inputFocusedWidget != ui->ds_CockpitCom1Active)
|
||||||
if (freq != this->ui->ds_CockpitCom2Active->value())
|
{
|
||||||
this->ui->ds_CockpitCom2Active->setValue(freq);
|
double freq = com1.getFrequencyActive().valueRounded(3);
|
||||||
|
if (freq != this->ui->ds_CockpitCom1Active->value())
|
||||||
|
this->ui->ds_CockpitCom1Active->setValue(freq);
|
||||||
|
}
|
||||||
|
|
||||||
freq = com1.getFrequencyStandby().valueRounded(3);
|
if (this->m_inputFocusedWidget != ui->ds_CockpitCom2Active)
|
||||||
if (freq != this->ui->ds_CockpitCom1Standby->value())
|
{
|
||||||
|
double freq = com2.getFrequencyActive().valueRounded(3);
|
||||||
|
if (freq != this->ui->ds_CockpitCom2Active->value())
|
||||||
|
this->ui->ds_CockpitCom2Active->setValue(freq);
|
||||||
|
}
|
||||||
|
|
||||||
this->ui->ds_CockpitCom1Standby->setValue(freq);
|
if (this->m_inputFocusedWidget != ui->ds_CockpitCom1Standby)
|
||||||
|
{
|
||||||
|
double freq = com1.getFrequencyStandby().valueRounded(3);
|
||||||
|
if (freq != this->ui->ds_CockpitCom1Standby->value())
|
||||||
|
this->ui->ds_CockpitCom1Standby->setValue(freq);
|
||||||
|
}
|
||||||
|
|
||||||
freq = com2.getFrequencyStandby().valueRounded(3);
|
if (this->m_inputFocusedWidget != ui->ds_CockpitCom2Standby)
|
||||||
if (freq != this->ui->ds_CockpitCom2Standby->value())
|
{
|
||||||
this->ui->ds_CockpitCom2Standby->setValue(freq);
|
double freq = com2.getFrequencyStandby().valueRounded(3);
|
||||||
|
if (freq != this->ui->ds_CockpitCom2Standby->value())
|
||||||
|
this->ui->ds_CockpitCom2Standby->setValue(freq);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -263,7 +282,7 @@ void MainWindow::sendCockpitUpdates()
|
|||||||
com1.setFrequencyStandbyMHz(this->ui->ds_CockpitCom1Standby->value());
|
com1.setFrequencyStandbyMHz(this->ui->ds_CockpitCom1Standby->value());
|
||||||
com2.setFrequencyActiveMHz(this->ui->ds_CockpitCom2Active->value());
|
com2.setFrequencyActiveMHz(this->ui->ds_CockpitCom2Active->value());
|
||||||
com2.setFrequencyStandbyMHz(this->ui->ds_CockpitCom2Standby->value());
|
com2.setFrequencyStandbyMHz(this->ui->ds_CockpitCom2Standby->value());
|
||||||
this->roundComFrequencyDisplays(com1, com2);
|
this->updateComFrequencyDisplays(com1, com2);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Send to context
|
// Send to context
|
||||||
@@ -358,3 +377,12 @@ QString MainWindow::getSelcalCode() const
|
|||||||
QString selcal = this->ui->cb_CockpitSelcal1->currentText().append(this->ui->cb_CockpitSelcal2->currentText());
|
QString selcal = this->ui->cb_CockpitSelcal1->currentText().append(this->ui->cb_CockpitSelcal2->currentText());
|
||||||
return selcal;
|
return selcal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Current input focus
|
||||||
|
*/
|
||||||
|
void MainWindow::inputFocusChanged(QWidget *oldWidget, QWidget *newWidget)
|
||||||
|
{
|
||||||
|
Q_UNUSED(oldWidget);
|
||||||
|
this->m_inputFocusedWidget = newWidget;
|
||||||
|
}
|
||||||
|
|||||||
@@ -299,6 +299,7 @@ void MainWindow::initGuiSignals()
|
|||||||
this->connect(this->ui->pb_CockpitToggleCom2, &QPushButton::clicked, this, &MainWindow::cockpitValuesChanged);
|
this->connect(this->ui->pb_CockpitToggleCom2, &QPushButton::clicked, this, &MainWindow::cockpitValuesChanged);
|
||||||
this->connect(this->ui->pb_CockpitIdent, &QPushButton::clicked, this, &MainWindow::cockpitValuesChanged);
|
this->connect(this->ui->pb_CockpitIdent, &QPushButton::clicked, this, &MainWindow::cockpitValuesChanged);
|
||||||
this->connect(this->ui->pb_CockpitSelcalTest, &QPushButton::clicked, this, &MainWindow::testSelcal);
|
this->connect(this->ui->pb_CockpitSelcalTest, &QPushButton::clicked, this, &MainWindow::testSelcal);
|
||||||
|
this->connect(qApp, &QApplication::focusChanged, this, &MainWindow::inputFocusChanged);
|
||||||
|
|
||||||
// voice
|
// voice
|
||||||
connected = this->connect(this->ui->cb_SettingsAudioInputDevice, SIGNAL(currentIndexChanged(int)), this, SLOT(audioDeviceSelected(int)));
|
connected = this->connect(this->ui->cb_SettingsAudioInputDevice, SIGNAL(currentIndexChanged(int)), this, SLOT(audioDeviceSelected(int)));
|
||||||
|
|||||||
Reference in New Issue
Block a user