diff --git a/plugins/darkmode/patch.py b/plugins/darkmode/patch.py index ab475cd..18a9269 100644 --- a/plugins/darkmode/patch.py +++ b/plugins/darkmode/patch.py @@ -219,6 +219,22 @@ def patch_settings_cpp(repo_dir): ' return std::string(I18N.get(settings[index].nameId));\n' ' },' ) + else: + for s_decl in [ + ' const auto& s = settings[index];\n', + ' const auto& s = settings[index];\n', + ]: + if s_decl in content and '"darkModeState") return "Dark Mode"' not in content: + content = content.replace( + s_decl, + s_decl + + s_decl[:len(s_decl) - len(s_decl.lstrip())] + + 'if (s.key && std::string(s.key) == "darkModeState") return "Dark Mode";\n' + + s_decl[:len(s_decl) - len(s_decl.lstrip())] + + 'if (s.key && std::string(s.key) == "smallerFontsMode") return "Smaller Fonts";\n', + 1 + ) + break both_present = 'DarkModePlugin::stateName' in content and 'SmallerFontsPlugin::modeName' in content only_dark = 'DarkModePlugin::stateName' in content and 'SmallerFontsPlugin::modeName' not in content diff --git a/plugins/locksreen/patch.py b/plugins/locksreen/patch.py index 75cf93a..0185a99 100644 --- a/plugins/locksreen/patch.py +++ b/plugins/locksreen/patch.py @@ -271,13 +271,18 @@ def patch_settings_cpp(repo_dir): ) changed = True elif '"lockscreenMode") return "Lockscreen"' not in content: - content = content.replace( - ' if (selectedCategoryIndex == 4) {\n' + for s_decl in [ ' const auto& s = settings[index];\n', - ' if (selectedCategoryIndex == 4) {\n' - ' const auto& s = settings[index];\n' - ' if (s.key && std::string(s.key) == "lockscreenMode") return "Lockscreen";\n' - ) + ' const auto& s = settings[index];\n', + ]: + if s_decl in content: + indent = s_decl[:len(s_decl) - len(s_decl.lstrip())] + content = content.replace( + s_decl, + s_decl + indent + 'if (s.key && std::string(s.key) == "lockscreenMode") return "Lockscreen";\n', + 1 + ) + break changed = True if 'LockscreenPlugin::modeName' not in content: