DolphinView: set the parent of layout in the ctor

This silences a runtime warning:
QLayout: Attempting to add QLayout "" to DolphinView "", which already
has a layout

Remove redudant setLayout() calls, passing a parent widget to the
Q*BoxLayout ctor sets that layout as the top-level layout for that widget.
This commit is contained in:
Ahmad Samir 2020-12-03 20:06:11 +02:00
parent 1344641775
commit 1d64b9bb10
5 changed files with 8 additions and 15 deletions

View file

@ -416,8 +416,12 @@ void DolphinSearchBox::init()
m_facetsWidget->layout()->setSpacing(Dolphin::LAYOUT_SPACING_SMALL);
connect(m_facetsWidget, &DolphinFacetsWidget::facetChanged, this, &DolphinSearchBox::slotFacetChanged);
// Put the options into a QScrollArea. This prevents increasing the view width
// in case that not enough width for the options is available.
QWidget* optionsContainer = new QWidget(this);
// Apply layout for the options
QHBoxLayout* optionsLayout = new QHBoxLayout();
QHBoxLayout* optionsLayout = new QHBoxLayout(optionsContainer);
optionsLayout->setContentsMargins(0, 0, 0, 0);
optionsLayout->setSpacing(Dolphin::LAYOUT_SPACING_SMALL);
optionsLayout->addWidget(m_fileNameButton);
@ -429,11 +433,6 @@ void DolphinSearchBox::init()
optionsLayout->addWidget(moreSearchToolsButton);
optionsLayout->addStretch(1);
// Put the options into a QScrollArea. This prevents increasing the view width
// in case that not enough width for the options is available.
QWidget* optionsContainer = new QWidget(this);
optionsContainer->setLayout(optionsLayout);
m_optionsScrollArea = new QScrollArea(this);
m_optionsScrollArea->setFrameShape(QFrame::NoFrame);
m_optionsScrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);

View file

@ -38,7 +38,6 @@ ConfigurePreviewPluginDialog::ConfigurePreviewPluginDialog(const QString& plugin
setMinimumWidth(400);
auto layout = new QVBoxLayout(this);
setLayout(layout);
if (previewPlugin) {
auto configurationWidget = previewPlugin->createConfigurationWidget();

View file

@ -64,7 +64,6 @@ ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) :
auto layout = new QFormLayout(this);
// Otherwise the dialog won't resize when we collapse the KCollapsibleGroupBox.
layout->setSizeConstraint(QLayout::SetFixedSize);
setLayout(layout);
// create 'Properties' group containing view mode, sorting, sort order and show hidden files
m_viewMode = new QComboBox();
@ -89,7 +88,7 @@ ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) :
auto additionalInfoBox = new KCollapsibleGroupBox();
additionalInfoBox->setTitle(i18nc("@title:group", "Additional Information"));
auto innerLayout = new QVBoxLayout();
auto innerLayout = new QVBoxLayout(additionalInfoBox);
{
QList<QByteArray> visibleRoles = m_viewProps->visibleRoles();
@ -133,8 +132,6 @@ ViewPropertiesDialog::ViewPropertiesDialog(DolphinView* dolphinView) :
innerLayout->addWidget(m_listWidget);
}
additionalInfoBox->setLayout(innerLayout);
QHBoxLayout* sortingLayout = new QHBoxLayout();
sortingLayout->setContentsMargins(0, 0, 0, 0);
sortingLayout->addWidget(m_sortOrder);

View file

@ -44,7 +44,6 @@ ViewPropsProgressInfo::ViewPropsProgressInfo(QWidget* parent,
m_viewProps->setAutoSaveEnabled(false);
auto layout = new QVBoxLayout(this);
setLayout(layout);
m_label = new QLabel(i18nc("@info:progress", "Counting folders: %1", 0), this);
layout->addWidget(m_label);

View file

@ -140,9 +140,8 @@ DolphinView::DolphinView(const QUrl& url, QWidget* parent) :
m_placeholderLabel->setGraphicsEffect(effect);
// Set initial text and visibility
updatePlaceholderLabel();
// Add a new layout to hold it and put it in the layout
auto *centeringLayout = new QVBoxLayout(this);
m_container->setLayout(centeringLayout);
auto *centeringLayout = new QVBoxLayout(m_container);
centeringLayout->addWidget(m_placeholderLabel);
centeringLayout->setAlignment(m_placeholderLabel, Qt::AlignCenter);