mirror of
https://github.com/NohamR/Reclass.git
synced 2026-05-10 19:59:21 +00:00
fix: type chooser updates colors when theme changes
Add applyTheme() to TypeSelectorPopup that refreshes palette and stylesheets for all child widgets. Controller connects it to ThemeManager::themeChanged on popup creation.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
#include "controller.h"
|
||||
#include "typeselectorpopup.h"
|
||||
#include "providerregistry.h"
|
||||
#include "themes/thememanager.h"
|
||||
#include <Qsci/qsciscintilla.h>
|
||||
#include <QSplitter>
|
||||
#include <QFile>
|
||||
@@ -1726,6 +1727,9 @@ void RcxController::updateCommandRow() {
|
||||
TypeSelectorPopup* RcxController::ensurePopup(RcxEditor* editor) {
|
||||
if (!m_cachedPopup) {
|
||||
m_cachedPopup = new TypeSelectorPopup(editor);
|
||||
// Keep popup colors in sync when theme changes
|
||||
connect(&ThemeManager::instance(), &ThemeManager::themeChanged,
|
||||
m_cachedPopup, &TypeSelectorPopup::applyTheme);
|
||||
// Pre-warm: force native window creation so first visible show is fast
|
||||
m_cachedPopup->warmUp();
|
||||
}
|
||||
|
||||
@@ -279,14 +279,14 @@ TypeSelectorPopup::TypeSelectorPopup(QWidget* parent)
|
||||
|
||||
// Separator
|
||||
{
|
||||
auto* sep = new QFrame;
|
||||
sep->setFrameShape(QFrame::HLine);
|
||||
sep->setFrameShadow(QFrame::Plain);
|
||||
m_separator = new QFrame;
|
||||
m_separator->setFrameShape(QFrame::HLine);
|
||||
m_separator->setFrameShadow(QFrame::Plain);
|
||||
QPalette sepPal = pal;
|
||||
sepPal.setColor(QPalette::WindowText, theme.border);
|
||||
sep->setPalette(sepPal);
|
||||
sep->setFixedHeight(1);
|
||||
layout->addWidget(sep);
|
||||
m_separator->setPalette(sepPal);
|
||||
m_separator->setFixedHeight(1);
|
||||
layout->addWidget(m_separator);
|
||||
}
|
||||
|
||||
// Row 3: Modifier toggles [ plain ] [ * ] [ ** ] [ [n] ]
|
||||
@@ -456,6 +456,60 @@ void TypeSelectorPopup::setFont(const QFont& font) {
|
||||
delegate->setFont(font);
|
||||
}
|
||||
|
||||
void TypeSelectorPopup::applyTheme(const Theme& theme) {
|
||||
QPalette pal;
|
||||
pal.setColor(QPalette::Window, theme.backgroundAlt);
|
||||
pal.setColor(QPalette::WindowText, theme.text);
|
||||
pal.setColor(QPalette::Base, theme.background);
|
||||
pal.setColor(QPalette::AlternateBase, theme.surface);
|
||||
pal.setColor(QPalette::Text, theme.text);
|
||||
pal.setColor(QPalette::Button, theme.button);
|
||||
pal.setColor(QPalette::ButtonText, theme.text);
|
||||
pal.setColor(QPalette::Highlight, theme.hover);
|
||||
pal.setColor(QPalette::HighlightedText, theme.text);
|
||||
setPalette(pal);
|
||||
|
||||
m_titleLabel->setPalette(pal);
|
||||
m_filterEdit->setPalette(pal);
|
||||
m_listView->setPalette(pal);
|
||||
m_previewLabel->setPalette(pal);
|
||||
m_arrayCountEdit->setPalette(pal);
|
||||
|
||||
// Separator
|
||||
QPalette sepPal = pal;
|
||||
sepPal.setColor(QPalette::WindowText, theme.border);
|
||||
m_separator->setPalette(sepPal);
|
||||
|
||||
// Esc button
|
||||
m_escLabel->setStyleSheet(QStringLiteral(
|
||||
"QToolButton { color: %1; border: none; padding: 2px 6px; }"
|
||||
"QToolButton:hover { color: %2; }")
|
||||
.arg(theme.textDim.name(), theme.indHoverSpan.name()));
|
||||
|
||||
// Create button
|
||||
m_createBtn->setStyleSheet(QStringLiteral(
|
||||
"QToolButton { color: %1; border: none; padding: 3px 6px; }"
|
||||
"QToolButton:hover { color: %2; background: %3; }")
|
||||
.arg(theme.textMuted.name(), theme.text.name(), theme.hover.name()));
|
||||
|
||||
// Modifier toggle buttons
|
||||
QString btnStyle = QStringLiteral(
|
||||
"QToolButton { color: %1; background: %2; border: 1px solid %3;"
|
||||
" padding: 2px 8px; border-radius: 3px; }"
|
||||
"QToolButton:checked { color: %4; background: %5; border-color: %5; }"
|
||||
"QToolButton:hover:!checked { background: %6; }")
|
||||
.arg(theme.textDim.name(), theme.background.name(), theme.border.name(),
|
||||
theme.text.name(), theme.selected.name(), theme.hover.name());
|
||||
m_btnPlain->setStyleSheet(btnStyle);
|
||||
m_btnPtr->setStyleSheet(btnStyle);
|
||||
m_btnDblPtr->setStyleSheet(btnStyle);
|
||||
m_btnArray->setStyleSheet(btnStyle);
|
||||
|
||||
// Preview label
|
||||
m_previewLabel->setStyleSheet(QStringLiteral(
|
||||
"QLabel { color: %1; padding: 1px 6px; }").arg(theme.syntaxType.name()));
|
||||
}
|
||||
|
||||
void TypeSelectorPopup::setTitle(const QString& title) {
|
||||
m_titleLabel->setText(title);
|
||||
}
|
||||
|
||||
@@ -16,6 +16,8 @@ class QWidget;
|
||||
|
||||
namespace rcx {
|
||||
|
||||
struct Theme;
|
||||
|
||||
// ── Popup mode ──
|
||||
|
||||
enum class TypePopupMode { Root, FieldType, ArrayElement, PointerTarget };
|
||||
@@ -53,6 +55,7 @@ public:
|
||||
void setFont(const QFont& font);
|
||||
void setTitle(const QString& title);
|
||||
void setMode(TypePopupMode mode);
|
||||
void applyTheme(const Theme& theme);
|
||||
void setCurrentNodeSize(int bytes);
|
||||
void setTypes(const QVector<TypeEntry>& types, const TypeEntry* current = nullptr);
|
||||
void popup(const QPoint& globalPos);
|
||||
@@ -77,6 +80,7 @@ private:
|
||||
QLabel* m_previewLabel = nullptr;
|
||||
QListView* m_listView = nullptr;
|
||||
QStringListModel* m_model = nullptr;
|
||||
QFrame* m_separator = nullptr;
|
||||
|
||||
// Modifier toggles
|
||||
QWidget* m_modRow = nullptr;
|
||||
|
||||
Reference in New Issue
Block a user