From efbd0295aa1d0985f80e7c799994bd04d7ba164a Mon Sep 17 00:00:00 2001 From: Colin Law Date: Sat, 31 Jan 2009 15:22:47 +0000 Subject: [PATCH] Implement Show Relative Times checkbox in Settings, Dialog 1. This checkbox now controls relative time display in Log and Blame --- src/Git/GitRev.cpp | 21 +++++++++------------ src/Git/GitRev.h | 3 +++ src/Resources/TortoiseProcENG.rc | Bin 399854 -> 402254 bytes src/TortoiseGitBlame/TortoiseGitBlameAppUtils.cpp | 1 - src/TortoiseProc/AppUtils.cpp | 3 +-- src/TortoiseProc/GitLogListBase.cpp | 8 ++++++-- src/TortoiseProc/GitLogListBase.h | 1 + src/TortoiseProc/Settings/SetDialogs.cpp | 7 +++++++ src/TortoiseProc/Settings/SetDialogs.h | 2 ++ src/TortoiseProc/resource.h | Bin 147616 -> 149034 bytes 10 files changed, 29 insertions(+), 17 deletions(-) diff --git a/src/Git/GitRev.cpp b/src/Git/GitRev.cpp index 5187484..6414c10 100644 --- a/src/Git/GitRev.cpp +++ b/src/Git/GitRev.cpp @@ -17,6 +17,11 @@ GitRev::GitRev(void) m_Action=0; m_IsFull = 0; m_IsUpdateing = 0; + // fetch local machine timezone info + if ( GetTimeZoneInformation( &m_TimeZone ) == TIME_ZONE_ID_INVALID ) + { + ASSERT(false); + } } GitRev::~GitRev(void) @@ -205,22 +210,14 @@ CTime GitRev::ConverFromString(CString input) // get local timezone SYSTEMTIME sysTime; tm.GetAsSystemTime( sysTime ); - TIME_ZONE_INFORMATION timeZone; - if ( GetTimeZoneInformation( &timeZone ) == TIME_ZONE_ID_INVALID ) + SYSTEMTIME local; + if ( SystemTimeToTzSpecificLocalTime( &m_TimeZone, &sysTime, &local ) ) { - ASSERT(false); + sysTime = local; } else { - SYSTEMTIME local; - if ( SystemTimeToTzSpecificLocalTime( &timeZone, &sysTime, &local ) ) - { - sysTime = local; - } - else - { - ASSERT(false); - } + ASSERT(false); } tm = CTime( sysTime, 0 ); return tm; diff --git a/src/Git/GitRev.h b/src/Git/GitRev.h index 0f630a7..78bc016 100644 --- a/src/Git/GitRev.h +++ b/src/Git/GitRev.h @@ -70,4 +70,7 @@ public: volatile LONG m_IsUpdateing; int SafeFetchFullInfo(CGit *git); + +private: + TIME_ZONE_INFORMATION m_TimeZone; }; diff --git a/src/Resources/TortoiseProcENG.rc b/src/Resources/TortoiseProcENG.rc index 1135ae124be4ff8f52e94c82cab09086ca52ba51..294f66f84d000b70e9d7fb0d1caad4687615904b 100644 GIT binary patch delta 1005 zcmaKrze_?<6vw~j)vz!z36qetXbZAHf|ih!?1u$fiBmi(GAgCaq9Cw_BwC6G-L*fU zt-__Hp_V9$XlZMT8iM|V&Qo9B8`tl@T*tPz5K*k z!&;Z1U=0gc#~eJEplX?_4Al!r!NYf$!QqM`gi!?O>mf{0t(_4%V_Yd1w$+Dgv(pbB zI?;`u^67&Wb+F_W)j&^8K~asj`~337)W#1l7_=J^U^F1yaeB&y{vN=xB~i(njMG7opBmlx9-k92HJBx%@@Lm zWR&KM(|mJS6nu7_k!{j^IwiWSLCP>8nVe#WK}up%@YqVfmn~9nB|>!A!j$3UfBOnk zf?0WAIwPB;d2~v2QSL*uuSwciNSf+b?%FNS($2KoukX4^WMyxwn8|YSKT@J~_v;gD sv4=2Fye+}%<`@}giuYxy*4pa1{> delta 56 zcmX?iOyb>UiH0qVUX!O=?P8ReE?~&0)IMPfBM>ufpD=}aMd$PfFIhd>6XaR8C&;t@ Mc)9(I09%s~0I9nde*gdg diff --git a/src/TortoiseGitBlame/TortoiseGitBlameAppUtils.cpp b/src/TortoiseGitBlame/TortoiseGitBlameAppUtils.cpp index f1067bf..632aeea 100644 --- a/src/TortoiseGitBlame/TortoiseGitBlameAppUtils.cpp +++ b/src/TortoiseGitBlame/TortoiseGitBlameAppUtils.cpp @@ -99,7 +99,6 @@ CString CAppUtils::ToRelativeTimeString(CTime time) time.GetAsSystemTime( sysTime ); COleDateTime oleTime( sysTime ); answer = ToRelativeTimeString(oleTime, COleDateTime::GetCurrentTime()); - // change this to return answer when happy return answer; } diff --git a/src/TortoiseProc/AppUtils.cpp b/src/TortoiseProc/AppUtils.cpp index a45a15c..ee13c09 100644 --- a/src/TortoiseProc/AppUtils.cpp +++ b/src/TortoiseProc/AppUtils.cpp @@ -1622,8 +1622,7 @@ CString CAppUtils::ToRelativeTimeString(CTime time) time.GetAsSystemTime( sysTime ); COleDateTime oleTime( sysTime ); answer = ToRelativeTimeString(oleTime, COleDateTime::GetCurrentTime()); - // change this to return answer when happy - return CAppUtils::FormatDateAndTime( time, DATE_SHORTDATE) + " " + answer; + return answer; } /** diff --git a/src/TortoiseProc/GitLogListBase.cpp b/src/TortoiseProc/GitLogListBase.cpp index c9cf2dd..1ffb73c 100644 --- a/src/TortoiseProc/GitLogListBase.cpp +++ b/src/TortoiseProc/GitLogListBase.cpp @@ -105,6 +105,9 @@ CGitLogListBase::CGitLogListBase():CHintListCtrl() { m_DateFormat = DATE_LONGDATE; } + // get relative time display setting from registry + DWORD regRelativeTimes = CRegDWORD(_T("Software\\TortoiseGit\\RelativeTimes"), FALSE); + m_bRelativeTimes = regRelativeTimes; } CGitLogListBase::~CGitLogListBase() @@ -862,7 +865,7 @@ void CGitLogListBase::OnLvnGetdispinfoLoglist(NMHDR *pNMHDR, LRESULT *pResult) case this->LOGLIST_DATE: //Date if (pLogEntry) lstrcpyn(pItem->pszText, - CAppUtils::FormatDateAndTime( pLogEntry->m_AuthorDate, m_DateFormat, true, true ), + CAppUtils::FormatDateAndTime( pLogEntry->m_AuthorDate, m_DateFormat, true, m_bRelativeTimes ), pItem->cchTextMax); break; @@ -1156,7 +1159,8 @@ void CGitLogListBase::CopySelectionToClipBoard(bool HashOnly) sLogCopyText.Format(_T("%s: %s\r\n%s: %s\r\n%s: %s\r\n%s:\r\n%s\r\n----\r\n%s\r\n\r\n"), (LPCTSTR)sRev, pLogEntry->m_CommitHash, (LPCTSTR)sAuthor, (LPCTSTR)pLogEntry->m_AuthorName, - (LPCTSTR)sDate, (LPCTSTR)CAppUtils::FormatDateAndTime( pLogEntry->m_AuthorDate, m_DateFormat ), + (LPCTSTR)sDate, + (LPCTSTR)CAppUtils::FormatDateAndTime( pLogEntry->m_AuthorDate, m_DateFormat, true, m_bRelativeTimes ), (LPCTSTR)sMessage, pLogEntry->m_Subject+_T("\r\n")+pLogEntry->m_Body, (LPCTSTR)sPaths); sClipdata += sLogCopyText; diff --git a/src/TortoiseProc/GitLogListBase.h b/src/TortoiseProc/GitLogListBase.h index 161f20b..9f9b06a 100644 --- a/src/TortoiseProc/GitLogListBase.h +++ b/src/TortoiseProc/GitLogListBase.h @@ -234,6 +234,7 @@ protected: COLORREF m_LineColors[Lanes::COLORS_NUM]; DWORD m_DateFormat; // DATE_SHORTDATE or DATE_LONGDATE + BOOL m_bRelativeTimes; // Show relative times }; diff --git a/src/TortoiseProc/Settings/SetDialogs.cpp b/src/TortoiseProc/Settings/SetDialogs.cpp index b6464e0..d4659e0 100644 --- a/src/TortoiseProc/Settings/SetDialogs.cpp +++ b/src/TortoiseProc/Settings/SetDialogs.cpp @@ -33,6 +33,7 @@ CSetDialogs::CSetDialogs() : ISettingsPropPage(CSetDialogs::IDD) , m_sDefaultLogs(_T("")) , m_bShortDateFormat(FALSE) + , m_bRelativeTimes(FALSE) , m_dwFontSize(0) , m_sFontName(_T("")) , m_bUseWCURL(FALSE) @@ -45,6 +46,7 @@ CSetDialogs::CSetDialogs() m_regAutoClose = CRegDWORD(_T("Software\\TortoiseGit\\AutoClose")); m_regDefaultLogs = CRegDWORD(_T("Software\\TortoiseGit\\NumberOfLogs"), 100); m_regShortDateFormat = CRegDWORD(_T("Software\\TortoiseGit\\LogDateFormat"), TRUE); + m_regRelativeTimes = CRegDWORD(_T("Software\\TortoiseGit\\RelativeTimes"), FALSE); m_regUseSystemLocaleForDates = CRegDWORD(_T("Software\\TortoiseGit\\UseSystemLocaleForDates"), TRUE); m_regFontName = CRegString(_T("Software\\TortoiseGit\\LogFontName"), _T("Courier New")); m_regFontSize = CRegDWORD(_T("Software\\TortoiseGit\\LogFontSize"), 8); @@ -73,6 +75,7 @@ void CSetDialogs::DoDataExchange(CDataExchange* pDX) DDX_Control(pDX, IDC_FONTNAMES, m_cFontNames); DDX_Text(pDX, IDC_DEFAULTLOG, m_sDefaultLogs); DDX_Check(pDX, IDC_SHORTDATEFORMAT, m_bShortDateFormat); + DDX_Check(pDX, IDC_RELATIVETIMES, m_bRelativeTimes); DDX_Control(pDX, IDC_AUTOCLOSECOMBO, m_cAutoClose); DDX_Check(pDX, IDC_WCURLFROM, m_bUseWCURL); DDX_Text(pDX, IDC_CHECKOUTPATH, m_sDefaultCheckoutPath); @@ -86,6 +89,7 @@ void CSetDialogs::DoDataExchange(CDataExchange* pDX) BEGIN_MESSAGE_MAP(CSetDialogs, ISettingsPropPage) ON_EN_CHANGE(IDC_DEFAULTLOG, OnChange) ON_BN_CLICKED(IDC_SHORTDATEFORMAT, OnChange) + ON_BN_CLICKED(IDC_RELATIVETIMES, OnChange) ON_BN_CLICKED(IDC_SYSTEMLOCALEFORDATES, OnChange) ON_CBN_SELCHANGE(IDC_FONTSIZES, OnChange) ON_CBN_SELCHANGE(IDC_FONTNAMES, OnChange) @@ -121,6 +125,7 @@ BOOL CSetDialogs::OnInitDialog() m_dwAutoClose = m_regAutoClose; m_bShortDateFormat = m_regShortDateFormat; + m_bRelativeTimes = m_regRelativeTimes; m_bUseSystemLocaleForDates = m_regUseSystemLocaleForDates; m_sFontName = m_regFontName; m_dwFontSize = m_regFontSize; @@ -143,6 +148,7 @@ BOOL CSetDialogs::OnInitDialog() m_tooltips.Create(this); m_tooltips.AddTool(IDC_SHORTDATEFORMAT, IDS_SETTINGS_SHORTDATEFORMAT_TT); + m_tooltips.AddTool(IDC_RELATIVETIMES, IDS_SETTINGS_RELATIVETIMES_TT); m_tooltips.AddTool(IDC_SYSTEMLOCALEFORDATES, IDS_SETTINGS_USESYSTEMLOCALEFORDATES_TT); m_tooltips.AddTool(IDC_AUTOCLOSECOMBO, IDS_SETTINGS_AUTOCLOSE_TT); m_tooltips.AddTool(IDC_WCURLFROM, IDS_SETTINGS_USEWCURL_TT); @@ -201,6 +207,7 @@ BOOL CSetDialogs::OnApply() Store (m_dwAutoClose, m_regAutoClose); Store (m_bShortDateFormat, m_regShortDateFormat); + Store (m_bRelativeTimes, m_regRelativeTimes); Store (m_bUseSystemLocaleForDates, m_regUseSystemLocaleForDates); long val = _ttol(m_sDefaultLogs); diff --git a/src/TortoiseProc/Settings/SetDialogs.h b/src/TortoiseProc/Settings/SetDialogs.h index a410d82..a154e52 100644 --- a/src/TortoiseProc/Settings/SetDialogs.h +++ b/src/TortoiseProc/Settings/SetDialogs.h @@ -50,7 +50,9 @@ protected: private: CToolTips m_tooltips; BOOL m_bShortDateFormat; + BOOL m_bRelativeTimes; CRegDWORD m_regShortDateFormat; + CRegDWORD m_regRelativeTimes; BOOL m_bUseSystemLocaleForDates; CRegDWORD m_regUseSystemLocaleForDates; CRegDWORD m_regAutoClose; diff --git a/src/TortoiseProc/resource.h b/src/TortoiseProc/resource.h index b6a409b1868474d3fe5b93f968a677d98e7bc073..5ac9e9b681672dde9f00cdbfd4bf86285c351471 100644 GIT binary patch delta 629 zcmZ3`$hoSAbAw;nIhd%1!6^ z#way?K^Y_4_G872tM*QAc)-FN2{gnJXjnXubf5f@QG0rTArss5Yo{6I_+fIva9K^T z?Bpe-Ky$R2*m(UJ{D5BdK$D+-B!*E=&==@bh%7?CI>huP2N>me!+|!tGI+!FLTsL# z;wd$~fsc`m7b1($3$~kOvXHdQ^n?sXHcm%|NVr~Ikhv_Ao4gcwU4R~mWI$*G8_P01 zNS8^0*8}LJP;}3-Oy6X|Bm)WzewaK$H`LNk-U>kfcmn+s3iPil++MJMSf($EXH*bI tmPZ(%3US$^Wip`X=iqe)hl&fD36n4RLFD;i@)#xrt&rJXV8~>^4*+Wiq*nj{ delta 123 zcmZ40!?~c5bAw;n=2dArInyUFGIC6w@P}=)!{uG`r|SeU@=XsYVq}}nQq1Tvy~`ZN z4J&4Jn4GmkVDg7_4n~W~f%9djKbXoWF#Sw1qtN6VJB6mnFmeIK4;INzZwO}O+AdJS Y_-OC+2R2L`({*f^q_)eLGx6~Q06dc`*8l(j -- 2.11.0