OSDN Git Service

PATCH: [ 1144545 ] Project Handling Patch3 (remember last valid project path)
authorKimmo Varis <kimmov@gmail.com>
Mon, 28 Feb 2005 20:39:15 +0000 (20:39 +0000)
committerKimmo Varis <kimmov@gmail.com>
Mon, 28 Feb 2005 20:39:15 +0000 (20:39 +0000)
 - submitted by Andreas Morsing

Src/MainFrm.cpp
Src/OpenDlg.cpp
Src/OptionsDef.h
Src/readme.txt

index 536bf4e..5b352dd 100644 (file)
@@ -226,6 +226,8 @@ CMainFrame::CMainFrame()
        m_options.InitOption(OPT_CLR_SELECTED_MOVEDBLOCK_DELETED, (int)RGB(252, 181, 163));
        m_options.InitOption(OPT_CLR_SELECTED_MOVEDBLOCK_TEXT, (int)RGB(0,0,0));
 
+       m_options.InitOption(OPT_PROJECTS_PATH,_T(""));
+
        // Overwrite WinMerge 2.0 default colors with new colors
        if (m_options.GetInt(OPT_CLR_DIFF) == RGB(255,255,92))
                m_options.SaveOption(OPT_CLR_DIFF, (int)RGB(239,203,5));
@@ -2710,12 +2712,24 @@ void CMainFrame::OnFileOpenproject()
        CString strFileExt;
        strFileExt.LoadString(IDS_PROJECTFILES_EXT);
        CFileDialog dlg(true,strFileExt,0,0,strFileFilter);
+       
+       // get the default projects path
+       CString strProjectPath = m_options.GetString(OPT_PROJECTS_PATH);
+       // set the initial directory to the projects path if present
+       if (!strProjectPath.IsEmpty())
+               dlg.m_ofn.lpstrInitialDir = strProjectPath;
 
        if (dlg.DoModal() != IDOK)
                return;
        
+       // get the path part from the filename
+       CString strFileName = dlg.GetPathName();
+       strProjectPath = paths_GetParentPath(strFileName);
+       // store this as the new project path
+       m_options.SaveOption(OPT_PROJECTS_PATH,strProjectPath);
+
        CStringArray files;
-       files.Add(dlg.GetPathName());
+       files.Add(strFileName);
        files.Add("");
        
        BOOL bRecursive = true;
index 6686e0c..7ff32ea 100644 (file)
@@ -600,10 +600,25 @@ void COpenDlg::OnSaveProjectButton()
        strFileExt.LoadString(IDS_PROJECTFILES_EXT);
        // show a fileopen dialog with the WinMerge extension
        CFileDialog dlg(false,strFileExt,0,0,strFileFilter);
+       
+       // get the default projects path
+       CMainFrame* pFrame = (CMainFrame*) theApp.m_pMainWnd;
+       CString strProjectPath = pFrame->m_options.GetString(OPT_PROJECTS_PATH);
+       // set the initial directory to the projects path if present
+       if (!strProjectPath.IsEmpty())
+               dlg.m_ofn.lpstrInitialDir = strProjectPath;
+
        if (dlg.DoModal() != IDOK)
                return;
+
+       // get the path part from the filename
+       CString strFileName = dlg.GetPathName();
+       strProjectPath = paths_GetParentPath(strFileName);
+       // store this as the new project path
+       pFrame->m_options.SaveOption(OPT_PROJECTS_PATH,strProjectPath);
+
        //get the chosen filename
-       CString strProjectFileName = dlg.GetPathName();
+       CString strProjectFileName = strFileName;
 
        // If prefix found from start..
        if (strExt.Find(filterPrefix, 0) == 0)
index d0b4be9..80d5646 100644 (file)
@@ -47,6 +47,8 @@ const TCHAR OPT_CP_DEFAULT_MODE[] = _T("Settings/CodepageDefaultMode");
 const TCHAR OPT_CP_DEFAULT_CUSTOM[] = _T("Settings/CodepageDefaultCustomValue");
 const TCHAR OPT_CP_DETECT[] = _T("Settings/CodepageDetection");
 
+const TCHAR OPT_PROJECTS_PATH[] =  _T("Settings/ProjectsPath");
+
 // Color options
 // The difference color
 const TCHAR OPT_CLR_DIFF[] = _T("Settings/DifferenceColor");
index 25c4087..d064aa9 100644 (file)
@@ -1,6 +1,9 @@
 2005-02-28 Kimmo
  PATCH: [ 1153091 ] Fix selecting default font from View menu
   Src: MainFrm.cpp MainFrm.h OptionsDef.h
+ PATCH: [ 1144545 ] Project Handling Patch3 (remember last valid project path)
+  Submitted by Andreas Morsing
+  Src: MainFrm.cpp OpenDlg.cpp OptionsDef.h
 
 2005-02-28 Perry
  BUG: [ 1039158 ] Confusing EOL differences messagebox