1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2012-2013 - 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
"ColumnsEveryWhere";
50 settings
[i
].type
= CSettingsAdvanced::SettingTypeBoolean
;
51 settings
[i
++].def
.b
= false;
53 settings
[i
].sName
= L
"Debug";
54 settings
[i
].type
= CSettingsAdvanced::SettingTypeBoolean
;
55 settings
[i
++].def
.b
= false;
57 settings
[i
].sName
= L
"DiffBlamesWithTortoiseMerge";
58 settings
[i
].type
= CSettingsAdvanced::SettingTypeBoolean
;
59 settings
[i
++].def
.b
= false;
61 settings
[i
].sName
= L
"FullRowSelect";
62 settings
[i
].type
= CSettingsAdvanced::SettingTypeBoolean
;
63 settings
[i
++].def
.b
= true;
65 settings
[i
].sName
= L
"GroupTaskbarIconsPerRepo";
66 settings
[i
].type
= CSettingsAdvanced::SettingTypeNumber
;
67 settings
[i
++].def
.l
= 3;
69 settings
[i
].sName
= L
"GroupTaskbarIconsPerRepoOverlay";
70 settings
[i
].type
= CSettingsAdvanced::SettingTypeBoolean
;
71 settings
[i
++].def
.b
= true;
74 settings
[i
].sName
= L
"LogIncludeBoundaryCommits";
75 settings
[i
].type
= CSettingsAdvanced::SettingTypeBoolean
;
76 settings
[i
++].def
.b
= false;
78 settings
[i
].sName
= L
"NoSortLocalBranchesFirst";
79 settings
[i
].type
= CSettingsAdvanced::SettingTypeBoolean
;
80 settings
[i
++].def
.b
= false;
82 settings
[i
].sName
= L
"NumDiffWarning";
83 settings
[i
].type
= CSettingsAdvanced::SettingTypeNumber
;
84 settings
[i
++].def
.l
= 10;
86 settings
[i
].sName
= L
"ReaddUnselectedAddedFilesAfterCommit";
87 settings
[i
].type
= CSettingsAdvanced::SettingTypeBoolean
;
88 settings
[i
++].def
.b
= true;
90 settings
[i
].sName
= L
"ScintillaDirect2D";
91 settings
[i
].type
= CSettingsAdvanced::SettingTypeBoolean
;
92 settings
[i
++].def
.b
= false;
94 settings
[i
].sName
= L
"ShellMenuAccelerators";
95 settings
[i
].type
= CSettingsAdvanced::SettingTypeBoolean
;
96 settings
[i
++].def
.b
= true;
98 settings
[i
].sName
= L
"ShowContextMenuIcons";
99 settings
[i
].type
= CSettingsAdvanced::SettingTypeBoolean
;
100 settings
[i
++].def
.b
= true;
102 settings
[i
].sName
= L
"ShowListBackgroundImage";
103 settings
[i
].type
= CSettingsAdvanced::SettingTypeBoolean
;
104 settings
[i
++].def
.b
= true;
106 settings
[i
].sName
= L
"StyleCommitMessages";
107 settings
[i
].type
= CSettingsAdvanced::SettingTypeBoolean
;
108 settings
[i
++].def
.b
= true;
110 settings
[i
].sName
= L
"TGitCacheCheckContent";
111 settings
[i
].type
= CSettingsAdvanced::SettingTypeBoolean
;
112 settings
[i
++].def
.b
= true;
114 settings
[i
].sName
= L
"UseLibgit2";
115 settings
[i
].type
= CSettingsAdvanced::SettingTypeBoolean
;
116 settings
[i
++].def
.b
= true;
118 settings
[i
].sName
= L
"VersionCheck";
119 settings
[i
].type
= CSettingsAdvanced::SettingTypeBoolean
;
120 settings
[i
++].def
.b
= true;
122 settings
[i
].sName
= L
"VersionCheckPreview";
123 settings
[i
].type
= CSettingsAdvanced::SettingTypeBoolean
;
124 settings
[i
++].def
.b
= false;
126 settings
[i
].sName
= L
"";
127 settings
[i
].type
= CSettingsAdvanced::SettingTypeNone
;
128 settings
[i
++].def
.b
= false;
131 CSettingsAdvanced::~CSettingsAdvanced()
135 void CSettingsAdvanced::DoDataExchange(CDataExchange
* pDX
)
137 ISettingsPropPage::DoDataExchange(pDX
);
138 DDX_Control(pDX
, IDC_CONFIG
, m_ListCtrl
);
142 BEGIN_MESSAGE_MAP(CSettingsAdvanced
, ISettingsPropPage
)
143 ON_NOTIFY(LVN_BEGINLABELEDIT
, IDC_CONFIG
, &CSettingsAdvanced::OnLvnBeginlabeledit
)
144 ON_NOTIFY(LVN_ENDLABELEDIT
, IDC_CONFIG
, &CSettingsAdvanced::OnLvnEndlabeledit
)
145 ON_NOTIFY(NM_DBLCLK
, IDC_CONFIG
, &CSettingsAdvanced::OnNMDblclkConfig
)
149 BOOL
CSettingsAdvanced::OnInitDialog()
151 ISettingsPropPage::OnInitDialog();
153 m_ListCtrl
.DeleteAllItems();
154 int c
= ((CHeaderCtrl
*)(m_ListCtrl
.GetDlgItem(0)))->GetItemCount() - 1;
156 m_ListCtrl
.DeleteColumn(c
--);
158 SetWindowTheme(m_ListCtrl
.GetSafeHwnd(), L
"Explorer", NULL
);
161 temp
.LoadString(IDS_SETTINGS_CONF_VALUECOL
);
162 m_ListCtrl
.InsertColumn(0, temp
);
163 temp
.LoadString(IDS_SETTINGS_CONF_NAMECOL
);
164 m_ListCtrl
.InsertColumn(1, temp
);
166 m_ListCtrl
.SetRedraw(FALSE
);
169 while (settings
[i
].type
!= SettingTypeNone
)
171 m_ListCtrl
.InsertItem(i
, settings
[i
].sName
);
172 m_ListCtrl
.SetItemText(i
, 1, settings
[i
].sName
);
173 switch (settings
[i
].type
)
175 case SettingTypeBoolean
:
177 CRegDWORD
s(_T("Software\\TortoiseGit\\") + settings
[i
].sName
, settings
[i
].def
.b
);
178 m_ListCtrl
.SetItemText(i
, 0, DWORD(s
) ? _T("true") : _T("false"));
181 case SettingTypeNumber
:
183 CRegDWORD
s(_T("Software\\TortoiseGit\\") + settings
[i
].sName
, settings
[i
].def
.l
);
184 temp
.Format(_T("%ld"), (DWORD
)s
);
185 m_ListCtrl
.SetItemText(i
, 0, temp
);
188 case SettingTypeString
:
190 CRegString
s(_T("Software\\TortoiseGit\\") + settings
[i
].sName
, settings
[i
].def
.s
);
191 m_ListCtrl
.SetItemText(i
, 0, CString(s
));
199 int maxcol
= ((CHeaderCtrl
*)(m_ListCtrl
.GetDlgItem(0)))->GetItemCount() - 1;
201 for (col
= mincol
; col
<= maxcol
; ++col
)
203 m_ListCtrl
.SetColumnWidth(col
, LVSCW_AUTOSIZE_USEHEADER
);
206 m_ListCtrl
.SetColumnOrderArray(2, arr
);
207 m_ListCtrl
.SetRedraw(TRUE
);
212 BOOL
CSettingsAdvanced::OnApply()
215 while (settings
[i
].type
!= SettingTypeNone
)
217 CString sValue
= m_ListCtrl
.GetItemText(i
, 0);
218 switch (settings
[i
].type
)
220 case SettingTypeBoolean
:
222 CRegDWORD
s(_T("Software\\TortoiseGit\\") + settings
[i
].sName
, settings
[i
].def
.b
);
223 if (sValue
.IsEmpty())
227 DWORD newValue
= sValue
.Compare(_T("true")) == 0;
228 if (DWORD(s
) != newValue
)
235 case SettingTypeNumber
:
237 CRegDWORD
s(_T("Software\\TortoiseGit\\") + settings
[i
].sName
, settings
[i
].def
.l
);
238 if (DWORD(_tstol(sValue
)) != DWORD(s
))
244 case SettingTypeString
:
246 CRegString
s(_T("Software\\TortoiseGit\\") + settings
[i
].sName
, settings
[i
].def
.s
);
247 if (sValue
.Compare(CString(s
)))
257 return ISettingsPropPage::OnApply();
260 void CSettingsAdvanced::OnLvnBeginlabeledit(NMHDR
* /*pNMHDR*/, LRESULT
*pResult
)
265 void CSettingsAdvanced::OnLvnEndlabeledit(NMHDR
*pNMHDR
, LRESULT
*pResult
)
267 NMLVDISPINFO
*pDispInfo
= reinterpret_cast<NMLVDISPINFO
*>(pNMHDR
);
269 if (pDispInfo
->item
.pszText
== NULL
)
272 bool allowEdit
= false;
273 switch (settings
[pDispInfo
->item
.iItem
].type
)
275 case SettingTypeBoolean
:
277 if ((pDispInfo
->item
.pszText
[0] == 0) ||
278 (_tcscmp(pDispInfo
->item
.pszText
, _T("true")) == 0) ||
279 (_tcscmp(pDispInfo
->item
.pszText
, _T("false")) == 0))
285 case SettingTypeNumber
:
287 TCHAR
* pChar
= pDispInfo
->item
.pszText
;
291 if (!_istdigit(*pChar
))
300 case SettingTypeString
:
308 *pResult
= allowEdit
? TRUE
: FALSE
;
311 BOOL
CSettingsAdvanced::PreTranslateMessage(MSG
* pMsg
)
313 if (pMsg
->message
== WM_KEYDOWN
)
315 switch (pMsg
->wParam
)
319 m_ListCtrl
.EditLabel(m_ListCtrl
.GetSelectionMark());
324 return ISettingsPropPage::PreTranslateMessage(pMsg
);
327 void CSettingsAdvanced::OnNMDblclkConfig(NMHDR
*pNMHDR
, LRESULT
*pResult
)
329 LPNMITEMACTIVATE pNMItemActivate
= reinterpret_cast<LPNMITEMACTIVATE
>(pNMHDR
);
330 m_ListCtrl
.EditLabel(pNMItemActivate
->iItem
);