mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-23 15:25:35 +08:00
Ref T111, some cleanup of XPDR mode and SELCAL selector
This commit is contained in:
committed by
Mathew Sutcliffe
parent
4013154a20
commit
31d398ffc8
@@ -35,11 +35,8 @@ namespace BlackGui
|
||||
ui->cb_SelcalPairs1->setStyleSheet("combobox-popup: 0;");
|
||||
ui->cb_SelcalPairs2->setStyleSheet("combobox-popup: 0;");
|
||||
|
||||
bool c = connect(ui->cb_SelcalPairs1, SIGNAL(currentIndexChanged(int)), this, SLOT(ps_selcalIndexChanged()));
|
||||
Q_ASSERT(c);
|
||||
c = connect(ui->cb_SelcalPairs2, SIGNAL(currentIndexChanged(int)), this, SLOT(ps_selcalIndexChanged()));
|
||||
Q_ASSERT(c);
|
||||
Q_UNUSED(c);
|
||||
connect(ui->cb_SelcalPairs1, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &CSelcalCodeSelector::selcalIndexChanged);
|
||||
connect(ui->cb_SelcalPairs2, static_cast<void(QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this, &CSelcalCodeSelector::selcalIndexChanged);
|
||||
}
|
||||
|
||||
CSelcalCodeSelector::~CSelcalCodeSelector()
|
||||
@@ -52,7 +49,7 @@ namespace BlackGui
|
||||
return selcal;
|
||||
}
|
||||
|
||||
BlackMisc::Aviation::CSelcal CSelcalCodeSelector::getSelcal() const
|
||||
CSelcal CSelcalCodeSelector::getSelcal() const
|
||||
{
|
||||
CSelcal selcal(getSelcalCode());
|
||||
return selcal;
|
||||
@@ -71,11 +68,11 @@ namespace BlackGui
|
||||
void CSelcalCodeSelector::setSelcalCode(const QString &selcal)
|
||||
{
|
||||
if (selcal.length() == 4 && this->getSelcalCode() == selcal) return; // avoid unintended signals
|
||||
QString s = selcal.isEmpty() ? " " : selcal.toUpper().trimmed();
|
||||
const QString s = selcal.isEmpty() ? " " : selcal.toUpper().trimmed();
|
||||
Q_ASSERT(s.length() == 4);
|
||||
if (s.length() != 4) return;
|
||||
QString s1 = s.left(2);
|
||||
QString s2 = s.right(2);
|
||||
const QString s1 = s.left(2);
|
||||
const QString s2 = s.right(2);
|
||||
if (BlackMisc::Aviation::CSelcal::codePairs().contains(s1))
|
||||
{
|
||||
ui->cb_SelcalPairs1->setCurrentText(s1);
|
||||
@@ -86,14 +83,14 @@ namespace BlackGui
|
||||
}
|
||||
}
|
||||
|
||||
void CSelcalCodeSelector::setSelcalCode(const BlackMisc::Aviation::CSelcal &selcal)
|
||||
void CSelcalCodeSelector::setSelcal(const BlackMisc::Aviation::CSelcal &selcal)
|
||||
{
|
||||
this->setSelcalCode(selcal.getCode());
|
||||
}
|
||||
|
||||
bool CSelcalCodeSelector::hasValidCode() const
|
||||
{
|
||||
QString s = this->getSelcalCode();
|
||||
const QString s = this->getSelcalCode();
|
||||
if (s.length() != 4) return false;
|
||||
return BlackMisc::Aviation::CSelcal::isValidCode(s);
|
||||
}
|
||||
@@ -105,8 +102,9 @@ namespace BlackGui
|
||||
ui->cb_SelcalPairs2->setCurrentIndex(0);
|
||||
}
|
||||
|
||||
void CSelcalCodeSelector::ps_selcalIndexChanged()
|
||||
void CSelcalCodeSelector::selcalIndexChanged(int index)
|
||||
{
|
||||
Q_UNUSED(index);
|
||||
this->setValidityHint();
|
||||
emit valueChanged();
|
||||
}
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
#include <QString>
|
||||
|
||||
class QWidget;
|
||||
namespace Ui { class CSelcalCodeSelector; }
|
||||
|
||||
namespace Ui { class CSelcalCodeSelector; }
|
||||
namespace BlackGui
|
||||
{
|
||||
namespace Components
|
||||
@@ -37,7 +37,7 @@ namespace BlackGui
|
||||
explicit CSelcalCodeSelector(QWidget *parent = nullptr);
|
||||
|
||||
//! Destructor
|
||||
~CSelcalCodeSelector();
|
||||
virtual ~CSelcalCodeSelector();
|
||||
|
||||
//! SELCAL code
|
||||
QString getSelcalCode() const;
|
||||
@@ -52,7 +52,7 @@ namespace BlackGui
|
||||
void setSelcalCode(const QString &selcal);
|
||||
|
||||
//! Set the SELCAL code
|
||||
void setSelcalCode(const BlackMisc::Aviation::CSelcal &selcal);
|
||||
void setSelcal(const BlackMisc::Aviation::CSelcal &selcal);
|
||||
|
||||
//! Valid code?
|
||||
bool hasValidCode() const;
|
||||
@@ -64,13 +64,12 @@ namespace BlackGui
|
||||
//! Value has been changed
|
||||
void valueChanged();
|
||||
|
||||
private slots:
|
||||
//! SELCAL changed
|
||||
void ps_selcalIndexChanged();
|
||||
|
||||
private:
|
||||
QScopedPointer<Ui::CSelcalCodeSelector> ui;
|
||||
|
||||
//! SELCAL changed
|
||||
void selcalIndexChanged(int index);
|
||||
|
||||
//! Set valid/invalid icon
|
||||
void setValidityHint();
|
||||
};
|
||||
|
||||
@@ -46,13 +46,12 @@ namespace BlackGui
|
||||
|
||||
const QStringList &CTransponderModeSelector::modes()
|
||||
{
|
||||
static QStringList modes;
|
||||
if (modes.isEmpty())
|
||||
static const QStringList modes(
|
||||
{
|
||||
modes << CTransponderModeSelector::transponderStateStandby();
|
||||
modes << CTransponderModeSelector::transponderModeC();
|
||||
modes << CTransponderModeSelector::transponderStateIdent();
|
||||
}
|
||||
CTransponderModeSelector::transponderStateStandby(),
|
||||
CTransponderModeSelector::transponderModeC(),
|
||||
CTransponderModeSelector::transponderStateIdent()
|
||||
});
|
||||
return modes;
|
||||
}
|
||||
|
||||
@@ -61,13 +60,18 @@ namespace BlackGui
|
||||
return this->m_currentMode;
|
||||
}
|
||||
|
||||
bool CTransponderModeSelector::isIdentSelected() const
|
||||
{
|
||||
return this->getSelectedTransponderMode() == BlackMisc::Aviation::CTransponder::StateIdent;
|
||||
}
|
||||
|
||||
void CTransponderModeSelector::setSelectedTransponderMode(CTransponder::TransponderMode mode)
|
||||
{
|
||||
if (mode != CTransponder::StateIdent) { this->m_resetMode = mode; }
|
||||
if (this->m_currentMode == mode) { return; }
|
||||
if (this->m_currentMode == CTransponder::StateIdent) { emit this->transponderStateIdentEnded(); }
|
||||
this->m_currentMode = mode;
|
||||
QString m = CTransponder::modeAsString(mode);
|
||||
const QString m = CTransponder::modeAsString(mode);
|
||||
QComboBox::setCurrentText(m);
|
||||
if (mode == CTransponder::StateIdent)
|
||||
{
|
||||
|
||||
@@ -33,7 +33,6 @@ namespace BlackGui
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
|
||||
public:
|
||||
//! Constructor
|
||||
explicit CTransponderModeSelector(QWidget *parent = nullptr);
|
||||
@@ -54,12 +53,8 @@ namespace BlackGui
|
||||
BlackMisc::Aviation::CTransponder::TransponderMode getSelectedTransponderMode() const;
|
||||
|
||||
//! Ident selected
|
||||
bool isIdentSelected() const
|
||||
{
|
||||
return this->getSelectedTransponderMode() == BlackMisc::Aviation::CTransponder::StateIdent;
|
||||
}
|
||||
bool isIdentSelected() const;
|
||||
|
||||
public slots:
|
||||
//! reset to last mode (unequal ident)
|
||||
void resetTransponderMode();
|
||||
|
||||
@@ -82,8 +77,7 @@ namespace BlackGui
|
||||
private:
|
||||
BlackMisc::Aviation::CTransponder::TransponderMode m_currentMode = BlackMisc::Aviation::CTransponder::StateStandby;
|
||||
BlackMisc::Aviation::CTransponder::TransponderMode m_resetMode = BlackMisc::Aviation::CTransponder::StateStandby;
|
||||
QTimer m_resetTimer;
|
||||
|
||||
QTimer m_resetTimer { this };
|
||||
};
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
Reference in New Issue
Block a user