Refactor rebase commit list: Don't fill list again and again when reordering commits
[TortoiseGit.git] / src / TortoiseProc / AboutDlg.cpp
blob8815a1e74a5c6d8f74338a4ff81a73051936f8bc
1 // TortoiseGit - a Windows shell extension for easy version control
3 // Copyright (C) 2003-2008 - TortoiseSVN
4 // Copyright (C) 2009-2018 - TortoiseGit
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 "stdafx.h"
22 #include "TortoiseProc.h"
23 #include "AboutDlg.h"
24 #include "PathUtils.h"
25 #define NEED_SIGNING_KEY
26 #include "../version.h"
27 #include "AppUtils.h"
28 #include "Git.h"
29 #include "DPIAware.h"
31 //IMPLEMENT_DYNAMIC(CAboutDlg, CStandAloneDialog)
32 CAboutDlg::CAboutDlg(CWnd* pParent /*=nullptr*/)
33 : CStandAloneDialog(CAboutDlg::IDD, pParent)
37 CAboutDlg::~CAboutDlg()
41 void CAboutDlg::DoDataExchange(CDataExchange* pDX)
43 CStandAloneDialog::DoDataExchange(pDX);
44 DDX_Control(pDX, IDC_WEBLINK, m_cWebLink);
45 DDX_Control(pDX, IDC_SUPPORTLINK, m_cSupportLink);
48 BEGIN_MESSAGE_MAP(CAboutDlg, CStandAloneDialog)
49 ON_WM_TIMER()
50 ON_WM_MOUSEMOVE()
51 ON_BN_CLICKED(IDC_UPDATE, OnBnClickedUpdate)
52 ON_WM_CLOSE()
53 END_MESSAGE_MAP()
55 static CString Lf2Crlf(const CString& text)
57 CString s;
58 if (text.IsEmpty())
59 return s;
61 TCHAR c = L'\0';
62 for (int i = 0; i < text.GetLength(); i++)
64 if (text[i] == L'\n' && c != L'\r')
65 s += "\r\n";
66 else
67 s += text[i];
68 c = text[i];
70 return s;
73 BOOL CAboutDlg::OnInitDialog()
75 CStandAloneDialog::OnInitDialog();
76 CAppUtils::MarkWindowAsUnpinnable(m_hWnd);
78 // set the version string
79 CString temp;
81 CString out, err;
82 if (g_Git.Run(L"git.exe --version", &out, &err, CP_UTF8))
83 out = L"git not found (" + err + L')';
84 out.Trim();
86 if (!CGit::ms_LastMsysGitDir.IsEmpty())
88 out += L" (" + CGit::ms_LastMsysGitDir;
89 out += L"; " + CGit::ms_MsysGitRootDir;
90 out += L"; " + g_Git.GetGitSystemConfig();
91 if (CGit::ms_bMsys2Git)
92 out += L"; with msys2 hack";
93 else if (CGit::ms_bCygwinGit)
94 out += L"; with cygwin hack";
95 else
96 out += L"; " + g_Git.GetGitProgramDataConfig();
97 out += L')';
100 CString tortoisegitprocpath;
101 tortoisegitprocpath.Format(L"(%s)", (LPCTSTR)CPathUtils::GetAppDirectory().TrimRight(L'\\'));
102 temp.Format(IDS_ABOUTVERSION, TGIT_VERMAJOR, TGIT_VERMINOR, TGIT_VERMICRO, TGIT_VERBUILD, (LPCTSTR)tortoisegitprocpath, (LPCTSTR)out);
103 SetDlgItemText(IDC_VERSIONABOUT, Lf2Crlf(temp));
105 this->SetWindowText(L"TortoiseGit");
107 // we can only put up to 256 chars into the resource file, so fill it here with the full list
108 SetDlgItemText(IDC_STATIC_AUTHORS, L"Sven Strickroth <email@cs-ware.de> (Current Maintainer), Sup Yut Sum <ch3cooli@gmail.com>, Frank Li <lznuaa@gmail.com> (Founder), Yue Lin Ho <b8732003@student.nsysu.edu.tw>, Colin Law <clanlaw@googlemail.com>, Myagi <snowcoder@gmail.com>, Johan 't Hart <johanthart@gmail.com>, Laszlo Papp <djszapi@archlinux.us>");
110 CPictureHolder tmpPic;
111 tmpPic.CreateFromBitmap(IDB_LOGOFLIPPED);
112 m_renderSrc.Create32BitFromPicture(&tmpPic,468,64);
113 m_renderDest.Create32BitFromPicture(&tmpPic,468,64);
115 m_waterEffect.Create(468,64);
116 SetTimer(ID_EFFECTTIMER, 40, nullptr);
117 SetTimer(ID_DROPTIMER, 1500, nullptr);
119 m_cWebLink.SetURL(L"https://tortoisegit.org/");
120 m_cSupportLink.SetURL(L"https://tortoisegit.org/donate");
122 CenterWindow(CWnd::FromHandle(GetExplorerHWND()));
123 GetDlgItem(IDOK)->SetFocus();
124 return FALSE;
127 void CAboutDlg::OnTimer(UINT_PTR nIDEvent)
129 if (nIDEvent == ID_EFFECTTIMER)
131 m_waterEffect.Render((DWORD*)m_renderSrc.GetDIBits(), (DWORD*)m_renderDest.GetDIBits());
132 CClientDC dc(this);
133 CPoint ptOrigin(CDPIAware::Instance().ScaleX(15), CDPIAware::Instance().ScaleY(20));
134 m_renderDest.Draw(&dc,ptOrigin);
136 if (nIDEvent == ID_DROPTIMER)
138 CRect r;
139 r.left = CDPIAware::Instance().ScaleX(15);
140 r.top = CDPIAware::Instance().ScaleY(20);
141 r.right = r.left + m_renderSrc.GetWidth();
142 r.bottom = r.top + m_renderSrc.GetHeight();
143 m_waterEffect.Blob(random(r.left,r.right), random(r.top, r.bottom), 5, 800, m_waterEffect.m_iHpage);
145 CStandAloneDialog::OnTimer(nIDEvent);
148 void CAboutDlg::OnMouseMove(UINT nFlags, CPoint point)
150 CRect r;
151 r.left = CDPIAware::Instance().ScaleX(15);
152 r.top = CDPIAware::Instance().ScaleY(20);
153 r.right = r.left + m_renderSrc.GetWidth();
154 r.bottom = r.top + m_renderSrc.GetHeight();
156 if(r.PtInRect(point) == TRUE)
158 // dibs are drawn upside down...
159 point.y -= CDPIAware::Instance().ScaleY(20);
160 point.y = 64-point.y;
162 if (nFlags & MK_LBUTTON)
163 m_waterEffect.Blob(point.x - CDPIAware::Instance().ScaleX(15), point.y, 10, 1600, m_waterEffect.m_iHpage);
164 else
165 m_waterEffect.Blob(point.x - CDPIAware::Instance().ScaleX(15), point.y, 5, 50, m_waterEffect.m_iHpage);
168 CStandAloneDialog::OnMouseMove(nFlags, point);
171 void CAboutDlg::OnBnClickedUpdate()
173 CAppUtils::RunTortoiseGitProc(L"/command:updatecheck /visible", false, false);
176 void CAboutDlg::OnClose()
178 KillTimer(ID_EFFECTTIMER);
179 KillTimer(ID_DROPTIMER);
181 __super::OnClose();