1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-25 17:28:50 -05:00

Massive UI revamping (v7): better handling of expandable rollup sub widgets. Part of #1209

This commit is contained in:
f4exb 2022-04-23 13:59:22 +02:00
parent db71b9fcb2
commit 5ba8b21dcc
4 changed files with 34 additions and 0 deletions

View File

@ -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);

View File

@ -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;

View File

@ -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<QWidget*>(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<QWidget*>(children()[i]);
if (r && isRollupChild(r) && !r->isHidden() && (r->sizePolicy().verticalPolicy() == QSizePolicy::Expanding)) {
return true;
}
}
return false;
}
int RollupContents::arrangeRollups()
{
QFontMetrics fm(font());

View File

@ -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);