1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-12-23 10:05:46 -05:00

RoolupWidget: exclude dialogs from children widgets that can be used as roll up widgets

This commit is contained in:
f4exb 2020-08-04 23:25:50 +02:00
parent eef1922b00
commit d80d050992
2 changed files with 40 additions and 27 deletions

View File

@ -2,6 +2,9 @@
#include <QPainter> #include <QPainter>
#include <QPainterPath> #include <QPainterPath>
#include <QMouseEvent> #include <QMouseEvent>
#include <QDebug>
#include <QDialog>
#include "gui/rollupwidget.h" #include "gui/rollupwidget.h"
#include "ui_glspectrumgui.h" #include "ui_glspectrumgui.h"
@ -117,19 +120,17 @@ int RollupWidget::arrangeRollups()
QFontMetrics fm(font()); QFontMetrics fm(font());
int pos = fm.height() + 4; int pos = fm.height() + 4;
for(int i = 0; i < children().count(); ++i) for (int i = 0; i < children().count(); ++i)
{ {
QWidget* r = qobject_cast<QWidget*>(children()[i]); QWidget* r = qobject_cast<QWidget*>(children()[i]);
if (r != nullptr)
if ((r != nullptr) && !r->isHidden() && isRollupChild(r))
{ {
pos += fm.height() + 2; pos += fm.height() + 2;
if (!r->isHidden() && (r->windowTitle() != "Basic channel settings") && (r->windowTitle() != "Select device stream"))
{
r->move(2, pos + 3); r->move(2, pos + 3);
int h = 0; int h = 0;
if(r->hasHeightForWidth()) { if (r->hasHeightForWidth()) {
h = r->heightForWidth(width() - 4); h = r->heightForWidth(width() - 4);
} else { } else {
h = r->sizeHint().height(); h = r->sizeHint().height();
@ -139,7 +140,6 @@ int RollupWidget::arrangeRollups()
pos += r->height() + 5; pos += r->height() + 5;
} }
} }
}
setMinimumHeight(pos); setMinimumHeight(pos);
setMaximumHeight(pos); setMaximumHeight(pos);
@ -225,27 +225,32 @@ void RollupWidget::paintEvent(QPaintEvent*)
QObjectList::ConstIterator w = c.begin(); QObjectList::ConstIterator w = c.begin();
QObjectList::ConstIterator n = c.begin(); QObjectList::ConstIterator n = c.begin();
for(n = c.begin(); n != c.end(); ++n) { for (n = c.begin(); n != c.end(); ++n)
if(qobject_cast<QWidget*>(*n) != NULL) {
if (qobject_cast<QWidget*>(*n) != nullptr) {
break; break;
} }
for(w = n; w != c.end(); w = n) { }
if(n != c.end())
for (w = n; w != c.end(); w = n)
{
if (n != c.end()) {
++n; ++n;
for(; n != c.end(); ++n) { }
if(qobject_cast<QWidget*>(*n) != NULL)
for (; n != c.end(); ++n)
{
if (qobject_cast<QWidget*>(*n) != nullptr) {
break; break;
} }
}
pos += paintRollup(qobject_cast<QWidget*>(*w), pos, &p, n == c.end(), frame); pos += paintRollup(qobject_cast<QWidget*>(*w), pos, &p, n == c.end(), frame);
} }
} }
int RollupWidget::paintRollup(QWidget* rollup, int pos, QPainter* p, bool last, const QColor& frame) int RollupWidget::paintRollup(QWidget* rollup, int pos, QPainter* p, bool last, const QColor& frame)
{ {
if ((rollup->windowTitle() == "Basic channel settings") || (rollup->windowTitle() == "Select device stream")) {
return 0;
}
QFontMetrics fm(font()); QFontMetrics fm(font());
int height = 1; int height = 1;
@ -392,3 +397,8 @@ void RollupWidget::setStreamIndicator(const QString& indicator)
m_streamIndicator = indicator; m_streamIndicator = indicator;
update(); update();
} }
bool RollupWidget::isRollupChild(QWidget *childWidget)
{
return (qobject_cast<QDialog*>(childWidget) == nullptr); // exclude Dialogs from rollups
}

View File

@ -49,6 +49,9 @@ protected:
void resetContextMenuType() { m_contextMenuType = ContextMenuNone; } void resetContextMenuType() { m_contextMenuType = ContextMenuNone; }
void setStreamIndicator(const QString& indicator); void setStreamIndicator(const QString& indicator);
private:
static bool isRollupChild(QWidget *childWidget); //!< chidl is part of rollups (ex: not a dialog)
}; };
#endif // INCLUDE_ROLLUPWIDGET_H #endif // INCLUDE_ROLLUPWIDGET_H