Added support for marking themes as deprecated in the theme downloader

This commit is contained in:
Leon Styhre 2024-04-16 21:05:04 +02:00
parent 47baa3629a
commit 278ba90c14
2 changed files with 29 additions and 5 deletions

View file

@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT
//
// ES-DE
// ES-DE Frontend
// GuiThemeDownloader.cpp
//
// Theme downloader.
@ -663,6 +663,9 @@ void GuiThemeDownloader::parseThemesList()
if (theme.HasMember("newEntry") && theme["newEntry"].IsBool())
themeEntry.newEntry = theme["newEntry"].GetBool();
if (theme.HasMember("deprecated") && theme["deprecated"].IsBool())
themeEntry.deprecated = theme["deprecated"].GetBool();
if (theme.HasMember("variants") && theme["variants"].IsArray()) {
const rapidjson::Value& variants {theme["variants"]};
for (int i {0}; i < static_cast<int>(variants.Size()); ++i)
@ -746,6 +749,11 @@ void GuiThemeDownloader::populateGUI()
std::shared_ptr<TextComponent> themeNameElement {std::make_shared<TextComponent>(
themeName, Font::get(FONT_SIZE_MEDIUM), mMenuColorPrimary)};
if (theme.deprecated)
themeNameElement->setOpacity(0.4f);
else
themeNameElement->setOpacity(1.0f);
ThemeGUIEntry guiEntry;
guiEntry.themeName = themeNameElement;
mThemeGUIEntries.emplace_back(guiEntry);
@ -907,11 +915,21 @@ void GuiThemeDownloader::updateGUI()
void GuiThemeDownloader::updateInfoPane()
{
assert(static_cast<size_t>(mList->size()) == mThemes.size());
if (!mThemes[mList->getCursorId()].screenshots.empty())
if (!mThemes[mList->getCursorId()].screenshots.empty()) {
mScreenshot->setImage(mThemeDirectory + "themes-list/" +
mThemes[mList->getCursorId()].screenshots.front().image);
else
if (mThemes[mList->getCursorId()].deprecated) {
mScreenshot->setSaturation(0.0f);
mScreenshot->setBrightness(-0.2f);
}
else {
mScreenshot->setSaturation(1.0f);
mScreenshot->setBrightness(0.0f);
}
}
else {
mScreenshot->setImage("");
}
if (mThemes[mList->getCursorId()].isCloned) {
mDownloadStatus->setText(ViewController::TICKMARK_CHAR + " INSTALLED");
@ -954,7 +972,11 @@ void GuiThemeDownloader::updateInfoPane()
mColorSchemesCount->setText(std::to_string(mThemes[mList->getCursorId()].colorSchemes.size()));
mAspectRatiosCount->setText(std::to_string(mThemes[mList->getCursorId()].aspectRatios.size()));
mFontSizesCount->setText(std::to_string(mThemes[mList->getCursorId()].fontSizes.size()));
mAuthor->setText("CREATED BY " + Utils::String::toUpper(mThemes[mList->getCursorId()].author));
if (mThemes[mList->getCursorId()].deprecated)
mAuthor->setText("THIS THEME ENTRY WILL BE REMOVED IN THE NEAR FUTURE");
else
mAuthor->setText("CREATED BY " +
Utils::String::toUpper(mThemes[mList->getCursorId()].author));
}
void GuiThemeDownloader::setupFullscreenViewer()

View file

@ -1,6 +1,6 @@
// SPDX-License-Identifier: MIT
//
// ES-DE
// ES-DE Frontend
// GuiThemeDownloader.h
//
// Theme downloader.
@ -68,6 +68,7 @@ private:
std::vector<std::string> transitions;
std::vector<Screenshot> screenshots;
bool newEntry;
bool deprecated;
bool invalidRepository;
bool corruptRepository;
bool shallowRepository;
@ -76,6 +77,7 @@ private:
bool isCloned;
ThemeEntry()
: newEntry {false}
, deprecated {false}
, invalidRepository {false}
, corruptRepository {false}
, shallowRepository {false}