OSDN Git Service

Send Mail Save attachment and combine status.
[tortoisegit/TortoiseGitJp.git] / src / TortoiseProc / SendMailDlg.cpp
index 47914da..1e78be1 100644 (file)
@@ -6,6 +6,8 @@
 #include "SendMailDlg.h"\r
 #include "MessageBox.h"\r
 #include "commonresource.h"\r
+#include "AppUtils.h"\r
+\r
 // CSendMailDlg dialog\r
 \r
 IMPLEMENT_DYNAMIC(CSendMailDlg, CResizableStandAloneDialog)\r
@@ -15,9 +17,12 @@ CSendMailDlg::CSendMailDlg(CWnd* pParent /*=NULL*/)
        , m_To(_T(""))\r
        , m_CC(_T(""))\r
        , m_Subject(_T(""))\r
-       , m_bAttachment(FALSE)\r
-       , m_bBranch(FALSE)\r
+       \r
+       , m_regAttach(_T("Software\\TortoiseGit\\TortoiseProc\\SendMail\\Attach"),0)\r
+       , m_regCombine(_T("Software\\TortoiseGit\\TortoiseProc\\SendMail\\Combine"),0)\r
 {\r
+       m_bAttachment  = m_regAttach;\r
+       m_bCombine =     m_regCombine;\r
 \r
 }\r
 \r
@@ -30,9 +35,8 @@ void CSendMailDlg::DoDataExchange(CDataExchange* pDX)
        CDialog::DoDataExchange(pDX);\r
        DDX_Text(pDX, IDC_SENDMAIL_TO, m_To);\r
        DDX_Text(pDX, IDC_SENDMAIL_CC, m_CC);\r
-       DDX_Text(pDX, IDC_SENDMAIL_SUBJECT, m_Subject);\r
        DDX_Check(pDX, IDC_SENDMAIL_ATTACHMENT, m_bAttachment);\r
-       DDX_Check(pDX, IDC_SENDMAIL_COMBINE, m_bBranch);\r
+       DDX_Check(pDX, IDC_SENDMAIL_COMBINE, m_bCombine);\r
        DDX_Control(pDX, IDC_SENDMAIL_PATCHS, m_ctrlList);\r
        DDX_Control(pDX,IDC_SENDMAIL_SETUP, this->m_SmtpSetup);\r
        DDX_Control(pDX,IDC_SENDMAIL_TO,m_ctrlTO);\r
@@ -43,6 +47,9 @@ void CSendMailDlg::DoDataExchange(CDataExchange* pDX)
 BEGIN_MESSAGE_MAP(CSendMailDlg, CResizableStandAloneDialog)\r
        ON_BN_CLICKED(IDC_SENDMAIL_COMBINE, &CSendMailDlg::OnBnClickedSendmailCombine)\r
        ON_BN_CLICKED(IDOK, &CSendMailDlg::OnBnClickedOk)\r
+       ON_NOTIFY(LVN_ITEMCHANGED, IDC_SENDMAIL_PATCHS, &CSendMailDlg::OnLvnItemchangedSendmailPatchs)\r
+       ON_NOTIFY(NM_DBLCLK, IDC_SENDMAIL_PATCHS, &CSendMailDlg::OnNMDblclkSendmailPatchs)\r
+       ON_EN_CHANGE(IDC_SENDMAIL_SUBJECT, &CSendMailDlg::OnEnChangeSendmailSubject)\r
 END_MESSAGE_MAP()\r
 \r
 \r
@@ -90,18 +97,26 @@ BOOL CSendMailDlg::OnInitDialog()
        \r
 //     m_ctrlCC.AddSearchString(_T("Tortoisegit-dev@google.com"));\r
 //     m_ctrlTO.AddSearchString(_T("Tortoisegit-dev@google.com"));\r
