From d3892de5938b3ffd173529e2178439379fa33b12 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Mon, 4 May 2020 21:43:09 +0200 Subject: [PATCH] Ref T783, no longer use stretch factor, but splitter sizes Using stretch factor can cause ASSERT: https://discordapp.com/channels/539048679160676382/539846348275449887/706825982283350047 --- .../components/atcstationcomponent.cpp | 31 ++++++++++++++++--- src/blackgui/components/atcstationcomponent.h | 4 +-- 2 files changed, 29 insertions(+), 6 deletions(-) diff --git a/src/blackgui/components/atcstationcomponent.cpp b/src/blackgui/components/atcstationcomponent.cpp index b7d1e2e91..08dc8b595 100644 --- a/src/blackgui/components/atcstationcomponent.cpp +++ b/src/blackgui/components/atcstationcomponent.cpp @@ -123,7 +123,7 @@ namespace BlackGui connect(&m_updateTimer, &QTimer::timeout, this, &CAtcStationComponent::update); // Group box - connect(ui->gb_Details, &QGroupBox::toggled, this, &CAtcStationComponent::onDetailsToggled); + connect(ui->gb_Details, &QGroupBox::toggled, this, &CAtcStationComponent::onDetailsToggled, Qt::QueuedConnection); // runtime based connects if (sGui) @@ -546,13 +546,36 @@ namespace BlackGui { if (checked) { - layout->setStretchFactor(ui->tw_Atc, m_stretch.at(0)); - layout->setStretchFactor(ui->gb_Details, m_stretch.at(1)); + if (!m_splitterSizes.isEmpty()) + { + ui->sp_AtcSplitter->setSizes(m_splitterSizes); + } + + /* before splitter + if (m_stretch.size() > 1) + { + 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); + m_splitterSizes = ui->sp_AtcSplitter->sizes(); + if (m_splitterSizes.size() > 1) + { + int min, max; + ui->sp_AtcSplitter->getRange(1, &min, &max); + QList newSizes; + newSizes.push_back(qMax(0, m_splitterSizes.first() + m_splitterSizes.last() - min)); + newSizes.push_back(min); + ui->sp_AtcSplitter->setSizes(newSizes); + } + + /* before splitter + layout->setStretchFactor(ui->tw_Atc, 0); layout->setStretchFactor(ui->gb_Details, 0); + */ } } diff --git a/src/blackgui/components/atcstationcomponent.h b/src/blackgui/components/atcstationcomponent.h index 733411716..30f9f41fe 100644 --- a/src/blackgui/components/atcstationcomponent.h +++ b/src/blackgui/components/atcstationcomponent.h @@ -169,8 +169,8 @@ namespace BlackGui QVBoxLayout *vLayout() const; QScopedPointer ui; - QTimer m_updateTimer; - QList m_stretch; + QTimer m_updateTimer; + QList m_splitterSizes; BlackMisc::Aviation::CCallsign m_selectedCallsign; QDateTime m_timestampLastReadOnlineStations; //!< stations read QDateTime m_timestampOnlineStationsChanged; //!< stations marked as changed