MCPcopy Create free account
hub / github.com/YACReader/yacreader / saveToFile

Method saveToFile

common/themes/theme_editor_dialog.cpp:386–409  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

384}
385
386void 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
411void ThemeEditorDialog::loadFromFile()
412{

Callers

nothing calls this directly

Calls 7

toStringMethod · 0.80
isEmptyMethod · 0.80
writeMethod · 0.80
QStringClass · 0.50
setTextMethod · 0.45
openMethod · 0.45

Tested by

no test coverage detected