OSDN Git Service

Add Help button handle and add Anchor at format patch for refbrowse button
[tortoisegit/TortoiseGitJp.git] / src / TortoiseProc / FormatPatchDlg.cpp
index 7528677..1d5baa5 100644 (file)
@@ -6,14 +6,19 @@
 #include "FormatPatchDlg.h"\r
 #include "git.h"\r
 #include "BrowseFolder.h"\r
+#include "LogDlg.h"\r
+#include "BrowseRefsDlg.h"\r
 // CFormatPatchDlg dialog\r
 \r
 IMPLEMENT_DYNAMIC(CFormatPatchDlg, CResizableStandAloneDialog)\r
 \r
 CFormatPatchDlg::CFormatPatchDlg(CWnd* pParent /*=NULL*/)\r
-       : CResizableStandAloneDialog(CFormatPatchDlg::IDD, pParent)\r
+       : CResizableStandAloneDialog(CFormatPatchDlg::IDD, pParent),\r
+       m_regSendMail(_T("Software\\TortoiseGit\\TortoiseProc\\FormatPatch\\SendMail"),0)\r
 {\r
        m_Num=1;\r
+       this->m_bSendMail = m_regSendMail;\r
+       this->m_Radio = IDC_RADIO_SINCE;\r
 }\r
 \r
 CFormatPatchDlg::~CFormatPatchDlg()\r
@@ -36,7 +41,7 @@ void CFormatPatchDlg::DoDataExchange(CDataExchange* pDX)
        DDX_Text(pDX, IDC_COMBOBOXEX_FROM,      m_From);\r
        DDX_Text(pDX, IDC_COMBOBOXEX_TO,        m_To);\r
        \r
-\r
+       DDX_Check(pDX, IDC_CHECK_SENDMAIL, m_bSendMail);\r
 }\r
 \r
 \r
@@ -48,6 +53,7 @@ BEGIN_MESSAGE_MAP(CFormatPatchDlg, CResizableStandAloneDialog)
        ON_BN_CLICKED(IDC_RADIO_SINCE, &CFormatPatchDlg::OnBnClickedRadio)\r
        ON_BN_CLICKED(IDC_RADIO_NUM, &CFormatPatchDlg::OnBnClickedRadio)\r
        ON_BN_CLICKED(IDC_RADIO_RANGE, &CFormatPatchDlg::OnBnClickedRadio)\r
+       ON_BN_CLICKED(IDC_BUTTON_REF, &CFormatPatchDlg::OnBnClickedButtonRef)\r
 END_MESSAGE_MAP()\r
 \r
 BOOL CFormatPatchDlg::OnInitDialog()\r
@@ -68,6 +74,13 @@ BOOL CFormatPatchDlg::OnInitDialog()
 \r
        AddAnchor(IDC_BUTTON_FROM,  TOP_RIGHT);\r
        AddAnchor(IDC_BUTTON_TO,        TOP_RIGHT);\r
+       AddAnchor(IDC_CHECK_SENDMAIL,BOTTOM_LEFT);\r
+       AddAnchor(IDOK,BOTTOM_RIGHT);\r
+       AddAnchor(IDCANCEL,BOTTOM_RIGHT);\r
+       AddAnchor(IDHELP, BOTTOM_RIGHT);\r
+       AddAnchor(IDC_BUTTON_REF,TOP_RIGHT);\r
+\r
+       this->AddOthersToAnchor();\r
 \r
        m_cDir.SetPathHistory(TRUE);\r
        m_cDir.LoadHistory(_T("Software\\TortoiseGit\\History\\FormatPatchURLS"), _T("path"));\r
@@ -75,18 +88,29 @@ BOOL CFormatPatchDlg::OnInitDialog()
 \r
        STRING_VECTOR list;\r
        g_Git.GetBranchList(list,NULL,CGit::BRANCH_ALL);\r
+       m_cSince.SetMaxHistoryItems(list.size());\r
        m_cSince.AddString(list);\r
 \r
