Improve theme editor usability so themes can be set from it

This commit is contained in:
luisangelsm
2026-03-06 15:06:20 +01:00
parent 86b5003f07
commit 0ceba0ea74
3 changed files with 35 additions and 3 deletions

View File

@ -150,14 +150,19 @@ ThemeEditorDialog::ThemeEditorDialog(const QJsonObject &params, QWidget *parent)
});
// --- bottom buttons ---
auto *saveBtn = new QPushButton(tr("Save to file..."), this);
auto *saveLibBtn = new QPushButton(tr("Save and apply"), this);
auto *exportBtn = new QPushButton(tr("Export to file..."), this);
auto *loadBtn = new QPushButton(tr("Load from file..."), this);
auto *closeBtn = new QPushButton(tr("Close"), this);
connect(saveBtn, &QPushButton::clicked, this, &ThemeEditorDialog::saveToFile);
connect(saveLibBtn, &QPushButton::clicked, this, [this]() {
emit saveToLibraryRequested(this->params);
});
connect(exportBtn, &QPushButton::clicked, this, &ThemeEditorDialog::saveToFile);
connect(loadBtn, &QPushButton::clicked, this, &ThemeEditorDialog::loadFromFile);
connect(closeBtn, &QPushButton::clicked, this, &QDialog::close);
auto *buttons = new QHBoxLayout();
buttons->addWidget(saveBtn);
buttons->addWidget(saveLibBtn);
buttons->addWidget(exportBtn);
buttons->addWidget(loadBtn);
buttons->addStretch();
buttons->addWidget(closeBtn);
@ -373,6 +378,14 @@ void ThemeEditorDialog::syncMetaFromParams()
variantCombo->setCurrentIndex(variant == "light" ? 0 : 1);
}
void ThemeEditorDialog::updateSavedId(const QString &id)
{
auto meta = params["meta"].toObject();
meta["id"] = id;
params["meta"] = meta;
idLabel->setText(id);
}
void ThemeEditorDialog::saveToFile()
{
// Assign a user-scoped UUID if the current id is builtin or empty