From d39ead74cd5b422a34db60b11f06c103f1150220 Mon Sep 17 00:00:00 2001 From: "Joachim Wuttke (h)" <j.wuttke@fz-juelich.de> Date: Thu, 26 Oct 2023 15:04:57 +0200 Subject: [PATCH] GUI Instr Det X now using local copy of GrpBoxCollapser; cannot be collapsed --- GUI/View/Instrument/DetectorEditor.cpp | 47 +++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 4 deletions(-) diff --git a/GUI/View/Instrument/DetectorEditor.cpp b/GUI/View/Instrument/DetectorEditor.cpp index 7b6bcc9ce1e..da28ba18dd5 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 -- GitLab