From e30cee8ee78f66bf7016039df6f9901066cf62c6 Mon Sep 17 00:00:00 2001 From: Bush2021 <79072750+Bush2021@users.noreply.github.com> Date: Sun, 8 Sep 2024 21:02:15 -0400 Subject: [PATCH] feat!: update INI section names and keys for consistency Some key values are deprecated and may be removed in the future. --- src/chrome++.ini | Bin 9808 -> 9828 bytes src/config.h | 52 ++++++++++++++++++++++++++++++++--------------- 2 files changed, 36 insertions(+), 16 deletions(-) diff --git a/src/chrome++.ini b/src/chrome++.ini index 39b0875db81b89acb63d5fc992dfad92e6b1c02e..51bf0b7026607a0055fd1c4f69cd597c0ef3be24 100644 GIT binary patch delta 247 zcmccM^TcNZADetSLn=ca5En5dGUPDCGVn5RF{A+5B|sd{kTO}DO_etp$WCU+0IC9t zY>sBrWE4zh$Y;m}!bG6v6rga<#xrCCO|P6B z&*?uof-gq21nizXpiBrAc8-+u_ zuE+!ObHFZ0W$>OX$S1z}4PO@{XE4y(e1>v{fX$5p`g|CM9h7Ti#Sjcu5o7`Y=lV5h diff --git a/src/config.h b/src/config.h index 1bcb485..a0d3bdd 100644 --- a/src/config.h +++ b/src/config.h @@ -23,7 +23,12 @@ std::wstring GetIniString(const std::wstring& section, } std::wstring GetCrCommandLine() { - return GetIniString(L"General", L"CommandLine", L""); + auto commandLine = GetIniString(L"general", L"command_line", L""); + if (!commandLine.empty()) { + return commandLine; + } + return GetIniString(L"General", L"CommandLine", L""); // Deprecated + return L""; } std::wstring CanonicalizePath(const std::wstring& path) { @@ -36,10 +41,17 @@ std::wstring GetDirPath(const std::wstring& dirType) { std::wstring path = CanonicalizePath(GetAppDir() + L"\\..\\" + dirType); std::wstring DirBuffer(MAX_PATH, '\0'); - ::GetPrivateProfileStringW(L"General", (dirType + L"Dir").c_str(), + ::GetPrivateProfileStringW(L"general", (dirType + L"_dir").c_str(), path.c_str(), &DirBuffer[0], MAX_PATH, kIniPath.c_str()); + // Deprecated + if (DirBuffer[0] == 0) { + ::GetPrivateProfileStringW(L"general", (dirType + L"dir").c_str(), + path.c_str(), &DirBuffer[0], MAX_PATH, + kIniPath.c_str()); + } + if (DirBuffer[0] == 0) { DirBuffer = path; } @@ -53,24 +65,32 @@ std::wstring GetDirPath(const std::wstring& dirType) { } std::wstring GetUserDataDir() { - return GetDirPath(L"Data"); + return GetDirPath(L"data"); } std::wstring GetDiskCacheDir() { - return GetDirPath(L"Cache"); + return GetDirPath(L"cache"); } std::wstring GetBosskey() { - return GetIniString(L"General", L"Bosskey", L""); + auto key = GetIniString(L"general", L"boss_key", L""); + if (!key.empty()) { + return key; + } + return GetIniString(L"General", L"Bosskey", L""); // Deprecated } std::wstring GetTranslateKey() { - return GetIniString(L"General", L"TranslateKey", L""); + auto key = GetIniString(L"general", L"translate_key", L""); + if (!key.empty()) { + return key; + } + return GetIniString(L"General", L"TranslateKey", L""); // Deprecated } // View password without verification bool IsShowPassword() { - return ::GetPrivateProfileIntW(L"General", L"ShowPassword", 1, + return ::GetPrivateProfileIntW(L"general", L"show_password", 1, kIniPath.c_str()) != 0; } @@ -81,32 +101,32 @@ bool IsWin32K() { } bool IsKeepLastTab() { - return ::GetPrivateProfileIntW(L"Tabs", L"keep_last_tab", 1, + return ::GetPrivateProfileIntW(L"tabs", L"keep_last_tab", 1, kIniPath.c_str()) != 0; } bool IsDoubleClickClose() { - return ::GetPrivateProfileIntW(L"Tabs", L"double_click_close", 1, + return ::GetPrivateProfileIntW(L"tabs", L"double_click_close", 1, kIniPath.c_str()) != 0; } bool IsRightClickClose() { - return ::GetPrivateProfileIntW(L"Tabs", L"right_click_close", 0, + return ::GetPrivateProfileIntW(L"tabs", L"right_click_close", 0, kIniPath.c_str()) != 0; } bool IsWheelTab() { - return ::GetPrivateProfileIntW(L"Tabs", L"wheel_tab", 1, kIniPath.c_str()) != + return ::GetPrivateProfileIntW(L"tabs", L"wheel_tab", 1, kIniPath.c_str()) != 0; } bool IsWheelTabWhenPressRightButton() { - return ::GetPrivateProfileIntW(L"Tabs", L"wheel_tab_when_press_rbutton", 1, + return ::GetPrivateProfileIntW(L"tabs", L"wheel_tab_when_press_rbutton", 1, kIniPath.c_str()) != 0; } std::string IsOpenUrlNewTabFun() { - int value = ::GetPrivateProfileIntW(L"Tabs", L"open_url_new_tab", 0, + int value = ::GetPrivateProfileIntW(L"tabs", L"open_url_new_tab", 0, kIniPath.c_str()); switch (value) { case 1: @@ -119,7 +139,7 @@ std::string IsOpenUrlNewTabFun() { } std::string IsBookmarkNewTab() { - int value = ::GetPrivateProfileIntW(L"Tabs", L"open_bookmark_new_tab", 0, + int value = ::GetPrivateProfileIntW(L"tabs", L"open_bookmark_new_tab", 0, kIniPath.c_str()); switch (value) { case 1: @@ -132,13 +152,13 @@ std::string IsBookmarkNewTab() { } bool IsNewTabDisable() { - return ::GetPrivateProfileIntW(L"Tabs", L"new_tab_disable", 1, + return ::GetPrivateProfileIntW(L"tabs", L"new_tab_disable", 1, kIniPath.c_str()) != 0; } // Customize disabled tab page name std::wstring GetDisableTabName() { - return GetIniString(L"Tabs", L"new_tab_disable_name", L""); + return GetIniString(L"tabs", L"new_tab_disable_name", L""); } #endif // CONFIG_H_ \ No newline at end of file