Fixed issue #3304: Double click on stash list item does nothing, show log instead
[TortoiseGit.git] / src / TortoiseProc / CommitDlg.h
blobb3c445be44c928e5c5f2aa9feddf7926dfe79158
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2003-2008 - TortoiseSVN
4 // Copyright (C) 2008-2018 - TortoiseGit
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License
8 // as published by the Free Software Foundation; either version 2
9 // of the License, or (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software Foundation,
18 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #pragma once
22 #include "StandAloneDlg.h"
23 #include "GitStatusListCtrl.h"
24 #include "RegHistory.h"
25 #include "registry.h"
26 #include "SciEdit.h"
27 #include "SplitterControl.h"
28 #include "LinkControl.h"
29 #include "PathWatcher.h"
30 #include "BugTraqAssociations.h"
31 #include "../IBugTraqProvider/IBugTraqProvider_h.h"
32 #include "HyperLink.h"
33 #include "PatchViewDlg.h"
34 #include "MenuButton.h"
36 #include <regex>
38 #define ENDDIALOGTIMER 100
39 #define REFRESHTIMER 101
40 #define FILLPATCHVTIMER 102
42 typedef enum
44 GIT_POSTCOMMIT_CMD_NOTHING,
45 GIT_POSTCOMMIT_CMD_RECOMMIT,
46 GIT_POSTCOMMIT_CMD_PUSH,
47 GIT_POSTCOMMIT_CMD_DCOMMIT,
48 GIT_POSTCOMMIT_CMD_PULL,
49 GIT_POSTCOMMIT_CMD_CREATETAG,
50 } GIT_POSTCOMMIT_CMD;
53 /**
54 * \ingroup TortoiseProc
55 * Dialog to enter log messages used in a commit.
57 class CCommitDlg : public CResizableStandAloneDialog, public CSciEditContextMenuInterface, IHasPatchView
59 DECLARE_DYNAMIC(CCommitDlg)
61 public:
62 CCommitDlg(CWnd* pParent = nullptr); // standard constructor
63 virtual ~CCommitDlg();
65 protected:
66 // CSciEditContextMenuInterface
67 virtual void InsertMenuItems(CMenu& mPopup, int& nCmd) override;
68 virtual bool HandleMenuItemClick(int cmd, CSciEdit* pSciEdit) override;
69 virtual void HandleSnippet(int type, const CString& text, CSciEdit* pSciEdit) override;
71 public:
72 void ShowViewPatchText(bool b=true)
74 if(b)
75 this->m_ctrlShowPatch.SetWindowText(CString(MAKEINTRESOURCE(IDS_PROC_COMMIT_SHOWPATCH)));
76 else
77 this->m_ctrlShowPatch.SetWindowText(CString(MAKEINTRESOURCE(IDS_PROC_COMMIT_HIDEPATCH)));
79 m_ctrlShowPatch.Invalidate();
81 void SetAuthor(CString author)
83 m_bSetAuthor = TRUE;
84 m_sAuthor = author;
86 void SetTime(CTime time)
88 m_bSetCommitDateTime = TRUE;
89 m_wantCommitTime = time;
91 private:
92 CTime m_wantCommitTime;
93 void ReloadHistoryEntries();
94 static UINT StatusThreadEntry(LPVOID pVoid);
95 UINT StatusThread();
96 void FillPatchView(bool onlySetTimer = false);
97 CWnd * GetPatchViewParentWnd() { return this; }
98 void TogglePatchView();
99 void SetDlgTitle();
100 CString GetSignedOffByLine();
101 CString m_sTitle;
103 // Dialog Data
104 enum { IDD = IDD_COMMITDLG };
106 protected:
107 virtual void DoDataExchange(CDataExchange* pDX) override; // DDX/DDV support
109 virtual BOOL OnInitDialog() override;
110 virtual void OnOK() override;
111 virtual void OnCancel() override;
112 virtual BOOL PreTranslateMessage(MSG* pMsg) override;
113 virtual LRESULT DefWindowProc(UINT message, WPARAM wParam, LPARAM lParam) override;
114 afx_msg void OnBnClickedShowunversioned();
115 afx_msg void OnBnClickedHistory();
116 afx_msg void OnBnClickedBugtraqbutton();
117 afx_msg void OnEnChangeLogmessage();
118 afx_msg void OnStnClickedExternalwarning();
119 afx_msg void OnFocusMessage();
120 afx_msg void OnFocusFileList();
121 afx_msg LRESULT OnGitStatusListCtrlItemCountChanged(WPARAM, LPARAM);
122 afx_msg LRESULT OnGitStatusListCtrlNeedsRefresh(WPARAM, LPARAM);
123 afx_msg LRESULT OnGitStatusListCtrlCheckChanged(WPARAM, LPARAM);
124 afx_msg LRESULT OnGitStatusListCtrlItemChanged(WPARAM, LPARAM);
125 afx_msg void OnSysColorChange();
127 afx_msg LRESULT OnCheck(WPARAM count, LPARAM);
128 afx_msg LRESULT OnAutoListReady(WPARAM, LPARAM);
129 afx_msg LRESULT OnUpdateOKButton(WPARAM, LPARAM);
130 afx_msg LRESULT OnUpdateDataFalse(WPARAM, LPARAM);
131 afx_msg LRESULT OnFileDropped(WPARAM, LPARAM lParam);
132 afx_msg void OnTimer(UINT_PTR nIDEvent);
133 afx_msg void OnSize(UINT nType, int cx, int cy);
134 void Refresh();
135 void StartStatusThread();
136 void StopStatusThread();
137 void GetAutocompletionList(std::map<CString, int>& autolist);
138 void ScanFile(std::map<CString, int>& autolist, const CString& sFilePath, const CString& sRegex, const CString& sExt);
139 void DoSize(int delta);
140 void SetSplitterRange();
141 void SaveSplitterPos();
142 void UpdateCheckLinks();
143 void ParseRegexFile(const CString& sFile, std::map<CString, CString>& mapRegex);
144 void ParseSnippetFile(const CString& sFile, std::map<CString, CString>& mapSnippet);
145 bool RunStartCommitHook();
147 DECLARE_MESSAGE_MAP()
149 public:
150 CString m_sLogMessage;
151 BOOL m_bKeepChangeList;
152 BOOL m_bDoNotAutoselectSubmodules;
153 bool m_bForceCommitAmend;
154 BOOL m_bCommitAmend;
155 BOOL m_bNoPostActions;
156 bool m_bSelectFilesForCommit;
157 bool m_bAutoClose;
158 CString m_AmendStr;
159 CString m_sBugID;
160 BOOL m_bWholeProject;
161 BOOL m_bWholeProject2;
162 CTGitPathList m_pathList;
163 GIT_POSTCOMMIT_CMD m_PostCmd;
164 BOOL m_bAmendDiffToLastCommit;
165 BOOL m_bCommitMessageOnly;
166 bool m_bWarnDetachedHead;
168 protected:
169 CTGitPathList m_selectedPathList;
170 CSciEdit m_cLogMessage;
171 INT_PTR m_itemsCount;
172 CComPtr<IBugTraqProvider> m_BugTraqProvider;
173 CString m_NoAmendStr;
174 BOOL m_bCreateNewBranch;
175 CString m_sCreateNewBranch;
176 BOOL m_bSetAuthor;
177 CString m_sAuthor;
178 volatile bool m_bDoNotStoreLastSelectedLine; // true on first start of commit dialog and set on recommit
180 int CheckHeadDetach();
182 private:
183 CWinThread* m_pThread;
184 std::map<CString, CString> m_snippet;
185 CGitStatusListCtrl m_ListCtrl;
186 BOOL m_bShowUnversioned;
187 volatile LONG m_bBlock;
188 volatile LONG m_bThreadRunning;
189 volatile LONG m_bRunThread;
190 CRegDWORD m_regAddBeforeCommit;
191 CRegDWORD m_regKeepChangelists;
192 CRegDWORD m_regDoNotAutoselectSubmodules;
193 CRegDWORD m_regShowWholeProject;
194 ProjectProperties m_ProjectProperties;
195 CString m_sWindowTitle;
196 static UINT WM_AUTOLISTREADY;
197 static UINT WM_UPDATEOKBUTTON;
198 static UINT WM_UPDATEDATAFALSE;
199 int m_nPopupPickCommitHash;
200 int m_nPopupPickCommitMessage;
201 int m_nPopupPasteListCmd;
202 int m_nPopupPasteLastMessage;
203 int m_nPopupRecentMessage;
204 CRegHistory m_History;
205 bool m_bCancelled;
206 CSplitterControl m_wndSplitter;
207 CRect m_DlgOrigRect;
208 CRect m_LogMsgOrigRect;
209 CPathWatcher m_pathwatcher;
210 CHyperLink m_ctrlShowPatch;
211 CPatchViewDlg m_patchViewdlg;
212 BOOL m_bSetCommitDateTime;
213 CDateTimeCtrl m_CommitDate;
214 CDateTimeCtrl m_CommitTime;
215 CButton m_AsCommitDateCtrl;
216 CLinkControl m_linkControl;
217 CString m_sLogTemplate;
218 CMenuButton m_ctrlOkButton;
219 CRegDWORD m_regLastAction;
220 void PrepareOkButton();
221 typedef struct
223 int id;
224 int cnt;
225 int wmid;
226 } ACCELLERATOR;
227 std::map<TCHAR, ACCELLERATOR> m_accellerators;
228 HACCEL m_hAccelOkButton;
230 CBugTraqAssociation m_bugtraq_association;
231 HACCEL m_hAccel;
232 bool RestoreFiles(bool doNotAsk = false, bool allowCancel = true);
234 protected:
235 afx_msg void OnBnClickedSignOff();
236 afx_msg void OnBnClickedCommitAmend();
237 afx_msg void OnBnClickedCommitMessageOnly();
238 afx_msg void OnBnClickedWholeProject();
239 afx_msg void OnScnUpdateUI(NMHDR *pNMHDR, LRESULT *pResult);
240 afx_msg void OnStnClickedViewPatch();
241 afx_msg void OnMoving(UINT fwSide, LPRECT pRect);
242 afx_msg void OnSizing(UINT fwSide, LPRECT pRect);
243 afx_msg void OnHdnItemchangedFilelist(NMHDR *pNMHDR, LRESULT *pResult);
244 afx_msg void OnBnClickedCommitAmenddiff();
245 afx_msg void OnBnClickedNoautoselectsubmodules();
246 afx_msg void OnBnClickedCommitSetDateTime();
247 afx_msg void OnBnClickedCommitAsCommitDate();
248 afx_msg void OnBnClickedCheckNewBranch();
249 afx_msg void OnBnClickedCommitSetauthor();
251 CLinkControl m_CheckAll;
252 CLinkControl m_CheckNone;
253 CLinkControl m_CheckUnversioned;
254 CLinkControl m_CheckVersioned;
255 CLinkControl m_CheckAdded;
256 CLinkControl m_CheckDeleted;
257 CLinkControl m_CheckModified;
258 CLinkControl m_CheckFiles;
259 CLinkControl m_CheckSubmodules;