Merge pull request #571 from cmitu/collections-label-for-system-options

Collections: make the display of system's name configurable.
This commit is contained in:
John Rassa 2019-07-13 08:44:12 -04:00 committed by GitHub
commit 13819ec0d9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 22 additions and 10 deletions

View file

@ -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";

View file

@ -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

View file

@ -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();
@ -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;
}
@ -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();

View file

@ -30,6 +30,7 @@ private:
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;
};

View file

@ -134,6 +134,7 @@ void Settings::setDefaults()
mStringMap["OMXAudioDev"] = "both";
mStringMap["CollectionSystemsAuto"] = "";
mStringMap["CollectionSystemsCustom"] = "";
mBoolMap["CollectionShowSystemInfo"] = true;
mBoolMap["SortAllSystems"] = false;
mBoolMap["UseCustomCollectionsSystem"] = true;