Skip to content

Commit

Permalink
mark skins from user-writable location
Browse files Browse the repository at this point in the history
  • Loading branch information
Kolcha committed Aug 29, 2024
1 parent 782d3af commit 81cf4cb
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
10 changes: 10 additions & 0 deletions app/core/skin_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

struct SkinManager::Impl {
QHash<QString, LegacySkinLoader> loaders;
QSet<QString> user_skins;

void reload();
};
Expand All @@ -26,6 +27,7 @@ void SkinManager::Impl::reload()
std::reverse(data_paths.begin(), data_paths.end());

for (const auto& p : std::as_const(data_paths)) {
bool is_user = p == QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
QDir d(p);

if (!d.exists() || !d.cd("skins"))
Expand All @@ -37,6 +39,9 @@ void SkinManager::Impl::reload()
iter->addOverlay(d.absoluteFilePath(sd));
else
loaders.emplace(sd, d.absoluteFilePath(sd));

if (is_user)
user_skins.insert(sd);
}
}

Expand Down Expand Up @@ -81,6 +86,11 @@ SkinManager::Metadata SkinManager::metadata(const QString& id) const
return {};
}

bool SkinManager::isUserSkin(const QString& id) const
{
return _impl->user_skins.contains(id);
}

void SkinManager::setSkinBaseSize(int sz)
{
for (auto& l : _impl->loaders)
Expand Down
2 changes: 2 additions & 0 deletions app/core/skin_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ class SkinManager {
using Metadata = QHash<QString, QString>;
Metadata metadata(const QString& id) const;

bool isUserSkin(const QString& id) const;

// skin base size (affects not all skins)
void setSkinBaseSize(int sz);

Expand Down
8 changes: 8 additions & 0 deletions app/gui/settings_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -811,6 +811,14 @@ void SettingsDialog::initAppearanceTab(int idx)
for (const auto& [t, s] : std::as_const(sorted_skins))
ui->skin_cbox->addItem(t, s);

auto user_fnt = ui->skin_cbox->font();
user_fnt.setItalic(true);
for (int i = 0; i < ui->skin_cbox->count(); i++) {
auto s = ui->skin_cbox->itemData(i).toString();
if (app->skinManager().isUserSkin(s))
ui->skin_cbox->setItemData(i, user_fnt, Qt::FontRole);
}

ui->skin_cbox->setCurrentIndex(-1); // if skin is available, next line will update the index
ui->skin_cbox->setCurrentText(app->skinManager().metadata(acfg.getSkin())["name"]);

Expand Down

0 comments on commit 81cf4cb

Please sign in to comment.