细节改进:打开新文件夹时默认显示当前文件夹的上一级文件夹

This commit is contained in:
Zhong Yang
2018-07-08 10:55:37 +08:00
parent 7ff59329a6
commit 86146cfa28
4 changed files with 15 additions and 1 deletions
Binary file not shown.
+12
View File
@@ -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;
+1
View File
@@ -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:
+2 -1
View File
@@ -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)
{