| 54 | } |
| 55 | |
| 56 | ThemeEditorDialog::ThemeEditorDialog(const QJsonObject ¶ms, QWidget *parent) |
| 57 | : QDialog(parent), params(normalizeThemeJson(params)) |
| 58 | { |
| 59 | setWindowTitle(tr("Theme Editor")); |
| 60 | resize(520, 700); |
| 61 | |
| 62 | // --- top toolbar --- |
| 63 | auto *expandBtn = new QPushButton(tr("+"), this); |
| 64 | auto *collapseBtn = new QPushButton(tr("-"), this); |
| 65 | auto *identifyBtn = new QPushButton(tr("i"), this); |
| 66 | expandBtn->setFixedWidth(28); |
| 67 | collapseBtn->setFixedWidth(28); |
| 68 | identifyBtn->setFixedWidth(28); |
| 69 | expandBtn->setToolTip(tr("Expand all")); |
| 70 | collapseBtn->setToolTip(tr("Collapse all")); |
| 71 | identifyBtn->setToolTip(tr("Hold to flash the selected value in the UI (magenta / toggled / 0↔10). Releases restore the original.")); |
| 72 | // NoFocus so clicking the button doesn't steal the tree's current item |
| 73 | identifyBtn->setFocusPolicy(Qt::NoFocus); |
| 74 | |
| 75 | searchEdit = new QLineEdit(this); |
| 76 | searchEdit->setPlaceholderText(tr("Search…")); |
| 77 | searchEdit->setClearButtonEnabled(true); |
| 78 | |
| 79 | auto *toolbar = new QHBoxLayout(); |
| 80 | toolbar->addWidget(expandBtn); |
| 81 | toolbar->addWidget(collapseBtn); |
| 82 | toolbar->addWidget(identifyBtn); |
| 83 | toolbar->addStretch(); |
| 84 | toolbar->addWidget(searchEdit); |
| 85 | |
| 86 | connect(identifyBtn, &QPushButton::pressed, this, &ThemeEditorDialog::identifyPressed); |
| 87 | connect(identifyBtn, &QPushButton::released, this, &ThemeEditorDialog::identifyReleased); |
| 88 | |
| 89 | // --- meta section --- |
| 90 | idLabel = new QLabel(this); |
| 91 | idLabel->setTextInteractionFlags(Qt::TextSelectableByMouse); |
| 92 | nameEdit = new QLineEdit(this); |
| 93 | variantCombo = new QComboBox(this); |
| 94 | variantCombo->addItem(tr("Light"), "light"); |
| 95 | variantCombo->addItem(tr("Dark"), "dark"); |
| 96 | |
| 97 | auto *metaForm = new QFormLayout(); |
| 98 | metaForm->addRow(tr("ID:"), idLabel); |
| 99 | metaForm->addRow(tr("Display name:"), nameEdit); |
| 100 | metaForm->addRow(tr("Variant:"), variantCombo); |
| 101 | |
| 102 | auto *metaBox = new QGroupBox(tr("Theme info"), this); |
| 103 | metaBox->setLayout(metaForm); |
| 104 | |
| 105 | syncMetaFromParams(); |
| 106 | |
| 107 | connect(nameEdit, &QLineEdit::textEdited, this, [this](const QString &text) { |
| 108 | auto meta = this->params["meta"].toObject(); |
| 109 | meta["displayName"] = text; |
| 110 | this->params["meta"] = meta; |
| 111 | }); |
| 112 | connect(nameEdit, &QLineEdit::editingFinished, this, [this]() { |
| 113 | emit themeJsonChanged(this->params); |
nothing calls this directly
no test coverage detected