[ZIPFLDR] Various usability improvements

- Take the user-entered folder into account
- Hide size / ratio for folders
CORE-14543
CORE-14542
This commit is contained in:
Mark Jansen 2018-04-21 12:50:05 +02:00
parent 2c90194ae4
commit fd0b834a0a
No known key found for this signature in database
GPG key ID: B39240EE84BEAE8B
3 changed files with 41 additions and 2 deletions

View file

@ -12,10 +12,12 @@ class CZipExtract :
{ {
CStringW m_Filename; CStringW m_Filename;
CStringW m_Directory; CStringW m_Directory;
bool m_DirectoryChanged;
unzFile uf; unzFile uf;
public: public:
CZipExtract(PCWSTR Filename) CZipExtract(PCWSTR Filename)
:uf(NULL) :m_DirectoryChanged(false)
,uf(NULL)
{ {
m_Filename = Filename; m_Filename = Filename;
m_Directory = m_Filename; m_Directory = m_Filename;
@ -158,6 +160,7 @@ public:
int OnSetActive() int OnSetActive()
{ {
SetDlgItemTextW(IDC_DIRECTORY, m_pExtract->m_Directory); SetDlgItemTextW(IDC_DIRECTORY, m_pExtract->m_Directory);
m_pExtract->m_DirectoryChanged = false;
::EnableWindow(GetDlgItem(IDC_PASSWORD), FALSE); /* Not supported for now */ ::EnableWindow(GetDlgItem(IDC_PASSWORD), FALSE); /* Not supported for now */
GetParent().CenterWindow(::GetDesktopWindow()); GetParent().CenterWindow(::GetDesktopWindow());
return 0; return 0;
@ -169,6 +172,9 @@ public:
::EnableWindow(GetDlgItem(IDC_DIRECTORY), FALSE); ::EnableWindow(GetDlgItem(IDC_DIRECTORY), FALSE);
::EnableWindow(GetDlgItem(IDC_PASSWORD), FALSE); ::EnableWindow(GetDlgItem(IDC_PASSWORD), FALSE);
if (m_pExtract->m_DirectoryChanged)
UpdateDirectory();
if (!m_pExtract->Extract(m_hWnd, GetDlgItem(IDC_PROGRESS))) if (!m_pExtract->Extract(m_hWnd, GetDlgItem(IDC_PROGRESS)))
{ {
/* Extraction failed, do not go to the next page */ /* Extraction failed, do not go to the next page */
@ -211,6 +217,9 @@ public:
CStringW title(MAKEINTRESOURCEW(IDS_WIZ_BROWSE_TITLE)); CStringW title(MAKEINTRESOURCEW(IDS_WIZ_BROWSE_TITLE));
bi.lpszTitle = title; bi.lpszTitle = title;
if (m_pExtract->m_DirectoryChanged)
UpdateDirectory();
browse_info info = { m_hWnd, m_pExtract->m_Directory.GetString() }; browse_info info = { m_hWnd, m_pExtract->m_Directory.GetString() };
bi.lParam = (LPARAM)&info; bi.lParam = (LPARAM)&info;
@ -222,21 +231,35 @@ public:
{ {
m_pExtract->m_Directory = tmpPath; m_pExtract->m_Directory = tmpPath;
SetDlgItemTextW(IDC_DIRECTORY, m_pExtract->m_Directory); SetDlgItemTextW(IDC_DIRECTORY, m_pExtract->m_Directory);
m_pExtract->m_DirectoryChanged = false;
} }
return 0; return 0;
} }
LRESULT OnEnChangeDirectory(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{
m_pExtract->m_DirectoryChanged = true;
return 0;
}
LRESULT OnPassword(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled) LRESULT OnPassword(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
{ {
return 0; return 0;
} }
void UpdateDirectory()
{
GetDlgItemText(IDC_DIRECTORY, m_pExtract->m_Directory);
m_pExtract->m_DirectoryChanged = false;
}
public: public:
enum { IDD = IDD_PROPPAGEDESTINATION }; enum { IDD = IDD_PROPPAGEDESTINATION };
BEGIN_MSG_MAP(CCompleteSettingsPage) BEGIN_MSG_MAP(CCompleteSettingsPage)
COMMAND_ID_HANDLER(IDC_BROWSE, OnBrowse) COMMAND_ID_HANDLER(IDC_BROWSE, OnBrowse)
COMMAND_ID_HANDLER(IDC_PASSWORD, OnPassword) COMMAND_ID_HANDLER(IDC_PASSWORD, OnPassword)
COMMAND_HANDLER(IDC_DIRECTORY, EN_CHANGE, OnEnChangeDirectory)
CHAIN_MSG_MAP(CPropertyPageImpl<CExtractSettingsPage>) CHAIN_MSG_MAP(CPropertyPageImpl<CExtractSettingsPage>)
END_MSG_MAP() END_MSG_MAP()
}; };
@ -319,6 +342,7 @@ public:
if (err != UNZ_OK) if (err != UNZ_OK)
{ {
DPRINT1("ERROR, unzGetGlobalInfo64: 0x%x\n", err); DPRINT1("ERROR, unzGetGlobalInfo64: 0x%x\n", err);
Close();
return false; return false;
} }
@ -326,6 +350,7 @@ public:
if (!zipEnum.initialize(this)) if (!zipEnum.initialize(this))
{ {
DPRINT1("ERROR, zipEnum.initialize\n"); DPRINT1("ERROR, zipEnum.initialize\n");
Close();
return false; return false;
} }
@ -351,6 +376,7 @@ public:
HRESULT hr = SHPathPrepareForWriteA(hDlg, NULL, FullPath, dwFlags); HRESULT hr = SHPathPrepareForWriteA(hDlg, NULL, FullPath, dwFlags);
if (FAILED_UNEXPECTEDLY(hr)) if (FAILED_UNEXPECTEDLY(hr))
{ {
Close();
return false; return false;
} }
CurrentFile++; CurrentFile++;
@ -363,6 +389,7 @@ public:
if (err != UNZ_OK) if (err != UNZ_OK)
{ {
DPRINT1("ERROR, unzOpenCurrentFilePassword: 0x%x\n", err); DPRINT1("ERROR, unzOpenCurrentFilePassword: 0x%x\n", err);
Close();
return false; return false;
} }
@ -386,6 +413,8 @@ public:
case CConfirmReplace::No: case CConfirmReplace::No:
break; break;
case CConfirmReplace::Cancel: case CConfirmReplace::Cancel:
unzCloseCurrentFile(uf);
Close();
return false; return false;
} }
} }
@ -408,6 +437,7 @@ public:
{ {
unzCloseCurrentFile(uf); unzCloseCurrentFile(uf);
DPRINT1("ERROR, CreateFileA: 0x%x (%s)\n", dwErr, bOverwriteAll ? "Y" : "N"); DPRINT1("ERROR, CreateFileA: 0x%x (%s)\n", dwErr, bOverwriteAll ? "Y" : "N");
Close();
return false; return false;
} }
} }
@ -454,6 +484,7 @@ public:
{ {
unzCloseCurrentFile(uf); unzCloseCurrentFile(uf);
DPRINT1("ERROR, unzReadCurrentFile2: 0x%x\n", err); DPRINT1("ERROR, unzReadCurrentFile2: 0x%x\n", err);
Close();
return false; return false;
} }
else else

