Skip to content

Commit

Permalink
播放列表中选择“从列表中删除”时增加确认对话框
Browse files Browse the repository at this point in the history
  • Loading branch information
zhongyang219 committed Jul 31, 2024
1 parent 45d6453 commit 19328d5
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
20 changes: 20 additions & 0 deletions MusicPlayer2/MusicPlayerCmdHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1089,6 +1089,26 @@ bool CMusicPlayerCmdHelper::OnRemoveFromPlaylist(const std::vector<SongInfo>& so
return false;
}

bool CMusicPlayerCmdHelper::OnRemoveFromCurrentPlaylist(const std::vector<int>& indexs)
{
if (CPlayer::GetInstance().IsPlaylistMode())
{
std::wstring playlist_name = CPlaylistMgr::GetPlaylistDisplayName(CPlayer::GetInstance().GetPlaylistPath());
std::wstring info = theApp.m_str_table.LoadTextFormat(L"MSG_REMOVE_FROM_PLAYLIST_INQUIRY", { playlist_name, indexs.size() });
if (GetOwner()->MessageBox(info.c_str(), NULL, MB_ICONQUESTION | MB_YESNO) == IDYES)
{
CPlayer::GetInstance().RemoveSongs(indexs);

//如果是我喜欢的曲目,则需要更新UI中的显示
if (CPlayer::GetInstance().GetPlaylistPath() == theApp.m_playlist_dir + FAVOURITE_PLAYLIST_NAME)
CUiMyFavouriteItemMgr::Instance().UpdateMyFavourite();

return true;
}
}
return false;
}

void CMusicPlayerCmdHelper::OnPlayMyFavourite(int index)
{
bool ok = CPlayer::GetInstance().SetPlaylist(theApp.m_playlist_dir + FAVOURITE_PLAYLIST_NAME, index, 0, true, true);
Expand Down
2 changes: 2 additions & 0 deletions MusicPlayer2/MusicPlayerCmdHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ class CMusicPlayerCmdHelper

//从播放列表中移除
bool OnRemoveFromPlaylist(const std::vector<SongInfo>& songs, const std::wstring& playlist_path);
//从正在播放的播放列表中移除
bool OnRemoveFromCurrentPlaylist(const std::vector<int>& indexs);

void OnPlayMyFavourite(int index);
void OnPlayMyFavourite();
Expand Down
7 changes: 5 additions & 2 deletions MusicPlayer2/MusicPlayerDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5204,8 +5204,9 @@ void CMusicPlayerDlg::OnPlaylistAddFile()
void CMusicPlayerDlg::OnRemoveFromPlaylist()
{
// TODO: 在此添加命令处理程序代码
CPlayer::GetInstance().RemoveSongs(m_items_selected);
ShowPlayList(false);
CMusicPlayerCmdHelper helper(this);
if (helper.OnRemoveFromCurrentPlaylist(m_items_selected))
ShowPlayList(false);
}


Expand Down Expand Up @@ -5246,6 +5247,7 @@ void CMusicPlayerDlg::OnMovePlaylistItemUp()
m_pFloatPlaylistDlg->GetListCtrl().SetCurSel(first - 1, last - 1);
m_pFloatPlaylistDlg->GetPlaylistItemSelected();
}
SetUiPlaylistSelected(first - 1);
}
}

Expand Down Expand Up @@ -5275,6 +5277,7 @@ void CMusicPlayerDlg::OnMovePlaylistItemDown()
m_pFloatPlaylistDlg->GetListCtrl().SetCurSel(first + 1, last + 1);
m_pFloatPlaylistDlg->GetPlaylistItemSelected();
}
SetUiPlaylistSelected(first + 1);
}
}

Expand Down

0 comments on commit 19328d5

Please sign in to comment.