Fix: toggle privacy wallpaper menu item to clear instead of re-picking when already set
This commit is contained in:
@@ -10488,41 +10488,50 @@ void CMy2015RemoteDlg::OnParamEnableLog()
|
||||
|
||||
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,
|
||||
OFN_FILEMUSTEXIST | OFN_HIDEREADONLY,
|
||||
_T("BMP Files (*.bmp)|*.bmp|All Files (*.*)|*.*||"), this);
|
||||
|
||||
if (dlg.DoModal() == IDOK) {
|
||||
CString path = dlg.GetPathName();
|
||||
if (dlg.DoModal() != IDOK)
|
||||
return;
|
||||
|
||||
// 验证文件是否可以读取
|
||||
CFile file;
|
||||
if (!file.Open(path, CFile::modeRead | CFile::typeBinary)) {
|
||||
MessageBox(_TR("无法读取指定的BMP文件,请检查文件是否存在或权限是否正确。"),
|
||||
_TR("错误"), MB_ICONERROR);
|
||||
return;
|
||||
}
|
||||
CString path = dlg.GetPathName();
|
||||
|
||||
// 验证是否是有效的BMP文件
|
||||
BITMAPFILEHEADER bmfh;
|
||||
if (file.Read(&bmfh, sizeof(bmfh)) != sizeof(bmfh) || bmfh.bfType != 0x4D42) {
|
||||
file.Close();
|
||||
MessageBox(_TR("指定的文件不是有效的BMP格式。"),
|
||||
_TR("错误"), MB_ICONERROR);
|
||||
return;
|
||||
}
|
||||
file.Close();
|
||||
|
||||
m_PrivateScreenWallpaper = path;
|
||||
THIS_CFG.SetStr("settings", "Wallpaper", path.GetString());
|
||||
auto SubMenu = m_MainMenu.GetSubMenu(2); // 工具菜单
|
||||
if (SubMenu) {
|
||||
SubMenu->CheckMenuItem(ID_PARAM_PRIVACY_WALLPAPER, MF_CHECKED);
|
||||
}
|
||||
CString msg;
|
||||
msg.Format(_TR("隐私屏幕壁纸已设置为:\n%s"), path);
|
||||
MessageBox(msg + CString("\n") + _L("如需恢复默认值,请从磁盘移除该文件。"), _TR("设置成功"), MB_ICONINFORMATION);
|
||||
CFile file;
|
||||
if (!file.Open(path, CFile::modeRead | CFile::typeBinary)) {
|
||||
MessageBox(_TR("无法读取指定的BMP文件,请检查文件是否存在或权限是否正确。"),
|
||||
_TR("错误"), MB_ICONERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
BITMAPFILEHEADER bmfh;
|
||||
if (file.Read(&bmfh, sizeof(bmfh)) != sizeof(bmfh) || bmfh.bfType != 0x4D42) {
|
||||
file.Close();
|
||||
MessageBox(_TR("指定的文件不是有效的BMP格式。"),
|
||||
_TR("错误"), MB_ICONERROR);
|
||||
return;
|
||||
}
|
||||
file.Close();
|
||||
|
||||
m_PrivateScreenWallpaper = path;
|
||||
THIS_CFG.SetStr("settings", "Wallpaper", path.GetString());
|
||||
if (SubMenu)
|
||||
SubMenu->CheckMenuItem(ID_PARAM_PRIVACY_WALLPAPER, MF_CHECKED);
|
||||
CString msg;
|
||||
msg.Format(_TR("隐私屏幕壁纸已设置为:\n%s"), path);
|
||||
MessageBox(msg, _TR("设置成功"), MB_ICONINFORMATION);
|
||||
}
|
||||
|
||||
void CMy2015RemoteDlg::OnParamFileV2()
|
||||
|
||||
Reference in New Issue
Block a user