refs #335, improved size handling for cockpit

* minimum values set to avoid issues when docked
* no manual values when just toggled floating
This commit is contained in:
Klaus Basan
2014-11-07 19:25:53 +01:00
committed by Roland Winklmeier
parent f4e8b40bf9
commit adba17da0f
5 changed files with 52 additions and 32 deletions

View File

@@ -171,7 +171,7 @@ namespace BlackGui
CSelcal selcal = this->getSelcal(); CSelcal selcal = this->getSelcal();
if (!selcal.isValid()) if (!selcal.isValid())
{ {
CLogMessage().validationWarning("Invalid SELCAL codde"); CLogMessage().validationWarning("Invalid SELCAL code");
} }
else if (this->getIContextAudio()) else if (this->getIContextAudio())
{ {

View File

@@ -140,7 +140,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item alignment="Qt::AlignHCenter"> <item alignment="Qt::AlignRight">
<widget class="QPushButton" name="pb_ComPanelSelcalTest"> <widget class="QPushButton" name="pb_ComPanelSelcalTest">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Maximum"> <sizepolicy hsizetype="Maximum" vsizetype="Maximum">
@@ -148,6 +148,12 @@
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="maximumSize">
<size>
<width>16</width>
<height>16777215</height>
</size>
</property>
<property name="toolTip"> <property name="toolTip">
<string>test SELCAL</string> <string>test SELCAL</string>
</property> </property>

View File

@@ -23,6 +23,7 @@ namespace BlackGui
ui(new Ui::CCockpitComponent) ui(new Ui::CCockpitComponent)
{ {
ui->setupUi(this); ui->setupUi(this);
this->m_minHeightInfoArea = this->ui->comp_CockpitInfoArea->minimumHeight();
connect(ui->wip_CockpitComPanelShowHideBar, &BlackGui::CShowHideBar::toggleShowHide, this, &CCockpitComponent::ps_onToggleShowHideDetails); connect(ui->wip_CockpitComPanelShowHideBar, &BlackGui::CShowHideBar::toggleShowHide, this, &CCockpitComponent::ps_onToggleShowHideDetails);
} }
@@ -51,13 +52,23 @@ namespace BlackGui
} }
void CCockpitComponent::ps_onToggleShowHideDetails(bool show) 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->isParentDockWidgetFloating()); // show hide should not be visible if docked
Q_ASSERT(this->window()); Q_ASSERT(this->window());
if (!this->isParentDockWidgetFloating()) { return; } 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 // keep old size
QSize oldSize = this->window()->size(); QSize manuallySetSize = this->window()->size();
// hide area // hide area
this->ui->comp_CockpitInfoArea->setVisible(show); this->ui->comp_CockpitInfoArea->setVisible(show);
@@ -65,44 +76,34 @@ namespace BlackGui
// adjust size // adjust size
if (show) 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 this->window()->resize(m_sizeFloatingShown);
QSize m(300, 400); if (considerCurrentSize) { this->m_sizeFloatingHidden = manuallySetSize; } // for next time
this->window()->resize(m);
this->m_sizeFloatingShown = this->window()->size();
} }
else 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 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 this->window()->resize(m_sizeFloatingHidden);
QSize m(300, 150); if (considerCurrentSize) { this->m_sizeFloatingShown = manuallySetSize; }
this->window()->setMinimumSize(m);
this->window()->resize(m);
this->m_sizeFloatingHidden = this->window()->size();
} }
else else
{ {
this->window()->setMinimumSize(m_sizeFloatingHidden); // manually setting size, all other approaches failed
this->window()->resize(m_sizeFloatingHidden); this->window()->resize(defaultSizeHidden);
} this->m_sizeFloatingHidden = this->window()->size();
if (this->m_sizeFloatingShown.isValid())
{
// was already initialized, override
this->m_sizeFloatingShown = oldSize;
} }
} }
} }
@@ -113,11 +114,13 @@ namespace BlackGui
if (floating) if (floating)
{ {
// use the toggle method to set the sizes // use the toggle method to set the sizes
this->ps_onToggleShowHideDetails(this->isInfoAreaShown()); this->toggleShowHideDetails(this->isInfoAreaShown(), false);
} }
else else
{ {
const QSize sizeMinimum(200, 100); // set when docked, must fit into parent info area
this->ui->comp_CockpitInfoArea->setVisible(true); this->ui->comp_CockpitInfoArea->setVisible(true);
this->window()->setMinimumSize(sizeMinimum);
} }
} }

View File

@@ -48,13 +48,18 @@ namespace BlackGui
//! Show or hide cockpit details //! Show or hide cockpit details
void ps_onToggleShowHideDetails(bool show); void ps_onToggleShowHideDetails(bool show);
//! Toogle floating //! Toggle floating
void ps_onToggleFloating(bool floating); void ps_onToggleFloating(bool floating);
private: private:
// toggle area on show/hide details
void toggleShowHideDetails(bool show, bool considerCurrentSize);
QScopedPointer<Ui::CCockpitComponent> ui; QScopedPointer<Ui::CCockpitComponent> ui;
QSize m_sizeFloatingShown; //! size when info area is shown QSize m_sizeFloatingShown; //! size when info area is shown
QSize m_sizeFloatingHidden; //! size when info area is hidden QSize m_sizeFloatingHidden; //! size when info area is hidden
int m_minHeightInfoArea = -1; //! minimum height of the info area
}; };
} // namespace } // namespace

View File

@@ -7,7 +7,7 @@
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>200</width> <width>200</width>
<height>129</height> <height>229</height>
</rect> </rect>
</property> </property>
<property name="minimumSize"> <property name="minimumSize">
@@ -57,7 +57,7 @@
</property> </property>
</widget> </widget>
</item> </item>
<item alignment="Qt::AlignTop"> <item>
<widget class="BlackGui::CShowHideBar" name="wip_CockpitComPanelShowHideBar" native="true"> <widget class="BlackGui::CShowHideBar" name="wip_CockpitComPanelShowHideBar" native="true">
<property name="sizePolicy"> <property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred"> <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
@@ -87,6 +87,12 @@
<verstretch>0</verstretch> <verstretch>0</verstretch>
</sizepolicy> </sizepolicy>
</property> </property>
<property name="minimumSize">
<size>
<width>0</width>
<height>100</height>
</size>
</property>
</widget> </widget>
</item> </item>
</layout> </layout>