| 274 | } |
| 275 | |
| 276 | void 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 | |
| 310 | void AppearanceTabWidget::deleteTheme(QComboBox *combo, QPushButton *deleteBtn) |
| 311 | { |
nothing calls this directly
no test coverage detected