diff --git a/src/Resources/Locales/en_US.axaml b/src/Resources/Locales/en_US.axaml index 0cc0f0a1..bd2efd9c 100644 --- a/src/Resources/Locales/en_US.axaml +++ b/src/Resources/Locales/en_US.axaml @@ -313,6 +313,7 @@ Switch Horizontal/Vertical Layout Switch Curve/Polyline Graph Mode AUTHOR + AUTHOR TIME GRAPH & SUBJECT SHA COMMIT TIME @@ -414,6 +415,7 @@ Check for updates on startup Language History Commits + Show author time intead of commit time in graph Subject Guide Length GIT Enable Auto CRLF diff --git a/src/Resources/Locales/zh_CN.axaml b/src/Resources/Locales/zh_CN.axaml index fe93e7d1..78e455d3 100644 --- a/src/Resources/Locales/zh_CN.axaml +++ b/src/Resources/Locales/zh_CN.axaml @@ -316,6 +316,7 @@ 切换横向/纵向显示 切换曲线/折线显示 作者 + 修改时间 路线图与主题 提交指纹 提交时间 @@ -413,6 +414,7 @@ 启动时检测软件更新 显示语言 最大历史提交数 + 在提交路线图中显示修改时间而非提交时间 SUBJECT字数检测 GIT配置 自动换行转换 diff --git a/src/Resources/Locales/zh_TW.axaml b/src/Resources/Locales/zh_TW.axaml index a75c1441..64ae8b06 100644 --- a/src/Resources/Locales/zh_TW.axaml +++ b/src/Resources/Locales/zh_TW.axaml @@ -316,6 +316,7 @@ 切換橫向/縱向顯示 切換曲線/折線顯示 作者 + 修改時間 路線圖與訊息標題 提交編號 提交時間 @@ -417,6 +418,7 @@ 啟動時檢查軟體更新 顯示語言 最大歷史提交數 + 在提交路線圖中顯示修改時間而非提交時間 提交標題字數偵測 Git 設定 自動換行轉換 diff --git a/src/ViewModels/Preference.cs b/src/ViewModels/Preference.cs index 49d70365..7a635498 100644 --- a/src/ViewModels/Preference.cs +++ b/src/ViewModels/Preference.cs @@ -132,6 +132,12 @@ namespace SourceGit.ViewModels set => SetProperty(ref _check4UpdatesOnStartup, value); } + public bool ShowAuthorTimeInGraph + { + get => _showAuthorTimeInGraph; + set => SetProperty(ref _showAuthorTimeInGraph, value); + } + public string IgnoreUpdateTag { get => _ignoreUpdateTag; @@ -577,6 +583,7 @@ namespace SourceGit.ViewModels private int _maxHistoryCommits = 20000; private int _subjectGuideLength = 50; private bool _useFixedTabWidth = true; + private bool _showAuthorTimeInGraph = false; private bool _check4UpdatesOnStartup = true; private double _lastCheckUpdateTime = 0; diff --git a/src/Views/Histories.axaml b/src/Views/Histories.axaml index 3996554d..65ec029d 100644 --- a/src/Views/Histories.axaml +++ b/src/Views/Histories.axaml @@ -51,7 +51,14 @@ - + + @@ -180,13 +187,13 @@ Opacity="{Binding Opacity}"/> - + diff --git a/src/Views/Histories.axaml.cs b/src/Views/Histories.axaml.cs index 2c8014ca..66aac50b 100644 --- a/src/Views/Histories.axaml.cs +++ b/src/Views/Histories.axaml.cs @@ -303,13 +303,13 @@ namespace SourceGit.Views set => SetValue(ShowAsDateTimeProperty, value); } - public static readonly StyledProperty TimestampProperty = - AvaloniaProperty.Register(nameof(Timestamp)); + public static readonly StyledProperty UseAuthorTimeProperty = + AvaloniaProperty.Register(nameof(UseAuthorTime), true); - public ulong Timestamp + public bool UseAuthorTime { - get => GetValue(TimestampProperty); - set => SetValue(TimestampProperty, value); + get => GetValue(UseAuthorTimeProperty); + set => SetValue(UseAuthorTimeProperty, value); } protected override Type StyleKeyOverride => typeof(TextBlock); @@ -318,7 +318,7 @@ namespace SourceGit.Views { base.OnPropertyChanged(change); - if (change.Property == TimestampProperty) + if (change.Property == UseAuthorTimeProperty) { SetCurrentValue(TextProperty, GetDisplayText()); } @@ -347,6 +347,12 @@ namespace SourceGit.Views StopTimer(); } + protected override void OnDataContextChanged(EventArgs e) + { + base.OnDataContextChanged(e); + SetCurrentValue(TextProperty, GetDisplayText()); + } + private void StartTimer() { if (_refreshTimer != null) @@ -376,30 +382,35 @@ namespace SourceGit.Views private string GetDisplayText() { + var commit = DataContext as Models.Commit; + if (commit == null) + return string.Empty; + + var timestamp = UseAuthorTime ? commit.AuthorTime : commit.CommitterTime; if (ShowAsDateTime) - return DateTime.UnixEpoch.AddSeconds(Timestamp).ToLocalTime().ToString("yyyy/MM/dd HH:mm:ss"); + return DateTime.UnixEpoch.AddSeconds(timestamp).ToLocalTime().ToString("yyyy/MM/dd HH:mm:ss"); var today = DateTime.Today; - var committerTime = DateTime.UnixEpoch.AddSeconds(Timestamp).ToLocalTime(); + var localTime = DateTime.UnixEpoch.AddSeconds(timestamp).ToLocalTime(); - if (committerTime >= today) + if (localTime >= today) { var now = DateTime.Now; - var timespan = now - committerTime; + var timespan = now - localTime; if (timespan.TotalHours > 1) return App.Text("Period.HoursAgo", (int)timespan.TotalHours); return timespan.TotalMinutes < 1 ? App.Text("Period.JustNow") : App.Text("Period.MinutesAgo", (int)timespan.TotalMinutes); } - var diffYear = today.Year - committerTime.Year; + var diffYear = today.Year - localTime.Year; if (diffYear == 0) { - var diffMonth = today.Month - committerTime.Month; + var diffMonth = today.Month - localTime.Month; if (diffMonth > 0) return diffMonth == 1 ? App.Text("Period.LastMonth") : App.Text("Period.MonthsAgo", diffMonth); - var diffDay = today.Day - committerTime.Day; + var diffDay = today.Day - localTime.Day; return diffDay == 1 ? App.Text("Period.Yesterday") : App.Text("Period.DaysAgo", diffDay); } diff --git a/src/Views/Preference.axaml b/src/Views/Preference.axaml index 88d335e3..1198008e 100644 --- a/src/Views/Preference.axaml +++ b/src/Views/Preference.axaml @@ -52,7 +52,7 @@ - + + +