diff --git a/src/blackgui/components/atcstationcomponent.cpp b/src/blackgui/components/atcstationcomponent.cpp index 283c7abda..5cda5d4a6 100644 --- a/src/blackgui/components/atcstationcomponent.cpp +++ b/src/blackgui/components/atcstationcomponent.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -56,15 +57,15 @@ namespace BlackGui namespace Components { CAtcStationComponent::CAtcStationComponent(QWidget *parent) : - COverlayMessagesTabWidget(parent), + COverlayMessagesFrame(parent), CIdentifiable(this), ui(new Ui::CAtcStationComponent) { Q_ASSERT_X(sGui, Q_FUNC_INFO, "Need sGui"); ui->setupUi(this); - this->setCurrentIndex(0); - this->tabBar()->setExpanding(false); - this->tabBar()->setUsesScrollButtons(true); + ui->tw_Atc->setCurrentIndex(0); + ui->tw_Atc->tabBar()->setExpanding(false); + ui->tw_Atc->tabBar()->setUsesScrollButtons(true); CUpperCaseValidator *ucv = new CUpperCaseValidator(ui->le_AtcStationsOnlineMetar); ui->le_AtcStationsOnlineMetar->setValidator(ucv); @@ -92,7 +93,7 @@ namespace BlackGui connect(ui->tb_AtcStationsLoadMetar, &QPushButton::clicked, this, &CAtcStationComponent::getMetarAsEntered); connect(ui->tb_Audio, &QPushButton::clicked, this, &CAtcStationComponent::requestAudioWidget); connect(ui->tb_TextMessageOverlay, &QPushButton::clicked, this, &CAtcStationComponent::showOverlayInlineTextMessage); - connect(this, &QTabWidget::currentChanged, this, &CAtcStationComponent::atcStationsTabChanged); // "local" tab changed (booked, online) + connect(ui->tw_Atc, &QTabWidget::currentChanged, this, &CAtcStationComponent::atcStationsTabChanged); // "local" tab changed (booked, online) connect(ui->tvp_AtcStationsOnline, &CAtcStationView::objectClicked, this, &CAtcStationComponent::onlineAtcStationSelected); connect(ui->tvp_AtcStationsOnline, &CAtcStationView::objectSelected, this, &CAtcStationComponent::onlineAtcStationSelected); connect(ui->tvp_AtcStationsOnline, &CAtcStationView::testRequestDummyAtcOnlineStations, this, &CAtcStationComponent::testCreateDummyOnlineAtcStations); @@ -113,6 +114,9 @@ namespace BlackGui connect(ui->tb_AtcStationsAtisReload, &QPushButton::clicked, this, &CAtcStationComponent::requestAtis); connect(&m_updateTimer, &QTimer::timeout, this, &CAtcStationComponent::update); + // Group box + connect(ui->gb_Details, &QGroupBox::toggled, this, &CAtcStationComponent::onDetailsToggled); + // runtime based connects connect(sGui->getIContextNetwork(), &IContextNetwork::changedAtcStationsOnlineDigest, this, &CAtcStationComponent::changedAtcStationsOnline, Qt::QueuedConnection); connect(sGui->getIContextNetwork(), &IContextNetwork::changedAtcStationsBookedDigest, this, &CAtcStationComponent::changedAtcStationsBooked, Qt::QueuedConnection); @@ -123,6 +127,10 @@ namespace BlackGui ui->tvp_AtcStationsOnline->acceptClickSelection(true); ui->tvp_AtcStationsOnline->acceptRowSelection(true); + QVBoxLayout *layout = this->vLayout(); + m_stretch.push_back(layout->stretch(0)); + m_stretch.push_back(layout->stretch(1)); + // web readers if (sGui->hasWebDataServices()) { @@ -140,7 +148,7 @@ namespace BlackGui void CAtcStationComponent::setTab(CAtcStationComponent::AtcTab tab) { const int t = static_cast(tab); - this->setCurrentIndex(t); + ui->tw_Atc->setCurrentIndex(t); } int CAtcStationComponent::countBookedStations() const @@ -326,7 +334,7 @@ namespace BlackGui const QPointer myself(this); QTimer::singleShot(1000, this, [ = ] { - if (!myself) { return; } + if (!sApp || sApp->isShuttingDown() || !myself) { return; } this->update(); }); Q_UNUSED(index); @@ -336,14 +344,18 @@ namespace BlackGui { Q_UNUSED(count); Q_UNUSED(withFilter); - int io = this->indexOf(ui->tb_AtcStationsOnline); - int ib = this->indexOf(ui->tb_AtcStationsBooked); - QString o = this->tabBar()->tabText(io); - QString b = this->tabBar()->tabText(ib); + const int io = ui->tw_Atc->indexOf(ui->tb_AtcStationsOnline); + const int it = ui->tw_Atc->indexOf(ui->tb_AtcStationsOnlineTree); + const int ib = ui->tw_Atc->indexOf(ui->tb_AtcStationsBooked); + QString o = ui->tw_Atc->tabBar()->tabText(io); + QString t = ui->tw_Atc->tabBar()->tabText(it); + QString b = ui->tw_Atc->tabBar()->tabText(ib); o = CGuiUtility::replaceTabCountValue(o, this->countOnlineStations()); + t = CGuiUtility::replaceTabCountValue(t, this->countOnlineStations()); b = CGuiUtility::replaceTabCountValue(b, this->countBookedStations()); - this->tabBar()->setTabText(io, o); - this->tabBar()->setTabText(ib, b); + ui->tw_Atc->tabBar()->setTabText(io, o); + ui->tw_Atc->tabBar()->setTabText(it, t); + ui->tw_Atc->tabBar()->setTabText(ib, b); } void CAtcStationComponent::setComFrequency(const PhysicalQuantities::CFrequency &frequency, CComSystem::ComUnit unit) @@ -416,13 +428,15 @@ namespace BlackGui void CAtcStationComponent::atcStationsTabChanged() { - if (this->currentWidget() == ui->tb_AtcStationsBooked) + const bool booked = ui->tw_Atc->currentWidget() == ui->tb_AtcStationsBooked; + if (booked) { if (ui->tvp_AtcStationsBooked->isEmpty()) { this->reloadAtcStationsBooked(); } } + ui->gb_Details->setVisible(!booked); } void CAtcStationComponent::requestAtis() @@ -445,7 +459,39 @@ namespace BlackGui void CAtcStationComponent::showOverlayInlineTextMessage() { - COverlayMessagesTabWidget::showOverlayInlineTextMessage(TextMessagesCom1); + COverlayMessagesFrame::showOverlayInlineTextMessage(TextMessagesCom1); + } + + void CAtcStationComponent::onDetailsToggled(bool checked) + { + QVBoxLayout *layout = this->vLayout(); + if (layout) + { + if (checked) + { + layout->setStretchFactor(ui->tw_Atc, m_stretch.at(0)); + layout->setStretchFactor(ui->gb_Details, m_stretch.at(1)); + } + else + { + layout->setStretchFactor(ui->tw_Atc, 0); + layout->setStretchFactor(ui->gb_Details, 0); + } + } + + ui->te_AtcStationsOnlineInfo->setVisible(checked); + ui->comp_AtcStationsSettings->setVisible(checked); + ui->le_AtcStationsOnlineMetar->setVisible(checked); + ui->tb_AtcStationsAtisReload->setVisible(checked); + ui->tb_AtcStationsLoadMetar->setVisible(checked); + ui->tb_TextMessageOverlay->setVisible(checked); + ui->tb_Audio->setVisible(checked); + } + + QVBoxLayout *CAtcStationComponent::vLayout() const + { + QVBoxLayout *layout = qobject_cast(this->layout()); + return layout; } } // namespace } // namespace diff --git a/src/blackgui/components/atcstationcomponent.h b/src/blackgui/components/atcstationcomponent.h index c3f4599ca..e7df6c36e 100644 --- a/src/blackgui/components/atcstationcomponent.h +++ b/src/blackgui/components/atcstationcomponent.h @@ -30,7 +30,9 @@ #include #include #include +#include #include +#include namespace BlackMisc { namespace Aviation { class CCallsign; } } namespace Ui { class CAtcStationComponent; } @@ -41,7 +43,7 @@ namespace BlackGui { //! ATC stations component class BLACKGUI_EXPORT CAtcStationComponent : - public COverlayMessagesTabWidget, + public COverlayMessagesFrame, public CEnableForDockWidgetInfoArea, public BlackMisc::CIdentifiable { @@ -155,13 +157,20 @@ namespace BlackGui //! Inline message void showOverlayInlineTextMessage(); + //! Details toggled + void onDetailsToggled(bool checked); + + //! Get the vertical layout + QVBoxLayout *vLayout() const; + QScopedPointer ui; QTimer m_updateTimer; + QList m_stretch; QDateTime m_timestampLastReadOnlineStations; //!< stations read QDateTime m_timestampOnlineStationsChanged; //!< stations marked as changed QDateTime m_timestampLastReadBookedStations; //!< stations read QDateTime m_timestampBookedStationsChanged; //!< stations marked as changed - BlackMisc::CSettingReadOnly m_settingsView { this, &CAtcStationComponent::settingsChanged }; + BlackMisc::CSettingReadOnly m_settingsView { this, &CAtcStationComponent::settingsChanged }; }; } // namespace } // namespace diff --git a/src/blackgui/components/atcstationcomponent.ui b/src/blackgui/components/atcstationcomponent.ui index 1b5934d0a..05c9ac0ad 100644 --- a/src/blackgui/components/atcstationcomponent.ui +++ b/src/blackgui/components/atcstationcomponent.ui @@ -1,262 +1,277 @@ CAtcStationComponent - + 0 0 - 400 - 462 + 278 + 507 ATC stations - - 0 - - - - Online - - - - 3 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 16777215 - 16777215 - - - - - - - QAbstractItemView::SingleSelection - - - QAbstractItemView::SelectRows - - - true - - - false + + + 1 + + + 1 + + + 1 + + + 1 + + + + + 0 + + + + ATC stations - - - - - + + + 3 + + + 0 + - 2 + 0 + + + 0 0 - - - - METAR: Airport ICAO code + + + + + 16777215 + 16777215 + - - 5 + + - - e.g. KLAX + + QAbstractItemView::SingleSelection - - - - - - Reload ATIS + + QAbstractItemView::SelectRows - - ATIS - - - - - - - goto audio panel - - - audio - - - - - - - text message - - - tm - - - - - - - Load METAR - - - METAR + + true + + false + - - - - - - 100 - 0 - - - - Qt::StrongFocus - - - - - - - - 0 - 0 - - - - - 0 - 0 - - - - - 16777215 - 16777215 - - - - true - - - - - - - - Online (tree) - - - - 3 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - QAbstractItemView::SingleSelection - - - QAbstractItemView::SelectRows - - - true - - - false + + + ATC tree + + + 3 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + QAbstractItemView::SingleSelection + + + QAbstractItemView::SelectRows + + + true + + + false + + + + - - - - - - Booked - - - - 3 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - QFrame::StyledPanel - - - QFrame::Sunken - - - 1 - - - true - - - QAbstractItemView::SingleSelection - - - QAbstractItemView::SelectRows - - - true - - - true - - - false + + + ATC booked + + + 3 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + QFrame::StyledPanel + + + QFrame::Sunken + + + 1 + + + true + + + QAbstractItemView::SingleSelection + + + QAbstractItemView::SelectRows + + + true + + + true + + + false + + + + - - - + + + + + + Details (METAR, ATIS, range) + + + true + + + + + + Load METAR + + + METAR + + + + + + + Reload ATIS + + + ATIS + + + + + + + text message + + + tm + + + + + + + + 0 + 0 + + + + + 0 + 0 + + + + + 16777215 + 16777215 + + + + true + + + + + + + METAR: Airport ICAO code + + + 5 + + + e.g. KLAX + + + + + + + goto audio panel + + + audio + + + + + + + + 0 + 25 + + + + + + + + @@ -277,13 +292,14 @@ + tw_Atc tvp_AtcStationsOnline + gb_Details le_AtcStationsOnlineMetar tb_AtcStationsLoadMetar tb_AtcStationsAtisReload tb_Audio tb_TextMessageOverlay - comp_AtcStationsSettings te_AtcStationsOnlineInfo tvp_AtcStationsOnlineTree tvp_AtcStationsBooked diff --git a/src/blackgui/components/settingsatcstationsinlinecomponent.ui b/src/blackgui/components/settingsatcstationsinlinecomponent.ui index c9bad339b..4f4bce296 100644 --- a/src/blackgui/components/settingsatcstationsinlinecomponent.ui +++ b/src/blackgui/components/settingsatcstationsinlinecomponent.ui @@ -6,14 +6,26 @@ 0 0 - 256 - 31 + 291 + 24 Frame + + 2 + + + 2 + + + 2 + + + 2 + @@ -34,6 +46,19 @@ + + + + Qt::Horizontal + + + + 40 + 20 + + + +