From b78c09382e32333d994c064a8fbf0a95c21d9ff4 Mon Sep 17 00:00:00 2001 From: dinhngtu <1257909+dinhngtu@users.noreply.github.com> Date: Sun, 26 May 2024 03:51:52 +0200 Subject: [PATCH] Use Extract dialog when extracting without selection. (#420) --- .../CPP/7zip/UI/FileManager/Panel.cpp | 37 ++++++++++++++++++- .../SevenZip/CPP/7zip/UI/FileManager/Panel.h | 1 + .../CPP/7zip/UI/FileManager/Panel.cpp | 37 ++++++++++++++++++- .../SevenZip/CPP/7zip/UI/FileManager/Panel.h | 1 + 4 files changed, 74 insertions(+), 2 deletions(-) diff --git a/NanaZip.UI.Classic/SevenZip/CPP/7zip/UI/FileManager/Panel.cpp b/NanaZip.UI.Classic/SevenZip/CPP/7zip/UI/FileManager/Panel.cpp index 0f16e8171..c42316e87 100644 --- a/NanaZip.UI.Classic/SevenZip/CPP/7zip/UI/FileManager/Panel.cpp +++ b/NanaZip.UI.Classic/SevenZip/CPP/7zip/UI/FileManager/Panel.cpp @@ -988,7 +988,7 @@ void CPanel::ExtractArchives() { if (_parentFolders.Size() > 0) { - _panelCallback->OnCopy(false, false); + ExtractFromArchive(); return; } CRecordVector indices; @@ -1015,6 +1015,41 @@ void CPanel::ExtractArchives() ); } +void CPanel::ExtractFromArchive() +{ + if (_parentFolders.Size() > 1) { + _panelCallback->OnCopy(false, false); + return; + } + + CRecordVector indices; + GetOperatedItemIndices(indices); + if (indices.Size() > 0) { + _panelCallback->OnCopy(false, false); + return; + } + + UString path = GetFsPath(); + if (IsPathSepar(path.Back())) + path.DeleteBack(); + if (path != _parentFolders[0].VirtualPath) { + _panelCallback->OnCopy(false, false); + return; + } + UStringVector paths; + paths.Add(path); + UString outFolder = GetSubFolderNameForExtract2(path); + + CContextMenuInfo ci; + ci.Load(); + + ::ExtractArchives(paths, outFolder + , true // showDialog + , false // elimDup + , ci.WriteZone + ); +} + /* static void AddValuePair(UINT resourceID, UInt64 value, UString &s) { diff --git a/NanaZip.UI.Classic/SevenZip/CPP/7zip/UI/FileManager/Panel.h b/NanaZip.UI.Classic/SevenZip/CPP/7zip/UI/FileManager/Panel.h index 0de35d516..7f89287ac 100644 --- a/NanaZip.UI.Classic/SevenZip/CPP/7zip/UI/FileManager/Panel.h +++ b/NanaZip.UI.Classic/SevenZip/CPP/7zip/UI/FileManager/Panel.h @@ -850,6 +850,7 @@ class CPanel: public NWindows::NControl::CWindow2 void GetFilePaths(const CRecordVector &indices, UStringVector &paths, bool allowFolders = false); void ExtractArchives(); + void ExtractFromArchive(); void TestArchives(); HRESULT CopyTo(CCopyToOptions &options, diff --git a/NanaZip.UI.Modern/SevenZip/CPP/7zip/UI/FileManager/Panel.cpp b/NanaZip.UI.Modern/SevenZip/CPP/7zip/UI/FileManager/Panel.cpp index 0f16e8171..c42316e87 100644 --- a/NanaZip.UI.Modern/SevenZip/CPP/7zip/UI/FileManager/Panel.cpp +++ b/NanaZip.UI.Modern/SevenZip/CPP/7zip/UI/FileManager/Panel.cpp @@ -988,7 +988,7 @@ void CPanel::ExtractArchives() { if (_parentFolders.Size() > 0) { - _panelCallback->OnCopy(false, false); + ExtractFromArchive(); return; } CRecordVector indices; @@ -1015,6 +1015,41 @@ void CPanel::ExtractArchives() ); } +void CPanel::ExtractFromArchive() +{ + if (_parentFolders.Size() > 1) { + _panelCallback->OnCopy(false, false); + return; + } + + CRecordVector indices; + GetOperatedItemIndices(indices); + if (indices.Size() > 0) { + _panelCallback->OnCopy(false, false); + return; + } + + UString path = GetFsPath(); + if (IsPathSepar(path.Back())) + path.DeleteBack(); + if (path != _parentFolders[0].VirtualPath) { + _panelCallback->OnCopy(false, false); + return; + } + UStringVector paths; + paths.Add(path); + UString outFolder = GetSubFolderNameForExtract2(path); + + CContextMenuInfo ci; + ci.Load(); + + ::ExtractArchives(paths, outFolder + , true // showDialog + , false // elimDup + , ci.WriteZone + ); +} + /* static void AddValuePair(UINT resourceID, UInt64 value, UString &s) { diff --git a/NanaZip.UI.Modern/SevenZip/CPP/7zip/UI/FileManager/Panel.h b/NanaZip.UI.Modern/SevenZip/CPP/7zip/UI/FileManager/Panel.h index 0de35d516..7f89287ac 100644 --- a/NanaZip.UI.Modern/SevenZip/CPP/7zip/UI/FileManager/Panel.h +++ b/NanaZip.UI.Modern/SevenZip/CPP/7zip/UI/FileManager/Panel.h @@ -850,6 +850,7 @@ class CPanel: public NWindows::NControl::CWindow2 void GetFilePaths(const CRecordVector &indices, UStringVector &paths, bool allowFolders = false); void ExtractArchives(); + void ExtractFromArchive(); void TestArchives(); HRESULT CopyTo(CCopyToOptions &options,