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
"LogIncludeBoundaryCommits";
66 settings
[i
].type
= CSettingsAdvanced::SettingTypeBoolean
;
67 settings
[i
++].def
.b
= false;
69 settings
[i
].sName
= L
"NoSortLocalBranchesFirst";
70 settings
[i
].type
= CSettingsAdvanced::SettingTypeBoolean
;
71 settings
[i
++].def
.b
= false;
73 settings
[i
].sName
= L
"NumDiffWarning";
74 settings
[i
].type
= CSettingsAdvanced::SettingTypeNumber
;
75 settings
[i
++].def
.l
= 10;
77 settings
[i
].sName
= L
"ReaddUnselectedAddedFilesAfterCommit";
78 settings
[i
].type
= CSettingsAdvanced::SettingTypeBoolean
;
79 settings
[i
++].def
.b
= true;
81 settings
[i
].sName
= L
"ScintillaDirect2D";
82 settings
[i
].type
= CSettingsAdvanced::SettingTypeBoolean
;
83 settings
[i
++].def
.b
= false;
85 settings
[i
].sName
= L
"ShellMenuAccelerators";
86 settings
[i
].type
= CSettingsAdvanced::SettingTypeBoolean
;
87 settings
[i
++].def
.b
= true;
89 settings
[i
].sName
= L
"ShowContextMenuIcons";
90 settings
[i
].type
= CSettingsAdvanced::SettingTypeBoolean
;
91 settings
[i
++].def
.b
= true;
93 settings
[i
].sName
= L
"ShowListBackgroundImage";
94 settings
[i
].type
= CSettingsAdvanced::SettingTypeBoolean
;
95 settings
[i
++].def
.b
= true;
97 settings
[i
].sName
= L
"StyleCommitMessages";
98 settings
[i
].type
= CSettingsAdvanced::SettingTypeBoolean
;
99 settings
[i
++].def
.b
= true;
101 settings
[i
].sName
= L
"TGitCacheCheckContent";
102 settings
[i
].type
= CSettingsAdvanced::SettingTypeBoolean
;
103 settings
[i
++].def
.b
= true;
105 settings
[i
].sName
= L
"UseLibgit2";
106 settings
[i
].type
= CSettingsAdvanced::SettingTypeBoolean
;
107 settings
[i
++].def
.b
= true;
109 settings
[i
].sName
= L
"VersionCheck";
110 settings
[i
].type
= CSettingsAdvanced::SettingTypeBoolean
;
111 settings
[i
++].def
.b
= true;
113 settings
[i
].sName
= L
"VersionCheckPreview";
114 settings
[i
].type
= CSettingsAdvanced::SettingTypeBoolean
;
115 settings
[i
++].def
.b
= false;
117 settings
[i
].sName
= L
"";
118 settings
[i
].type
= CSettingsAdvanced::SettingTypeNone
;
119 settings
[i
++].def
.b
= false;
122 CSettingsAdvanced::~CSettingsAdvanced()
126 void CSettingsAdvanced::DoDataExchange(CDataExchange
* pDX
)
128 ISettingsPropPage::DoDataExchange(pDX
);
129 DDX_Control(pDX
, IDC_CONFIG
, m_ListCtrl
);
133 BEGIN_MESSAGE_MAP(CSettingsAdvanced
, ISettingsPropPage
)
134 ON_NOTIFY(LVN_BEGINLABELEDIT
, IDC_CONFIG
, &CSettingsAdvanced::OnLvnBeginlabeledit
)
135 ON_NOTIFY(LVN_ENDLABELEDIT
, IDC_CONFIG
, &CSettingsAdvanced::OnLvnEndlabeledit
)
136 ON_NOTIFY(NM_DBLCLK
, IDC_CONFIG
, &CSettingsAdvanced::OnNMDblclkConfig
)
140 BOOL
CSettingsAdvanced::OnInitDialog()
142 ISettingsPropPage::OnInitDialog();
144 m_ListCtrl
.DeleteAllItems();
145 int c
= ((CHeaderCtrl
*)(m_ListCtrl
.GetDlgItem(0)))->GetItemCount() - 1;
147 m_ListCtrl
.DeleteColumn(c
--);
149 SetWindowTheme(m_ListCtrl
.GetSafeHwnd(), L
"Explorer", NULL
);
152 temp
.LoadString(IDS_SETTINGS_CONF_VALUECOL
);
153 m_ListCtrl
.InsertColumn(0, temp
);
154 temp
.LoadString(IDS_SETTINGS_CONF_NAMECOL
);
155 m_ListCtrl
.InsertColumn(1, temp
);
157 m_ListCtrl
.SetRedraw(FALSE
);
160 while (settings
[i
].type
!= SettingTypeNone
)
162 m_ListCtrl
.InsertItem(i
, settings
[i
].sName
);
163 m_ListCtrl
.SetItemText(i
, 1, settings
[i
].sName
);
164 switch (settings
[i
].type
)
166 case SettingTypeBoolean
:
168 CRegDWORD
s(_T("Software\\TortoiseGit\\") + settings
[i
].sName
, settings
[i
].def
.b
);
169 m_ListCtrl
.SetItemText(i
, 0, DWORD(s
) ? _T("true") : _T("false"));
172 case SettingTypeNumber
:
174 CRegDWORD
s(_T("Software\\TortoiseGit\\") + settings
[i
].sName
, settings
[i
].def
.l
);
175 temp
.Format(_T("%ld"), (DWORD
)s
);
176 m_ListCtrl
.SetItemText(i
, 0, temp
);
179 case SettingTypeString
:
181 CRegString
s(_T("Software\\TortoiseGit\\") + settings
[i
].sName
, settings
[i
].def
.s
);
182 m_ListCtrl
.SetItemText(i
, 0, CString(s
));
190 int maxcol
= ((CHeaderCtrl
*)(m_ListCtrl
.GetDlgItem(0)))->GetItemCount() - 1;
192 for (col
= mincol
; col
<= maxcol
; ++col
)
194 m_ListCtrl
.SetColumnWidth(col
, LVSCW_AUTOSIZE_USEHEADER
);
197 m_ListCtrl
.SetColumnOrderArray(2, arr
);
198 m_ListCtrl
.SetRedraw(TRUE
);
203 BOOL
CSettingsAdvanced::OnApply()
206 while (settings
[i
].type
!= SettingTypeNone
)
208 CString sValue
= m_ListCtrl
.GetItemText(i
, 0);
209 switch (settings
[i
].type
)
211 case SettingTypeBoolean
:
213 CRegDWORD
s(_T("Software\\TortoiseGit\\") + settings
[i
].sName
, settings
[i
].def
.b
);
214 if (sValue
.IsEmpty())
218 DWORD newValue
= sValue
.Compare(_T("true")) == 0;
219 if (DWORD(s
) != newValue
)
226 case SettingTypeNumber
:
228 CRegDWORD
s(_T("Software\\TortoiseGit\\") + settings
[i
].sName
, settings
[i
].def
.l
);
229 if (DWORD(_tstol(sValue
)) != DWORD(s
))
235 case SettingTypeString
:
237 CRegString
s(_T("Software\\TortoiseGit\\") + settings
[i
].sName
, settings
[i
].def
.s
);
238 if (sValue
.Compare(CString(s
)))
248 return ISettingsPropPage::OnApply();
251 void CSettingsAdvanced::OnLvnBeginlabeledit(NMHDR
* /*pNMHDR*/, LRESULT
*pResult
)
256 void CSettingsAdvanced::OnLvnEndlabeledit(NMHDR
*pNMHDR
, LRESULT
*pResult
)
258 NMLVDISPINFO
*pDispInfo
= reinterpret_cast<NMLVDISPINFO
*>(pNMHDR
);
260 if (pDispInfo
->item
.pszText
== NULL
)
263 bool allowEdit
= false;
264 switch (settings
[pDispInfo
->item
.iItem
].type
)
266 case SettingTypeBoolean
:
268 if ((pDispInfo
->item
.pszText
[0] == 0) ||
269 (_tcscmp(pDispInfo
->item
.pszText
, _T("true")) == 0) ||
270 (_tcscmp(pDispInfo
->item
.pszText
, _T("false")) == 0))
276 case SettingTypeNumber
:
278 TCHAR
* pChar
= pDispInfo
->item
.pszText
;
282 if (!_istdigit(*pChar
))
291 case SettingTypeString
:
299 *pResult
= allowEdit
? TRUE
: FALSE
;
302 BOOL
CSettingsAdvanced::PreTranslateMessage(MSG
* pMsg
)
304 if (pMsg
->message
== WM_KEYDOWN
)
306 switch (pMsg
->wParam
)
310 m_ListCtrl
.EditLabel(m_ListCtrl
.GetSelectionMark());
315 return ISettingsPropPage::PreTranslateMessage(pMsg
);
318 void CSettingsAdvanced::OnNMDblclkConfig(NMHDR
*pNMHDR
, LRESULT
*pResult
)
320 LPNMITEMACTIVATE pNMItemActivate
= reinterpret_cast<LPNMITEMACTIVATE
>(pNMHDR
);
321 m_ListCtrl
.EditLabel(pNMItemActivate
->iItem
);