mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#4282 Improve look of Summary Plot Editor after layout changes
* In particular make the QMinimizePanel title panel fixed in size.
This commit is contained in:
@@ -102,10 +102,11 @@ void RicSummaryCurveCreatorSplitterUi::recursivelyConfigureAndUpdateTopLevelUiOr
|
||||
auto nameConfigGroupBox = createGroupBoxWithContent(nameConfigGroup, uiConfigName);
|
||||
m_lowerLeftLayout->insertWidget(1, nameConfigGroupBox);
|
||||
|
||||
m_lowerLeftLayout->insertWidget(2, getOrCreateCurveTreeWidget(), 1);
|
||||
|
||||
QMinimizePanel* curveGroup = getOrCreateCurveTreeGroup();
|
||||
m_lowerLeftLayout->insertWidget(2, curveGroup, 1);
|
||||
m_lowerLeftLayout->addStretch(0);
|
||||
m_secondRowLayout->insertWidget(1, getOrCreatePlotWidget());
|
||||
|
||||
|
||||
// Fields at bottom of dialog
|
||||
configureAndUpdateFields(1, m_bottomFieldLayout, topLevelUiItems, uiConfigName);
|
||||
}
|
||||
@@ -128,7 +129,7 @@ QWidget* RicSummaryCurveCreatorSplitterUi::createWidget(QWidget* parent)
|
||||
|
||||
QFrame* secondRowFrame = new QFrame(widget);
|
||||
m_secondRowLayout = new QHBoxLayout;
|
||||
m_secondRowLayout->setContentsMargins(0, 0, 0, 0);
|
||||
m_secondRowLayout->setContentsMargins(0, 4, 0, 0);
|
||||
secondRowFrame->setLayout(m_secondRowLayout);
|
||||
|
||||
m_lowerLeftLayout = new QVBoxLayout;
|
||||
@@ -148,7 +149,7 @@ QWidget* RicSummaryCurveCreatorSplitterUi::createWidget(QWidget* parent)
|
||||
m_layout->addWidget(m_firstColumnSplitter);
|
||||
|
||||
m_bottomFieldLayout = new QHBoxLayout;
|
||||
m_bottomFieldLayout->setContentsMargins(0, 0, 0, 0);
|
||||
m_bottomFieldLayout->setContentsMargins(0, 2, 0, 0);
|
||||
m_layout->addLayout(m_bottomFieldLayout);
|
||||
m_bottomFieldLayout->insertStretch(0, 1);
|
||||
|
||||
@@ -180,7 +181,7 @@ caf::PdmUiGroup* RicSummaryCurveCreatorSplitterUi::findGroupByKeyword(const std:
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
QWidget* RicSummaryCurveCreatorSplitterUi::getOrCreateCurveTreeWidget()
|
||||
QMinimizePanel* RicSummaryCurveCreatorSplitterUi::getOrCreateCurveTreeGroup()
|
||||
{
|
||||
if (!m_curvesPanel)
|
||||
{
|
||||
@@ -189,6 +190,8 @@ QWidget* RicSummaryCurveCreatorSplitterUi::getOrCreateCurveTreeWidget()
|
||||
QVBoxLayout* curvesLayout = new QVBoxLayout(m_curvesPanel->contentFrame());
|
||||
|
||||
m_curveTreeView = new caf::PdmUiTreeView(m_curvesPanel->contentFrame());
|
||||
curvesLayout->setStretchFactor(m_curveTreeView, 1);
|
||||
|
||||
curvesLayout->addWidget(m_curveTreeView);
|
||||
|
||||
m_curveTreeView->treeView()->setHeaderHidden(true);
|
||||
|
||||
@@ -62,7 +62,7 @@ private:
|
||||
|
||||
QWidget* createWidget(QWidget* parent) override;
|
||||
|
||||
QWidget* getOrCreateCurveTreeWidget();
|
||||
QMinimizePanel* getOrCreateCurveTreeGroup();
|
||||
QWidget* getOrCreatePlotWidget();
|
||||
|
||||
static caf::PdmUiGroup* findGroupByKeyword(const std::vector<caf::PdmUiItem *>& topLevelUiItems,
|
||||
|
||||
@@ -193,6 +193,14 @@ void QMinimizePanel::enableFrame(bool showFrame)
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool QMinimizePanel::isExpanded() const
|
||||
{
|
||||
return !m_contentFrame->isHidden();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -201,7 +209,17 @@ void QMinimizePanel::setExpanded(bool isExpanded)
|
||||
if (m_contentFrame->isHidden() != isExpanded) return;
|
||||
|
||||
m_contentFrame->setVisible(isExpanded);
|
||||
isExpanded ? m_collapseButton->setIcon(expandUpIcon()) : m_collapseButton->setIcon(expandDownIcon());
|
||||
if (isExpanded)
|
||||
{
|
||||
m_collapseButton->setIcon(expandUpIcon());
|
||||
this->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_collapseButton->setIcon(expandDownIcon());
|
||||
this->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
|
||||
}
|
||||
|
||||
this->QWidget::updateGeometry();
|
||||
|
||||
emit expandedChanged(isExpanded);
|
||||
@@ -235,7 +253,7 @@ void QMinimizePanel::initialize(const QString &title)
|
||||
QHBoxLayout* titleLayout = new QHBoxLayout();
|
||||
titleLayout->setContentsMargins(4, 2, 0, 2);
|
||||
m_titleFrame->setLayout(titleLayout);
|
||||
|
||||
m_titleFrame->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
|
||||
{
|
||||
m_titleLabel = new QLabel(title);
|
||||
QPalette titleLabelPalette = m_titleLabel->palette();
|
||||
|
||||
@@ -58,7 +58,7 @@ public:
|
||||
void setTitle (const QString& title);
|
||||
QString title() const;
|
||||
void enableFrame(bool showFrame);
|
||||
|
||||
bool isExpanded() const;
|
||||
public slots:
|
||||
void setExpanded(bool isExpanded);
|
||||
void toggleExpanded();
|
||||
@@ -78,6 +78,5 @@ private:
|
||||
|
||||
QString titleFrameStyleSheet();
|
||||
QString contentFrameStyleSheet();
|
||||
QSize calculateSizeHint(bool minimumSizeHint) const;
|
||||
|
||||
};
|
||||
|
||||
@@ -96,13 +96,13 @@ bool caf::PdmUiFormLayoutObjectEditor::recursivelyConfigureAndUpdateUiOrderingIn
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Add all widgets at a recursion level in the form.
|
||||
/// Returns true if the level should get a row stretch at the level above.
|
||||
/// Returns the stretch factor that should be applied at the level above.
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool caf::PdmUiFormLayoutObjectEditor::recursivelyConfigureAndUpdateUiOrderingInGridLayout(const PdmUiOrdering& uiOrdering,
|
||||
int caf::PdmUiFormLayoutObjectEditor::recursivelyConfigureAndUpdateUiOrderingInGridLayout(const PdmUiOrdering& uiOrdering,
|
||||
QWidget* containerWidgetWithGridLayout,
|
||||
const QString& uiConfigName)
|
||||
{
|
||||
int maxRowStretch = 0;
|
||||
int sumRowStretch = 0;
|
||||
CAF_ASSERT(containerWidgetWithGridLayout);
|
||||
|
||||
QWidget* previousTabOrderWidget = nullptr;
|
||||
@@ -153,17 +153,16 @@ bool caf::PdmUiFormLayoutObjectEditor::recursivelyConfigureAndUpdateUiOrderingIn
|
||||
|
||||
if (currentItem->isUiGroup())
|
||||
{
|
||||
bool stretchGroup = recursivelyAddGroupToGridLayout(currentItem,
|
||||
containerWidgetWithGridLayout,
|
||||
uiConfigName,
|
||||
parentLayout,
|
||||
currentRowIndex,
|
||||
currentColumn,
|
||||
itemColumnSpan);
|
||||
int groupStretchFactor = stretchGroup ? 1 : 0;
|
||||
int groupStretchFactor = recursivelyAddGroupToGridLayout(currentItem,
|
||||
containerWidgetWithGridLayout,
|
||||
uiConfigName,
|
||||
parentLayout,
|
||||
currentRowIndex,
|
||||
currentColumn,
|
||||
itemColumnSpan);
|
||||
parentLayout->setRowStretch(currentRowIndex, groupStretchFactor);
|
||||
currentColumn += itemColumnSpan;
|
||||
maxRowStretch = std::max(maxRowStretch, groupStretchFactor);
|
||||
sumRowStretch += groupStretchFactor;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -185,7 +184,7 @@ bool caf::PdmUiFormLayoutObjectEditor::recursivelyConfigureAndUpdateUiOrderingIn
|
||||
{
|
||||
parentLayout->addWidget(fieldCombinedWidget, currentRowIndex, currentColumn, 1, itemColumnSpan);
|
||||
parentLayout->setRowStretch(currentRowIndex, fieldEditor->rowStretchFactor());
|
||||
maxRowStretch = std::max(maxRowStretch, fieldEditor->rowStretchFactor());
|
||||
sumRowStretch += fieldEditor->rowStretchFactor();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -261,7 +260,7 @@ bool caf::PdmUiFormLayoutObjectEditor::recursivelyConfigureAndUpdateUiOrderingIn
|
||||
previousTabOrderWidget = fieldEditorWidget;
|
||||
|
||||
parentLayout->setRowStretch(currentRowIndex, fieldEditor->rowStretchFactor());
|
||||
maxRowStretch = std::max(maxRowStretch, fieldEditor->rowStretchFactor());
|
||||
sumRowStretch += fieldEditor->rowStretchFactor();
|
||||
}
|
||||
fieldEditor->updateUi(uiConfigName);
|
||||
}
|
||||
@@ -272,25 +271,25 @@ bool caf::PdmUiFormLayoutObjectEditor::recursivelyConfigureAndUpdateUiOrderingIn
|
||||
}
|
||||
containerWidgetWithGridLayout->updateGeometry();
|
||||
// The magnitude of the stretch should not be sent up, only if there was stretch or not
|
||||
return maxRowStretch > 0;
|
||||
return sumRowStretch;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
/// Create a group and add widgets. Return true if the containing row needs to be stretched.
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool caf::PdmUiFormLayoutObjectEditor::recursivelyAddGroupToGridLayout(PdmUiItem* currentItem,
|
||||
QWidget* containerWidgetWithGridLayout,
|
||||
const QString& uiConfigName,
|
||||
QGridLayout* parentLayout,
|
||||
int currentRowIndex,
|
||||
int currentColumn,
|
||||
int itemColumnSpan)
|
||||
int caf::PdmUiFormLayoutObjectEditor::recursivelyAddGroupToGridLayout(PdmUiItem* currentItem,
|
||||
QWidget* containerWidgetWithGridLayout,
|
||||
const QString& uiConfigName,
|
||||
QGridLayout* parentLayout,
|
||||
int currentRowIndex,
|
||||
int currentColumn,
|
||||
int itemColumnSpan)
|
||||
{
|
||||
PdmUiGroup* group = static_cast<PdmUiGroup*>(currentItem);
|
||||
|
||||
QMinimizePanel* groupBox = findOrCreateGroupBox(containerWidgetWithGridLayout, group, uiConfigName);
|
||||
|
||||
bool stretch = recursivelyConfigureAndUpdateUiOrderingInGridLayout(*group, groupBox->contentFrame(), uiConfigName);
|
||||
int stretch = recursivelyConfigureAndUpdateUiOrderingInGridLayout(*group, groupBox->contentFrame(), uiConfigName);
|
||||
|
||||
/// Insert the group box at the correct position of the parent layout
|
||||
parentLayout->addWidget(groupBox, currentRowIndex, currentColumn, 1, itemColumnSpan);
|
||||
|
||||
@@ -78,11 +78,11 @@ protected:
|
||||
bool recursivelyConfigureAndUpdateUiOrderingInNewGridLayout(const PdmUiOrdering& uiOrdering,
|
||||
QWidget* containerWidget,
|
||||
const QString& uiConfigName);
|
||||
bool recursivelyConfigureAndUpdateUiOrderingInGridLayout(const PdmUiOrdering& uiOrdering,
|
||||
int recursivelyConfigureAndUpdateUiOrderingInGridLayout(const PdmUiOrdering& uiOrdering,
|
||||
QWidget* containerWidgetWithGridLayout,
|
||||
const QString& uiConfigName);
|
||||
|
||||
bool recursivelyAddGroupToGridLayout(PdmUiItem* currentItem,
|
||||
int recursivelyAddGroupToGridLayout(PdmUiItem* currentItem,
|
||||
QWidget* containerWidget,
|
||||
const QString& uiConfigName,
|
||||
QGridLayout* parentLayout,
|
||||
|
||||
Reference in New Issue
Block a user