Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions CPP/7zip/UI/FileManager/App.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,17 @@ class CApp
RedrawListItems_InPanels();
}

int GetSizeDisplayMode() const { return Panels[LastFocusedPanel]._sizeDisplayMode; }
void SetSizeDisplayMode(int mode)
{
for (unsigned i = 0; i < kNumPanelsMax; i++)
{
CPanel &panel = Panels[i];
panel._sizeDisplayMode = mode;
}
RedrawListItems_InPanels();
}

void RedrawListItems_InPanels()
{
for (unsigned i = 0; i < kNumPanelsMax; i++)
Expand Down
11 changes: 11 additions & 0 deletions CPP/7zip/UI/FileManager/MyLoadMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,9 @@ void OnMenuActivating(HWND /* hWnd */, HMENU hMenu, int position)
menu.CheckItemByID(IDM_VIEW_TOOLBARS_LARGE_BUTTONS, g_App.LargeButtons);
menu.CheckItemByID(IDM_VIEW_TOOLBARS_SHOW_BUTTONS_TEXT, g_App.ShowButtonsLables);
menu.CheckItemByID(IDM_VIEW_AUTO_REFRESH, g_App.Get_AutoRefresh_Mode());
menu.CheckRadioItem(
IDM_VIEW_SIZE_BYTES, IDM_VIEW_SIZE_AUTO,
IDM_VIEW_SIZE_BYTES + g_App.GetSizeDisplayMode(), MF_BYCOMMAND);
// menu.CheckItemByID(IDM_VIEW_SHOW_STREAMS, g_App.Get_ShowNtfsStrems_Mode());
// menu.CheckItemByID(IDM_VIEW_SHOW_DELETED, g_App.ShowDeletedFiles);

Expand Down Expand Up @@ -911,6 +914,14 @@ bool OnMenuCommand(HWND hWnd, unsigned id)
g_App.RedrawListItems_InPanels();
break;

case IDM_VIEW_SIZE_BYTES:
g_App.SetSizeDisplayMode(k_SizeDisplayMode_Bytes);
break;

case IDM_VIEW_SIZE_AUTO:
g_App.SetSizeDisplayMode(k_SizeDisplayMode_Auto);
break;

// Tools
case IDM_OPTIONS: OptionsDialog(hWnd, g_hInstance); break;

Expand Down
8 changes: 8 additions & 0 deletions CPP/7zip/UI/FileManager/Panel.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ const int kParentFolderID = 100;
const unsigned kParentIndex = (unsigned)(int)-1;
const UInt32 kParentIndex_UInt32 = (UInt32)(Int32)kParentIndex;

enum
{
k_SizeDisplayMode_Bytes = 0,
k_SizeDisplayMode_Auto = 1
};

#if !defined(_WIN32) || defined(UNDER_CE)
#define ROOT_FS_FOLDER L"\\"
#else
Expand Down Expand Up @@ -366,6 +372,7 @@ class CPanel Z7_final: public NWindows::NControl::CWindow2
DWORD _exStyle;
// CUIntVector _realIndices;
int _timestampLevel;
int _sizeDisplayMode;
UInt32 _listViewMode;
int _xSize;
private:
Expand Down Expand Up @@ -617,6 +624,7 @@ class CPanel Z7_final: public NWindows::NControl::CWindow2

_exStyle(0),
_timestampLevel(kTimestampPrintLevel_MIN),
_sizeDisplayMode(k_SizeDisplayMode_Auto),
_listViewMode(3),
_xSize(300),
_startGroupSelect(0),
Expand Down
70 changes: 69 additions & 1 deletion CPP/7zip/UI/FileManager/PanelListNotify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,48 @@ UString ConvertSizeToString(UInt64 value)
return s;
}

static void ConvertSizeToString_Auto(UInt64 val, wchar_t *s) throw()
{
if (val < ((UInt64)1 << 10))
{
ConvertSizeToString(val, s);
return;
}

static const wchar_t *const k_Units[5] = { L"", L"KB", L"MB", L"GB", L"TB" };

unsigned unit = 0;
UInt64 whole = val;

while (unit < 4 && whole >= ((UInt64)1 << 10))
{
whole >>= 10;
unit++;
}

const unsigned shiftBits = 10 * unit;
const UInt64 rem = val & ((((UInt64)1) << shiftBits) - 1);
const unsigned hundredths = (unsigned)((rem * 100) >> shiftBits);

wchar_t buf[32];
ConvertUInt64ToString(whole, buf);

wchar_t *d = s;
const wchar_t *src;

for (src = buf; *src != 0; src++)
*d++ = *src;

*d++ = '.';
*d++ = (wchar_t)('0' + hundredths / 10);
*d++ = (wchar_t)('0' + hundredths % 10);
*d++ = ' ';

for (src = k_Units[unit]; *src != 0; src++)
*d++ = *src;
*d = 0;
}

bool IsSizeProp(UINT propID) throw();
bool IsSizeProp(UINT propID) throw()
{
Expand Down Expand Up @@ -124,6 +166,29 @@ bool IsSizeProp(UINT propID) throw()
return false;
}

static bool IsByteSizeProp(UINT propID) throw()
{
switch (propID)
{
case kpidSize:
case kpidPackSize:
case kpidOffset:
case kpidPhySize:
case kpidHeadersSize:
case kpidTotalSize:
case kpidFreeSpace:
case kpidClusterSize:
case kpidAltStreamsSize:
case kpidVirtualSize:
case kpidUnpackSize:
case kpidTotalPhySize:
case kpidTailSize:
case kpidEmbeddedStubSize:
return true;
}
return false;
}



/*
Expand Down Expand Up @@ -485,7 +550,10 @@ LRESULT CPanel::SetItemText(LVITEMW &item)
{
UInt64 v = 0;
ConvertPropVariantToUInt64(prop, v);
ConvertSizeToString(v, text);
if (_sizeDisplayMode == k_SizeDisplayMode_Auto && IsByteSizeProp(propID))
ConvertSizeToString_Auto(v, text);
else
ConvertSizeToString(v, text);
}
else if (prop.vt == VT_BSTR)
{
Expand Down
4 changes: 4 additions & 0 deletions CPP/7zip/UI/FileManager/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@
#define IDM_VIEW_TIME 761
#define IDM_VIEW_TIME_UTC 799

#define IDM_VIEW_SIZE_POPUP 770
#define IDM_VIEW_SIZE_BYTES 771
#define IDM_VIEW_SIZE_AUTO 772

#define IDM_ADD_TO_FAVORITES 800
#define IDS_BOOKMARK 801

Expand Down
6 changes: 6 additions & 0 deletions CPP/7zip/UI/FileManager/resource.rc
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@ BEGIN
MENUITEM "Time", IDM_VIEW_TIME
END

POPUP "Size" MY_MENUITEM_ID(IDM_VIEW_SIZE_POPUP)
BEGIN
MENUITEM "Bytes", IDM_VIEW_SIZE_BYTES
MENUITEM "Auto", IDM_VIEW_SIZE_AUTO
END

POPUP "Toolbars" MY_MENUITEM_ID(IDM_VIEW_TOOLBARS)
BEGIN
MENUITEM "Archive Toolbar", IDM_VIEW_ARCHIVE_TOOLBAR
Expand Down