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

Method loadFromFile

common/themes/theme_editor_dialog.cpp:411–441  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

409}
410
411void ThemeEditorDialog::loadFromFile()
412{
413 const QString path = QFileDialog::getOpenFileName(
414 this, tr("Load theme"), QString(), tr("JSON files (*.json);;All files (*)"));
415 if (path.isEmpty())
416 return;
417
418 QFile file(path);
419 if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
420 QMessageBox::warning(this, tr("Load failed"), tr("Could not open file:\n%1").arg(path));
421 return;
422 }
423
424 QJsonParseError err;
425 const QJsonDocument doc = QJsonDocument::fromJson(file.readAll(), &err);
426 if (doc.isNull()) {
427 QMessageBox::warning(this, tr("Load failed"), tr("Invalid JSON:\n%1").arg(err.errorString()));
428 return;
429 }
430 if (!doc.isObject()) {
431 QMessageBox::warning(this, tr("Load failed"), tr("Expected a JSON object."));
432 return;
433 }
434
435 params = normalizeThemeJson(doc.object());
436 syncMetaFromParams();
437 tree->clear();
438 populate(nullptr, params, { });
439 tree->expandAll();
440 emit themeJsonChanged(params);
441}
442
443void ThemeEditorDialog::identifyPressed()
444{

Callers

nothing calls this directly

Calls 6

normalizeThemeJsonFunction · 0.85
isEmptyMethod · 0.80
errorStringMethod · 0.80
QStringClass · 0.50
openMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected