Skip to content

Commit

Permalink
chore: translate and remove some comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Bush2021 committed Sep 8, 2024
1 parent 7008f30 commit 404baaf
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 37 deletions.
20 changes: 3 additions & 17 deletions src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

const std::wstring kIniPath = GetAppDir() + L"\\chrome++.ini";

// 读取 ini 文件
bool IsIniExist() {
if (PathFileExists(kIniPath.data())) {
return true;
Expand All @@ -20,7 +19,6 @@ std::wstring GetIniString(const std::wstring& section,
bytesread = ::GetPrivateProfileStringW(
section.c_str(), key.c_str(), default_value.c_str(), buffer.data(),
(DWORD)buffer.size(), kIniPath.c_str());
// 如果字符串过长,则倍增缓冲区大小
if (bytesread >= buffer.size() - 1) {
buffer.resize(buffer.size() * 2);
} else {
Expand All @@ -31,12 +29,10 @@ std::wstring GetIniString(const std::wstring& section,
return std::wstring(buffer.data());
}

// 追加参数
std::wstring GetCrCommandLine() {
return IsIniExist() ? GetIniString(L"General", L"CommandLine", L"") : L"";
}

// 读取 UserData 和 DiskCache
std::wstring CanonicalizePath(const std::wstring& path) {
TCHAR temp[MAX_PATH];
::PathCanonicalize(temp, path.data());
Expand Down Expand Up @@ -75,61 +71,53 @@ std::wstring GetDiskCacheDir() {
return GetDirPath(L"Cache");
}

// 老板键
std::wstring GetBosskey() {
return IsIniExist() ? GetIniString(L"General", L"Bosskey", L"")
: std::wstring(L"");
}

// 定义翻译快捷键
std::wstring GetTranslateKey() {
return IsIniExist() ? GetIniString(L"General", L"TranslateKey", L"")
: std::wstring(L"");
}

// 无需验证直接查看密码
// View password without verification
bool IsShowPassword() {
return ::GetPrivateProfileIntW(L"General", L"ShowPassword", 1,
kIniPath.c_str()) != 0;
}

// 强制启用 win32k
// Force enable win32k
bool IsWin32K() {
return ::GetPrivateProfileIntW(L"general", L"win32k", 0, kIniPath.c_str()) !=
0;
}

// 保留最后一个标签
bool IsKeepLastTab() {
return ::GetPrivateProfileIntW(L"Tabs", L"keep_last_tab", 1,
kIniPath.c_str()) != 0;
}

// 双击关闭
bool IsDoubleClickClose() {
return ::GetPrivateProfileIntW(L"Tabs", L"double_click_close", 1,
kIniPath.c_str()) != 0;
}

// 单击右键关闭
bool IsRightClickClose() {
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()) !=
0;
}

// 在任何位置按住右键时滚轮切换标签
bool IsWheelTabWhenPressRightButton() {
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,
kIniPath.c_str());
Expand All @@ -143,7 +131,6 @@ std::string IsOpenUrlNewTabFun() {
}
}

// 书签在新标签页打开
std::string IsBookmarkNewTab() {
int value = ::GetPrivateProfileIntW(L"Tabs", L"open_bookmark_new_tab", 0,
kIniPath.c_str());
Expand All @@ -157,13 +144,12 @@ std::string IsBookmarkNewTab() {
}
}

// 新标签页不生效
bool IsNewTabDisable() {
return ::GetPrivateProfileIntW(L"Tabs", L"new_tab_disable", 1,
kIniPath.c_str()) != 0;
}

// 自定义禁用标签页名称
// Customize disabled tab page name
std::wstring GetDisableTabName() {
return IsIniExist() ? GetIniString(L"Tabs", L"new_tab_disable_name", L"")
: L"";
Expand Down
40 changes: 20 additions & 20 deletions src/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -268,24 +268,24 @@ std::wstring ExpandEnvironmentPath(const std::wstring& path) {

// Debug log function.
void DebugLog(const wchar_t* format, ...) {
// va_list args;
//
// va_start(args, format);
// auto str = Format(format, args);
// va_end(args);
//
// str = Format(L"[chrome++] %s\n", str.c_str());
//
// std::string nstr = wstring_to_string(str);
// const char* cstr = nstr.c_str();
//
// FILE* fp = nullptr;
// std::wstring logPath = GetAppDir() + L"\\Chrome++_Debug.log";
// _wfopen_s(&fp, logPath.c_str(), L"a+");
// if (fp) {
// fwrite(cstr, strlen(cstr), 1, fp);
// fclose(fp);
// }
va_list args;

va_start(args, format);
auto str = Format(format, args);
va_end(args);

str = Format(L"[chrome++] %s\n", str.c_str());

std::string nstr = wstring_to_string(str);
const char* cstr = nstr.c_str();

FILE* fp = nullptr;
std::wstring logPath = GetAppDir() + L"\\Chrome++_Debug.log";
_wfopen_s(&fp, logPath.c_str(), L"a+");
if (fp) {
fwrite(cstr, strlen(cstr), 1, fp);
fclose(fp);
}
}

// Window and message processing functions.
Expand Down Expand Up @@ -366,7 +366,7 @@ void SendKey(T&&... keys) {
inputs.reserve(keys_.size() * 2);
for (auto& key : keys_) {
INPUT input = {0};
// 修正鼠标消息
// Adjust mouse messages
switch (key) {
case VK_RBUTTON:
input.type = INPUT_MOUSE;
Expand Down Expand Up @@ -398,7 +398,7 @@ void SendKey(T&&... keys) {
}
for (auto& key : keys_) {
INPUT input = {0};
// 修正鼠标消息
// Adjust mouse messages
switch (key) {
case VK_RBUTTON:
input.type = INPUT_MOUSE;
Expand Down

0 comments on commit 404baaf

Please sign in to comment.