From 652064366f69099b0729ffa4546af9d4c3be7a88 Mon Sep 17 00:00:00 2001 From: a1waysbeta <2366650060@qq.com> Date: Fri, 11 Sep 2026 13:04:22 +0800 Subject: [PATCH] Add files via upload --- CPP/7zip/UI/FileManager/App.h | 11 ++++ CPP/7zip/UI/FileManager/MyLoadMenu.cpp | 11 ++++ CPP/7zip/UI/FileManager/Panel.h | 8 +++ CPP/7zip/UI/FileManager/PanelListNotify.cpp | 70 ++++++++++++++++++++- CPP/7zip/UI/FileManager/resource.h | 4 ++ CPP/7zip/UI/FileManager/resource.rc | 6 ++ 6 files changed, 109 insertions(+), 1 deletion(-) diff --git a/CPP/7zip/UI/FileManager/App.h b/CPP/7zip/UI/FileManager/App.h index cf74d6a5d..8e84c0d51 100644 --- a/CPP/7zip/UI/FileManager/App.h +++ b/CPP/7zip/UI/FileManager/App.h @@ -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++) diff --git a/CPP/7zip/UI/FileManager/MyLoadMenu.cpp b/CPP/7zip/UI/FileManager/MyLoadMenu.cpp index f190929f7..41671ef7f 100644 --- a/CPP/7zip/UI/FileManager/MyLoadMenu.cpp +++ b/CPP/7zip/UI/FileManager/MyLoadMenu.cpp @@ -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); @@ -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; diff --git a/CPP/7zip/UI/FileManager/Panel.h b/CPP/7zip/UI/FileManager/Panel.h index 9ef09265e..3a54e52cf 100644 --- a/CPP/7zip/UI/FileManager/Panel.h +++ b/CPP/7zip/UI/FileManager/Panel.h @@ -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 @@ -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: @@ -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), diff --git a/CPP/7zip/UI/FileManager/PanelListNotify.cpp b/CPP/7zip/UI/FileManager/PanelListNotify.cpp index 05ab36bcd..9c79c5bde 100644 --- a/CPP/7zip/UI/FileManager/PanelListNotify.cpp +++ b/CPP/7zip/UI/FileManager/PanelListNotify.cpp @@ -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() { @@ -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; +} + /* @@ -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) { diff --git a/CPP/7zip/UI/FileManager/resource.h b/CPP/7zip/UI/FileManager/resource.h index 36c4b531a..901dc8632 100644 --- a/CPP/7zip/UI/FileManager/resource.h +++ b/CPP/7zip/UI/FileManager/resource.h @@ -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 diff --git a/CPP/7zip/UI/FileManager/resource.rc b/CPP/7zip/UI/FileManager/resource.rc index d9fc6f25e..df617a757 100644 --- a/CPP/7zip/UI/FileManager/resource.rc +++ b/CPP/7zip/UI/FileManager/resource.rc @@ -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