View > Theme offers Follow system / Light / Dark, stored in the settings. Follow system uses the desktop's colour scheme where Qt reports it (6.5+) and is light otherwise. The dark theme is a deep indigo (#1A1D3A panels, #12142B entry fields and charts). The palettes live in the new ViewerTheme module. A switch applies at once: the application stylesheet is set again after the palette so every widget is re-polished (with a stylesheet active, polished widgets otherwise keep their old palette); widgets that bake colours into stylesheets use SetThemedStyleSheet, which re-applies them on ThemeNotifier::changed; toolbar icons draw their glyph at paint time through an icon engine, so the ink follows the theme (and stays sharp at any size); charts re-theme and rebuild. Hard-coded white backgrounds on entry fields and tables are removed in favour of the palette's base colour. The idle detector-status badge in the status bar is now transparent instead of an empty default-styled progress bar. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
48 lines
1.6 KiB
C++
48 lines
1.6 KiB
C++
// SPDX-FileCopyrightText: 2026 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
|
|
|
#include "CollapsibleSection.h"
|
|
#include "../ViewerTheme.h"
|
|
|
|
#include <QToolButton>
|
|
#include <QVBoxLayout>
|
|
|
|
CollapsibleSection::CollapsibleSection(const QString &title, QWidget *parent) : QWidget(parent) {
|
|
auto *v = new QVBoxLayout(this);
|
|
v->setContentsMargins(0, 0, 0, 0);
|
|
v->setSpacing(0);
|
|
|
|
header_ = new QToolButton(this);
|
|
header_->setText(title);
|
|
header_->setCheckable(true);
|
|
header_->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
|
|
header_->setArrowType(Qt::RightArrow);
|
|
header_->setCursor(Qt::PointingHandCursor);
|
|
header_->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
|
|
SetThemedStyleSheet(header_, [] {
|
|
return QString("QToolButton { color:%1; font-weight:bold; text-align:left;"
|
|
" padding:3px 6px 3px 6px; border:none;"
|
|
" border-left:3px solid #FA7268; border-bottom:1px solid #FA7268; background:transparent; }")
|
|
.arg(AccentTextColor().name());
|
|
});
|
|
|
|
content_ = new QWidget(this);
|
|
content_->setVisible(false);
|
|
|
|
v->addWidget(header_);
|
|
v->addWidget(content_);
|
|
|
|
connect(header_, &QToolButton::toggled, this, [this](bool on) {
|
|
content_->setVisible(on);
|
|
header_->setArrowType(on ? Qt::DownArrow : Qt::RightArrow);
|
|
});
|
|
}
|
|
|
|
void CollapsibleSection::setContentLayout(QLayout *layout) {
|
|
content_->setLayout(layout);
|
|
}
|
|
|
|
void CollapsibleSection::setExpanded(bool on) {
|
|
header_->setChecked(on);
|
|
}
|