Skip to content

Commit

Permalink
添加自动刷新媒体库时略过过短文件设置
Browse files Browse the repository at this point in the history
  • Loading branch information
lrisora committed Aug 18, 2023
1 parent fc5049f commit 07a67cc
Show file tree
Hide file tree
Showing 7 changed files with 217 additions and 162 deletions.
2 changes: 2 additions & 0 deletions MusicPlayer2/CommonData.h
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,8 @@ struct MediaLibSettingData
bool disable_delete_from_disk; //禁用从磁盘删除
bool show_tree_tool_tips; //树控件显示鼠标提示
bool update_media_lib_when_start_up; //启动时自动更新媒体库
bool ignore_too_short_when_update; // 自动更新/刷新媒体库时忽略时长低于阈值的文件(不影响手动加入)
int file_too_short_sec; // 音频低时长阈值(清理媒体库功能也使用这个设置)
bool remove_file_not_exist_when_update{}; //更新媒体库时移除不存在的音频文件
bool disable_drag_sort; //禁止通过拖放排序
DisplayFormat display_format{}; //播放列表中项目的显示样式
Expand Down
21 changes: 20 additions & 1 deletion MusicPlayer2/MediaLibSettingDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ void CMediaLibSettingDlg::DoDataExchange(CDataExchange* pDX)
DDX_Control(pDX, IDC_DISABLE_DRAGE_SORT_CHECK, m_disable_drag_sort_chk);
DDX_Control(pDX, IDC_PLAYLIST_DISPLAY_MODE_OMBO, m_playlist_display_mode_combo);
DDX_Control(pDX, IDC_RECENT_PLAYED_RANGE_OMBO, m_recent_played_range_combo);
DDX_Control(pDX, IDC_IGNORE_TOO_SHORT_CHECK, m_ignore_too_short_chk);
DDX_Control(pDX, IDC_FILE_TOO_SHORT_SEC_EDIT, m_file_too_short_sec_edit);
DDX_Control(pDX, IDC_IGNORE_EXIST_CHECK, m_ignore_exist_chk);
DDX_Control(pDX, IDC_ID3V2_TYPE_COMBO, m_id3v2_type_combo);
DDX_Control(pDX, IDC_ENABLE_LASTFM, m_enable_lastfm);
Expand Down Expand Up @@ -90,9 +92,13 @@ void CMediaLibSettingDlg::GetDataFromUi()
m_data.lastfm_least_dur = m_lastfm_least_dur.GetValue();
m_data.lastfm_auto_scrobble_min = m_lastfm_auto_scrobble_min.GetValue();
m_data.playlist_item_height = m_playlist_item_height_edit.GetValue();
m_data.file_too_short_sec = m_file_too_short_sec_edit.GetValue();
m_data.remove_file_not_exist_when_update = (IsDlgButtonChecked(IDC_REMOVE_FILE_NOT_EXIST_WHEN_UPDATE_CHECK));
}

// void CMediaLibSettingDlg::ApplyDataToUi()
// {
// }

BEGIN_MESSAGE_MAP(CMediaLibSettingDlg, CTabDlg)
ON_WM_TIMER()
Expand All @@ -119,6 +125,7 @@ BEGIN_MESSAGE_MAP(CMediaLibSettingDlg, CTabDlg)
ON_BN_CLICKED(IDC_LASTFM_ENABLE_HTTPS, &CMediaLibSettingDlg::OnBnClickedLastfmEnableHttps)
ON_BN_CLICKED(IDC_LASTFM_ENABLE_NOWPLAYING, &CMediaLibSettingDlg::OnBnClickedLastfmEnableNowplaying)
ON_MESSAGE(WM_EDIT_BROWSE_CHANGED, &CMediaLibSettingDlg::OnEditBrowseChanged)
ON_BN_CLICKED(IDC_IGNORE_TOO_SHORT_CHECK, &CMediaLibSettingDlg::OnBnClickedIgnoreTooShortCheck)
END_MESSAGE_MAP()


Expand Down Expand Up @@ -171,6 +178,7 @@ BOOL CMediaLibSettingDlg::OnInitDialog()
m_recent_played_range_combo.SetCurSel(static_cast<int>(m_data.recent_played_range));