View file

@ -172,6 +172,9 @@ public:
case 2: /* Compressed size */ case 2: /* Compressed size */
case 4: /* Size */ case 4: /* Size */
{ {
if (isDir)
return SHSetStrRet(&psd->str, L"");
ULONG64 Size = iColumn == 2 ? zipEntry->CompressedSize : zipEntry->UncompressedSize; ULONG64 Size = iColumn == 2 ? zipEntry->CompressedSize : zipEntry->UncompressedSize;
if (!StrFormatByteSizeW(Size, Buffer, _countof(Buffer))) if (!StrFormatByteSizeW(Size, Buffer, _countof(Buffer)))
return E_FAIL; return E_FAIL;
@ -183,8 +186,11 @@ public:
return SHSetStrRet(&psd->str, _AtlBaseModule.GetResourceInstance(), zipEntry->Password ? IDS_YES : IDS_NO); return SHSetStrRet(&psd->str, _AtlBaseModule.GetResourceInstance(), zipEntry->Password ? IDS_YES : IDS_NO);
case 5: /* Ratio */ case 5: /* Ratio */
{ {
if (isDir)
return SHSetStrRet(&psd->str, L"");
int ratio = 0; int ratio = 0;
if (zipEntry->UncompressedSize && !isDir) if (zipEntry->UncompressedSize)
ratio = 100 - (int)((zipEntry->CompressedSize*100)/zipEntry->UncompressedSize); ratio = 100 - (int)((zipEntry->CompressedSize*100)/zipEntry->UncompressedSize);
StringCchPrintfW(Buffer, _countof(Buffer), L"%d%%", ratio); StringCchPrintfW(Buffer, _countof(Buffer), L"%d%%", ratio);
return SHSetStrRet(&psd->str, Buffer); return SHSetStrRet(&psd->str, Buffer);

View file

@ -14,6 +14,8 @@ LPITEMIDLIST _ILCreate(ZipPidlType Type, LPCSTR lpString, unz_file_info64& info)
if (!pidl) if (!pidl)
return NULL; return NULL;
ZeroMemory(pidl, cbData + sizeof(WORD));
pidl->cb = cbData; pidl->cb = cbData;
pidl->MagicType = 'z'; pidl->MagicType = 'z';
pidl->ZipType = Type; pidl->ZipType = Type;