17#include "moc_qgsuserinputwidget.cpp"
26 QFrame *f =
new QFrame();
27 f->setObjectName( QStringLiteral(
"mUserInputContainer" ) );
29 QPalette
pal = palette();
30 pal.setBrush( backgroundRole(),
pal.window() );
32 f->setAutoFillBackground(
true );
33 f->setFrameShape( QFrame::StyledPanel );
34 f->setFrameShadow( QFrame::Plain );
36 mLayout =
new QBoxLayout( QBoxLayout::TopToBottom );
37 mLayout->setAlignment( Qt::AlignRight | Qt::AlignTop );
38 f->setLayout( mLayout );
40 QBoxLayout *topLayout =
new QBoxLayout( QBoxLayout::TopToBottom );
41 topLayout->setContentsMargins( 0, 0, 0, 0 );
42 topLayout->addWidget( f );
43 setLayout( topLayout );
46 topLayout->setSizeConstraint( QLayout::SetFixedSize );
47 mLayout->setSizeConstraint( QLayout::SetFixedSize );
49 setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding );
55 QFrame *line =
nullptr;
56 if ( mWidgetList.count() > 0 )
58 line =
new QFrame(
this );
59 line->setFrameShadow( QFrame::Sunken );
60 line->setFrameShape( mLayoutHorizontal ? QFrame::VLine : QFrame::HLine );
61 mLayout->addWidget( line );
63 mLayout->addWidget( widget );
65 connect( widget, &QObject::destroyed,
this, &QgsUserInputWidget::widgetDestroyed );
67 mWidgetList.insert( widget, line );
74void QgsUserInputWidget::widgetDestroyed( QObject *obj )
76 if ( obj->isWidgetType() )
78 QWidget *w = qobject_cast<QWidget *>( obj );
79 const auto it = mWidgetList.find( w );
80 if ( it != mWidgetList.end() )
82 if ( QFrame *frame = it.value() )
86 mWidgetList.erase( it );
89 if ( mWidgetList.count() == 0 )
95void QgsUserInputWidget::setLayoutDirection( QBoxLayout::Direction direction )
97 mLayout->setDirection( direction );
99 const bool horizontal = direction == QBoxLayout::LeftToRight || direction == QBoxLayout::RightToLeft;
100 QMap<QWidget *, QFrame *>::const_iterator i = mWidgetList.constBegin();
101 while ( i != mWidgetList.constEnd() )
103 if (
auto *lValue = i.value() )
105 lValue->setFrameShape( horizontal ? QFrame::VLine : QFrame::HLine );
115 if ( mWidgetList.count() == 0 )