From adba17da0f8538c296ca2b940067388e564383f4 Mon Sep 17 00:00:00 2001 From: Klaus Basan Date: Fri, 7 Nov 2014 19:25:53 +0100 Subject: [PATCH] refs #335, improved size handling for cockpit * minimum values set to avoid issues when docked * no manual values when just toggled floating --- .../components/cockpitcomcomponent.cpp | 2 +- .../components/cockpitcomcomponent.ui | 8 ++- src/blackgui/components/cockpitcomponent.cpp | 57 ++++++++++--------- src/blackgui/components/cockpitcomponent.h | 7 ++- src/blackgui/components/cockpitcomponent.ui | 10 +++- 5 files changed, 52 insertions(+), 32 deletions(-) diff --git a/src/blackgui/components/cockpitcomcomponent.cpp b/src/blackgui/components/cockpitcomcomponent.cpp index 854ebb91d..6ca64bd37 100644 --- a/src/blackgui/components/cockpitcomcomponent.cpp +++ b/src/blackgui/components/cockpitcomcomponent.cpp @@ -171,7 +171,7 @@ namespace BlackGui CSelcal selcal = this->getSelcal(); if (!selcal.isValid()) { - CLogMessage().validationWarning("Invalid SELCAL codde"); + CLogMessage().validationWarning("Invalid SELCAL code"); } else if (this->getIContextAudio()) { diff --git a/src/blackgui/components/cockpitcomcomponent.ui b/src/blackgui/components/cockpitcomcomponent.ui index b8135ff79..450845a3b 100644 --- a/src/blackgui/components/cockpitcomcomponent.ui +++ b/src/blackgui/components/cockpitcomcomponent.ui @@ -140,7 +140,7 @@ - + @@ -148,6 +148,12 @@ 0 + + + 16 + 16777215 + + test SELCAL diff --git a/src/blackgui/components/cockpitcomponent.cpp b/src/blackgui/components/cockpitcomponent.cpp index f59a6b892..6244d0838 100644 --- a/src/blackgui/components/cockpitcomponent.cpp +++ b/src/blackgui/components/cockpitcomponent.cpp @@ -23,6 +23,7 @@ namespace BlackGui ui(new Ui::CCockpitComponent) { ui->setupUi(this); + this->m_minHeightInfoArea = this->ui->comp_CockpitInfoArea->minimumHeight(); connect(ui->wip_CockpitComPanelShowHideBar, &BlackGui::CShowHideBar::toggleShowHide, this, &CCockpitComponent::ps_onToggleShowHideDetails); } @@ -51,13 +52,23 @@ namespace BlackGui } void CCockpitComponent::ps_onToggleShowHideDetails(bool show) + { + // use the toggle method to set the sizes + this->toggleShowHideDetails(show, true); + } + + void CCockpitComponent::toggleShowHideDetails(bool show, bool considerCurrentSize) { Q_ASSERT(this->isParentDockWidgetFloating()); // show hide should not be visible if docked Q_ASSERT(this->window()); if (!this->isParentDockWidgetFloating()) { return; } + // manually setting size, all other approaches failed + static const QSize defaultSizeShown(300, 400); + static const QSize defaultSizeHidden(300, 150); + // keep old size - QSize oldSize = this->window()->size(); + QSize manuallySetSize = this->window()->size(); // hide area this->ui->comp_CockpitInfoArea->setVisible(show); @@ -65,44 +76,34 @@ namespace BlackGui // adjust size if (show) { - if (!this->m_sizeFloatingShown.isValid()) + this->ui->comp_CockpitInfoArea->setMinimumHeight(m_minHeightInfoArea); + if (this->m_sizeFloatingShown.isValid()) { - // manually setting size, all other approaches failed - QSize m(300, 400); - this->window()->resize(m); - this->m_sizeFloatingShown = this->window()->size(); + this->window()->resize(m_sizeFloatingShown); + if (considerCurrentSize) { this->m_sizeFloatingHidden = manuallySetSize; } // for next time } else { - this->window()->resize(m_sizeFloatingShown); - } + // manually setting size, all other approaches failed + this->window()->resize(defaultSizeShown); + this->m_sizeFloatingShown = this->window()->size(); - if (this->m_sizeFloatingHidden.isValid()) - { - // was already initialized, override - this->m_sizeFloatingHidden = oldSize; } } else { - if (!this->m_sizeFloatingHidden.isValid()) + this->ui->comp_CockpitInfoArea->setMinimumHeight(0); + this->window()->setMinimumSize(defaultSizeHidden); + if (this->m_sizeFloatingHidden.isValid()) { - // manually setting size, all other approaches failed - QSize m(300, 150); - this->window()->setMinimumSize(m); - this->window()->resize(m); - this->m_sizeFloatingHidden = this->window()->size(); + this->window()->resize(m_sizeFloatingHidden); + if (considerCurrentSize) { this->m_sizeFloatingShown = manuallySetSize; } } else { - this->window()->setMinimumSize(m_sizeFloatingHidden); - this->window()->resize(m_sizeFloatingHidden); - } - - if (this->m_sizeFloatingShown.isValid()) - { - // was already initialized, override - this->m_sizeFloatingShown = oldSize; + // manually setting size, all other approaches failed + this->window()->resize(defaultSizeHidden); + this->m_sizeFloatingHidden = this->window()->size(); } } } @@ -113,11 +114,13 @@ namespace BlackGui if (floating) { // use the toggle method to set the sizes - this->ps_onToggleShowHideDetails(this->isInfoAreaShown()); + this->toggleShowHideDetails(this->isInfoAreaShown(), false); } else { + const QSize sizeMinimum(200, 100); // set when docked, must fit into parent info area this->ui->comp_CockpitInfoArea->setVisible(true); + this->window()->setMinimumSize(sizeMinimum); } } diff --git a/src/blackgui/components/cockpitcomponent.h b/src/blackgui/components/cockpitcomponent.h index 81e6a8243..334a6a48a 100644 --- a/src/blackgui/components/cockpitcomponent.h +++ b/src/blackgui/components/cockpitcomponent.h @@ -48,13 +48,18 @@ namespace BlackGui //! Show or hide cockpit details void ps_onToggleShowHideDetails(bool show); - //! Toogle floating + //! Toggle floating void ps_onToggleFloating(bool floating); private: + + // toggle area on show/hide details + void toggleShowHideDetails(bool show, bool considerCurrentSize); + QScopedPointer ui; QSize m_sizeFloatingShown; //! size when info area is shown QSize m_sizeFloatingHidden; //! size when info area is hidden + int m_minHeightInfoArea = -1; //! minimum height of the info area }; } // namespace diff --git a/src/blackgui/components/cockpitcomponent.ui b/src/blackgui/components/cockpitcomponent.ui index 74ffe064a..a3466b0c7 100644 --- a/src/blackgui/components/cockpitcomponent.ui +++ b/src/blackgui/components/cockpitcomponent.ui @@ -7,7 +7,7 @@ 0 0 200 - 129 + 229 @@ -57,7 +57,7 @@ - + @@ -87,6 +87,12 @@ 0 + + + 0 + 100 + +