m_ignore_exist_chk.SetCheck(m_data.ignore_songs_already_in_playlist);
m_ignore_too_short_chk.SetCheck(m_data.ignore_too_short_when_update);
CheckDlgButton(IDC_SHOW_PLAYLIST_TOOLTIP_CHECK, m_data.show_playlist_tooltip);
CheckDlgButton(IDC_FLOAT_PLAYLIST_FOLLOW_MAIN_WND_CHECK, m_data.float_playlist_follow_main_wnd);

Expand Down Expand Up @@ -202,6 +210,8 @@ BOOL CMediaLibSettingDlg::OnInitDialog()

m_playlist_item_height_edit.SetRange(MIN_PLAYLIST_ITEM_HEIGHT, MAX_PLAYLIST_ITEM_HEIGHT);
m_playlist_item_height_edit.SetValue(m_data.playlist_item_height);
m_file_too_short_sec_edit.SetRange(1, 60);
m_file_too_short_sec_edit.SetValue(m_data.file_too_short_sec);

//设置控件不响应鼠标滚轮消息
m_playlist_display_mode_combo.SetMouseWheelEnable(false);
Expand All @@ -211,6 +221,8 @@ BOOL CMediaLibSettingDlg::OnInitDialog()
m_lastfm_least_dur.SetMouseWheelEnable(false);
m_lastfm_auto_scrobble_min.SetMouseWheelEnable(false);
m_playlist_item_height_edit.SetMouseWheelEnable(false);
m_file_too_short_sec_edit.SetMouseWheelEnable(false);

UpdateLastFMStatus();
SetTimer(TIMER_1_SEC, 1000, NULL);

Expand Down Expand Up @@ -308,7 +320,7 @@ void CMediaLibSettingDlg::OnBnClickedCleanDataFileButton()
{
clear_cnt += CMusicPlayerCmdHelper::CleanUpSongData([&](const SongInfo& song)
{
return song.length().toInt() < 30 * 1000;
return song.length().toInt() < m_data.file_too_short_sec * 1000;
});
}
if (clear_cnt > 0)
Expand Down Expand Up @@ -521,3 +533,10 @@ afx_msg LRESULT CMediaLibSettingDlg::OnEditBrowseChanged(WPARAM wParam, LPARAM l
}
return 0;
}


void CMediaLibSettingDlg::OnBnClickedIgnoreTooShortCheck()
{
// TODO: 在此添加控件通知处理程序代码
m_data.ignore_too_short_when_update = (m_ignore_too_short_chk.GetCheck() != 0);
}
9 changes: 9 additions & 0 deletions MusicPlayer2/MediaLibSettingDlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ class CMediaLibSettingDlg : public CTabDlg
CButton m_disable_drag_sort_chk;
CMyComboBox m_playlist_display_mode_combo;
CMyComboBox m_recent_played_range_combo;
CButton m_ignore_too_short_chk;
CSpinEdit m_file_too_short_sec_edit;
CButton m_ignore_exist_chk;
CMyComboBox m_id3v2_type_combo;
CButton m_enable_lastfm;
Expand All @@ -54,7 +56,12 @@ class CMediaLibSettingDlg : public CTabDlg
void ShowDataSizeInfo();

virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV 支持
// 在点击选项设置对话框的“应用”或“确定”时CMusicPlayerDlg::ApplySettings()将所有m_data写入theApp前被调用
// 这里是设置应用前最后的更新ui到m_data的机会,不需要实时更新到m_data的ui也可以只在这里获取
virtual void GetDataFromUi() override;
// 在点击选项设置对话框的“应用”时,时CMusicPlayerDlg::ApplySettings()将所有m_data写入theApp后被调用
// 进行一些只有在CMusicPlayerDlg::ApplySettings()后才能做的ui更新
// virtual void ApplyDataToUi() override;
void UpdateLastFMStatus();
void UpdateLastFMCacheStatus();
afx_msg void OnTimer(UINT_PTR nIDEvent);
Expand Down Expand Up @@ -88,4 +95,6 @@ class CMediaLibSettingDlg : public CTabDlg
afx_msg void OnBnClickedLastfmEnableNowplaying();
protected:
afx_msg LRESULT OnEditBrowseChanged(WPARAM wParam, LPARAM lParam);
public:
afx_msg void OnBnClickedIgnoreTooShortCheck();
};
Loading

0 comments on commit 07a67cc

Please sign in to comment.