| 384 | } |
| 385 | |
| 386 | void ThemeEditorDialog::saveToFile() |
| 387 | { |
| 388 | // Assign a user-scoped UUID if the current id is builtin or empty |
| 389 | auto meta = params["meta"].toObject(); |
| 390 | const QString currentId = meta["id"].toString(); |
| 391 | if (currentId.isEmpty() || currentId.startsWith("builtin/")) { |
| 392 | const QString newId = "user/" + QUuid::createUuid().toString(QUuid::WithoutBraces); |
| 393 | meta["id"] = newId; |
| 394 | params["meta"] = meta; |
| 395 | idLabel->setText(newId); |
| 396 | } |
| 397 | |
| 398 | const QString path = QFileDialog::getSaveFileName( |
| 399 | this, tr("Save theme"), QString(), tr("JSON files (*.json);;All files (*)")); |
| 400 | if (path.isEmpty()) |
| 401 | return; |
| 402 | |
| 403 | QFile file(path); |
| 404 | if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) { |
| 405 | QMessageBox::warning(this, tr("Save failed"), tr("Could not open file for writing:\n%1").arg(path)); |
| 406 | return; |
| 407 | } |
| 408 | file.write(serializeNormalizedThemeJson(params)); |
| 409 | } |
| 410 | |
| 411 | void ThemeEditorDialog::loadFromFile() |
| 412 | { |