From 8aee089200ec98dcaae68bb0349bf0a9e1377b3b Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (o)" <j.wuttke@fz-juelich.de> Date: Tue, 31 Oct 2023 09:12:02 +0100 Subject: [PATCH] SampleEditor inherit frm QScrollArea --- GUI/View/SampleDesigner/SampleEditor.cpp | 20 +++++++------------- GUI/View/SampleDesigner/SampleEditor.h | 5 ++--- 2 files changed, 9 insertions(+), 16 deletions(-) diff --git a/GUI/View/SampleDesigner/SampleEditor.cpp b/GUI/View/SampleDesigner/SampleEditor.cpp index fe6a5095f3e..5dd15b5b13d 100644 --- a/GUI/View/SampleDesigner/SampleEditor.cpp +++ b/GUI/View/SampleDesigner/SampleEditor.cpp @@ -24,22 +24,16 @@ #include <QActionGroup> #include <QBoxLayout> #include <QPushButton> -#include <QScrollArea> SampleEditor::SampleEditor(QWidget* parent, ProjectDocument* document) - : QWidget(parent) + : QScrollArea(parent) , m_currentSampleWidget(nullptr) , m_currentSample(nullptr) , m_document(document) { - m_scrollArea = new QScrollArea(this); - m_scrollArea->setWidgetResizable(true); - m_scrollArea->setWidget(createEmptyWidget()); - - auto* mainLayout = new QVBoxLayout(this); - mainLayout->setContentsMargins(0, 0, 0, 0); - mainLayout->setSpacing(0); - mainLayout->addWidget(m_scrollArea); + QScrollArea::setWidgetResizable(true); + QScrollArea::setWidget(createEmptyWidget()); + } SampleEditor::~SampleEditor() @@ -53,11 +47,11 @@ void SampleEditor::setCurrentSample(SampleItem* sampleItem) m_editControllers[m_currentSample]->setSampleForm(nullptr); m_currentSampleWidget = nullptr; - delete m_scrollArea->takeWidget(); + delete QScrollArea::takeWidget(); m_currentSample = sampleItem; if (m_currentSample == nullptr) { - m_scrollArea->setWidget(createEmptyWidget()); + QScrollArea::setWidget(createEmptyWidget()); return; } @@ -75,7 +69,7 @@ void SampleEditor::setCurrentSample(SampleItem* sampleItem) m_currentSampleWidget = new SampleForm(this, m_currentSample, ec); ec->setSampleForm(m_currentSampleWidget); m_currentSampleWidget->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); - m_scrollArea->setWidget(m_currentSampleWidget); + QScrollArea::setWidget(m_currentSampleWidget); } void SampleEditor::createLayerColors() // #baLayerEditor move to better place diff --git a/GUI/View/SampleDesigner/SampleEditor.h b/GUI/View/SampleDesigner/SampleEditor.h index dd36fe469f1..467ec9de1f9 100644 --- a/GUI/View/SampleDesigner/SampleEditor.h +++ b/GUI/View/SampleDesigner/SampleEditor.h @@ -16,7 +16,7 @@ #define BORNAGAIN_GUI_VIEW_SAMPLEDESIGNER_SAMPLEEDITOR_H #include <QMap> -#include <QWidget> +#include <QScrollArea> class Item3D; class SampleForm; @@ -26,7 +26,7 @@ class QScrollArea; class SampleEditorController; //! Sample editor with layer oriented presentation of a sample -class SampleEditor : public QWidget { +class SampleEditor : public QScrollArea { Q_OBJECT public: SampleEditor(QWidget* parent, ProjectDocument* document); @@ -47,7 +47,6 @@ private: QWidget* createEmptyWidget(); SampleForm* m_currentSampleWidget; - QScrollArea* m_scrollArea; SampleItem* m_currentSample = nullptr; QMap<SampleItem*, SampleEditorController*> m_editControllers; ProjectDocument* m_document; -- GitLab