Skip to content

Commit

Permalink
Update: Jump to previous folder
Browse files Browse the repository at this point in the history
* show at most immediate containing folder instead of full path, and shorten long ones.
* remember previous folder when using file open popup too
  • Loading branch information
sdneon committed Aug 25, 2024
1 parent 66a44c7 commit ec5dc21
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 1 deletion.
43 changes: 43 additions & 0 deletions src/JPEGView/FileList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,49 @@ CString CFileList::CurrentDirectoryNameShort() const {
return name.Left(10) + "..." + name.Right(10);
}

CString CFileList::ShortName(CString path)
{
int len = path.GetLength();
if (len <= 23)
return path;

return path.Left(10) + "..." + path.Right(10);
}

CString CFileList::ShortBasePath(CString path)
{
int len = path.GetLength();
if (len > 0) {
int pos = path.ReverseFind('\\');
if (pos == (len - 1))
{
path = path.Left(pos);
pos = path.ReverseFind('\\');
}
if (pos >= 0)
{
int cnt = len - pos - 1;
if (cnt > 0)
{
CString name = ShortName(path.Right(cnt));
path = path.Left(pos);
len = path.GetLength();
pos = path.ReverseFind('\\');
if (pos >= 0)
{
cnt = len - pos - 1;
if (cnt > 0)
{
name = ShortName(path.Right(cnt)) + "\\" + name;
}
return name;
}
}
}
}
return ShortName(path);
}

int CFileList::CurrentIndex() const {
int i = 0;
std::list<CFileDesc>::const_iterator iter;
Expand Down
4 changes: 4 additions & 0 deletions src/JPEGView/FileList.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ class CFileList
CString CurrentDirectoryName() const;
// Current directory's base name shortened if too long
CString CurrentDirectoryNameShort() const;
//Get short base name with '...' substituted if too long
static CString ShortName(CString path);
//Get base name with immediate containing folder
static CString ShortBasePath(CString path);
// Modification time of current file
const FILETIME* CurrentModificationTime() const;
// Get the n-next file, does not change the internal state
Expand Down
3 changes: 2 additions & 1 deletion src/JPEGView/MainDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2759,6 +2759,7 @@ bool CMainDlg::OpenFileWithDialog(bool bFullScreen, bool bAfterStartup) {
CFileOpenDialog dlgOpen(this->m_hWnd, m_pFileList->Current(), CFileList::GetSupportedFileEndings(), bFullScreen);
if (IDOK == dlgOpen.DoModal(this->m_hWnd)) {
m_isBeforeFileSelected = false;
m_sPrevStartupFile = m_sStartupFile;
m_sStartupFile = dlgOpen.m_szFileName;
DetermineInitMinFilesizeMode();
OpenFile(dlgOpen.m_szFileName, bAfterStartup);
Expand Down Expand Up @@ -2805,7 +2806,7 @@ void CMainDlg::OpenPrevAlbumIfAny()
{
CString sNewStartupFile = m_sPrevStartupFile;
m_sPrevStartupFile = m_sStartupFile;
SetToast("Revert > " + sNewStartupFile);
SetToast("Revert > " + CFileList::ShortBasePath(sNewStartupFile));
OpenFile(sNewStartupFile, true);
}
}
Expand Down

0 comments on commit ec5dc21

Please sign in to comment.