mirror of
https://github.com/zhongyang219/MusicPlayer2.git
synced 2026-10-29 13:18:58 +08:00
细节改进:打开新文件夹时默认显示当前文件夹的上一级文件夹
This commit is contained in:
Binary file not shown.
@@ -52,6 +52,18 @@ wstring CFilePathHelper::GetDir() const
|
||||
return m_file_path.substr(0, index + 1);
|
||||
}
|
||||
|
||||
wstring CFilePathHelper::GetParentDir() const
|
||||
{
|
||||
wstring dir{ GetDir() };
|
||||
size_t index;
|
||||
if (!dir.empty() && (dir.back() == L'\\' || dir.back() == L'/'))
|
||||
dir.pop_back();
|
||||
index = dir.rfind('\\');
|
||||
if (index == wstring::npos)
|
||||
index = dir.rfind('/');
|
||||
return m_file_path.substr(0, index + 1);
|
||||
}
|
||||
|
||||
const wstring& CFilePathHelper::ReplaceFileExtension(const wchar_t * new_extension)
|
||||
{
|
||||
size_t index;
|
||||
|
||||
@@ -13,6 +13,7 @@ public:
|
||||
wstring GetFileName() const; //获取文件名
|
||||
wstring GetFileNameWithoutExtension() const; //获取文件名(不含扩展名)
|
||||
wstring GetDir() const; //获取目录
|
||||
wstring GetParentDir() const; //获取上级目录
|
||||
wstring GetFilePath() const { return m_file_path; } //获取完整路径
|
||||
const wstring& ReplaceFileExtension(const wchar_t* new_extension); //替换文件的扩展名,返回文件完整路径
|
||||
protected:
|
||||
|
||||
@@ -1866,7 +1866,8 @@ void CMusicPlayerDlg::OnFileOpenFolder()
|
||||
CFolderBrowserDlg folderPickerDlg(this->GetSafeHwnd());
|
||||
folderPickerDlg.SetInfo(_T("请选择一个文件夹,文件夹里的所有音频文件都将添加到播放列表。"));
|
||||
#else
|
||||
CFolderPickerDialog folderPickerDlg(theApp.m_player.GetCurrentPath().c_str());
|
||||
CFilePathHelper current_path(theApp.m_player.GetCurrentPath());
|
||||
CFolderPickerDialog folderPickerDlg(current_path.GetParentDir().c_str());
|
||||
#endif
|
||||
if (folderPickerDlg.DoModal() == IDOK)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user