switchauto component

Signed-off-by: Nicolas Adenis-Lamarre <nicolas.adenis.lamarre@gmail.com>
This commit is contained in:
Nicolas Adenis-Lamarre
2024-09-08 22:57:04 +02:00
parent d7e17cd4ea
commit f1418a44d5
5 changed files with 72 additions and 12 deletions
+16
View File
@@ -2194,6 +2194,22 @@ void GuiMenu::addFeatureItem(Window* window, GuiSettings* settings, const Custom
return;
}
if (feat.preset == "switchauto")
{
auto switchComponent = std::make_shared<SwitchComponent>(window);
switchComponent->setHasAuto(true);
switchComponent->setAutoState(storedValue == "");
switchComponent->setState(storedValue == "1");
if (!feat.description.empty())
settings->addWithDescription(pgettext("game_options", feat.name.c_str()), pgettext("game_options", feat.description.c_str()), switchComponent);
else
settings->addWithLabel(pgettext("game_options", feat.name.c_str()), switchComponent);
settings->addSaveFunc([storageName, switchComponent] { SystemConf::getInstance()->set(storageName, switchComponent->getAutoState() ? "" : (switchComponent->getState() ? "1" : "0")); });
return;
}
if (feat.preset == "switchon" || feat.preset == "switch_default_on")
{
auto switchComponent = std::make_shared<SwitchComponent>(window);
+7 -1
View File
@@ -2460,6 +2460,12 @@ ThemeData::ThemeMenu::ThemeMenu(ThemeData* theme)
mMenuIcons[prop.first] = path;
}
}
// switch auto
std::string language = SystemConf::getInstance()->get("system.language");
std::string auto_lang = ":/auto_" + language + ".svg";
if(ResourceManager::getInstance()->fileExists(auto_lang))
Icons.onoffauto = auto_lang;
}
void ThemeData::setDefaultTheme(ThemeData* theme)
@@ -2682,4 +2688,4 @@ void ThemeData::applySelfTheme(GuiComponent* comp, const ThemeElement& elem)
// Clear storyboard or they'll be deleted as we use a temporary fake theme...
element.first->second.mStoryBoards.clear();
}
}
@@ -127,6 +127,22 @@ void SwitchComponent::setValue(const std::string& statestring)
onStateChanged();
}
bool SwitchComponent::hasAuto() const {
return mHasAuto;
}
void SwitchComponent::setHasAuto(bool hasAuto) {
mHasAuto = hasAuto;
}
bool SwitchComponent::getAutoState() const {
return mAutoState;
}
void SwitchComponent::setAutoState(bool bAuto) {
mAutoState = bAuto;
}
void SwitchComponent::onStateChanged()
{
auto theme = ThemeData::getMenuTheme();
+6 -1
View File
@@ -21,7 +21,12 @@ public:
void setState(bool state);
std::string getValue() const;
void setValue(const std::string& statestring) override;
bool changed();
bool changed();
bool hasAuto() const;
void setHasAuto(bool hasAuto);
bool getAutoState() const;
void setAutoState(bool bAuto);
virtual std::vector<HelpPrompt> getHelpPrompts() override;
+27 -10
View File
@@ -13,6 +13,28 @@
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:dc="http://purl.org/dc/elements/1.1/">
<g
aria-label="AUTO"
transform="scale(0.87568251,1.1419664)"
id="text680"
style="font-size:14.0601px;line-height:1.25;fill:#ffffff;stroke-width:0.081116">
<path
d="M 9.9631698,5.6775182 8.0820822,10.778423 H 11.851123 Z M 9.1805275,4.3113269 H 10.752677 L 14.659023,14.561194 H 13.217314 L 12.283635,11.931791 H 7.6633 L 6.7296215,14.561194 H 5.2673162 Z"
id="path3635"
style="fill:#ffffff" />
<path
d="m 15.997753,4.3113269 h 1.393653 v 6.2268121 q 0,1.647667 0.597279,2.375387 0.59728,0.720855 1.93601,0.720855 1.331865,0 1.929145,-0.720855 0.597279,-0.72772 0.597279,-2.375387 V 4.3113269 h 1.393653 v 6.3984441 q 0,2.004662 -0.995466,3.027589 -0.988601,1.022928 -2.924611,1.022928 -1.942875,0 -2.938341,-1.022928 -0.988601,-1.022927 -0.988601,-3.027589 z"
id="path3637"
style="fill:#ffffff" />
<path
d="m 25.025601,4.3113269 h 8.670852 V 5.478425 h -3.6386 v 9.082769 H 28.664201 V 5.478425 h -3.6386 z"
id="path3639"
style="fill:#ffffff" />
<path
d="m 39.195546,5.2518707 q -1.510362,0 -2.402849,1.1259064 -0.885621,1.1259064 -0.885621,3.0687815 0,1.9360094 0.885621,3.0619164 0.892487,1.125906 2.402849,1.125906 1.510363,0 2.389119,-1.125906 0.885621,-1.125907 0.885621,-3.0619164 0,-1.9428751 -0.885621,-3.0687815 -0.878756,-1.1259064 -2.389119,-1.1259064 z m 0,-1.1259065 q 2.155699,0 3.446372,1.4485748 1.290674,1.4417094 1.290674,3.8720196 0,2.4234444 -1.290674,3.8720194 -1.290673,1.44171 -3.446372,1.44171 -2.162564,0 -3.460102,-1.44171 -1.290674,-1.441709 -1.290674,-3.8720194 0,-2.4303102 1.290674,-3.8720196 1.297538,-1.4485748 3.460102,-1.4485748 z"
id="path3641"
style="fill:#ffffff" />
</g>
<metadata
id="metadata12">
<rdf:RDF>
@@ -39,20 +61,15 @@
inkscape:window-height="1016"
id="namedview8"
showgrid="false"
inkscape:zoom="32.425539"
inkscape:cx="21.603342"
inkscape:cy="13.492451"
inkscape:zoom="11.464159"
inkscape:cx="49.938246"
inkscape:cy="32.579799"
inkscape:window-x="66"
inkscape:window-y="27"
inkscape:window-maximized="1"
inkscape:current-layer="svg6"
inkscape:pagecheckerboard="0" />
<path
inkscape:connector-curvature="0"
d="m 22.433336,3.2447139 c -3.951702,0 -7.16667,3.4606288 -7.16667,7.7142851 0,4.253654 3.214968,7.714288 7.16667,7.714288 3.9517,0 7.166664,-3.460634 7.166664,-7.714288 0,-4.2536563 -3.214964,-7.7142851 -7.166664,-7.7142851 z"
id="path65"
style="fill:#ffffff;stroke-width:0.743544"
sodipodi:nodetypes="sssss" />
inkscape:pagecheckerboard="0"
inkscape:snap-global="false" />
<path
inkscape:connector-curvature="0"
d="M 33.366664,0.159 H 10.433336 C 4.9006664,0.159 0.4,5.0035711 0.4,10.958999 0.4,16.914434 4.9006664,21.759 10.433336,21.759 H 33.366664 C 38.899336,21.759 43.4,16.914434 43.4,10.958999 43.4,5.0035711 38.899336,0.159 33.366664,0.159 Z m 0,20.057147 H 10.433336 c -4.742186,0 -8.6000024,-4.1526 -8.6000024,-9.257148 0,-5.1045428 3.8578164,-9.2571425 8.6000024,-9.2571425 h 22.933328 c 4.742186,0 8.6,4.1525997 8.6,9.2571425 0,5.104548 -3.857814,9.257148 -8.6,9.257148 z"

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 3.7 KiB