1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2008-2009,2011,2013-2016 - TortoiseGit
4 // Copyright (C) 2003-2008,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.
21 #include "TortoiseProc.h"
22 #include "SetOverlayPage.h"
23 #include "SetOverlayIcons.h"
25 #include "..\TGitCache\CacheInterface.h"
26 #include "StringUtils.h"
28 IMPLEMENT_DYNAMIC(CSetOverlayPage
, ISettingsPropPage
)
29 CSetOverlayPage::CSetOverlayPage()
30 : ISettingsPropPage(CSetOverlayPage::IDD
)
37 , m_bOnlyExplorer(FALSE
)
38 , m_bUnversionedAsModified(FALSE
)
39 , m_bRecurseSubmodules(FALSE
)
41 , m_bShowExcludedAsNormal(TRUE
)
43 m_regOnlyExplorer
= CRegDWORD(L
"Software\\TortoiseGit\\LoadDllOnlyInExplorer", FALSE
);
44 m_regDriveMaskRemovable
= CRegDWORD(L
"Software\\TortoiseGit\\DriveMaskRemovable");
45 m_regDriveMaskFloppy
= CRegDWORD(L
"Software\\TortoiseGit\\DriveMaskFloppy");
46 m_regDriveMaskRemote
= CRegDWORD(L
"Software\\TortoiseGit\\DriveMaskRemote");
47 m_regDriveMaskFixed
= CRegDWORD(L
"Software\\TortoiseGit\\DriveMaskFixed", TRUE
);
48 m_regDriveMaskCDROM
= CRegDWORD(L
"Software\\TortoiseGit\\DriveMaskCDROM");
49 m_regDriveMaskRAM
= CRegDWORD(L
"Software\\TortoiseGit\\DriveMaskRAM");
50 m_regDriveMaskUnknown
= CRegDWORD(L
"Software\\TortoiseGit\\DriveMaskUnknown");
51 m_regExcludePaths
= CRegString(L
"Software\\TortoiseGit\\OverlayExcludeList");
52 m_regIncludePaths
= CRegString(L
"Software\\TortoiseGit\\OverlayIncludeList");
53 m_regCacheType
= CRegDWORD(L
"Software\\TortoiseGit\\CacheType", GetSystemMetrics(SM_REMOTESESSION
) ? 2 : 1);
54 m_regUnversionedAsModified
= CRegDWORD(L
"Software\\TortoiseGit\\UnversionedAsModified", FALSE
);
55 m_regRecurseSubmodules
= CRegDWORD(L
"Software\\TortoiseGit\\TGitCacheRecurseSubmodules", FALSE
);
56 m_regShowExcludedAsNormal
= CRegDWORD(L
"Software\\TortoiseGit\\ShowExcludedAsNormal", TRUE
);
58 m_bOnlyExplorer
= m_regOnlyExplorer
;
59 m_bRemovable
= m_regDriveMaskRemovable
;
60 m_bFloppy
= m_regDriveMaskFloppy
;
61 m_bNetwork
= m_regDriveMaskRemote
;
62 m_bFixed
= m_regDriveMaskFixed
;
63 m_bCDROM
= m_regDriveMaskCDROM
;
64 m_bRAM
= m_regDriveMaskRAM
;
65 m_bUnknown
= m_regDriveMaskUnknown
;
66 m_bUnversionedAsModified
= m_regUnversionedAsModified
;
67 m_bRecurseSubmodules
= m_regRecurseSubmodules
;
68 m_bShowExcludedAsNormal
= m_regShowExcludedAsNormal
;
69 m_sExcludePaths
= m_regExcludePaths
;
70 m_sExcludePaths
.Replace(L
"\n", L
"\r\n");
71 m_sIncludePaths
= m_regIncludePaths
;
72 m_sIncludePaths
.Replace(L
"\n", L
"\r\n");
73 m_dwCacheType
= m_regCacheType
;
76 CSetOverlayPage::~CSetOverlayPage()
80 void CSetOverlayPage::DoDataExchange(CDataExchange
* pDX
)
82 ISettingsPropPage::DoDataExchange(pDX
);
83 DDX_Check(pDX
, IDC_REMOVABLE
, m_bRemovable
);
84 DDX_Check(pDX
, IDC_NETWORK
, m_bNetwork
);
85 DDX_Check(pDX
, IDC_FIXED
, m_bFixed
);
86 DDX_Check(pDX
, IDC_CDROM
, m_bCDROM
);
87 DDX_Check(pDX
, IDC_RAM
, m_bRAM
);
88 DDX_Check(pDX
, IDC_UNKNOWN
, m_bUnknown
);
89 DDX_Check(pDX
, IDC_ONLYEXPLORER
, m_bOnlyExplorer
);
90 DDX_Text(pDX
, IDC_EXCLUDEPATHS
, m_sExcludePaths
);
91 DDX_Text(pDX
, IDC_INCLUDEPATHS
, m_sIncludePaths
);
92 DDX_Check(pDX
, IDC_UNVERSIONEDASMODIFIED
, m_bUnversionedAsModified
);
93 DDX_Check(pDX
, IDC_RECURSIVESUBMODULES
, m_bRecurseSubmodules
);
94 DDX_Check(pDX
, IDC_FLOPPY
, m_bFloppy
);
95 DDX_Check(pDX
, IDC_SHOWEXCLUDEDASNORMAL
, m_bShowExcludedAsNormal
);
98 BEGIN_MESSAGE_MAP(CSetOverlayPage
, ISettingsPropPage
)
99 ON_BN_CLICKED(IDC_REMOVABLE
, OnChange
)
100 ON_BN_CLICKED(IDC_FLOPPY
, &CSetOverlayPage::OnChange
)
101 ON_BN_CLICKED(IDC_NETWORK
, OnChange
)
102 ON_BN_CLICKED(IDC_FIXED
, OnChange
)
103 ON_BN_CLICKED(IDC_CDROM
, OnChange
)
104 ON_BN_CLICKED(IDC_UNKNOWN
, OnChange
)
105 ON_BN_CLICKED(IDC_RAM
, OnChange
)
106 ON_BN_CLICKED(IDC_ONLYEXPLORER
, OnChange
)
107 ON_EN_CHANGE(IDC_EXCLUDEPATHS
, OnChange
)
108 ON_EN_CHANGE(IDC_INCLUDEPATHS
, OnChange
)
109 ON_BN_CLICKED(IDC_CACHEDEFAULT
, &CSetOverlayPage::OnChange
)
110 ON_BN_CLICKED(IDC_CACHESHELL
, &CSetOverlayPage::OnChange
)
111 ON_BN_CLICKED(IDC_CACHESHELL2
, &CSetOverlayPage::OnChange
)
112 ON_BN_CLICKED(IDC_CACHENONE
, &CSetOverlayPage::OnChange
)
113 ON_BN_CLICKED(IDC_UNVERSIONEDASMODIFIED
, &CSetOverlayPage::OnChange
)
114 ON_BN_CLICKED(IDC_RECURSIVESUBMODULES
, &CSetOverlayPage::OnChange
)
115 ON_BN_CLICKED(IDC_SHOWEXCLUDEDASNORMAL
, &CSetOverlayPage::OnChange
)
118 BOOL
CSetOverlayPage::OnInitDialog()
120 ISettingsPropPage::OnInitDialog();
122 AdjustControlSize(IDC_REMOVABLE
);
123 AdjustControlSize(IDC_NETWORK
);
124 AdjustControlSize(IDC_FIXED
);
125 AdjustControlSize(IDC_CDROM
);
126 AdjustControlSize(IDC_RAM
);
127 AdjustControlSize(IDC_UNKNOWN
);
128 AdjustControlSize(IDC_ONLYEXPLORER
);
129 AdjustControlSize(IDC_UNVERSIONEDASMODIFIED
);
130 AdjustControlSize(IDC_RECURSIVESUBMODULES
);
131 AdjustControlSize(IDC_FLOPPY
);
132 AdjustControlSize(IDC_CACHEDEFAULT
);
133 AdjustControlSize(IDC_CACHENONE
);
134 AdjustControlSize(IDC_CACHESHELL
);
135 AdjustControlSize(IDC_CACHESHELL2
);
137 switch (m_dwCacheType
)
140 CheckRadioButton(IDC_CACHEDEFAULT
, IDC_CACHENONE
, IDC_CACHENONE
);
144 CheckRadioButton(IDC_CACHEDEFAULT
, IDC_CACHENONE
, IDC_CACHEDEFAULT
);
147 CheckRadioButton(IDC_CACHEDEFAULT
, IDC_CACHENONE
, IDC_CACHESHELL
);
150 CheckRadioButton(IDC_CACHEDEFAULT
, IDC_CACHENONE
, IDC_CACHESHELL2
);
153 GetDlgItem(IDC_UNVERSIONEDASMODIFIED
)->EnableWindow(m_dwCacheType
== 1);
154 GetDlgItem(IDC_RECURSIVESUBMODULES
)->EnableWindow(m_dwCacheType
== 1);
156 m_tooltips
.AddTool(IDC_ONLYEXPLORER
, IDS_SETTINGS_ONLYEXPLORER_TT
);
157 m_tooltips
.AddTool(IDC_EXCLUDEPATHS
, IDS_SETTINGS_EXCLUDELIST_TT
);
158 m_tooltips
.AddTool(IDC_INCLUDEPATHS
, IDS_SETTINGS_INCLUDELIST_TT
);
159 m_tooltips
.AddTool(IDC_CACHEDEFAULT
, IDS_SETTINGS_CACHEDEFAULT_TT
);
160 m_tooltips
.AddTool(IDC_CACHESHELL
, IDS_SETTINGS_CACHESHELL_TT
);
161 m_tooltips
.AddTool(IDC_CACHESHELL2
, IDS_SETTINGS_CACHESHELLEXT_TT
);
162 m_tooltips
.AddTool(IDC_CACHENONE
, IDS_SETTINGS_CACHENONE_TT
);
163 m_tooltips
.AddTool(IDC_UNVERSIONEDASMODIFIED
, IDS_SETTINGS_UNVERSIONEDASMODIFIED_TT
);
164 m_tooltips
.AddTool(IDC_SHOWEXCLUDEDASNORMAL
, IDS_SETTINGS_SHOWEXCLUDEDASNORMAL_TT
);
171 void CSetOverlayPage::OnChange()
174 int id
= GetCheckedRadioButton(IDC_CACHEDEFAULT
, IDC_CACHENONE
);
178 case IDC_CACHEDEFAULT
:
184 case IDC_CACHESHELL2
:
191 GetDlgItem(IDC_UNVERSIONEDASMODIFIED
)->EnableWindow(m_dwCacheType
== 1);
192 GetDlgItem(IDC_RECURSIVESUBMODULES
)->EnableWindow(m_dwCacheType
== 1);
196 BOOL
CSetOverlayPage::OnApply()
199 Store(m_bOnlyExplorer
, m_regOnlyExplorer
);
200 if (DWORD(m_regDriveMaskRemovable
) != DWORD(m_bRemovable
))
201 m_restart
= Restart_Cache
;
202 Store(m_bRemovable
, m_regDriveMaskRemovable
);
204 if (DWORD(m_regDriveMaskFloppy
) != DWORD(m_bFloppy
))
205 m_restart
= Restart_Cache
;
206 Store(m_bFloppy
, m_regDriveMaskFloppy
);
208 if (DWORD(m_regDriveMaskRemote
) != DWORD(m_bNetwork
))
209 m_restart
= Restart_Cache
;
210 Store(m_bNetwork
, m_regDriveMaskRemote
);
212 if (DWORD(m_regDriveMaskFixed
) != DWORD(m_bFixed
))
213 m_restart
= Restart_Cache
;
214 Store(m_bFixed
, m_regDriveMaskFixed
);
216 if (DWORD(m_regDriveMaskCDROM
) != DWORD(m_bCDROM
))
217 m_restart
= Restart_Cache
;
218 Store(m_bCDROM
, m_regDriveMaskCDROM
);
220 if (DWORD(m_regDriveMaskRAM
) != DWORD(m_bRAM
))
221 m_restart
= Restart_Cache
;
222 Store(m_bRAM
, m_regDriveMaskRAM
);
224 if (DWORD(m_regDriveMaskUnknown
) != DWORD(m_bUnknown
))
225 m_restart
= Restart_Cache
;
226 Store(m_bUnknown
, m_regDriveMaskUnknown
);
228 if (m_sExcludePaths
.Compare(CString(m_regExcludePaths
)))
229 m_restart
= Restart_Cache
;
230 m_sExcludePaths
.Remove(L
'\r');
231 if (!CStringUtils::EndsWith(m_sExcludePaths
, L
'\n'))
232 m_sExcludePaths
+= L
'\n';
233 Store(m_sExcludePaths
, m_regExcludePaths
);
234 m_sExcludePaths
.Replace(L
"\n", L
"\r\n");
235 m_sIncludePaths
.Remove(L
'\r');
236 if (!CStringUtils::EndsWith(m_sIncludePaths
, L
'\n'))
237 m_sIncludePaths
+= L
'\n';
238 if (m_sIncludePaths
.Compare(CString(m_regIncludePaths
)))
239 m_restart
= Restart_Cache
;
240 Store(m_sIncludePaths
, m_regIncludePaths
);
241 m_sIncludePaths
.Replace(L
"\n", L
"\r\n");
243 if (DWORD(m_regUnversionedAsModified
) != DWORD(m_bUnversionedAsModified
))
244 m_restart
= Restart_Cache
;
245 Store(m_bUnversionedAsModified
, m_regUnversionedAsModified
);
246 if (DWORD(m_regRecurseSubmodules
) != DWORD(m_bRecurseSubmodules
))
247 m_restart
= Restart_Cache
;
248 Store(m_bRecurseSubmodules
, m_regRecurseSubmodules
);
249 if (DWORD(m_regShowExcludedAsNormal
) != DWORD(m_bShowExcludedAsNormal
))
250 m_restart
= Restart_Cache
;
251 Store(m_bShowExcludedAsNormal
, m_regShowExcludedAsNormal
);
253 Store(m_dwCacheType
, m_regCacheType
);
254 if (m_dwCacheType
!= 1)
256 // close the possible running cache process
257 HWND hWnd
= ::FindWindow(TGIT_CACHE_WINDOW_NAME
, TGIT_CACHE_WINDOW_NAME
);
259 ::PostMessage(hWnd
, WM_CLOSE
, NULL
, NULL
);
260 m_restart
= Restart_None
;
263 return ISettingsPropPage::OnApply();