diff --git a/GUI/View/Instrument/DetectorEditor.cpp b/GUI/View/Instrument/DetectorEditor.cpp index 7b6bcc9ce1eb67a5f607c9d6b4cedf73486eafe9..da28ba18dd55f266a4fc3dabde76365ab0f29e55 100644 --- a/GUI/View/Instrument/DetectorEditor.cpp +++ b/GUI/View/Instrument/DetectorEditor.cpp @@ -23,6 +23,48 @@ #include "GUI/View/Numeric/SafeSpinBox.h" #include <QFormLayout> +#include "GUI/Support/Style/ApplicationSettings.h" +#include <QToolButton> + +void installGroup(QGroupBox* groupBox) +{ + auto* m_toggleButton = new QToolButton(groupBox); + m_toggleButton->setObjectName("GroupBoxToggler"); + if (appSettings->currentStyle() == ApplicationSettings::Style::native) + m_toggleButton->setStyleSheet( + "QToolButton { border: none; text-align: left; font: bold; padding: 5px}"); + m_toggleButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon); + m_toggleButton->setCheckable(true); + m_toggleButton->setText(groupBox->title()); + m_toggleButton->setArrowType(Qt::ArrowType::DownArrow); + m_toggleButton->setChecked(true); + m_toggleButton->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::MinimumExpanding); + + auto* m_titleLayout = new QHBoxLayout; + m_titleLayout->setContentsMargins(0, 0, 3, 0); + m_titleLayout->setSpacing(3); + m_titleLayout->setAlignment(Qt::AlignVCenter); + m_titleLayout->addWidget(m_toggleButton); + + auto* m_titleWidget = new QWidget(groupBox); + m_titleWidget->setObjectName("GroupBoxTitleWidget"); + m_titleWidget->setAttribute(Qt::WA_StyledBackground, true); + m_titleWidget->setLayout(m_titleLayout); + + auto* m_contentArea = new QWidget(groupBox); + m_contentArea->setObjectName("ContentArea"); + m_contentArea->setLayout(groupBox->layout()); + + auto* mainLayout = new QVBoxLayout; + mainLayout->setSpacing(0); + mainLayout->setContentsMargins(0, 0, 0, 0); + mainLayout->setMenuBar(m_titleWidget); + mainLayout->addWidget(m_contentArea); + + groupBox->setTitle(""); // title has been read above + groupBox->setLayout(mainLayout); // overwrites layout that has been read above +} + DetectorEditor::DetectorEditor(QWidget* parent, GISASInstrumentItem* instrItem) : QGroupBox("Detector parameters", parent) { @@ -67,10 +109,7 @@ DetectorEditor::DetectorEditor(QWidget* parent, GISASInstrumentItem* instrItem) emit dataChanged(); }); grid->addWidget(xAxisGroupBox, 1, 0); - auto* collapserX = GroupBoxCollapser::installIntoGroupBox(xAxisGroupBox); - collapserX->setExpanded(detectorItem->isExpandXaxis()); - connect(collapserX, &GroupBoxCollapser::toggled, this, - [detectorItem](bool b) { detectorItem->setExpandXaxis(b); }); + installGroup(xAxisGroupBox); // -- y-axis controls