From dee3259e586a150f84e7947a30adc15520a5731b Mon Sep 17 00:00:00 2001 From: shunf4 Date: Tue, 3 Sep 2024 00:21:26 +0800 Subject: [PATCH] copy history excludes appended filename path segment; always check open output folder, unless manually changing registry --- CPP/7zip/UI/FileManager/App.cpp | 4 +++- CPP/7zip/UI/FileManager/CopyDialog.cpp | 5 +++++ CPP/7zip/UI/FileManager/CopyDialog.h | 6 +++++- CPP/7zip/UI/FileManager/ViewSettings.cpp | 11 ++++++----- 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/CPP/7zip/UI/FileManager/App.cpp b/CPP/7zip/UI/FileManager/App.cpp index 31da7e45..ea33385d 100755 --- a/CPP/7zip/UI/FileManager/App.cpp +++ b/CPP/7zip/UI/FileManager/App.cpp @@ -610,6 +610,7 @@ void CApp::OnCopy(bool move, bool copyToSame, unsigned srcPanelIndex) CRecordVector indices; UString destPath; + UString destPathBeforeAppendingFilename; bool openOutputFolder; bool deleteSourceFile; bool close7Zip; @@ -663,6 +664,7 @@ void CApp::OnCopy(bool move, bool copyToSame, unsigned srcPanelIndex) close7Zip = copyDialog.m_bClose7Zip; destPath = copyDialog.Value; + destPathBeforeAppendingFilename = copyDialog.isActuallyAppendingFilename ? copyDialog.ValueBeforeAppendingFilename : destPath; } { @@ -787,7 +789,7 @@ void CApp::OnCopy(bool move, bool copyToSame, unsigned srcPanelIndex) if (!destIsFsPath) useDestPanel = true; - AddUniqueStringToHeadOfList(copyFolders, destPath); + AddUniqueStringToHeadOfList(copyFolders, destPathBeforeAppendingFilename); while (copyFolders.Size() > 20) copyFolders.DeleteBack(); SaveCopyHistory(copyFolders); diff --git a/CPP/7zip/UI/FileManager/CopyDialog.cpp b/CPP/7zip/UI/FileManager/CopyDialog.cpp index c4f602f9..5948f88b 100755 --- a/CPP/7zip/UI/FileManager/CopyDialog.cpp +++ b/CPP/7zip/UI/FileManager/CopyDialog.cpp @@ -63,6 +63,7 @@ bool CCopyDialog::OnInit() m_sizeMinWindow.cy = (RECT_SIZE_Y(rc))*4/5; ///////////////////////////////////////////////////////// m_strRealFileName.Empty(); + ValueBeforeAppendingFilename.Empty(); if (IsDirectory(m_currentFolderPrefix)) { EnableItem(IDC_COPY_ADD_FILE_NAME, false); @@ -264,12 +265,16 @@ void CCopyDialog::OnButtonAddFileName() } if (strLastDir != m_strRealFileName) { + ValueBeforeAppendingFilename = currentPath; currentPath += L'\\'; currentPath += m_strRealFileName; _path.SetText(currentPath); + + isActuallyAppendingFilename = true; } else { _path.SetText(currentPath.Mid(0, n)); + isActuallyAppendingFilename = false; } _path.SetFocus(); } diff --git a/CPP/7zip/UI/FileManager/CopyDialog.h b/CPP/7zip/UI/FileManager/CopyDialog.h index 7ca68cc0..0543c663 100755 --- a/CPP/7zip/UI/FileManager/CopyDialog.h +++ b/CPP/7zip/UI/FileManager/CopyDialog.h @@ -31,7 +31,7 @@ protected: public: // soleDir=2: undecided - CCopyDialog(): soleDir(2), m_bOpenOutputFolder(false), m_bDeleteSourceFile(false), m_bClose7Zip (false) { m_sizeMinWindow.cx = 0; m_sizeMinWindow.cy = 0; } + CCopyDialog(): soleDir(2), m_bOpenOutputFolder(false), m_bDeleteSourceFile(false), m_bClose7Zip (false), isActuallyAppendingFilename(false) { m_sizeMinWindow.cx = 0; m_sizeMinWindow.cy = 0; } UString Title; UString Static; @@ -48,6 +48,10 @@ public: UString m_currentFolderPrefix; UString m_strRealFileName; + UString ValueBeforeAppendingFilename; + + bool isActuallyAppendingFilename; + INT_PTR Create(HWND parentWindow = NULL) { return CModalDialog::Create(IDD_COPY, parentWindow); } bool OnMessage(UINT message, WPARAM wParam, LPARAM lParam); diff --git a/CPP/7zip/UI/FileManager/ViewSettings.cpp b/CPP/7zip/UI/FileManager/ViewSettings.cpp index 3efe6f30..afd45a71 100755 --- a/CPP/7zip/UI/FileManager/ViewSettings.cpp +++ b/CPP/7zip/UI/FileManager/ViewSettings.cpp @@ -317,19 +317,20 @@ void AddUniqueStringToHeadOfList(UStringVector &list, const UString &s) void SaveOptOpenOutputFolder(bool bOpen) { - CKey key; - key.Create(HKEY_CURRENT_USER, kCUBasePath); - key.SetValue(kOpenOutputFolderValueName, bOpen); + // CKey key; + // key.Create(HKEY_CURRENT_USER, kCUBasePath); + // key.SetValue(kOpenOutputFolderValueName, bOpen); + (void)(bOpen); } bool ReadOptOpenOutputFolder() { CKey key; if (key.Open(HKEY_CURRENT_USER, kCUBasePath, KEY_READ) != ERROR_SUCCESS) - return false; + return true; bool bOpen; if (key.QueryValue(kOpenOutputFolderValueName, bOpen) != ERROR_SUCCESS) - return false; + return true; return bOpen; }