1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2012 - TortoiseGit
4 // Copyright (C) 2009-2011 - 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
"AutocompleteRemovesExtensions";
34 settings
[i
].type
= CSettingsAdvanced::SettingTypeBoolean
;
35 settings
[i
++].def
.b
= false;
37 settings
[i
].sName
= L
"BlockStatus";
38 settings
[i
].type
= CSettingsAdvanced::SettingTypeBoolean
;
39 settings
[i
++].def
.b
= false;
41 settings
[i
].sName
= L
"CacheTrayIcon";
42 settings
[i
].type
= CSettingsAdvanced::SettingTypeBoolean
;
43 settings
[i
++].def
.b
= false;
45 settings
[i
].sName
= L
"ColumnsEveryWhere";
46 settings
[i
].type
= CSettingsAdvanced::SettingTypeBoolean
;
47 settings
[i
++].def
.b
= false;
49 settings
[i
].sName
= L
"Debug";
50 settings
[i
].type
= CSettingsAdvanced::SettingTypeBoolean
;
51 settings
[i
++].def
.b
= false;
53 settings
[i
].sName
= L
"DiffBlamesWithTortoiseMerge";
54 settings
[i
].type
= CSettingsAdvanced::SettingTypeBoolean
;
55 settings
[i
++].def
.b
= false;
57 settings
[i
].sName
= L
"FullRowSelect";
58 settings
[i
].type
= CSettingsAdvanced::SettingTypeBoolean
;
59 settings
[i
++].def
.b
= true;
61 settings
[i
].sName
= L
"ScintillaDirect2D";
62 settings
[i
].type
= CSettingsAdvanced::SettingTypeBoolean
;
63 settings
[i
++].def
.b
= true;
65 settings
[i
].sName
= L
"ShowContextMenuIcons";
66 settings
[i
].type
= CSettingsAdvanced::SettingTypeBoolean
;
67 settings
[i
++].def
.b
= true;
69 settings
[i
].sName
= L
"UseLibgit2";
70 settings
[i
].type
= CSettingsAdvanced::SettingTypeBoolean
;
71 settings
[i
++].def
.b
= false;
73 settings
[i
].sName
= L
"VersionCheck";
74 settings
[i
].type
= CSettingsAdvanced::SettingTypeBoolean
;
75 settings
[i
++].def
.b
= true;
77 settings
[i
].sName
= L
"";
78 settings
[i
].type
= CSettingsAdvanced::SettingTypeNone
;
79 settings
[i
++].def
.b
= false;
82 CSettingsAdvanced::~CSettingsAdvanced()
86 void CSettingsAdvanced::DoDataExchange(CDataExchange
* pDX
)
88 ISettingsPropPage::DoDataExchange(pDX
);
89 DDX_Control(pDX
, IDC_CONFIG
, m_ListCtrl
);
93 BEGIN_MESSAGE_MAP(CSettingsAdvanced
, ISettingsPropPage
)
94 ON_NOTIFY(LVN_BEGINLABELEDIT
, IDC_CONFIG
, &CSettingsAdvanced::OnLvnBeginlabeledit
)
95 ON_NOTIFY(LVN_ENDLABELEDIT
, IDC_CONFIG
, &CSettingsAdvanced::OnLvnEndlabeledit
)
96 ON_NOTIFY(NM_DBLCLK
, IDC_CONFIG
, &CSettingsAdvanced::OnNMDblclkConfig
)
100 BOOL
CSettingsAdvanced::OnInitDialog()
102 ISettingsPropPage::OnInitDialog();
104 m_ListCtrl
.DeleteAllItems();
105 int c
= ((CHeaderCtrl
*)(m_ListCtrl
.GetDlgItem(0)))->GetItemCount() - 1;
107 m_ListCtrl
.DeleteColumn(c
--);
109 SetWindowTheme(m_ListCtrl
.GetSafeHwnd(), L
"Explorer", NULL
);
112 temp
.LoadString(IDS_SETTINGS_CONF_VALUECOL
);
113 m_ListCtrl
.InsertColumn(0, temp
);
114 temp
.LoadString(IDS_SETTINGS_CONF_NAMECOL
);
115 m_ListCtrl
.InsertColumn(1, temp
);
117 m_ListCtrl
.SetRedraw(FALSE
);
120 while (settings
[i
].type
!= SettingTypeNone
)
122 m_ListCtrl
.InsertItem(i
, settings
[i
].sName
);
123 m_ListCtrl
.SetItemText(i
, 1, settings
[i
].sName
);
124 switch (settings
[i
].type
)
126 case SettingTypeBoolean
:
128 CRegDWORD
s(_T("Software\\TortoiseGit\\") + settings
[i
].sName
, settings
[i
].def
.b
);
129 m_ListCtrl
.SetItemText(i
, 0, DWORD(s
) ? _T("true") : _T("false"));
132 case SettingTypeNumber
:
134 CRegDWORD
s(_T("Software\\TortoiseGit\\") + settings
[i
].sName
, settings
[i
].def
.l
);
135 temp
.Format(_T("%ld"), (DWORD
)s
);
136 m_ListCtrl
.SetItemText(i
, 0, temp
);
139 case SettingTypeString
:
141 CRegString
s(_T("Software\\TortoiseGit\\") + settings
[i
].sName
, settings
[i
].def
.s
);
142 m_ListCtrl
.SetItemText(i
, 0, CString(s
));
150 int maxcol
= ((CHeaderCtrl
*)(m_ListCtrl
.GetDlgItem(0)))->GetItemCount() - 1;
152 for (col
= mincol
; col
<= maxcol
; col
++)
154 m_ListCtrl
.SetColumnWidth(col
, LVSCW_AUTOSIZE_USEHEADER
);
157 m_ListCtrl
.SetColumnOrderArray(2, arr
);
158 m_ListCtrl
.SetRedraw(TRUE
);
163 BOOL
CSettingsAdvanced::OnApply()
166 while (settings
[i
].type
!= SettingTypeNone
)
168 CString sValue
= m_ListCtrl
.GetItemText(i
, 0);
169 switch (settings
[i
].type
)
171 case SettingTypeBoolean
:
173 CRegDWORD
s(_T("Software\\TortoiseGit\\") + settings
[i
].sName
, settings
[i
].def
.b
);
174 if (sValue
.IsEmpty())
178 DWORD newValue
= sValue
.Compare(_T("true")) == 0;
179 if (DWORD(s
) != newValue
)
186 case SettingTypeNumber
:
188 CRegDWORD
s(_T("Software\\TortoiseGit\\") + settings
[i
].sName
, settings
[i
].def
.l
);
189 if (DWORD(_tstol(sValue
)) != DWORD(s
))
195 case SettingTypeString
:
197 CRegString
s(_T("Software\\TortoiseGit\\") + settings
[i
].sName
, settings
[i
].def
.s
);
198 if (sValue
.Compare(CString(s
)))
208 return ISettingsPropPage::OnApply();
211 void CSettingsAdvanced::OnLvnBeginlabeledit(NMHDR
* /*pNMHDR*/, LRESULT
*pResult
)
216 void CSettingsAdvanced::OnLvnEndlabeledit(NMHDR
*pNMHDR
, LRESULT
*pResult
)
218 NMLVDISPINFO
*pDispInfo
= reinterpret_cast<NMLVDISPINFO
*>(pNMHDR
);
220 if (pDispInfo
->item
.pszText
== NULL
)
223 bool allowEdit
= false;
224 switch (settings
[pDispInfo
->item
.iItem
].type
)
226 case SettingTypeBoolean
:
228 if ((pDispInfo
->item
.pszText
[0] == 0) ||
229 (_tcscmp(pDispInfo
->item
.pszText
, _T("true")) == 0) ||
230 (_tcscmp(pDispInfo
->item
.pszText
, _T("false")) == 0))
236 case SettingTypeNumber
:
238 TCHAR
* pChar
= pDispInfo
->item
.pszText
;
242 if (!_istdigit(*pChar
))
251 case SettingTypeString
:
259 *pResult
= allowEdit
? TRUE
: FALSE
;
262 BOOL
CSettingsAdvanced::PreTranslateMessage(MSG
* pMsg
)
264 if (pMsg
->message
== WM_KEYDOWN
)
266 switch (pMsg
->wParam
)
270 m_ListCtrl
.EditLabel(m_ListCtrl
.GetSelectionMark());
275 return ISettingsPropPage::PreTranslateMessage(pMsg
);
278 void CSettingsAdvanced::OnNMDblclkConfig(NMHDR
*pNMHDR
, LRESULT
*pResult
)
280 LPNMITEMACTIVATE pNMItemActivate
= reinterpret_cast<LPNMITEMACTIVATE
>(pNMHDR
);
281 m_ListCtrl
.EditLabel(pNMItemActivate
->iItem
);