OSDN Git Service

Implement Show Relative Times checkbox in Settings, Dialog 1. This checkbox now contr...
authorColin Law <colin@clanlaw.org.uk>
Sat, 31 Jan 2009 15:22:47 +0000 (15:22 +0000)
committerFrank Li <lznuaa@gmail.com>
Sun, 1 Feb 2009 08:11:18 +0000 (16:11 +0800)
src/Git/GitRev.cpp
src/Git/GitRev.h
src/Resources/TortoiseProcENG.rc
src/TortoiseGitBlame/TortoiseGitBlameAppUtils.cpp
src/TortoiseProc/AppUtils.cpp
src/TortoiseProc/GitLogListBase.cpp
src/TortoiseProc/GitLogListBase.h
src/TortoiseProc/Settings/SetDialogs.cpp
src/TortoiseProc/Settings/SetDialogs.h
src/TortoiseProc/resource.h

index 5187484..6414c10 100644 (file)
@@ -17,6 +17,11 @@ GitRev::GitRev(void)
        m_Action=0;\r
        m_IsFull = 0;\r
        m_IsUpdateing = 0;\r
+       // fetch local machine timezone info\r
+       if ( GetTimeZoneInformation( &m_TimeZone ) == TIME_ZONE_ID_INVALID )\r
+       {\r
+               ASSERT(false);\r
+       }\r
 }\r
 \r
 GitRev::~GitRev(void)\r
@@ -205,22 +210,14 @@ CTime GitRev::ConverFromString(CString input)
        // get local timezone\r
        SYSTEMTIME sysTime;\r
        tm.GetAsSystemTime( sysTime );\r
-       TIME_ZONE_INFORMATION timeZone;\r
-       if ( GetTimeZoneInformation( &timeZone ) == TIME_ZONE_ID_INVALID )\r
+       SYSTEMTIME local;\r
+       if ( SystemTimeToTzSpecificLocalTime( &m_TimeZone, &sysTime, &local ) )\r
        {\r
-               ASSERT(false);\r
+               sysTime = local;\r
        }\r
        else\r
        {\r
-               SYSTEMTIME local;\r
-               if ( SystemTimeToTzSpecificLocalTime( &timeZone, &sysTime, &local ) )\r
-               {\r
-                       sysTime = local;\r
-               }\r
-               else\r
-               {\r
-                       ASSERT(false);\r
-               }\r
+               ASSERT(false);\r
        }\r
        tm = CTime( sysTime, 0 );\r
        return tm;\r
index 0f630a7..78bc016 100644 (file)
@@ -70,4 +70,7 @@ public:
        volatile LONG m_IsUpdateing;\r
        \r
        int SafeFetchFullInfo(CGit *git);\r
+\r
+private:\r
+       TIME_ZONE_INFORMATION m_TimeZone;\r
 };\r
index 1135ae1..294f66f 100644 (file)
Binary files a/src/Resources/TortoiseProcENG.rc and b/src/Resources/TortoiseProcENG.rc differ
index f1067bf..632aeea 100644 (file)
@@ -99,7 +99,6 @@ CString CAppUtils::ToRelativeTimeString(CTime time)
        time.GetAsSystemTime( sysTime );\r
        COleDateTime oleTime( sysTime );\r
        answer = ToRelativeTimeString(oleTime, COleDateTime::GetCurrentTime());\r
-       // change this to return answer when happy\r
        return answer;\r
 }\r
 \r
index a45a15c..ee13c09 100644 (file)
@@ -1622,8 +1622,7 @@ CString CAppUtils::ToRelativeTimeString(CTime time)
        time.GetAsSystemTime( sysTime );\r
        COleDateTime oleTime( sysTime );\r
        answer = ToRelativeTimeString(oleTime, COleDateTime::GetCurrentTime());\r
