Fix: toggle privacy wallpaper menu item to clear instead of re-picking when already set

This commit is contained in:
yuanyuanxiang
2026-07-03 20:57:54 +02:00
parent 6d0b1bb07b
commit 8e170cf971

View File

@@ -10488,14 +10488,27 @@ void CMy2015RemoteDlg::OnParamEnableLog()
void CMy2015RemoteDlg::OnParamPrivacyWallpaper() void CMy2015RemoteDlg::OnParamPrivacyWallpaper()
{ {
auto SubMenu = m_MainMenu.GetSubMenu(2);
// 已设置壁纸:再次点击则清空
if (!m_PrivateScreenWallpaper.IsEmpty()) {
m_PrivateScreenWallpaper.Empty();
THIS_CFG.SetStr("settings", "Wallpaper", "");
if (SubMenu)
SubMenu->CheckMenuItem(ID_PARAM_PRIVACY_WALLPAPER, MF_UNCHECKED);
return;
}
// 未设置壁纸:弹出文件对话框
CFileDialog dlg(TRUE, _T("bmp"), NULL, CFileDialog dlg(TRUE, _T("bmp"), NULL,
OFN_FILEMUSTEXIST | OFN_HIDEREADONLY, OFN_FILEMUSTEXIST | OFN_HIDEREADONLY,
_T("BMP Files (*.bmp)|*.bmp|All Files (*.*)|*.*||"), this); _T("BMP Files (*.bmp)|*.bmp|All Files (*.*)|*.*||"), this);
if (dlg.DoModal() == IDOK) { if (dlg.DoModal() != IDOK)
return;
CString path = dlg.GetPathName(); CString path = dlg.GetPathName();
// 验证文件是否可以读取
CFile file; CFile file;
if (!file.Open(path, CFile::modeRead | CFile::typeBinary)) { if (!file.Open(path, CFile::modeRead | CFile::typeBinary)) {
MessageBox(_TR("无法读取指定的BMP文件请检查文件是否存在或权限是否正确。"), MessageBox(_TR("无法读取指定的BMP文件请检查文件是否存在或权限是否正确。"),
@@ -10503,7 +10516,6 @@ void CMy2015RemoteDlg::OnParamPrivacyWallpaper()
return; return;
} }
// 验证是否是有效的BMP文件
BITMAPFILEHEADER bmfh; BITMAPFILEHEADER bmfh;
if (file.Read(&bmfh, sizeof(bmfh)) != sizeof(bmfh) || bmfh.bfType != 0x4D42) { if (file.Read(&bmfh, sizeof(bmfh)) != sizeof(bmfh) || bmfh.bfType != 0x4D42) {
file.Close(); file.Close();
@@ -10515,14 +10527,11 @@ void CMy2015RemoteDlg::OnParamPrivacyWallpaper()
m_PrivateScreenWallpaper = path; m_PrivateScreenWallpaper = path;
THIS_CFG.SetStr("settings", "Wallpaper", path.GetString()); THIS_CFG.SetStr("settings", "Wallpaper", path.GetString());
auto SubMenu = m_MainMenu.GetSubMenu(2); // 工具菜单 if (SubMenu)
if (SubMenu) {
SubMenu->CheckMenuItem(ID_PARAM_PRIVACY_WALLPAPER, MF_CHECKED); SubMenu->CheckMenuItem(ID_PARAM_PRIVACY_WALLPAPER, MF_CHECKED);
}
CString msg; CString msg;
msg.Format(_TR("隐私屏幕壁纸已设置为:\n%s"), path); msg.Format(_TR("隐私屏幕壁纸已设置为:\n%s"), path);
MessageBox(msg + CString("\n") + _L("如需恢复默认值,请从磁盘移除该文件。"), _TR("设置成功"), MB_ICONINFORMATION); MessageBox(msg, _TR("设置成功"), MB_ICONINFORMATION);
}
} }
void CMy2015RemoteDlg::OnParamFileV2() void CMy2015RemoteDlg::OnParamFileV2()