Removed code for restarting the application, fixed system reboot and power off (and changed these names), fixed some small cosmetic issues with log file output and main menu

This commit is contained in:
Leon Styhre 2020-05-15 17:58:25 +02:00
parent ffcf52c710
commit f5d3c8ac0b
6 changed files with 43 additions and 65 deletions

View file

@ -238,7 +238,7 @@ void GuiMenu::openUISettings()
screenmode.push_back("borderless"); screenmode.push_back("borderless");
for(auto it = screenmode.cbegin(); it != screenmode.cend(); it++) for(auto it = screenmode.cbegin(); it != screenmode.cend(); it++)
fullscreen_mode->add(*it, *it, Settings::getInstance()->getString("FullscreenMode") == *it); fullscreen_mode->add(*it, *it, Settings::getInstance()->getString("FullscreenMode") == *it);
s->addWithLabel("FULLSCREEN MODE (RESTART REQUIRED)", fullscreen_mode); s->addWithLabel("FULLSCREEN MODE (REQUIRES RESTART)", fullscreen_mode);
s->addSaveFunc([fullscreen_mode] { s->addSaveFunc([fullscreen_mode] {
if (Settings::getInstance()->getString("FullscreenMode") == "normal" if (Settings::getInstance()->getString("FullscreenMode") == "normal"
&& fullscreen_mode->getSelected() != "normal") && fullscreen_mode->getSelected() != "normal")
@ -390,17 +390,17 @@ void GuiMenu::openUISettings()
s->addWithLabel("DISABLE START MENU IN KID MODE", disable_start); s->addWithLabel("DISABLE START MENU IN KID MODE", disable_start);
s->addSaveFunc([disable_start] { Settings::getInstance()->setBool("DisableKidStartMenu", disable_start->getState()); }); s->addSaveFunc([disable_start] { Settings::getInstance()->setBool("DisableKidStartMenu", disable_start->getState()); });
// hide Restart System option in the Quit menu // hide Reboot System option in the Quit menu
auto show_restartsystem = std::make_shared<SwitchComponent>(mWindow); auto show_rebootsystem = std::make_shared<SwitchComponent>(mWindow);
show_restartsystem->setState(Settings::getInstance()->getBool("ShowRestartSystem")); show_rebootsystem->setState(Settings::getInstance()->getBool("ShowRebootSystem"));
s->addWithLabel("SHOW \"RESTART SYSTEM\" MENU ENTRY", show_restartsystem); s->addWithLabel("SHOW \"REBOOT SYSTEM\" MENU ENTRY", show_rebootsystem);
s->addSaveFunc([show_restartsystem] { Settings::getInstance()->setBool("ShowRestartSystem", show_restartsystem->getState()); }); s->addSaveFunc([show_rebootsystem] { Settings::getInstance()->setBool("ShowRebootSystem", show_rebootsystem->getState()); });
// hide Shutdown System option in the Quit menu // hide Power Off System option in the Quit menu
auto show_shutdownsystem = std::make_shared<SwitchComponent>(mWindow); auto show_poweroffsystem = std::make_shared<SwitchComponent>(mWindow);
show_shutdownsystem->setState(Settings::getInstance()->getBool("ShowShutdownSystem")); show_poweroffsystem->setState(Settings::getInstance()->getBool("ShowPoweroffSystem"));
s->addWithLabel("SHOW \"SHUTDOWN SYSTEM\" MENU ENTRY", show_shutdownsystem); s->addWithLabel("SHOW \"POWER OFF SYSTEM\" MENU ENTRY", show_poweroffsystem);
s->addSaveFunc([show_shutdownsystem] { Settings::getInstance()->setBool("ShowShutdownSystem", show_shutdownsystem->getState()); }); s->addSaveFunc([show_poweroffsystem] { Settings::getInstance()->setBool("ShowPoweroffSystem", show_poweroffsystem->getState()); });
// Show favorites first in gamelists // Show favorites first in gamelists
auto favoritesFirstSwitch = std::make_shared<SwitchComponent>(mWindow); auto favoritesFirstSwitch = std::make_shared<SwitchComponent>(mWindow);
@ -527,23 +527,8 @@ void GuiMenu::openQuitMenu()
ComponentListRow row; ComponentListRow row;
if (UIModeController::getInstance()->isUIModeFull()) if (UIModeController::getInstance()->isUIModeFull())
{ {
row.makeAcceptInputHandler([window] {
window->pushGui(new GuiMsgBox(window, "REALLY RESTART?", "YES",
[] {
Scripting::fireEvent("quit");
if(quitES(QuitMode::RESTART) != 0)
LOG(LogWarning) << "Restart terminated with non-zero result!";
}, "NO", nullptr));
});
row.addElement(std::make_shared<TextComponent>(window, "RESTART EMULATIONSTATION", Font::get(FONT_SIZE_MEDIUM), 0x777777FF), true);
s->addRow(row);
if(Settings::getInstance()->getBool("ShowExit")) if(Settings::getInstance()->getBool("ShowExit"))
{ {
row.elements.clear();
row.makeAcceptInputHandler([window] { row.makeAcceptInputHandler([window] {
window->pushGui(new GuiMsgBox(window, "REALLY QUIT?", "YES", window->pushGui(new GuiMsgBox(window, "REALLY QUIT?", "YES",
[] { [] {
@ -556,35 +541,35 @@ void GuiMenu::openQuitMenu()
} }
} }
if(Settings::getInstance()->getBool("ShowRestartSystem")) if(Settings::getInstance()->getBool("ShowRebootSystem"))
{ {
row.elements.clear(); row.elements.clear();
row.makeAcceptInputHandler([window] { row.makeAcceptInputHandler([window] {
window->pushGui(new GuiMsgBox(window, "REALLY RESTART?", "YES", window->pushGui(new GuiMsgBox(window, "REALLY REBOOT?", "YES",
[] { [] {
Scripting::fireEvent("quit", "reboot"); Scripting::fireEvent("quit", "reboot");
Scripting::fireEvent("reboot"); Scripting::fireEvent("reboot");
if (quitES(QuitMode::REBOOT) != 0) if (quitES(QuitMode::REBOOT) != 0)
LOG(LogWarning) << "Restart terminated with non-zero result!"; LOG(LogWarning) << "Reboot terminated with non-zero result!";
}, "NO", nullptr)); }, "NO", nullptr));
}); });
row.addElement(std::make_shared<TextComponent>(window, "RESTART SYSTEM", Font::get(FONT_SIZE_MEDIUM), 0x777777FF), true); row.addElement(std::make_shared<TextComponent>(window, "REBOOT SYSTEM", Font::get(FONT_SIZE_MEDIUM), 0x777777FF), true);
s->addRow(row); s->addRow(row);
} }
if(Settings::getInstance()->getBool("ShowShutdownSystem")) if(Settings::getInstance()->getBool("ShowPoweroffSystem"))
{ {
row.elements.clear(); row.elements.clear();
row.makeAcceptInputHandler([window] { row.makeAcceptInputHandler([window] {
window->pushGui(new GuiMsgBox(window, "REALLY SHUTDOWN?", "YES", window->pushGui(new GuiMsgBox(window, "REALLY POWER OFF?", "YES",
[] { [] {
Scripting::fireEvent("quit", "shutdown"); Scripting::fireEvent("quit", "poweroff");
Scripting::fireEvent("shutdown"); Scripting::fireEvent("poweroff");
if (quitES(QuitMode::SHUTDOWN) != 0) if (quitES(QuitMode::POWEROFF) != 0)
LOG(LogWarning) << "Shutdown terminated with non-zero result!"; LOG(LogWarning) << "Poweroff terminated with non-zero result!";
}, "NO", nullptr)); }, "NO", nullptr));
}); });
row.addElement(std::make_shared<TextComponent>(window, "SHUTDOWN SYSTEM", Font::get(FONT_SIZE_MEDIUM), 0x777777FF), true); row.addElement(std::make_shared<TextComponent>(window, "POWER OFF SYSTEM", Font::get(FONT_SIZE_MEDIUM), 0x777777FF), true);
s->addRow(row); s->addRow(row);
} }

View file

@ -60,8 +60,8 @@ void Settings::setDefaults()
mBoolMap["ShowHiddenFiles"] = false; mBoolMap["ShowHiddenFiles"] = false;
mBoolMap["DrawFramerate"] = false; mBoolMap["DrawFramerate"] = false;
mBoolMap["ShowExit"] = true; mBoolMap["ShowExit"] = true;
mBoolMap["ShowRestartSystem"] = true; mBoolMap["ShowRebootSystem"] = true;
mBoolMap["ShowShutdownSystem"] = true; mBoolMap["ShowPoweroffSystem"] = true;
mBoolMap["Windowed"] = false; mBoolMap["Windowed"] = false;
mBoolMap["SplashScreen"] = true; mBoolMap["SplashScreen"] = true;
mBoolMap["SplashScreenProgress"] = true; mBoolMap["SplashScreenProgress"] = true;

View file

@ -10,21 +10,21 @@
#include "Log.h" #include "Log.h"
int runShutdownCommand() int runRebootCommand()
{
#ifdef WIN32 // windows
return system("shutdown -s -t 0");
#else // osx / linux
return system("sudo shutdown -h now");
#endif
}
int runRestartCommand()
{ {
#ifdef WIN32 // windows #ifdef WIN32 // windows
return system("shutdown -r -t 0"); return system("shutdown -r -t 0");
#else // osx / linux #else // osx / linux
return system("sudo shutdown -r now"); return system("shutdown --reboot now");
#endif
}
int runPoweroffCommand()
{
#ifdef WIN32 // windows
return system("shutdown -s -t 0");
#else // osx / linux
return system("shutdown --poweroff now");
#endif #endif
} }
@ -71,19 +71,13 @@ void processQuitMode()
{ {
switch (quitMode) switch (quitMode)
{ {
case QuitMode::RESTART:
LOG(LogInfo) << "Restarting EmulationStation";
touch("/tmp/es-restart");
break;
case QuitMode::REBOOT: case QuitMode::REBOOT:
LOG(LogInfo) << "Rebooting system"; LOG(LogInfo) << "Rebooting system";
touch("/tmp/es-sysrestart"); runRebootCommand();
runRestartCommand();
break; break;
case QuitMode::SHUTDOWN: case QuitMode::POWEROFF:
LOG(LogInfo) << "Shutting system down"; LOG(LogInfo) << "Powering off system";
touch("/tmp/es-shutdown"); runPoweroffCommand();
runShutdownCommand();
break; break;
} }
} }

View file

@ -12,9 +12,8 @@
enum QuitMode enum QuitMode
{ {
QUIT = 0, QUIT = 0,
RESTART = 1, REBOOT = 1,
SHUTDOWN = 2, POWEROFF = 2
REBOOT = 3
}; };
int runSystemCommand(const std::string& cmd_utf8); // run a utf-8 encoded in the shell (requires wstring conversion on Windows) int runSystemCommand(const std::string& cmd_utf8); // run a utf-8 encoded in the shell (requires wstring conversion on Windows)

View file

@ -106,7 +106,7 @@ namespace Renderer
LOG(LogInfo) << "GL version: " << version; LOG(LogInfo) << "GL version: " << version;
LOG(LogInfo) << "Checking available OpenGL extensions..."; LOG(LogInfo) << "Checking available OpenGL extensions...";
std::string glExts = glGetString(GL_EXTENSIONS) ? (const char*)glGetString(GL_EXTENSIONS) : ""; std::string glExts = glGetString(GL_EXTENSIONS) ? (const char*)glGetString(GL_EXTENSIONS) : "";
LOG(LogInfo) << " ARB_texture_non_power_of_two: " << (extensions.find("ARB_texture_non_power_of_two") != std::string::npos ? "ok" : "MISSING"); LOG(LogInfo) << "ARB_texture_non_power_of_two: " << (extensions.find("ARB_texture_non_power_of_two") != std::string::npos ? "ok" : "MISSING");
uint8_t data[4] = {255, 255, 255, 255}; uint8_t data[4] = {255, 255, 255, 255};
whiteTexture = createTexture(Texture::RGBA, false, true, 1, 1, data); whiteTexture = createTexture(Texture::RGBA, false, true, 1, 1, data);

View file

@ -106,7 +106,7 @@ namespace Renderer
LOG(LogInfo) << "GL version: " << version; LOG(LogInfo) << "GL version: " << version;
LOG(LogInfo) << "Checking available OpenGL extensions..."; LOG(LogInfo) << "Checking available OpenGL extensions...";
std::string glExts = glGetString(GL_EXTENSIONS) ? (const char*)glGetString(GL_EXTENSIONS) : ""; std::string glExts = glGetString(GL_EXTENSIONS) ? (const char*)glGetString(GL_EXTENSIONS) : "";
LOG(LogInfo) << " ARB_texture_non_power_of_two: " << (extensions.find("ARB_texture_non_power_of_two") != std::string::npos ? "ok" : "MISSING"); LOG(LogInfo) << "ARB_texture_non_power_of_two: " << (extensions.find("ARB_texture_non_power_of_two") != std::string::npos ? "ok" : "MISSING");
uint8_t data[4] = {255, 255, 255, 255}; uint8_t data[4] = {255, 255, 255, 255};
whiteTexture = createTexture(Texture::RGBA, false, true, 1, 1, data); whiteTexture = createTexture(Texture::RGBA, false, true, 1, 1, data);