Skip to content

Commit

Permalink
Save RootFolder in settings
Browse files Browse the repository at this point in the history
  • Loading branch information
funap committed Aug 17, 2023
1 parent 7297560 commit 04c5387
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
8 changes: 4 additions & 4 deletions src/Explorer/ContextMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ UINT ContextMenu::ShowContextMenu(HINSTANCE hInst, HWND hWndNpp, HWND hWndParent
}
::AppendMenu(hMainMenu, MF_STRING, CTX_OPEN_CMD, _T("Open Command Window Here"));
::AppendMenu(hMainMenu, MF_STRING, CTX_SET_AS_ROOT_FOLDER, _T("Set as Root Folder"));
if (!exProp.rootDirectory.empty()) {
if (!exProp.rootFolder.empty()) {
::AppendMenu(hMainMenu, MF_STRING, CTX_GO_TO_ROOT_FOLDER, _T("Go to Root Folder"));
::AppendMenu(hMainMenu, MF_STRING, CTX_CLEAR_ROOT_FOLDER, _T("Clear Root Folder"));
}
Expand Down Expand Up @@ -827,18 +827,18 @@ void ContextMenu::setRootFolder()
}
}

exProp.rootDirectory = path;
exProp.rootFolder = path;
}

void ContextMenu::gotoRootFolder()
{
extern ExplorerDialog explorerDlg;
explorerDlg.gotoFileLocation(exProp.rootDirectory);
explorerDlg.gotoFileLocation(exProp.rootFolder);
}

void ContextMenu::clearRootFolder()
{
exProp.rootDirectory.clear();
exProp.rootFolder.clear();
}


Expand Down
12 changes: 8 additions & 4 deletions src/Explorer/Explorer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ constexpr WCHAR Faves[] = L"Faves";

/* section Explorer */
constexpr WCHAR LastPath[] = L"LastPath";
constexpr WCHAR RootFolder[] = L"RootFolder";
constexpr WCHAR SplitterPos[] = L"SplitterPos";
constexpr WCHAR SplitterPosHor[] = L"SplitterPosHor";
constexpr WCHAR SortAsc[] = L"SortAsc";
Expand Down Expand Up @@ -389,7 +390,9 @@ void loadSettings(void)
}
}

WCHAR temp[MAX_PATH]{};
::GetPrivateProfileString(Explorer, LastPath, _T("C:\\"), exProp.szCurrentPath, MAX_PATH, iniFilePath);
::GetPrivateProfileString(Explorer, RootFolder, L"", temp, MAX_PATH, iniFilePath); exProp.rootFolder.assign(temp);
exProp.iSplitterPos = ::GetPrivateProfileInt(Explorer, SplitterPos, 120, iniFilePath);
exProp.iSplitterPosHorizontal = ::GetPrivateProfileInt(Explorer, SplitterPosHor, 200, iniFilePath);
exProp.bAscending = ::GetPrivateProfileInt(Explorer, SortAsc, TRUE, iniFilePath);
Expand Down Expand Up @@ -458,6 +461,7 @@ void saveSettings(void)
WCHAR temp[256]{};

::WritePrivateProfileString(Explorer, LastPath, exProp.szCurrentPath, iniFilePath);
::WritePrivateProfileString(Explorer, RootFolder, exProp.rootFolder.c_str(), iniFilePath);
::WritePrivateProfileString(Explorer, SplitterPos, _itot(exProp.iSplitterPos, temp, 10), iniFilePath);
::WritePrivateProfileString(Explorer, SplitterPosHor, _itot(exProp.iSplitterPosHorizontal, temp, 10), iniFilePath);
::WritePrivateProfileString(Explorer, SortAsc, _itot(exProp.bAscending, temp, 10), iniFilePath);
Expand Down Expand Up @@ -531,8 +535,8 @@ void gotoUserFolder(void)
void gotoRootFolder(void)
{
explorerDlg.doDialog();
if (!exProp.rootDirectory.empty()) {
explorerDlg.gotoFileLocation(exProp.rootDirectory);
if (!exProp.rootFolder.empty()) {
explorerDlg.gotoFileLocation(exProp.rootFolder);
}
}

Expand Down Expand Up @@ -591,8 +595,8 @@ void openHelpDlg(void)

void openQuickOpenDlg(void)
{
if (!exProp.rootDirectory.empty()) {
quickOpenDlg.setRootPath(exProp.rootDirectory);
if (!exProp.rootFolder.empty()) {
quickOpenDlg.setRootPath(exProp.rootFolder);
}
else {
quickOpenDlg.setRootPath(exProp.szCurrentPath);
Expand Down
2 changes: 1 addition & 1 deletion src/Explorer/Explorer.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ struct CphProgram {
struct ExProp{
/* pointer to global current path */
WCHAR szCurrentPath[MAX_PATH] {};
std::wstring rootDirectory {};
std::wstring rootFolder {};
LOGFONT logfont {};
HFONT defaultFont = nullptr;
HFONT underlineFont = nullptr;
Expand Down

0 comments on commit 04c5387

Please sign in to comment.