1 parent
5eda68a7a2
commit
9e287c3a1d
7 files changed
+154
-23
No files matched your search
+56
-7
@@ -331,6 +331,7 @@ FolderSize measureFolder(const fs::path &root,std::stop_token stop,const ListDir
|
||||
}
|
||||
|
||||
constexpr auto schemeKey = L"Software\\KSwitcher\\Files";
|
||||
#include "files_registry_json.inl"
|
||||
#include "files_ftp.inl"
|
||||
|
||||
|
||||
@@ -359,6 +360,8 @@ bool inLocalBranch(const fs::path &ancestor,fs::path directory)
|
||||
return false;
|
||||
}
|
||||
|
||||
#include "files_recent_folders.inl"
|
||||
|
||||
struct LocalNavigation
|
||||
{
|
||||
std::vector<fs::path> history;
|
||||
@@ -554,7 +557,12 @@ std::vector<size_t> commandAccessPositions;
|
||||
std::vector<int> commandActions;
|
||||
int menuIndex{};
|
||||
bool commandPicker{};
|
||||
struct FolderPicker { const wchar_t *caption; std::vector<fs::path> paths; };
|
||||
struct FolderPicker
|
||||
{
|
||||
const wchar_t *caption;
|
||||
std::vector<fs::path> paths;
|
||||
bool recent{};
|
||||
};
|
||||
std::optional<FolderPicker> folderPicker;
|
||||
constexpr int defaultSizeWidth=6, defaultFontPoints=110;
|
||||
constexpr bool defaultWide=false, defaultAlignExtensions=true, defaultShowDetails=true, defaultAlignFolders=false;
|
||||
@@ -2367,7 +2375,11 @@ bool applyDirectoryScan(Panel &panel,Panel::ScanRequest request,Panel::ScanResul
|
||||
panel.findOrigin.reset();
|
||||
}
|
||||
if(peer || request.ftp) panel.navigation={};
|
||||
else if(!finding) panel.navigation.opened(directory,request.navigationPosition);
|
||||
else if(!finding)
|
||||
{
|
||||
panel.navigation.opened(directory,request.navigationPosition);
|
||||
if(!sameDirectory && !panel.directory.empty() && !partial) updateRecentFolders(directory,true);
|
||||
}
|
||||
panel.directory = directory;
|
||||
panel.peer=std::move(peer);
|
||||
panel.ftp=std::move(request.ftp);
|
||||
@@ -2836,6 +2848,8 @@ void runActivePeerAction(HWND owner,bool update)
|
||||
}
|
||||
|
||||
LRESULT ftpDriveRow() {return static_cast<LRESULT>(drivePaths.size())+1;}
|
||||
LRESULT recentDriveRow() {return ftpDriveRow()+1;}
|
||||
void showRecentFolders(int side);
|
||||
|
||||
bool selectablePickerRow(LRESULT row)
|
||||
{
|
||||
@@ -2843,7 +2857,8 @@ bool selectablePickerRow(LRESULT row)
|
||||
if(folderPicker) return static_cast<size_t>(row)<folderPicker->paths.size();
|
||||
if(commandPicker)
|
||||
return static_cast<size_t>(row)<commandActions.size() && commandActions[row]>=0;
|
||||
return row<static_cast<LRESULT>(drivePaths.size()) || row==ftpDriveRow() || remoteDriveRows.contains(row);
|
||||
return row<static_cast<LRESULT>(drivePaths.size()) || row==ftpDriveRow() || row==recentDriveRow() ||
|
||||
remoteDriveRows.contains(row);
|
||||
}
|
||||
|
||||
void selectDrive()
|
||||
@@ -2895,6 +2910,7 @@ void selectDrive()
|
||||
}
|
||||
else setStatus(L"Cannot load saved FTP connections.");
|
||||
}
|
||||
else if(row==recentDriveRow()) showRecentFolders(pickerPanel);
|
||||
else if(remote!=remoteDriveRows.end())
|
||||
{
|
||||
const auto &choice=remote->second;
|
||||
@@ -2905,6 +2921,37 @@ void selectDrive()
|
||||
|
||||
LRESULT CALLBACK pickerKeys(HWND window, UINT msg, WPARAM wp, LPARAM lp, UINT_PTR, DWORD_PTR)
|
||||
{
|
||||
if(folderPicker && folderPicker->recent && msg==WM_KEYDOWN && wp==VK_DELETE)
|
||||
{
|
||||
const auto row=SendMessageW(window,LB_GETCURSEL,0,0);
|
||||
if(!selectablePickerRow(row)) return 0;
|
||||
auto &paths=folderPicker->paths;
|
||||
if(!updateRecentFolders(paths[row],false))
|
||||
{
|
||||
setStatus(L"Could not remove the recent folder.");
|
||||
return 0;
|
||||
}
|
||||
paths.erase(paths.begin()+row);
|
||||
SendMessageW(window,LB_DELETESTRING,row,0);
|
||||
if(paths.empty())
|
||||
{
|
||||
hidePicker();
|
||||
setStatus(L"No recent local folders.");
|
||||
}
|
||||
else SendMessageW(window,LB_SETCURSEL,std::min(row,static_cast<LRESULT>(paths.size()-1)),0);
|
||||
return 0;
|
||||
}
|
||||
if(folderPicker && msg==WM_LBUTTONUP)
|
||||
{
|
||||
const auto hit=SendMessageW(window,LB_ITEMFROMPOINT,0,lp);
|
||||
const auto result=DefSubclassProc(window,msg,wp,lp);
|
||||
if(folderPicker && !HIWORD(hit) && selectablePickerRow(LOWORD(hit)))
|
||||
{
|
||||
SendMessageW(window,LB_SETCURSEL,LOWORD(hit),0);
|
||||
selectDrive();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
if(msg==WM_KEYDOWN && (wp==VK_UP || wp==VK_DOWN))
|
||||
{
|
||||
const auto count=SendMessageW(window,LB_GETCOUNT,0,0);
|
||||
@@ -2989,7 +3036,7 @@ LRESULT CALLBACK pickerKeys(HWND window, UINT msg, WPARAM wp, LPARAM lp, UINT_PT
|
||||
if(!HIWORD(hit))
|
||||
{
|
||||
const auto choice=remoteDriveRows.find(LOWORD(hit));
|
||||
if(LOWORD(hit)<drivePaths.size() || LOWORD(hit)==ftpDriveRow() ||
|
||||
if(LOWORD(hit)<drivePaths.size() || LOWORD(hit)==ftpDriveRow() || LOWORD(hit)==recentDriveRow() ||
|
||||
(choice!=remoteDriveRows.end() && !choice->second.path &&
|
||||
driveWakeAction.hit(window,LOWORD(hit),lp,cellWidth)))
|
||||
row=LOWORD(hit);
|
||||
@@ -3113,7 +3160,7 @@ void showRemoteDrives(bool focus=false,int initialRow=0)
|
||||
auto selection=SendMessageW(picker,LB_GETCURSEL,0,0);
|
||||
std::optional<DriveChoice> previous;
|
||||
if(auto row=remoteDriveRows.find(selection);row!=remoteDriveRows.end()) previous=row->second;
|
||||
if(selection>ftpDriveRow()) selection=-1;
|
||||
if(selection>recentDriveRow()) selection=-1;
|
||||
if(focus) selection=initialRow;
|
||||
const auto top=SendMessageW(picker,LB_GETTOPINDEX,0,0);
|
||||
for(auto count=SendMessageW(picker,LB_GETCOUNT,0,0);count>static_cast<LRESULT>(drivePaths.size());--count)
|
||||
@@ -3126,6 +3173,7 @@ void showRemoteDrives(bool focus=false,int initialRow=0)
|
||||
};
|
||||
add(L"");
|
||||
add(L"FTP");
|
||||
add(L"Recent folders");
|
||||
add(L"KSwitcher LAN");
|
||||
if(!drivePeerLookupError.empty()) add(L" "+drivePeerLookupError);
|
||||
else if(driveQueries.empty()) add(L" No paired computers");
|
||||
@@ -7138,7 +7186,8 @@ LRESULT CALLBACK filesWindow(HWND window, UINT message, WPARAM wp, LPARAM lp)
|
||||
paintDialogFrameCaptions(item.hDC,item.rcItem,box,L"Change drive",teal,colors[Text],mono);
|
||||
}
|
||||
if(item.hwndItem==pickerFrame && folderPicker)
|
||||
paintDialogFrameCaptions(item.hDC,item.rcItem,box,folderPicker->caption,teal,colors[Text],mono);
|
||||
paintDialogFrameCaptions(item.hDC,item.rcItem,box,folderPicker->caption,teal,colors[Text],mono,
|
||||
folderPicker->recent?L"Del Remove":nullptr);
|
||||
const auto list=item.hwndItem==pickerFrame?picker:completionList;
|
||||
paintScrollPosition(item.hwndItem,item.hDC,list,colors[Dialog]);
|
||||
DeleteObject(border);
|
||||
@@ -7186,7 +7235,7 @@ LRESULT CALLBACK filesWindow(HWND window, UINT message, WPARAM wp, LPARAM lp)
|
||||
FillRect(item.hDC,&line,static_cast<HBRUSH>(GetStockObject(DC_BRUSH)));
|
||||
return TRUE;
|
||||
}
|
||||
if(item.hwndItem==picker && !commandPicker && !folderPicker && item.itemID==ftpDriveRow()+1)
|
||||
if(item.hwndItem==picker && !commandPicker && !folderPicker && item.itemID==recentDriveRow()+1)
|
||||
{
|
||||
auto row=item.rcItem;
|
||||
FillRect(item.hDC,&row,teal);
|
||||
|
||||
Reference in new issue
Block a user