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

Method importTheme

common/themes/appearance_tab_widget.cpp:276–308  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

274}
275
276void AppearanceTabWidget::importTheme()
277{
278 const QString path = QFileDialog::getOpenFileName(
279 this, tr("Import theme"), QString(), tr("JSON files (*.json);;All files (*)"));
280 if (path.isEmpty() || !repository)
281 return;
282
283 QString errorMessage;
284 const QString id = repository->importThemeFromFile(path, &errorMessage);
285 if (id.isEmpty()) {
286 const QString detail = errorMessage.isEmpty()
287 ? tr("Could not import theme from:\n%1").arg(path)
288 : tr("Could not import theme from:\n%1\n\n%2").arg(path, errorMessage);
289 QMessageBox::warning(this, tr("Import failed"), detail);
290 return;
291 }
292
293 // Detect variant of the imported theme to auto-select it in the right combo
294 const QJsonObject json = repository->loadThemeJson(id);
295 const bool isLight = (json["meta"].toObject()["variant"].toString() == "light");
296
297 repopulateCombos();
298
299 // Select in the appropriate combo → triggers currentIndexChanged → config update
300 if (isLight)
301 selectInCombo(lightCombo, id);
302 else
303 selectInCombo(darkCombo, id);
304
305 // If in Custom mode, also select in customCombo
306 if (config && config->selection().mode == ThemeMode::ForcedTheme)
307 selectInCombo(customCombo, id);
308}
309
310void AppearanceTabWidget::deleteTheme(QComboBox *combo, QPushButton *deleteBtn)
311{

Callers

nothing calls this directly

Calls 7

selectInComboFunction · 0.85
isEmptyMethod · 0.80
importThemeFromFileMethod · 0.80
loadThemeJsonMethod · 0.80
toStringMethod · 0.80
selectionMethod · 0.80
QStringClass · 0.50

Tested by

no test coverage detected