From 2845749eb5106f0acf4c918e2be39ca82065e511 Mon Sep 17 00:00:00 2001 From: Sup Yut Sum Date: Mon, 7 Jul 2014 18:50:39 +0800 Subject: [PATCH] If only one path is specified like it would happen if someone used the "open with" feature in explorer, pre-fill that path in the "open" dialog Based on TortoiseSVN revision 25657 Signed-off-by: Sup Yut Sum --- src/TortoiseMerge/MainFrm.cpp | 9 ++++++++- src/TortoiseMerge/MainFrm.h | 2 ++ src/TortoiseMerge/TortoiseMerge.cpp | 11 ++++++++++- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/TortoiseMerge/MainFrm.cpp b/src/TortoiseMerge/MainFrm.cpp index 63705fcc3..b13b2fcc0 100644 --- a/src/TortoiseMerge/MainFrm.cpp +++ b/src/TortoiseMerge/MainFrm.cpp @@ -735,8 +735,15 @@ void CMainFrame::OnFileOpen() { if (CheckForSave(CHFSR_OPEN)==IDCANCEL) return; + return OnFileOpen(false); +} + +void CMainFrame::OnFileOpen(bool fillyours) +{ COpenDlg dlg; - if (dlg.DoModal()!=IDOK) + if (fillyours) + dlg.m_sBaseFile = m_Data.m_yourFile.GetFilename(); + if (dlg.DoModal() != IDOK) { return; } diff --git a/src/TortoiseMerge/MainFrm.h b/src/TortoiseMerge/MainFrm.h index b88de2a79..cd6736389 100644 --- a/src/TortoiseMerge/MainFrm.h +++ b/src/TortoiseMerge/MainFrm.h @@ -81,6 +81,8 @@ protected: afx_msg void OnFileSave(); afx_msg void OnFileSaveAs(); afx_msg void OnFileOpen(); + afx_msg void OnFileOpen(bool fillyours); + afx_msg void OnFileReload(); afx_msg void OnClose(); afx_msg void OnActivate(UINT, CWnd*, BOOL); diff --git a/src/TortoiseMerge/TortoiseMerge.cpp b/src/TortoiseMerge/TortoiseMerge.cpp index e090e8ed2..4c344181d 100644 --- a/src/TortoiseMerge/TortoiseMerge.cpp +++ b/src/TortoiseMerge/TortoiseMerge.cpp @@ -449,6 +449,15 @@ BOOL CTortoiseMergeApp::InitInstance() } } } + else if (nArgs == 2) + { + // only one path specified: use it to fill the "open" dialog + if (PathFileExists(szArglist[1])) + { + pFrame->m_Data.m_yourFile.SetFileName(szArglist[1]); + pFrame->m_Data.m_yourFile.StoreFileAttributes(); + } + } } // Free memory allocated for CommandLineToArgvW arguments. @@ -496,7 +505,7 @@ BOOL CTortoiseMergeApp::InitInstance() pFrame->ShowDiffBar(!pFrame->m_bOneWay); if (!pFrame->m_Data.IsBaseFileInUse() && pFrame->m_Data.m_sPatchPath.IsEmpty() && pFrame->m_Data.m_sDiffFile.IsEmpty()) { - pFrame->OnFileOpen(); + pFrame->OnFileOpen(pFrame->m_Data.m_yourFile.InUse()); return TRUE; } -- 2.11.4.GIT