Skip to content

Commit

Permalink
选项设置中关闭硬件监控时,关闭并禁用任务栏中对应的显示项;硬件监控功能默认关闭
Browse files Browse the repository at this point in the history
  • Loading branch information
zhongyang219 committed May 29, 2021
1 parent 8bd3084 commit 34fae52
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 1 deletion.
18 changes: 18 additions & 0 deletions TrafficMonitor/GeneralSettingsDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ void CGeneralSettingsDlg::SetControlEnable()
m_gpu_temp_tip_edit.EnableWindow(m_data.gpu_temp_tip.enable);
m_hdd_temp_tip_edit.EnableWindow(m_data.hdd_temp_tip.enable);
m_mbd_temp_tip_edit.EnableWindow(m_data.mainboard_temp_tip.enable);

m_hard_disk_combo.EnableWindow(m_data.IsHardwareEnable(HI_HDD));
m_select_cpu_combo.EnableWindow(m_data.IsHardwareEnable(HI_CPU));
}


Expand Down Expand Up @@ -319,6 +322,21 @@ void CGeneralSettingsDlg::OnOK()

m_data.monitor_time_span = m_monitor_span_edit.GetValue();

//如果选项设置中关闭了某个硬件监控,则不显示对应的温度监控相关项目
int taskbar_displat_item_ori = theApp.m_cfg_data.m_tbar_display_item;
if (!m_data.IsHardwareEnable(HI_CPU))
theApp.m_cfg_data.m_tbar_display_item &= ~TDI_CPU_TEMP;
if (!m_data.IsHardwareEnable(HI_GPU))
{
theApp.m_cfg_data.m_tbar_display_item &= ~TDI_GPU_USAGE;
theApp.m_cfg_data.m_tbar_display_item &= ~TDI_GPU_TEMP;
}
if (!m_data.IsHardwareEnable(HI_HDD))
theApp.m_cfg_data.m_tbar_display_item &= ~TDI_HDD_TEMP;
if (!m_data.IsHardwareEnable(HI_MBD))
theApp.m_cfg_data.m_tbar_display_item &= ~TDI_MAIN_BOARD_TEMP;
m_taskbar_item_modified = (theApp.m_cfg_data.m_tbar_display_item != taskbar_displat_item_ori);

CTabDlg::OnOK();
}

Expand Down
2 changes: 2 additions & 0 deletions TrafficMonitor/GeneralSettingsDlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@ class CGeneralSettingsDlg : public CTabDlg
bool IsAutoRunModified() const { return m_auto_run_modified; }
bool IsShowAllInterfaceModified() const { return m_show_all_interface_modified; }
bool IsMonitorTimeSpanModified() const;
bool IsTaskbarItemModified() const { return m_taskbar_item_modified; }

protected:
bool m_auto_run_modified{ false }; //如果更改了开机自动运行的设置,则会置为true
bool m_show_all_interface_modified{ false };
int m_monitor_time_span_ori{};
int m_update_source_ori{};
bool m_taskbar_item_modified{ false };

//控件变量
CSpinEdit m_traffic_tip_edit;
Expand Down
7 changes: 7 additions & 0 deletions TrafficMonitor/TaskBarDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -958,6 +958,13 @@ void CTaskBarDlg::OnInitMenu(CMenu* pMenu)
pMenu->EnableMenuItem(ID_SHOW_GPU_TEMPERATURE, MF_BYCOMMAND | MF_GRAYED);
pMenu->EnableMenuItem(ID_SHOW_HDD_TEMPERATURE, MF_BYCOMMAND | MF_GRAYED);
pMenu->EnableMenuItem(ID_SHOW_MAIN_BOARD_TEMPERATURE, MF_BYCOMMAND | MF_GRAYED);
#else
//根据是否关闭硬件监控禁用对应的菜单项
pMenu->EnableMenuItem(ID_SHOW_GPU, MF_BYCOMMAND | (theApp.m_general_data.IsHardwareEnable(HI_GPU) ? MF_ENABLED : MF_GRAYED));
pMenu->EnableMenuItem(ID_SHOW_CPU_TEMPERATURE, MF_BYCOMMAND | (theApp.m_general_data.IsHardwareEnable(HI_CPU) ? MF_ENABLED : MF_GRAYED));
pMenu->EnableMenuItem(ID_SHOW_GPU_TEMPERATURE, MF_BYCOMMAND | (theApp.m_general_data.IsHardwareEnable(HI_GPU) ? MF_ENABLED : MF_GRAYED));
pMenu->EnableMenuItem(ID_SHOW_HDD_TEMPERATURE, MF_BYCOMMAND | (theApp.m_general_data.IsHardwareEnable(HI_HDD) ? MF_ENABLED : MF_GRAYED));
pMenu->EnableMenuItem(ID_SHOW_MAIN_BOARD_TEMPERATURE, MF_BYCOMMAND | (theApp.m_general_data.IsHardwareEnable(HI_MBD) ? MF_ENABLED : MF_GRAYED));
#endif

pMenu->EnableMenuItem(ID_SELECT_ALL_CONNECTION, MF_BYCOMMAND | (theApp.m_general_data.show_all_interface ? MF_GRAYED : MF_ENABLED));
Expand Down
15 changes: 14 additions & 1 deletion TrafficMonitor/TrafficMonitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void CTrafficMonitorApp::LoadConfig()
m_general_data.monitor_time_span = 1000;
m_general_data.hard_disk_name = ini.GetString(L"general", L"hard_disk_name", L"");
m_general_data.cpu_core_name = ini.GetString(L"general", L"cpu_core_name", L"");
m_general_data.hardware_monitor_item = ini.GetInt(L"general", L"hardware_monitor_item", HI_CPU | HI_GPU | HI_HDD | HI_MBD);
m_general_data.hardware_monitor_item = ini.GetInt(L"general", L"hardware_monitor_item", 0);

//Windows10颜色模式设置
bool is_windows10_light_theme = m_win_version.IsWindows10LightTheme();
Expand Down Expand Up @@ -171,6 +171,19 @@ void CTrafficMonitorApp::LoadConfig()
m_cfg_data.m_tbar_display_item &= ~TDI_MAIN_BOARD_TEMP;
#endif

//如果选项设置中关闭了某个硬件监控,则不显示对应的温度监控相关项目
if (!m_general_data.IsHardwareEnable(HI_CPU))
m_cfg_data.m_tbar_display_item &= ~TDI_CPU_TEMP;
if (!m_general_data.IsHardwareEnable(HI_GPU))
{
m_cfg_data.m_tbar_display_item &= ~TDI_GPU_USAGE;
m_cfg_data.m_tbar_display_item &= ~TDI_GPU_TEMP;
}
if (!m_general_data.IsHardwareEnable(HI_HDD))
m_cfg_data.m_tbar_display_item &= ~TDI_HDD_TEMP;
if (!m_general_data.IsHardwareEnable(HI_MBD))
m_cfg_data.m_tbar_display_item &= ~TDI_MAIN_BOARD_TEMP;

m_taskbar_data.swap_up_down = ini.GetBool(_T("task_bar"), _T("task_bar_swap_up_down"), false);

if (m_taskbar_data.back_color == 0 && !m_taskbar_data.text_colors.empty() && m_taskbar_data.text_colors.begin()->second.label == 0) //万一读取到的背景色和文本颜色都为0(黑色),则将文本色和背景色设置成默认颜色
Expand Down

0 comments on commit 34fae52

Please sign in to comment.