mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-05 09:15:34 +08:00
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:
committed by
Roland Winklmeier
parent
f4e8b40bf9
commit
adba17da0f
@@ -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())
|
||||
{
|
||||
|
||||
@@ -140,7 +140,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item alignment="Qt::AlignHCenter">
|
||||
<item alignment="Qt::AlignRight">
|
||||
<widget class="QPushButton" name="pb_ComPanelSelcalTest">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
|
||||
@@ -148,6 +148,12 @@
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>16</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>test SELCAL</string>
|
||||
</property>
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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::CCockpitComponent> 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
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>200</width>
|
||||
<height>129</height>
|
||||
<height>229</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
@@ -57,7 +57,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item alignment="Qt::AlignTop">
|
||||
<item>
|
||||
<widget class="BlackGui::CShowHideBar" name="wip_CockpitComPanelShowHideBar" native="true">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
@@ -87,6 +87,12 @@
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>100</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
||||
Reference in New Issue
Block a user