1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2012-2015 - TortoiseGit
4 // Copyright (C) 2009-2011, 2013 - TortoiseSVN
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.
22 #include "TortoiseProc.h"
23 #include "SettingsAdvanced.h"
27 IMPLEMENT_DYNAMIC(CSettingsAdvanced
, ISettingsPropPage
)
29 CSettingsAdvanced::CSettingsAdvanced()
30 : ISettingsPropPage(CSettingsAdvanced::IDD
)
33 settings
[i
].sName
= L
"AutoCompleteMinChars";
34 settings
[i
].type
= CSettingsAdvanced::SettingTypeNumber
;
35 settings
[i
++].def
.l
= 3;
37 settings
[i
].sName
= L
"AutocompleteRemovesExtensions";
38 settings
[i
].type
= CSettingsAdvanced::SettingTypeBoolean
;
39 settings
[i
++].def
.b
= false;
41 settings
[i
].sName
= L
"BlockStatus";
42 settings
[i
].type
= CSettingsAdvanced::SettingTypeBoolean
;
43 settings
[i
++].def
.b
= false;
45 settings
[i
].sName
= L
"CacheTrayIcon";
46 settings
[i
].type
= CSettingsAdvanced::SettingTypeBoolean
;
47 settings
[i
++].def
.b
= false;
49 settings
[i
].sName
= L
"CacheSave";
50 settings
[i
].type
= CSettingsAdvanced::SettingTypeBoolean
;
51 settings
[i
++].def
.b
= true;
53 settings
[i
].sName
= L
"CygwinHack";
54 settings
[i
].type
= CSettingsAdvanced::SettingTypeBoolean
;
55 settings
[i
++].def
.b
= false;
57 settings
[i
].sName
= L
"Debug";
58 settings
[i
].type
= CSettingsAdvanced::SettingTypeBoolean
;
59 settings
[i
++].def
.b
= false;
61 settings
[i
].sName
= L
"DebugOutputString";
62 settings
[i
].type
= CSettingsAdvanced::SettingTypeBoolean
;
63 settings
[i
++].def
.b
= false;
65 settings
[i
].sName
= L
"DiffBlamesWithTortoiseMerge";
66 settings
[i
].type
= CSettingsAdvanced::SettingTypeBoolean
;
67 settings
[i
++].def
.b
= false;
69 settings
[i
].sName
= L
"FullRowSelect";
70 settings
[i
].type
= CSettingsAdvanced::SettingTypeBoolean
;
71 settings
[i
++].def
.b
= true;
73 settings
[i
].sName
= L
"GroupTaskbarIconsPerRepo";
74 settings
[i
].type
= CSettingsAdvanced::SettingTypeNumber
;
75 settings
[i
++].def
.l
= 3;
77 settings
[i
].sName
= L
"GroupTaskbarIconsPerRepoOverlay";
78 settings
[i
].type
= CSettingsAdvanced::SettingTypeBoolean
;
79 settings
[i
++].def
.b
= true;
81 settings
[i
].sName
= L
"LogIncludeBoundaryCommits";
82 settings
[i
].type
= CSettingsAdvanced::SettingTypeBoolean
;
83 settings
[i
++].def
.b
= false;
85 settings
[i
].sName
= L
"MaxRefHistoryItems";
86 settings
[i
].type
= CSettingsAdvanced::SettingTypeNumber
;
87 settings
[i
++].def
.l
= 5;
89 settings
[i
].sName
= L
"Msys2Hack";
90 settings
[i
].type
= CSettingsAdvanced::SettingTypeBoolean
;
91 settings
[i
++].def
.b
= false;
93 settings
[i
].sName
= L
"NoSortLocalBranchesFirst";
94 settings
[i
].type
= CSettingsAdvanced::SettingTypeBoolean
;
95 settings
[i
++].def
.b
= false;
97 settings
[i
].sName
= L
"NumDiffWarning";
98 settings
[i
].type
= CSettingsAdvanced::SettingTypeNumber
;
99 settings
[i
++].def
.l
= 10;
101 settings
[i
].sName
= L
"ReaddUnselectedAddedFilesAfterCommit";
102 settings
[i
].type
= CSettingsAdvanced::SettingTypeBoolean
;
103 settings
[i
++].def
.b
= true;
105 settings
[i
].sName
= L
"RefreshFileListAfterResolvingConflict";
106 settings
[i
].type
= CSettingsAdvanced::SettingTypeBoolean
;
107 settings
[i
++].def
.b
= true;
109 settings
[i
].sName
= L
"SanitizeCommitMsg";
110 settings
[i
].type
= CSettingsAdvanced::SettingTypeBoolean
;
111 settings
[i
++].def
.b
= true;
113 settings
[i
].sName
= L
"ScintillaDirect2D";
114 settings
[i
].type
= CSettingsAdvanced::SettingTypeBoolean
;
115 settings
[i
++].def
.b
= false;
117 settings
[i
].sName
= L
"ShellMenuAccelerators";
118 settings
[i
].type
= CSettingsAdvanced::SettingTypeBoolean
;
119 settings
[i
++].def
.b
= true;
121 settings
[i
].sName
= L
"ShowContextMenuIcons";
122 settings
[i
].type
= CSettingsAdvanced::SettingTypeBoolean
;
123 settings
[i
++].def
.b
= true;
125 settings
[i
].sName
= L
"ShowAppContextMenuIcons";
126 settings
[i
].type
= CSettingsAdvanced::SettingTypeBoolean
;
127 settings
[i
++].def
.b
= true;
129 settings
[i
].sName
= L
"ShowListBackgroundImage";
130 settings
[i
].type
= CSettingsAdvanced::SettingTypeBoolean
;
131 settings
[i
++].def
.b
= true;
133 settings
[i
].sName
= L
"StyleCommitMessages";
134 settings
[i
].type
= CSettingsAdvanced::SettingTypeBoolean
;
135 settings
[i
++].def
.b
= true;
137 settings
[i
].sName
= L
"TGitCacheCheckContent";
138 settings
[i
].type
= CSettingsAdvanced::SettingTypeBoolean
;
139 settings
[i
++].def
.b
= true;
141 settings
[i
].sName
= L
"TGitCacheCheckContentMaxSize";
142 settings
[i
].type
= CSettingsAdvanced::SettingTypeNumber
;
143 settings
[i
++].def
.l
= 10 * 1024;
145 settings
[i
].sName
= L
"UseLibgit2";
146 settings
[i
].type
= CSettingsAdvanced::SettingTypeBoolean
;
147 settings
[i
++].def
.b
= true;
149 settings
[i
].sName
= L
"VersionCheck";
150 settings
[i
].type
= CSettingsAdvanced::SettingTypeBoolean
;
151 settings
[i
++].def
.b
= true;
153 settings
[i
].sName
= L
"VersionCheckPreview";
154 settings
[i
].type
= CSettingsAdvanced::SettingTypeBoolean
;
155 settings
[i
++].def
.b
= false;
157 settings
[i
].sName
= L
"";
158 settings
[i
].type
= CSettingsAdvanced::SettingTypeNone
;
159 settings
[i
++].def
.b
= false;
162 CSettingsAdvanced::~CSettingsAdvanced()
166 void CSettingsAdvanced::DoDataExchange(CDataExchange
* pDX
)
168 ISettingsPropPage::DoDataExchange(pDX
);
169 DDX_Control(pDX
, IDC_CONFIG
, m_ListCtrl
);
173 BEGIN_MESSAGE_MAP(CSettingsAdvanced
, ISettingsPropPage
)
174 ON_NOTIFY(LVN_BEGINLABELEDIT
, IDC_CONFIG
, &CSettingsAdvanced::OnLvnBeginlabeledit
)
175 ON_NOTIFY(LVN_ENDLABELEDIT
, IDC_CONFIG
, &CSettingsAdvanced::OnLvnEndlabeledit
)
176 ON_NOTIFY(NM_DBLCLK
, IDC_CONFIG
, &CSettingsAdvanced::OnNMDblclkConfig
)
180 BOOL
CSettingsAdvanced::OnInitDialog()
182 ISettingsPropPage::OnInitDialog();
184 m_ListCtrl
.DeleteAllItems();
185 int c
= ((CHeaderCtrl
*)(m_ListCtrl
.GetDlgItem(0)))->GetItemCount() - 1;
187 m_ListCtrl
.DeleteColumn(c
--);
189 SetWindowTheme(m_ListCtrl
.GetSafeHwnd(), L
"Explorer", NULL
);
192 temp
.LoadString(IDS_SETTINGS_CONF_VALUECOL
);
193 m_ListCtrl
.InsertColumn(0, temp
);
194 temp
.LoadString(IDS_SETTINGS_CONF_NAMECOL
);
195 m_ListCtrl
.InsertColumn(1, temp
);
197 m_ListCtrl
.SetRedraw(FALSE
);
200 while (settings
[i
].type
!= SettingTypeNone
)
202 m_ListCtrl
.InsertItem(i
, settings
[i
].sName
);
203 m_ListCtrl
.SetItemText(i
, 1, settings
[i
].sName
);
204 switch (settings
[i
].type
)
206 case SettingTypeBoolean
:
208 CRegDWORD
s(_T("Software\\TortoiseGit\\") + settings
[i
].sName
, settings
[i
].def
.b
);
209 m_ListCtrl
.SetItemText(i
, 0, DWORD(s
) ? _T("true") : _T("false"));
212 case SettingTypeNumber
:
214 CRegDWORD
s(_T("Software\\TortoiseGit\\") + settings
[i
].sName
, settings
[i
].def
.l
);
215 temp
.Format(_T("%ld"), (DWORD
)s
);
216 m_ListCtrl
.SetItemText(i
, 0, temp
);
219 case SettingTypeString
:
221 CRegString
s(_T("Software\\TortoiseGit\\") + settings
[i
].sName
, settings
[i
].def
.s
);
222 m_ListCtrl
.SetItemText(i
, 0, CString(s
));
230 int maxcol
= ((CHeaderCtrl
*)(m_ListCtrl
.GetDlgItem(0)))->GetItemCount() - 1;
232 for (col
= mincol
; col
<= maxcol
; ++col
)
234 m_ListCtrl
.SetColumnWidth(col
, LVSCW_AUTOSIZE_USEHEADER
);
237 m_ListCtrl
.SetColumnOrderArray(2, arr
);
238 m_ListCtrl
.SetRedraw(TRUE
);
243 BOOL
CSettingsAdvanced::OnApply()
246 while (settings
[i
].type
!= SettingTypeNone
)
248 CString sValue
= m_ListCtrl
.GetItemText(i
, 0);
249 switch (settings
[i
].type
)
251 case SettingTypeBoolean
:
253 CRegDWORD
s(_T("Software\\TortoiseGit\\") + settings
[i
].sName
, settings
[i
].def
.b
);
254 if (sValue
.IsEmpty())
258 DWORD newValue
= sValue
.Compare(_T("true")) == 0;
259 if (DWORD(s
) != newValue
)
266 case SettingTypeNumber
:
268 CRegDWORD
s(_T("Software\\TortoiseGit\\") + settings
[i
].sName
, settings
[i
].def
.l
);
269 if (DWORD(_tstol(sValue
)) != DWORD(s
))
275 case SettingTypeString
:
277 CRegString
s(_T("Software\\TortoiseGit\\") + settings
[i
].sName
, settings
[i
].def
.s
);
278 if (sValue
.Compare(CString(s
)))
288 return ISettingsPropPage::OnApply();
291 void CSettingsAdvanced::OnLvnBeginlabeledit(NMHDR
* /*pNMHDR*/, LRESULT
*pResult
)
296 void CSettingsAdvanced::OnLvnEndlabeledit(NMHDR
*pNMHDR
, LRESULT
*pResult
)
298 NMLVDISPINFO
*pDispInfo
= reinterpret_cast<NMLVDISPINFO
*>(pNMHDR
);
300 if (pDispInfo
->item
.pszText
== NULL
)
303 bool allowEdit
= false;
304 switch (settings
[pDispInfo
->item
.iItem
].type
)
306 case SettingTypeBoolean
:
308 if ((pDispInfo
->item
.pszText
[0] == 0) ||
309 (_tcscmp(pDispInfo
->item
.pszText
, _T("true")) == 0) ||
310 (_tcscmp(pDispInfo
->item
.pszText
, _T("false")) == 0))
316 case SettingTypeNumber
:
318 TCHAR
* pChar
= pDispInfo
->item
.pszText
;
322 if (!_istdigit(*pChar
))
331 case SettingTypeString
:
339 *pResult
= allowEdit
? TRUE
: FALSE
;
342 BOOL
CSettingsAdvanced::PreTranslateMessage(MSG
* pMsg
)
344 if (pMsg
->message
== WM_KEYDOWN
)
346 switch (pMsg
->wParam
)
350 m_ListCtrl
.EditLabel(m_ListCtrl
.GetSelectionMark());
355 return ISettingsPropPage::PreTranslateMessage(pMsg
);
358 void CSettingsAdvanced::OnNMDblclkConfig(NMHDR
*pNMHDR
, LRESULT
*pResult
)
360 LPNMITEMACTIVATE pNMItemActivate
= reinterpret_cast<LPNMITEMACTIVATE
>(pNMHDR
);
361 m_ListCtrl
.EditLabel(pNMItemActivate
->iItem
);