From 5ba8b21dcc4b731bdf2db4c9dc6add589c4b2784 Mon Sep 17 00:00:00 2001 From: f4exb Date: Sat, 23 Apr 2022 13:59:22 +0200 Subject: [PATCH] Massive UI revamping (v7): better handling of expandable rollup sub widgets. Part of #1209 --- sdrgui/channel/channelgui.cpp | 1 + sdrgui/channel/channelgui.h | 1 + sdrgui/gui/rollupcontents.cpp | 30 ++++++++++++++++++++++++++++++ sdrgui/gui/rollupcontents.h | 2 ++ 4 files changed, 34 insertions(+) diff --git a/sdrgui/channel/channelgui.cpp b/sdrgui/channel/channelgui.cpp index 6a76d5066..69e70ad5f 100644 --- a/sdrgui/channel/channelgui.cpp +++ b/sdrgui/channel/channelgui.cpp @@ -140,6 +140,7 @@ ChannelGUI::ChannelGUI(QWidget *parent) : m_topLayout->addWidget(m_closeButton); m_centerLayout = new QHBoxLayout(); + m_centerLayout->setContentsMargins(0, 0, 0, 0); m_rollupContents = new RollupContents(); // Do not delete! Done in child's destructor with "delete ui" m_centerLayout->addWidget(m_rollupContents); diff --git a/sdrgui/channel/channelgui.h b/sdrgui/channel/channelgui.h index 889638adf..9e02236ef 100644 --- a/sdrgui/channel/channelgui.h +++ b/sdrgui/channel/channelgui.h @@ -95,6 +95,7 @@ protected: void mouseMoveEvent(QMouseEvent* event) override; void resetContextMenuType() { m_contextMenuType = ContextMenuNone; } void updateIndexLabel(); + int getAdditionalHeight() const { return 29 + 26; } DeviceType m_deviceType; int m_deviceSetIndex; diff --git a/sdrgui/gui/rollupcontents.cpp b/sdrgui/gui/rollupcontents.cpp index 19294e78e..cce640575 100644 --- a/sdrgui/gui/rollupcontents.cpp +++ b/sdrgui/gui/rollupcontents.cpp @@ -92,6 +92,36 @@ void RollupContents::setHighlighted(bool highlighted) } } +int RollupContents::getAdditionalHeiht() +{ + int pos = 0; + + for (int i = 0; i < children().count(); ++i) + { + QWidget* r = qobject_cast(children()[i]); + + if (r && isRollupChild(r) && !r->isHidden()) { + pos += 5; + } + } + + return pos; +} + +bool RollupContents::hasExpandableWidgets() +{ + for (int i = 0; i < children().count(); ++i) + { + QWidget* r = qobject_cast(children()[i]); + + if (r && isRollupChild(r) && !r->isHidden() && (r->sizePolicy().verticalPolicy() == QSizePolicy::Expanding)) { + return true; + } + } + + return false; +} + int RollupContents::arrangeRollups() { QFontMetrics fm(font()); diff --git a/sdrgui/gui/rollupcontents.h b/sdrgui/gui/rollupcontents.h index 649398a17..2777b6f78 100644 --- a/sdrgui/gui/rollupcontents.h +++ b/sdrgui/gui/rollupcontents.h @@ -34,6 +34,8 @@ public: void saveState(RollupState& state) const; void restoreState(const RollupState& state); int arrangeRollups(); + int getAdditionalHeiht(); + bool hasExpandableWidgets(); signals: void widgetRolled(QWidget* widget, bool rollDown);