-\r
+       this->UpdateData(FALSE);\r
+       OnBnClickedSendmailCombine();\r
        return TRUE;\r
 }\r
 void CSendMailDlg::OnBnClickedSendmailCombine()\r
 {\r
        // TODO: Add your control notification handler code here\r
+       this->UpdateData();\r
+       this->GetDlgItem(IDC_SENDMAIL_SUBJECT)->EnableWindow(this->m_bCombine);\r
+       if(m_bCombine)\r
+               GetDlgItem(IDC_SENDMAIL_SUBJECT)->SetWindowText(this->m_Subject);\r
+\r
+       UpdateSubject();\r
 }\r
 \r
 void CSendMailDlg::OnBnClickedOk()\r
 {\r
        \r
        this->UpdateData();\r
+\r
        if(this->m_To.IsEmpty() && this->m_CC.IsEmpty())\r
        {\r
                CMessageBox::Show(NULL,IDS_ERR_ADDRESS_NO_EMPTY,IDS_APPNAME,MB_OK|MB_ICONERROR);\r
@@ -123,6 +138,79 @@ void CSendMailDlg::OnBnClickedOk()
                m_AddressReg.Save();\r
        }       \r
        \r
+       this->m_PathList.Clear();\r
+       for(int i=0;i<m_ctrlList.GetItemCount();i++)\r
+       {\r
+               CTGitPath path;\r
+               if(m_ctrlList.GetCheck(i))\r
+               {\r
+                       path.SetFromWin(m_ctrlList.GetItemText(i,0));\r
+                       this->m_PathList.AddPath(path);\r
+               }\r
+       }\r
+\r
+       m_regAttach=m_bAttachment;\r
+       m_regCombine=m_bCombine;\r
+\r
        OnOK();\r
        // TODO: Add your control notification handler code here\r
 }\r
+\r
+void CSendMailDlg::UpdateSubject()\r
+{\r
+       this->UpdateData();\r
+\r
+       if(!this->m_bCombine)\r
+       {\r
+               if(m_ctrlList.GetSelectedCount()==1)\r
+               {\r
+                       POSITION pos=m_ctrlList.GetFirstSelectedItemPosition();\r
+                       int index=m_ctrlList.GetNextSelectedItem(pos);\r
+                       if(this->m_MapPatch.find(index) == m_MapPatch.end() )\r
+                       {\r
+                               m_MapPatch[index].Parser(m_ctrlList.GetItemText(index,0));\r
+                       }\r
+                       GetDlgItem(IDC_SENDMAIL_SUBJECT)->SetWindowText(m_MapPatch[index].m_Subject);\r
+               }\r
+               else\r
+               {\r
+                       GetDlgItem(IDC_SENDMAIL_SUBJECT)->SetWindowText(_T(""));\r
+               }\r
+       }\r
+}\r
+\r
+void CSendMailDlg::OnLvnItemchangedSendmailPatchs(NMHDR *pNMHDR, LRESULT *pResult)\r
+{\r
+       LPNMLISTVIEW pNMLV = reinterpret_cast<LPNMLISTVIEW>(pNMHDR);\r
+       \r
+       UpdateSubject();\r
+       // TODO: Add your control notification handler code here\r
+       \r
+       *pResult = 0;\r
+}\r
+\r
+void CSendMailDlg::OnNMDblclkSendmailPatchs(NMHDR *pNMHDR, LRESULT *pResult)\r
+{\r
+       LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast<LPNMITEMACTIVATE>(pNMHDR);\r
+       // TODO: Add your control notification handler code here\r
+       CString path=this->m_ctrlList.GetItemText(pNMItemActivate->iItem,0);\r
+       CTGitPath gitpath;\r
+       gitpath.SetFromWin(path);\r
+       \r
+       CAppUtils::StartUnifiedDiffViewer(path,gitpath.GetFilename());\r
+\r
+       *pResult = 0;\r
+}\r
+\r
+void CSendMailDlg::OnEnChangeSendmailSubject()\r
+{\r
+       // TODO:  If this is a RICHEDIT control, the control will not\r
+       // send this notification unless you override the CResizableStandAloneDialog::OnInitDialog()\r
+       // function and call CRichEditCtrl().SetEventMask()\r
+       // with the ENM_CHANGE flag ORed into the mask.\r
+\r
+       // TODO:  Add your control notification handler code here\r
+       this->UpdateData();\r
+       if(this->m_bCombine)\r
+               GetDlgItem(IDC_SENDMAIL_SUBJECT)->GetWindowText(this->m_Subject);\r
+}\r