Skip to content

Commit

Permalink
Merge pull request #571 from cmitu/collections-label-for-system-options
Browse files Browse the repository at this point in the history
Collections: make the display of system's name configurable.
  • Loading branch information
jrassa authored Jul 13, 2019
2 parents 6defa8e + c84290e commit 13819ec
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 10 deletions.
1 change: 0 additions & 1 deletion es-app/src/CollectionSystemManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1032,7 +1032,6 @@ bool CollectionSystemManager::includeFileInAutoCollections(FileData* file)
return file->getName() != "kodi" && file->getSystem()->isGameSystem();
}


std::string getCustomCollectionConfigPath(std::string collectionName)
{
return getCollectionsFolder() + "/custom-" + collectionName + ".cfg";
Expand Down
19 changes: 11 additions & 8 deletions es-app/src/FileData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,14 +345,17 @@ void CollectionFileData::refreshMetadata()
mDirty = true;
}

const std::string& CollectionFileData::getName()
{
if (mDirty) {
mCollectionFileName = Utils::String::removeParenthesis(mSourceFileData->metadata.get("name"));
mCollectionFileName += " [" + Utils::String::toUpper(mSourceFileData->getSystem()->getName()) + "]";
mDirty = false;
}
return mCollectionFileName;
const std::string& CollectionFileData::getName()
{
if (mDirty) {
mCollectionFileName = Utils::String::removeParenthesis(mSourceFileData->metadata.get("name"));
mCollectionFileName += " [" + Utils::String::toUpper(mSourceFileData->getSystem()->getName()) + "]";
mDirty = false;
}

if (Settings::getInstance()->getBool("CollectionShowSystemInfo"))
return mCollectionFileName;
return mSourceFileData->metadata.get("name");
}

// returns Sort Type based on a string description
Expand Down
10 changes: 9 additions & 1 deletion es-app/src/guis/GuiCollectionSystemsOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,10 @@ void GuiCollectionSystemsOptions::initializeMenu()
sortAllSystemsSwitch->setState(Settings::getInstance()->getBool("SortAllSystems"));
mMenu.addWithLabel("SORT CUSTOM COLLECTIONS AND SYSTEMS", sortAllSystemsSwitch);

toggleSystemNameInCollections = std::make_shared<SwitchComponent>(mWindow);
toggleSystemNameInCollections->setState(Settings::getInstance()->getBool("CollectionShowSystemInfo"));
mMenu.addWithLabel("SHOW SYSTEM NAME IN COLLECTIONS", toggleSystemNameInCollections);

if(CollectionSystemManager::get()->isEditing())
{
row.elements.clear();
Expand Down Expand Up @@ -170,11 +174,14 @@ void GuiCollectionSystemsOptions::applySettings()
bool prevSort = Settings::getInstance()->getBool("SortAllSystems");
bool outBundle = bundleCustomCollections->getState();
bool prevBundle = Settings::getInstance()->getBool("UseCustomCollectionsSystem");
bool needUpdateSettings = prevAuto != outAuto || prevCustom != outCustom || outSort != prevSort || outBundle != prevBundle;
bool prevShow = Settings::getInstance()->getBool("CollectionShowSystemInfo");
bool outShow = toggleSystemNameInCollections->getState();
bool needUpdateSettings = prevAuto != outAuto || prevCustom != outCustom || outSort != prevSort || outBundle != prevBundle || prevShow != outShow ;
if (needUpdateSettings)
{
updateSettings(outAuto, outCustom);
}

delete this;
}

Expand All @@ -184,6 +191,7 @@ void GuiCollectionSystemsOptions::updateSettings(std::string newAutoSettings, st
Settings::getInstance()->setString("CollectionSystemsCustom", newCustomSettings);
Settings::getInstance()->setBool("SortAllSystems", sortAllSystemsSwitch->getState());
Settings::getInstance()->setBool("UseCustomCollectionsSystem", bundleCustomCollections->getState());
Settings::getInstance()->setBool("CollectionShowSystemInfo", toggleSystemNameInCollections->getState());
Settings::getInstance()->saveFile();
CollectionSystemManager::get()->loadEnabledListFromSettings();
CollectionSystemManager::get()->updateSystemsList();
Expand Down
1 change: 1 addition & 0 deletions es-app/src/guis/GuiCollectionSystemsOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class GuiCollectionSystemsOptions : public GuiComponent
std::shared_ptr< OptionListComponent<std::string> > customOptionList;
std::shared_ptr<SwitchComponent> sortAllSystemsSwitch;
std::shared_ptr<SwitchComponent> bundleCustomCollections;
std::shared_ptr<SwitchComponent> toggleSystemNameInCollections;
MenuComponent mMenu;
SystemData* mSystem;
};
Expand Down
1 change: 1 addition & 0 deletions es-core/src/Settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ void Settings::setDefaults()
mStringMap["OMXAudioDev"] = "both";
mStringMap["CollectionSystemsAuto"] = "";
mStringMap["CollectionSystemsCustom"] = "";
mBoolMap["CollectionShowSystemInfo"] = true;
mBoolMap["SortAllSystems"] = false;
mBoolMap["UseCustomCollectionsSystem"] = true;

Expand Down

0 comments on commit 13819ec

Please sign in to comment.