]> cloud.milkyroute.net Git - dolphin.git/commitdiff
DolphinView: set the parent of layout in the ctor
authorAhmad Samir <a.samirh78@gmail.com>
Thu, 3 Dec 2020 18:06:11 +0000 (20:06 +0200)
committerAhmad Samir <a.samirh78@gmail.com>
Thu, 3 Dec 2020 19:50:04 +0000 (19:50 +0000)
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.

src/search/dolphinsearchbox.cpp
src/settings/general/configurepreviewplugindialog.cpp
src/settings/viewpropertiesdialog.cpp
src/settings/viewpropsprogressinfo.cpp
src/views/dolphinview.cpp

index 16f12b989e7dbf699ccd12319d8350a966ea31d5..9143ddcb770023038ef245b2d61d05836216c7b6 100644 (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);
index d29b63b7dc3d2a902b057e559bcb2100f6bc55a4..4d7ee589aae7248fb1473ff70e4f30ff28ada298 100644 (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();
index c6dbc82b43f42d673e9eadc44dba4eedb1031521..2bf31744000a972f47ddf160e66030d7627e9637 100644 (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);
index 57a00c2b1856ccc293da7b13e77ade855afeb4b0..cd4ff379ca7d3af215578f9249ea95a8fdebf309 100644 (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);
index ef346b3e40f5042fdf0c3a3a3ce25bd26f01527b..71c16bf46de31476f9a4e9a365fdea6a14b326da 100644 (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);