+       if(!m_Since.IsEmpty())\r
+               m_cSince.SetWindowText(m_Since);\r
+\r
        m_cFrom.LoadHistory(_T("Software\\TortoiseGit\\History\\FormatPatchFromURLS"), _T("ver"));\r
        m_cFrom.SetCurSel(0);\r
 \r
+       if(!m_From.IsEmpty())\r
+               m_cFrom.SetWindowText(m_From);\r
+\r
        m_cTo.LoadHistory(_T("Software\\TortoiseGit\\History\\FormatPatchToURLS"), _T("ver"));\r
        m_cTo.SetCurSel(0);\r
 \r
-       this->CheckRadioButton(IDC_RADIO_SINCE,IDC_RADIO_RANGE,IDC_RADIO_SINCE);\r
+       if(!m_To.IsEmpty())\r
+               m_cTo.SetWindowText(m_To);\r
+\r
+       this->CheckRadioButton(IDC_RADIO_SINCE,IDC_RADIO_RANGE,this->m_Radio);\r
        \r
        OnBnClickedRadio();\r
 \r
+       EnableSaveRestore(_T("FormatPatchDlg"));\r
        return TRUE;\r
 }\r
 // CFormatPatchDlg message handlers\r
@@ -108,12 +132,38 @@ void CFormatPatchDlg::OnBnClickedButtonDir()
 \r
 void CFormatPatchDlg::OnBnClickedButtonFrom()\r
 {\r
-       // TODO: Add your control notification handler code here\r
+       CLogDlg dlg;\r
+       // tell the dialog to use mode for selecting revisions\r
+       dlg.SetSelect(true);\r
+       // only one revision must be selected however\r
+       dlg.SingleSelection(true);\r
+       if ( dlg.DoModal() == IDOK )\r
+       {\r
+               // get selected hash if any\r
+               CString selectedHash = dlg.GetSelectedHash();\r
+               // load into window, do this even if empty so that it is clear that nothing has been selected\r
+               m_cFrom.AddString(selectedHash);\r
+               CheckRadioButton(IDC_RADIO_SINCE, IDC_RADIO_RANGE, IDC_RADIO_RANGE);\r
+               OnBnClickedRadio();\r
+       }\r
 }\r
 \r
 void CFormatPatchDlg::OnBnClickedButtonTo()\r
 {\r
-       // TODO: Add your control notification handler code here\r
+       CLogDlg dlg;\r
+       // tell the dialog to use mode for selecting revisions\r
+       dlg.SetSelect(true);\r
+       // only one revision must be selected however\r
+       dlg.SingleSelection(true);\r
+       if ( dlg.DoModal() == IDOK )\r
+       {\r
+               // get selected hash if any\r
+               CString selectedHash = dlg.GetSelectedHash();\r
+               // load into window, do this even if empty so that it is clear that nothing has been selected\r
+               m_cTo.AddString(selectedHash);\r
+               CheckRadioButton(IDC_RADIO_SINCE, IDC_RADIO_RANGE, IDC_RADIO_RANGE);\r
+               OnBnClickedRadio();\r
+       }\r
 }\r
 \r
 void CFormatPatchDlg::OnBnClickedOk()\r
@@ -125,6 +175,8 @@ void CFormatPatchDlg::OnBnClickedOk()
        m_cTo.SaveHistory();\r
        this->UpdateData(TRUE);\r
        this->m_Radio=GetCheckedRadioButton(IDC_RADIO_SINCE,IDC_RADIO_RANGE);\r
+\r
+       m_regSendMail=this->m_bSendMail;\r
        OnOK();\r
 }\r
 \r
@@ -149,3 +201,12 @@ void CFormatPatchDlg::OnBnClickedRadio()
                m_cTo.EnableWindow(TRUE);\r
        }\r
 }\r
+\r
+void CFormatPatchDlg::OnBnClickedButtonRef()\r
+{\r
+       if(CBrowseRefsDlg::PickRefForCombo(&m_cSince, gPickRef_NoTag))\r
+       {\r
+               CheckRadioButton(IDC_RADIO_SINCE, IDC_RADIO_RANGE, IDC_RADIO_SINCE);\r
+               OnBnClickedRadio();\r
+       }\r
+}\r