From 796684367f3bff4a7c21474f5736edd906a42441 Mon Sep 17 00:00:00 2001 From: Justin Oros Date: Wed, 22 Apr 2026 18:37:54 -0700 Subject: [PATCH] =?UTF-8?q?darkmode:=20Added=20an=20else=20branch=20that?= =?UTF-8?q?=20finds=20the=20const=20auto&=20s=20declaration=20at=20either?= =?UTF-8?q?=20indent=20level=20and=20inserts=20the=20darkModeState/smaller?= =?UTF-8?q?FontsMode=20checks=20immediately=20after=20it.=20locksreen:=20S?= =?UTF-8?q?ame=20fix=20=E2=80=94=20the=20elif=20branch=20now=20tries=20bot?= =?UTF-8?q?h=20indent=20variants=20instead=20of=20hardcoding=206-space=20i?= =?UTF-8?q?ndent.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- plugins/darkmode/patch.py | 16 ++++++++++++++++ plugins/locksreen/patch.py | 17 +++++++++++------ 2 files changed, 27 insertions(+), 6 deletions(-) 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: