diff --git a/app/core/skin_manager.cpp b/app/core/skin_manager.cpp index c4f7605..a0d2744 100644 --- a/app/core/skin_manager.cpp +++ b/app/core/skin_manager.cpp @@ -19,6 +19,8 @@ struct SkinManager::Impl { QSet user_skins; void reload(); + + const LegacySkinLoader* find(const QString& id) const; }; void SkinManager::Impl::reload() @@ -56,6 +58,17 @@ void SkinManager::Impl::reload() loaders.remove(id); } +const LegacySkinLoader* SkinManager::Impl::find(const QString& id) const +{ + if (auto iter = loaders.find(id); iter != loaders.end()) + return &iter.value(); + // search skin by name as fallback + for (auto iter = loaders.begin(); iter != loaders.end(); ++iter) + if (iter->title() == id) + return &iter.value(); + return nullptr; +} + SkinManager::SkinManager() : _impl(std::make_unique()) { @@ -71,12 +84,8 @@ std::unique_ptr SkinManager::loadSkin(const QFont& font) const std::unique_ptr SkinManager::loadSkin(const QString& id) const { - if (auto iter = _impl->loaders.find(id); iter != _impl->loaders.end()) + if (auto iter = _impl->find(id)) return iter->skin(); - // search skin by name as fallback - for (auto iter = _impl->loaders.begin(); iter != _impl->loaders.end(); ++iter) - if (iter->title() == id) - return iter->skin(); return std::make_unique(); } @@ -87,7 +96,7 @@ QStringList SkinManager::availableSkins() const SkinManager::Metadata SkinManager::metadata(const QString& id) const { - if (auto iter = _impl->loaders.find(id); iter != _impl->loaders.end()) + if (auto iter = _impl->find(id)) return iter->metadata(); return {}; } diff --git a/app/gui/settings_dialog.cpp b/app/gui/settings_dialog.cpp index e594788..7835eea 100644 --- a/app/gui/settings_dialog.cpp +++ b/app/gui/settings_dialog.cpp @@ -134,7 +134,7 @@ void SettingsDialog::on_import_btn_clicked() void SettingsDialog::on_export_btn_clicked() { auto filename = QFileDialog::getSaveFileName(this, tr("Export settings"), - QDir::home().filePath("digital_clock_5.dc5"), + QDir::home().filePath("clock_settings.dc5"), tr("Digital Clock 5 Settings (*.dc5)")); if (filename.isEmpty()) return; QVariantHash settings;