Skip to content

Commit

Permalink
Briefly show folder name when jumped
Browse files Browse the repository at this point in the history
  • Loading branch information
sdneon committed Jul 31, 2024
1 parent 81a15f2 commit f8993ff
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/JPEGView/FileList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,28 @@ LPCTSTR CFileList::CurrentDirectory() const {
}
}

CString CFileList::CurrentDirectoryName() const {
if (m_sDirectory.GetLength() > 0) {
int pos = m_sDirectory.ReverseFind('\\');
if (pos >= 0)
{
int cnt = m_sDirectory.GetLength() - pos - 1;
if (cnt > 0)
return m_sDirectory.Right(cnt);
}
}
return m_sDirectory;
}

CString CFileList::CurrentDirectoryNameShort() const {
CString name = CurrentDirectoryName();
int len = name.GetLength();
if (len <= 44)
return name;

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

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 @@ -98,6 +98,10 @@ class CFileList
LPCTSTR CurrentFileTitle() const;
// Current directory without file name, NULL if none
LPCTSTR CurrentDirectory() const;
// Current directory's base name
CString CurrentDirectoryName() const;
// Current directory's base name shortened if too long
CString CurrentDirectoryNameShort() const;
// Modification time of current file
const FILETIME* CurrentModificationTime() const;
// Get the n-next file, does not change the internal state
Expand Down
8 changes: 8 additions & 0 deletions src/JPEGView/MainDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3187,11 +3187,19 @@ void CMainDlg::GotoImage(EImagePosition ePos, int nFlags) {
case POS_Next_Folder:
{
m_pFileList = m_pFileList->NextFolder();
if (m_pFileList)
{
SetToast("Jumped > " + m_pFileList->CurrentDirectoryNameShort());
}
break;
}
case POS_Previous_Folder:
{
m_pFileList = m_pFileList->PrevFolder();
if (m_pFileList)
{
SetToast("Jumped < " + m_pFileList->CurrentDirectoryNameShort());
}
break;
}
}
Expand Down

0 comments on commit f8993ff

Please sign in to comment.