-       // change this to return answer when happy\r
-       return CAppUtils::FormatDateAndTime( time, DATE_SHORTDATE) + " " + answer;\r
+       return answer;\r
 }\r
 \r
 /**\r
index c9cf2dd..1ffb73c 100644 (file)
@@ -105,6 +105,9 @@ CGitLogListBase::CGitLogListBase():CHintListCtrl()
        {\r
                m_DateFormat = DATE_LONGDATE;\r
        }\r
+       // get relative time display setting from registry\r
+       DWORD regRelativeTimes = CRegDWORD(_T("Software\\TortoiseGit\\RelativeTimes"), FALSE);\r
+       m_bRelativeTimes = regRelativeTimes;\r
 }\r
 \r
 CGitLogListBase::~CGitLogListBase()\r
@@ -862,7 +865,7 @@ void CGitLogListBase::OnLvnGetdispinfoLoglist(NMHDR *pNMHDR, LRESULT *pResult)
        case this->LOGLIST_DATE: //Date\r
                if (pLogEntry)\r
                        lstrcpyn(pItem->pszText,\r
-                               CAppUtils::FormatDateAndTime( pLogEntry->m_AuthorDate, m_DateFormat, true, true ), \r
+                               CAppUtils::FormatDateAndTime( pLogEntry->m_AuthorDate, m_DateFormat, true, m_bRelativeTimes ), \r
                                pItem->cchTextMax);\r
                break;\r
                \r
@@ -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"),\r
                                        (LPCTSTR)sRev, pLogEntry->m_CommitHash,\r
                                        (LPCTSTR)sAuthor, (LPCTSTR)pLogEntry->m_AuthorName,\r
-                                       (LPCTSTR)sDate, (LPCTSTR)CAppUtils::FormatDateAndTime( pLogEntry->m_AuthorDate, m_DateFormat ),\r
+                                       (LPCTSTR)sDate, \r
+                                       (LPCTSTR)CAppUtils::FormatDateAndTime( pLogEntry->m_AuthorDate, m_DateFormat, true, m_bRelativeTimes ),\r
                                        (LPCTSTR)sMessage, pLogEntry->m_Subject+_T("\r\n")+pLogEntry->m_Body,\r
                                        (LPCTSTR)sPaths);\r
                                sClipdata +=  sLogCopyText;\r
index 161f20b..9f9b06a 100644 (file)
@@ -234,6 +234,7 @@ protected:
        \r
        COLORREF                        m_LineColors[Lanes::COLORS_NUM];\r
        DWORD                           m_DateFormat;   // DATE_SHORTDATE or DATE_LONGDATE\r
+       BOOL                            m_bRelativeTimes;       // Show relative times\r
 };\r
 \r
 \r
index b6464e0..d4659e0 100644 (file)
@@ -33,6 +33,7 @@ CSetDialogs::CSetDialogs()
        : ISettingsPropPage(CSetDialogs::IDD)\r
        , m_sDefaultLogs(_T(""))\r
        , m_bShortDateFormat(FALSE)\r
+       , m_bRelativeTimes(FALSE)\r
        , m_dwFontSize(0)\r
        , m_sFontName(_T(""))\r
        , m_bUseWCURL(FALSE)\r
@@ -45,6 +46,7 @@ CSetDialogs::CSetDialogs()
        m_regAutoClose = CRegDWORD(_T("Software\\TortoiseGit\\AutoClose"));\r
        m_regDefaultLogs = CRegDWORD(_T("Software\\TortoiseGit\\NumberOfLogs"), 100);\r
        m_regShortDateFormat = CRegDWORD(_T("Software\\TortoiseGit\\LogDateFormat"), TRUE);\r
+       m_regRelativeTimes = CRegDWORD(_T("Software\\TortoiseGit\\RelativeTimes"), FALSE);\r
        m_regUseSystemLocaleForDates = CRegDWORD(_T("Software\\TortoiseGit\\UseSystemLocaleForDates"), TRUE);\r
        m_regFontName = CRegString(_T("Software\\TortoiseGit\\LogFontName"), _T("Courier New"));\r
        m_regFontSize = CRegDWORD(_T("Software\\TortoiseGit\\LogFontSize"), 8);\r
@@ -73,6 +75,7 @@ void CSetDialogs::DoDataExchange(CDataExchange* pDX)
        DDX_Control(pDX, IDC_FONTNAMES, m_cFontNames);\r
        DDX_Text(pDX, IDC_DEFAULTLOG, m_sDefaultLogs);\r
        DDX_Check(pDX, IDC_SHORTDATEFORMAT, m_bShortDateFormat);\r
+       DDX_Check(pDX, IDC_RELATIVETIMES, m_bRelativeTimes);\r
        DDX_Control(pDX, IDC_AUTOCLOSECOMBO, m_cAutoClose);\r
        DDX_Check(pDX, IDC_WCURLFROM, m_bUseWCURL);\r
        DDX_Text(pDX, IDC_CHECKOUTPATH, m_sDefaultCheckoutPath);\r
@@ -86,6 +89,7 @@ void CSetDialogs::DoDataExchange(CDataExchange* pDX)
 BEGIN_MESSAGE_MAP(CSetDialogs, ISettingsPropPage)\r
        ON_EN_CHANGE(IDC_DEFAULTLOG, OnChange)\r
        ON_BN_CLICKED(IDC_SHORTDATEFORMAT, OnChange)\r
+       ON_BN_CLICKED(IDC_RELATIVETIMES, OnChange)\r
        ON_BN_CLICKED(IDC_SYSTEMLOCALEFORDATES, OnChange)\r
        ON_CBN_SELCHANGE(IDC_FONTSIZES, OnChange)\r
        ON_CBN_SELCHANGE(IDC_FONTNAMES, OnChange)\r
@@ -121,6 +125,7 @@ BOOL CSetDialogs::OnInitDialog()
 \r
        m_dwAutoClose = m_regAutoClose;\r
        m_bShortDateFormat = m_regShortDateFormat;\r
+       m_bRelativeTimes = m_regRelativeTimes;\r
        m_bUseSystemLocaleForDates = m_regUseSystemLocaleForDates;\r
        m_sFontName = m_regFontName;\r
        m_dwFontSize = m_regFontSize;\r
@@ -143,6 +148,7 @@ BOOL CSetDialogs::OnInitDialog()
 \r
        m_tooltips.Create(this);\r
        m_tooltips.AddTool(IDC_SHORTDATEFORMAT, IDS_SETTINGS_SHORTDATEFORMAT_TT);\r
+       m_tooltips.AddTool(IDC_RELATIVETIMES, IDS_SETTINGS_RELATIVETIMES_TT);\r
        m_tooltips.AddTool(IDC_SYSTEMLOCALEFORDATES, IDS_SETTINGS_USESYSTEMLOCALEFORDATES_TT);\r
        m_tooltips.AddTool(IDC_AUTOCLOSECOMBO, IDS_SETTINGS_AUTOCLOSE_TT);\r
        m_tooltips.AddTool(IDC_WCURLFROM, IDS_SETTINGS_USEWCURL_TT);\r
@@ -201,6 +207,7 @@ BOOL CSetDialogs::OnApply()
 \r
     Store (m_dwAutoClose, m_regAutoClose);\r
        Store (m_bShortDateFormat, m_regShortDateFormat);\r
+       Store (m_bRelativeTimes, m_regRelativeTimes);\r
     Store (m_bUseSystemLocaleForDates, m_regUseSystemLocaleForDates);\r
 \r
     long val = _ttol(m_sDefaultLogs);\r
index a410d82..a154e52 100644 (file)
@@ -50,7 +50,9 @@ protected:
 private:\r
        CToolTips               m_tooltips;\r
        BOOL                    m_bShortDateFormat;\r
+       BOOL                    m_bRelativeTimes;\r
        CRegDWORD               m_regShortDateFormat;\r
+       CRegDWORD               m_regRelativeTimes;\r
        BOOL                    m_bUseSystemLocaleForDates;\r
        CRegDWORD               m_regUseSystemLocaleForDates;\r
        CRegDWORD               m_regAutoClose;\r
index b6a409b..5ac9e9b 100644 (file)
Binary files a/src/TortoiseProc/resource.h and b/src/TortoiseProc/resource.h differ