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(); return file->getName() != "kodi" && file->getSystem()->isGameSystem();
} }
std::string getCustomCollectionConfigPath(std::string collectionName) std::string getCustomCollectionConfigPath(std::string collectionName)
{ {
return getCollectionsFolder() + "/custom-" + collectionName + ".cfg"; return getCollectionsFolder() + "/custom-" + collectionName + ".cfg";

View file

@ -348,11 +348,14 @@ void CollectionFileData::refreshMetadata()
const std::string& CollectionFileData::getName() const std::string& CollectionFileData::getName()
{ {
if (mDirty) { if (mDirty) {
mCollectionFileName = Utils::String::removeParenthesis(mSourceFileData->metadata.get("name")); mCollectionFileName = Utils::String::removeParenthesis(mSourceFileData->metadata.get("name"));
mCollectionFileName += " [" + Utils::String::toUpper(mSourceFileData->getSystem()->getName()) + "]"; mCollectionFileName += " [" + Utils::String::toUpper(mSourceFileData->getSystem()->getName()) + "]";
mDirty = false; mDirty = false;
} }
return mCollectionFileName;
if (Settings::getInstance()->getBool("CollectionShowSystemInfo"))
return mCollectionFileName;
return mSourceFileData->metadata.get("name");
} }
// returns Sort Type based on a string description // returns Sort Type based on a string description

View file

@ -75,6 +75,10 @@ void GuiCollectionSystemsOptions::initializeMenu()
sortAllSystemsSwitch->setState(Settings::getInstance()->getBool("SortAllSystems")); sortAllSystemsSwitch->setState(Settings::getInstance()->getBool("SortAllSystems"));
mMenu.addWithLabel("SORT CUSTOM COLLECTIONS AND SYSTEMS", sortAllSystemsSwitch); 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()) if(CollectionSystemManager::get()->isEditing())
{ {
row.elements.clear(); row.elements.clear();
@ -170,11 +174,14 @@ void GuiCollectionSystemsOptions::applySettings()
bool prevSort = Settings::getInstance()->getBool("SortAllSystems"); bool prevSort = Settings::getInstance()->getBool("SortAllSystems");
bool outBundle = bundleCustomCollections->getState(); bool outBundle = bundleCustomCollections->getState();
bool prevBundle = Settings::getInstance()->getBool("UseCustomCollectionsSystem"); 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) if (needUpdateSettings)
{ {
updateSettings(outAuto, outCustom); updateSettings(outAuto, outCustom);
} }
delete this; delete this;
} }
@ -184,6 +191,7 @@ void GuiCollectionSystemsOptions::updateSettings(std::string newAutoSettings, st
Settings::getInstance()->setString("CollectionSystemsCustom", newCustomSettings); Settings::getInstance()->setString("CollectionSystemsCustom", newCustomSettings);
Settings::getInstance()->setBool("SortAllSystems", sortAllSystemsSwitch->getState()); Settings::getInstance()->setBool("SortAllSystems", sortAllSystemsSwitch->getState());
Settings::getInstance()->setBool("UseCustomCollectionsSystem", bundleCustomCollections->getState()); Settings::getInstance()->setBool("UseCustomCollectionsSystem", bundleCustomCollections->getState());
Settings::getInstance()->setBool("CollectionShowSystemInfo", toggleSystemNameInCollections->getState());
Settings::getInstance()->saveFile(); Settings::getInstance()->saveFile();
CollectionSystemManager::get()->loadEnabledListFromSettings(); CollectionSystemManager::get()->loadEnabledListFromSettings();
CollectionSystemManager::get()->updateSystemsList(); CollectionSystemManager::get()->updateSystemsList();

View file

@ -30,6 +30,7 @@ private:
std::shared_ptr< OptionListComponent<std::string> > customOptionList; std::shared_ptr< OptionListComponent<std::string> > customOptionList;
std::shared_ptr<SwitchComponent> sortAllSystemsSwitch; std::shared_ptr<SwitchComponent> sortAllSystemsSwitch;
std::shared_ptr<SwitchComponent> bundleCustomCollections; std::shared_ptr<SwitchComponent> bundleCustomCollections;
std::shared_ptr<SwitchComponent> toggleSystemNameInCollections;
MenuComponent mMenu; MenuComponent mMenu;
SystemData* mSystem; SystemData* mSystem;
}; };

View file

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