Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

draft add config options to hide applications and games #41

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/gmenu2x.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -927,6 +927,7 @@ void GMenu2X::readConfig() {
string conf = exe_path() + "/gmenu2x.conf";
// Defaults *** Sync with default values in writeConfig
confInt["saveSelection"] = 1;
//confStr["HideSections"] = "";
confInt["dialogAutoStart"] = 1;
confInt["showHints"] = 1;
confStr["datetime"] = xstr(__BUILDTIME__);
Expand All @@ -950,6 +951,9 @@ void GMenu2X::readConfig() {
confInt["cpuLink"] = CPU_LINK;
confInt["cpuStep"] = CPU_STEP;

confInt["hideSectionApplications"] = 0;
confInt["hideSectionGames"] = 0;

// input.update(false);

// if (!input[SETTINGS] && file_exists(conf)) {
Expand Down Expand Up @@ -988,6 +992,9 @@ void GMenu2X::readConfig() {
confInt["section"] = 0;
confInt["link"] = 0;
}

hideSectionApplications = confInt["hideSectionApplications"] != 0;
hideSectionGames = confInt["hideSectionGames"] != 0;
}

void GMenu2X::writeConfig() {
Expand Down
2 changes: 2 additions & 0 deletions src/gmenu2x.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ class GMenu2X {
Menu *menu;
bool f200 = true; //gp2x type // touchscreen
string currBackdrop;
bool hideSectionApplications = false;
bool hideSectionGames = false;

~GMenu2X();
void quit();
Expand Down
15 changes: 15 additions & 0 deletions src/menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,21 @@ void Menu::readSections() {
addSection("settings");
addSection("applications");

/* To keep things simple, we will always create the applications section */
if (gmenu2x->hideSectionApplications)
{
auto itr = std::find(sections.begin(), sections.end(), "applications");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we are within std namespace, so I think no need for std::

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So I don't want to go into a theological discussion about using namespace std;. It has been my personal style to never omit std::. Of course I have to adjust my personal coding style to the coding style of the project I contribute to. So I will of course remove std:: there.

if (itr != sections.end())
sections.erase(itr);
}

if (gmenu2x->hideSectionGames)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see now that section Apps\Settings is always created if nonexistent, so maybe we could add simply a setting to hide them if requested (still I see no reason to hide Games). On a second look we could check if it's prefixed with dot (.) and then hide - would be useful in the long run

{
auto itr = std::find(sections.begin(), sections.end(), "games");
if (itr != sections.end())
sections.erase(itr);
}

closedir(dirp);
sort(sections.begin(),sections.end(), case_less());
}
Expand Down