mirror of
https://github.com/sourcegit-scm/sourcegit.git
synced 2024-12-25 21:07:20 -08:00
feature: add a toggle in perference to show author time instead of committer time in graph (#558)
This commit is contained in:
parent
1f7a54e61e
commit
21e15a1af4
7 changed files with 53 additions and 17 deletions
|
@ -313,6 +313,7 @@
|
||||||
<x:String x:Key="Text.Histories.DisplayMode" xml:space="preserve">Switch Horizontal/Vertical Layout</x:String>
|
<x:String x:Key="Text.Histories.DisplayMode" xml:space="preserve">Switch Horizontal/Vertical Layout</x:String>
|
||||||
<x:String x:Key="Text.Histories.GraphMode" xml:space="preserve">Switch Curve/Polyline Graph Mode</x:String>
|
<x:String x:Key="Text.Histories.GraphMode" xml:space="preserve">Switch Curve/Polyline Graph Mode</x:String>
|
||||||
<x:String x:Key="Text.Histories.Header.Author" xml:space="preserve">AUTHOR</x:String>
|
<x:String x:Key="Text.Histories.Header.Author" xml:space="preserve">AUTHOR</x:String>
|
||||||
|
<x:String x:Key="Text.Histories.Header.AuthorTime" xml:space="preserve">AUTHOR TIME</x:String>
|
||||||
<x:String x:Key="Text.Histories.Header.GraphAndSubject" xml:space="preserve">GRAPH & SUBJECT</x:String>
|
<x:String x:Key="Text.Histories.Header.GraphAndSubject" xml:space="preserve">GRAPH & SUBJECT</x:String>
|
||||||
<x:String x:Key="Text.Histories.Header.SHA" xml:space="preserve">SHA</x:String>
|
<x:String x:Key="Text.Histories.Header.SHA" xml:space="preserve">SHA</x:String>
|
||||||
<x:String x:Key="Text.Histories.Header.Time" xml:space="preserve">COMMIT TIME</x:String>
|
<x:String x:Key="Text.Histories.Header.Time" xml:space="preserve">COMMIT TIME</x:String>
|
||||||
|
@ -414,6 +415,7 @@
|
||||||
<x:String x:Key="Text.Preference.General.Check4UpdatesOnStartup" xml:space="preserve">Check for updates on startup</x:String>
|
<x:String x:Key="Text.Preference.General.Check4UpdatesOnStartup" xml:space="preserve">Check for updates on startup</x:String>
|
||||||
<x:String x:Key="Text.Preference.General.Locale" xml:space="preserve">Language</x:String>
|
<x:String x:Key="Text.Preference.General.Locale" xml:space="preserve">Language</x:String>
|
||||||
<x:String x:Key="Text.Preference.General.MaxHistoryCommits" xml:space="preserve">History Commits</x:String>
|
<x:String x:Key="Text.Preference.General.MaxHistoryCommits" xml:space="preserve">History Commits</x:String>
|
||||||
|
<x:String x:Key="Text.Preference.General.ShowAuthorTime" xml:space="preserve">Show author time intead of commit time in graph</x:String>
|
||||||
<x:String x:Key="Text.Preference.General.SubjectGuideLength" xml:space="preserve">Subject Guide Length</x:String>
|
<x:String x:Key="Text.Preference.General.SubjectGuideLength" xml:space="preserve">Subject Guide Length</x:String>
|
||||||
<x:String x:Key="Text.Preference.Git" xml:space="preserve">GIT</x:String>
|
<x:String x:Key="Text.Preference.Git" xml:space="preserve">GIT</x:String>
|
||||||
<x:String x:Key="Text.Preference.Git.CRLF" xml:space="preserve">Enable Auto CRLF</x:String>
|
<x:String x:Key="Text.Preference.Git.CRLF" xml:space="preserve">Enable Auto CRLF</x:String>
|
||||||
|
|
|
@ -316,6 +316,7 @@
|
||||||
<x:String x:Key="Text.Histories.DisplayMode" xml:space="preserve">切换横向/纵向显示</x:String>
|
<x:String x:Key="Text.Histories.DisplayMode" xml:space="preserve">切换横向/纵向显示</x:String>
|
||||||
<x:String x:Key="Text.Histories.GraphMode" xml:space="preserve">切换曲线/折线显示</x:String>
|
<x:String x:Key="Text.Histories.GraphMode" xml:space="preserve">切换曲线/折线显示</x:String>
|
||||||
<x:String x:Key="Text.Histories.Header.Author" xml:space="preserve">作者</x:String>
|
<x:String x:Key="Text.Histories.Header.Author" xml:space="preserve">作者</x:String>
|
||||||
|
<x:String x:Key="Text.Histories.Header.AuthorTime" xml:space="preserve">修改时间</x:String>
|
||||||
<x:String x:Key="Text.Histories.Header.GraphAndSubject" xml:space="preserve">路线图与主题</x:String>
|
<x:String x:Key="Text.Histories.Header.GraphAndSubject" xml:space="preserve">路线图与主题</x:String>
|
||||||
<x:String x:Key="Text.Histories.Header.SHA" xml:space="preserve">提交指纹</x:String>
|
<x:String x:Key="Text.Histories.Header.SHA" xml:space="preserve">提交指纹</x:String>
|
||||||
<x:String x:Key="Text.Histories.Header.Time" xml:space="preserve">提交时间</x:String>
|
<x:String x:Key="Text.Histories.Header.Time" xml:space="preserve">提交时间</x:String>
|
||||||
|
@ -413,6 +414,7 @@
|
||||||
<x:String x:Key="Text.Preference.General.Check4UpdatesOnStartup" xml:space="preserve">启动时检测软件更新</x:String>
|
<x:String x:Key="Text.Preference.General.Check4UpdatesOnStartup" xml:space="preserve">启动时检测软件更新</x:String>
|
||||||
<x:String x:Key="Text.Preference.General.Locale" xml:space="preserve">显示语言</x:String>
|
<x:String x:Key="Text.Preference.General.Locale" xml:space="preserve">显示语言</x:String>
|
||||||
<x:String x:Key="Text.Preference.General.MaxHistoryCommits" xml:space="preserve">最大历史提交数</x:String>
|
<x:String x:Key="Text.Preference.General.MaxHistoryCommits" xml:space="preserve">最大历史提交数</x:String>
|
||||||
|
<x:String x:Key="Text.Preference.General.ShowAuthorTime" xml:space="preserve">在提交路线图中显示修改时间而非提交时间</x:String>
|
||||||
<x:String x:Key="Text.Preference.General.SubjectGuideLength" xml:space="preserve">SUBJECT字数检测</x:String>
|
<x:String x:Key="Text.Preference.General.SubjectGuideLength" xml:space="preserve">SUBJECT字数检测</x:String>
|
||||||
<x:String x:Key="Text.Preference.Git" xml:space="preserve">GIT配置</x:String>
|
<x:String x:Key="Text.Preference.Git" xml:space="preserve">GIT配置</x:String>
|
||||||
<x:String x:Key="Text.Preference.Git.CRLF" xml:space="preserve">自动换行转换</x:String>
|
<x:String x:Key="Text.Preference.Git.CRLF" xml:space="preserve">自动换行转换</x:String>
|
||||||
|
|
|
@ -316,6 +316,7 @@
|
||||||
<x:String x:Key="Text.Histories.DisplayMode" xml:space="preserve">切換橫向/縱向顯示</x:String>
|
<x:String x:Key="Text.Histories.DisplayMode" xml:space="preserve">切換橫向/縱向顯示</x:String>
|
||||||
<x:String x:Key="Text.Histories.GraphMode" xml:space="preserve">切換曲線/折線顯示</x:String>
|
<x:String x:Key="Text.Histories.GraphMode" xml:space="preserve">切換曲線/折線顯示</x:String>
|
||||||
<x:String x:Key="Text.Histories.Header.Author" xml:space="preserve">作者</x:String>
|
<x:String x:Key="Text.Histories.Header.Author" xml:space="preserve">作者</x:String>
|
||||||
|
<x:String x:Key="Text.Histories.Header.AuthorTime" xml:space="preserve">修改時間</x:String>
|
||||||
<x:String x:Key="Text.Histories.Header.GraphAndSubject" xml:space="preserve">路線圖與訊息標題</x:String>
|
<x:String x:Key="Text.Histories.Header.GraphAndSubject" xml:space="preserve">路線圖與訊息標題</x:String>
|
||||||
<x:String x:Key="Text.Histories.Header.SHA" xml:space="preserve">提交編號</x:String>
|
<x:String x:Key="Text.Histories.Header.SHA" xml:space="preserve">提交編號</x:String>
|
||||||
<x:String x:Key="Text.Histories.Header.Time" xml:space="preserve">提交時間</x:String>
|
<x:String x:Key="Text.Histories.Header.Time" xml:space="preserve">提交時間</x:String>
|
||||||
|
@ -417,6 +418,7 @@
|
||||||
<x:String x:Key="Text.Preference.General.Check4UpdatesOnStartup" xml:space="preserve">啟動時檢查軟體更新</x:String>
|
<x:String x:Key="Text.Preference.General.Check4UpdatesOnStartup" xml:space="preserve">啟動時檢查軟體更新</x:String>
|
||||||
<x:String x:Key="Text.Preference.General.Locale" xml:space="preserve">顯示語言</x:String>
|
<x:String x:Key="Text.Preference.General.Locale" xml:space="preserve">顯示語言</x:String>
|
||||||
<x:String x:Key="Text.Preference.General.MaxHistoryCommits" xml:space="preserve">最大歷史提交數</x:String>
|
<x:String x:Key="Text.Preference.General.MaxHistoryCommits" xml:space="preserve">最大歷史提交數</x:String>
|
||||||
|
<x:String x:Key="Text.Preference.General.ShowAuthorTime" xml:space="preserve">在提交路線圖中顯示修改時間而非提交時間</x:String>
|
||||||
<x:String x:Key="Text.Preference.General.SubjectGuideLength" xml:space="preserve">提交標題字數偵測</x:String>
|
<x:String x:Key="Text.Preference.General.SubjectGuideLength" xml:space="preserve">提交標題字數偵測</x:String>
|
||||||
<x:String x:Key="Text.Preference.Git" xml:space="preserve">Git 設定</x:String>
|
<x:String x:Key="Text.Preference.Git" xml:space="preserve">Git 設定</x:String>
|
||||||
<x:String x:Key="Text.Preference.Git.CRLF" xml:space="preserve">自動換行轉換</x:String>
|
<x:String x:Key="Text.Preference.Git.CRLF" xml:space="preserve">自動換行轉換</x:String>
|
||||||
|
|
|
@ -132,6 +132,12 @@ namespace SourceGit.ViewModels
|
||||||
set => SetProperty(ref _check4UpdatesOnStartup, value);
|
set => SetProperty(ref _check4UpdatesOnStartup, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool ShowAuthorTimeInGraph
|
||||||
|
{
|
||||||
|
get => _showAuthorTimeInGraph;
|
||||||
|
set => SetProperty(ref _showAuthorTimeInGraph, value);
|
||||||
|
}
|
||||||
|
|
||||||
public string IgnoreUpdateTag
|
public string IgnoreUpdateTag
|
||||||
{
|
{
|
||||||
get => _ignoreUpdateTag;
|
get => _ignoreUpdateTag;
|
||||||
|
@ -577,6 +583,7 @@ namespace SourceGit.ViewModels
|
||||||
private int _maxHistoryCommits = 20000;
|
private int _maxHistoryCommits = 20000;
|
||||||
private int _subjectGuideLength = 50;
|
private int _subjectGuideLength = 50;
|
||||||
private bool _useFixedTabWidth = true;
|
private bool _useFixedTabWidth = true;
|
||||||
|
private bool _showAuthorTimeInGraph = false;
|
||||||
|
|
||||||
private bool _check4UpdatesOnStartup = true;
|
private bool _check4UpdatesOnStartup = true;
|
||||||
private double _lastCheckUpdateTime = 0;
|
private double _lastCheckUpdateTime = 0;
|
||||||
|
|
|
@ -51,7 +51,14 @@
|
||||||
<ToggleButton Classes="time_display_mode"
|
<ToggleButton Classes="time_display_mode"
|
||||||
Width="10" Height="10"
|
Width="10" Height="10"
|
||||||
IsChecked="{Binding Source={x:Static vm:Preference.Instance}, Path=DisplayTimeAsPeriodInHistories, Mode=TwoWay}"/>
|
IsChecked="{Binding Source={x:Static vm:Preference.Instance}, Path=DisplayTimeAsPeriodInHistories, Mode=TwoWay}"/>
|
||||||
<TextBlock Classes="table_header" Margin="6,0,0,0" Text="{DynamicResource Text.Histories.Header.Time}"/>
|
<TextBlock Classes="table_header"
|
||||||
|
Margin="6,0,0,0"
|
||||||
|
Text="{DynamicResource Text.Histories.Header.Time}"
|
||||||
|
IsVisible="{Binding Source={x:Static vm:Preference.Instance}, Path=ShowAuthorTimeInGraph, Converter={x:Static BoolConverters.Not}, Mode=OneWay}"/>
|
||||||
|
<TextBlock Classes="table_header"
|
||||||
|
Margin="6,0,0,0"
|
||||||
|
Text="{DynamicResource Text.Histories.Header.AuthorTime}"
|
||||||
|
IsVisible="{Binding Source={x:Static vm:Preference.Instance}, Path=ShowAuthorTimeInGraph, Mode=OneWay}"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Border>
|
</Border>
|
||||||
|
@ -180,13 +187,13 @@
|
||||||
Opacity="{Binding Opacity}"/>
|
Opacity="{Binding Opacity}"/>
|
||||||
</Border>
|
</Border>
|
||||||
|
|
||||||
<!-- COMMIT TIME -->
|
<!-- TIME -->
|
||||||
<Border Grid.Column="3" Padding="4,0" ClipToBounds="True" IsHitTestVisible="False">
|
<Border Grid.Column="3" Padding="4,0" ClipToBounds="True" IsHitTestVisible="False">
|
||||||
<v:CommitTimeTextBlock Classes="primary"
|
<v:CommitTimeTextBlock Classes="primary"
|
||||||
HorizontalAlignment="Center"
|
HorizontalAlignment="Center"
|
||||||
FontWeight="{Binding FontWeight}"
|
FontWeight="{Binding FontWeight}"
|
||||||
Opacity="{Binding Opacity}"
|
Opacity="{Binding Opacity}"
|
||||||
Timestamp="{Binding CommitterTime}"
|
UseAuthorTime="{Binding Source={x:Static vm:Preference.Instance}, Path=ShowAuthorTimeInGraph, Mode=OneWay}"
|
||||||
ShowAsDateTime="{Binding Source={x:Static vm:Preference.Instance}, Path=!DisplayTimeAsPeriodInHistories}"/>
|
ShowAsDateTime="{Binding Source={x:Static vm:Preference.Instance}, Path=!DisplayTimeAsPeriodInHistories}"/>
|
||||||
</Border>
|
</Border>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
|
@ -303,13 +303,13 @@ namespace SourceGit.Views
|
||||||
set => SetValue(ShowAsDateTimeProperty, value);
|
set => SetValue(ShowAsDateTimeProperty, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static readonly StyledProperty<ulong> TimestampProperty =
|
public static readonly StyledProperty<bool> UseAuthorTimeProperty =
|
||||||
AvaloniaProperty.Register<CommitTimeTextBlock, ulong>(nameof(Timestamp));
|
AvaloniaProperty.Register<CommitTimeTextBlock, bool>(nameof(UseAuthorTime), true);
|
||||||
|
|
||||||
public ulong Timestamp
|
public bool UseAuthorTime
|
||||||
{
|
{
|
||||||
get => GetValue(TimestampProperty);
|
get => GetValue(UseAuthorTimeProperty);
|
||||||
set => SetValue(TimestampProperty, value);
|
set => SetValue(UseAuthorTimeProperty, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override Type StyleKeyOverride => typeof(TextBlock);
|
protected override Type StyleKeyOverride => typeof(TextBlock);
|
||||||
|
@ -318,7 +318,7 @@ namespace SourceGit.Views
|
||||||
{
|
{
|
||||||
base.OnPropertyChanged(change);
|
base.OnPropertyChanged(change);
|
||||||
|
|
||||||
if (change.Property == TimestampProperty)
|
if (change.Property == UseAuthorTimeProperty)
|
||||||
{
|
{
|
||||||
SetCurrentValue(TextProperty, GetDisplayText());
|
SetCurrentValue(TextProperty, GetDisplayText());
|
||||||
}
|
}
|
||||||
|
@ -347,6 +347,12 @@ namespace SourceGit.Views
|
||||||
StopTimer();
|
StopTimer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void OnDataContextChanged(EventArgs e)
|
||||||
|
{
|
||||||
|
base.OnDataContextChanged(e);
|
||||||
|
SetCurrentValue(TextProperty, GetDisplayText());
|
||||||
|
}
|
||||||
|
|
||||||
private void StartTimer()
|
private void StartTimer()
|
||||||
{
|
{
|
||||||
if (_refreshTimer != null)
|
if (_refreshTimer != null)
|
||||||
|
@ -376,30 +382,35 @@ namespace SourceGit.Views
|
||||||
|
|
||||||
private string GetDisplayText()
|
private string GetDisplayText()
|
||||||
{
|
{
|
||||||
|
var commit = DataContext as Models.Commit;
|
||||||
|
if (commit == null)
|
||||||
|
return string.Empty;
|
||||||
|
|
||||||
|
var timestamp = UseAuthorTime ? commit.AuthorTime : commit.CommitterTime;
|
||||||
if (ShowAsDateTime)
|
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 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 now = DateTime.Now;
|
||||||
var timespan = now - committerTime;
|
var timespan = now - localTime;
|
||||||
if (timespan.TotalHours > 1)
|
if (timespan.TotalHours > 1)
|
||||||
return App.Text("Period.HoursAgo", (int)timespan.TotalHours);
|
return App.Text("Period.HoursAgo", (int)timespan.TotalHours);
|
||||||
|
|
||||||
return timespan.TotalMinutes < 1 ? App.Text("Period.JustNow") : App.Text("Period.MinutesAgo", (int)timespan.TotalMinutes);
|
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)
|
if (diffYear == 0)
|
||||||
{
|
{
|
||||||
var diffMonth = today.Month - committerTime.Month;
|
var diffMonth = today.Month - localTime.Month;
|
||||||
if (diffMonth > 0)
|
if (diffMonth > 0)
|
||||||
return diffMonth == 1 ? App.Text("Period.LastMonth") : App.Text("Period.MonthsAgo", diffMonth);
|
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);
|
return diffDay == 1 ? App.Text("Period.Yesterday") : App.Text("Period.DaysAgo", diffDay);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@
|
||||||
<TabItem.Header>
|
<TabItem.Header>
|
||||||
<TextBlock Classes="tab_header" Text="{DynamicResource Text.Preference.General}"/>
|
<TextBlock Classes="tab_header" Text="{DynamicResource Text.Preference.General}"/>
|
||||||
</TabItem.Header>
|
</TabItem.Header>
|
||||||
<Grid Margin="8" RowDefinitions="32,32,32,32,32" ColumnDefinitions="Auto,*">
|
<Grid Margin="8" RowDefinitions="32,32,32,32,32,32" ColumnDefinitions="Auto,*">
|
||||||
<TextBlock Grid.Row="0" Grid.Column="0"
|
<TextBlock Grid.Row="0" Grid.Column="0"
|
||||||
Text="{DynamicResource Text.Preference.General.Locale}"
|
Text="{DynamicResource Text.Preference.General.Locale}"
|
||||||
HorizontalAlignment="Right"
|
HorizontalAlignment="Right"
|
||||||
|
@ -116,6 +116,11 @@
|
||||||
Height="32"
|
Height="32"
|
||||||
Content="{DynamicResource Text.Preference.General.Check4UpdatesOnStartup}"
|
Content="{DynamicResource Text.Preference.General.Check4UpdatesOnStartup}"
|
||||||
IsChecked="{Binding Source={x:Static vm:Preference.Instance}, Path=Check4UpdatesOnStartup, Mode=TwoWay}"/>
|
IsChecked="{Binding Source={x:Static vm:Preference.Instance}, Path=Check4UpdatesOnStartup, Mode=TwoWay}"/>
|
||||||
|
|
||||||
|
<CheckBox Grid.Row="5" Grid.Column="1"
|
||||||
|
Height="32"
|
||||||
|
Content="{DynamicResource Text.Preference.General.ShowAuthorTime}"
|
||||||
|
IsChecked="{Binding Source={x:Static vm:Preference.Instance}, Path=ShowAuthorTimeInGraph, Mode=TwoWay}"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</TabItem>
|
</TabItem>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue