Files
Jungfraujoch/viewer/widgets/NumericComboBox.cpp
T
Filip LeonarskiandClaude Opus 5.5 0be8eb2bca Viewer: dark theme, switchable live from the View menu
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>
2026-09-26 17:51:50 +02:00

51 lines
1.3 KiB
C++

// SPDX-FileCopyrightText: 2025 Filip Leonarski, Paul Scherrer Institute <filip.leonarski@psi.ch>
// SPDX-License-Identifier: GPL-3.0-only
#include "NumericComboBox.h"
NumericComboBox::NumericComboBox(std::vector<int> options, int min, int max, QWidget *parent) {
setEditable(true);
for (const auto &i: options)
addItem(QString::number(i));
validator = new QIntValidator(this);
validator->setBottom(min);
validator->setTop(max);
setValidator(validator);
setCurrentText(QString::number(min));
connect(this, QOverload<int>::of(&QComboBox::currentIndexChanged),
this, &NumericComboBox::onCurrentIndexChanged);
connect(this, &QComboBox::editTextChanged,
this, &NumericComboBox::onEditTextChanged);
}
int NumericComboBox::getValue() const {
return currentText().toInt();
}
void NumericComboBox::setValue(int value) {
setCurrentText(QString::number(value));
}
void NumericComboBox::onCurrentIndexChanged(int index) {
if (index >= 0) {
setStyleSheet("");
emit valueChanged(getValue());
}
}
void NumericComboBox::onEditTextChanged(const QString &text) {
bool ok;
int value = text.toInt(&ok);
if (ok) {
setStyleSheet("");
emit valueChanged(value);
} else {
setStyleSheet("background-color: rgb(125, 0, 0);");
}
}