From 247501e50df39726a9d9898fffeeafd0451c30d3 Mon Sep 17 00:00:00 2001 From: zhongyang219 Date: Wed, 21 Aug 2024 13:51:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=8E=E7=A3=81=E7=9B=98=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E6=97=B6=E5=A6=82=E6=9E=9C=E5=8F=AA=E6=9C=89?= =?UTF-8?q?=E4=B8=80=E4=B8=AA=E6=96=87=E4=BB=B6=E6=98=BE=E7=A4=BA=E8=A6=81?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=E7=9A=84=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=90=8D=EF=BC=9B=E5=88=A0=E9=99=A4=E6=AD=A3=E5=9C=A8=E6=92=AD?= =?UTF-8?q?=E6=94=BE=E7=9A=84=E6=9B=B2=E7=9B=AE=E6=97=B6=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E7=A1=AE=E8=AE=A4=E6=B6=88=E6=81=AF=E6=A1=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- MusicPlayer2/MusicPlayerCmdHelper.cpp | 9 ++++++++- MusicPlayer2/MusicPlayerDlg.cpp | 23 ++++++++++++++++++++--- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/MusicPlayer2/MusicPlayerCmdHelper.cpp b/MusicPlayer2/MusicPlayerCmdHelper.cpp index db25a10c..90e901ff 100644 --- a/MusicPlayer2/MusicPlayerCmdHelper.cpp +++ b/MusicPlayer2/MusicPlayerCmdHelper.cpp @@ -238,7 +238,14 @@ bool CMusicPlayerCmdHelper::DeleteSongsFromDisk(const std::vector& fil if (theApp.m_media_lib_setting_data.disable_delete_from_disk) return false; - wstring info = theApp.m_str_table.LoadTextFormat(L"MSG_DELETE_SEL_AUDIO_FILE_INQUIRY", { files.size() }); + if (files.empty()) + return false; + + wstring info; + if (files.size() == 1) + info = theApp.m_str_table.LoadTextFormat(L"MSG_DELETE_SINGLE_FILE_INQUIRY", { files.front().file_path }); + else + info = theApp.m_str_table.LoadTextFormat(L"MSG_DELETE_SEL_AUDIO_FILE_INQUIRY", { files.size() }); if (GetOwner()->MessageBox(info.c_str(), NULL, MB_ICONWARNING | MB_OKCANCEL) != IDOK) return false; diff --git a/MusicPlayer2/MusicPlayerDlg.cpp b/MusicPlayer2/MusicPlayerDlg.cpp index eda29fea..39ae56f8 100644 --- a/MusicPlayer2/MusicPlayerDlg.cpp +++ b/MusicPlayer2/MusicPlayerDlg.cpp @@ -3610,7 +3610,17 @@ void CMusicPlayerDlg::OnDeleteFromDisk() if (m_item_selected < 0 || m_item_selected >= CPlayer::GetInstance().GetSongNum()) return; - wstring info = theApp.m_str_table.LoadTextFormat(L"MSG_DELETE_SEL_AUDIO_FILE_INQUIRY", { m_items_selected.size() }); + + wstring info; + if (m_items_selected.size() == 1) + { + const auto& song = CPlayer::GetInstance().GetPlayList()[m_items_selected.front()]; + info = theApp.m_str_table.LoadTextFormat(L"MSG_DELETE_SINGLE_FILE_INQUIRY", { song.file_path }); + } + else + { + info = theApp.m_str_table.LoadTextFormat(L"MSG_DELETE_SEL_AUDIO_FILE_INQUIRY", { m_items_selected.size() }); + } if (MessageBoxW(info.c_str(), NULL, MB_ICONWARNING | MB_OKCANCEL) != IDOK) return; // 以下操作可能涉及MusicControl,先取得锁 if (!CPlayer::GetInstance().GetPlayStatusMutex().try_lock_for(std::chrono::milliseconds(1000))) return; @@ -5918,8 +5928,15 @@ void CMusicPlayerDlg::OnRemoveCurrentFromPlaylist() // TODO: 在此添加命令处理程序代码 if (CPlayer::GetInstance().IsPlaylistMode()) { - CPlayer::GetInstance().RemoveSong(CPlayer::GetInstance().GetIndex()); - ShowPlayList(false); + const SongInfo& song = CPlayer::GetInstance().GetCurrentSongInfo(); + std::wstring song_display_name = CSongInfoHelper::GetDisplayStr(song, theApp.m_media_lib_setting_data.display_format); + std::wstring playlist_name = CPlaylistMgr::GetPlaylistDisplayName(CPlayer::GetInstance().GetPlaylistPath()); + std::wstring info = theApp.m_str_table.LoadTextFormat(L"MSG_REMOVE_SINGLE_ITEM_FROM_PLAYLIST_INQUIRY", { playlist_name, song_display_name }); + if (MessageBox(info.c_str(), NULL, MB_ICONQUESTION | MB_YESNO) == IDYES) + { + CPlayer::GetInstance().RemoveSong(CPlayer::GetInstance().GetIndex()); + ShowPlayList(false); + } } }