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

pull/1215/head
f4exb 2022-04-23 13:59:22 +02:00
rodzic db71b9fcb2
commit 5ba8b21dcc
4 zmienionych plików z 34 dodań i 0 usunięć

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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

Wyświetl plik

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