enhance: notification popup

This commit is contained in:
leo 2024-12-13 10:06:28 +08:00
parent 6eb226eb44
commit 02658839c2
No known key found for this signature in database
3 changed files with 23 additions and 5 deletions

View file

@ -74,7 +74,11 @@ namespace SourceGit.Commands
} }
if (string.IsNullOrEmpty(e.Data)) if (string.IsNullOrEmpty(e.Data))
{
errs.Add(string.Empty);
return; return;
}
if (TraitErrorAsOutput) if (TraitErrorAsOutput)
OnReadline(e.Data); OnReadline(e.Data);
@ -89,6 +93,7 @@ namespace SourceGit.Commands
return; return;
if (REG_PROGRESS().IsMatch(e.Data)) if (REG_PROGRESS().IsMatch(e.Data))
return; return;
errs.Add(e.Data); errs.Add(e.Data);
}; };

View file

@ -112,19 +112,24 @@
<Border Margin="6" HorizontalAlignment="Stretch" VerticalAlignment="Top" Effect="drop-shadow(0 0 8 #8F000000)"> <Border Margin="6" HorizontalAlignment="Stretch" VerticalAlignment="Top" Effect="drop-shadow(0 0 8 #8F000000)">
<Border Padding="8" CornerRadius="6" Background="{DynamicResource Brush.Popup}"> <Border Padding="8" CornerRadius="6" Background="{DynamicResource Brush.Popup}">
<Grid RowDefinitions="26,Auto"> <Grid RowDefinitions="26,Auto">
<Grid Grid.Row="0" ColumnDefinitions="Auto,*,Auto" Margin="8,0"> <Grid Grid.Row="0" ColumnDefinitions="Auto,*,Auto,Auto" Margin="8,0">
<Path Grid.Column="0" Width="14" Height="14" Data="{StaticResource Icons.Error}" Fill="Red" IsVisible="{Binding IsError}"/> <Path Grid.Column="0" Width="14" Height="14" Data="{StaticResource Icons.Error}" Fill="Red" IsVisible="{Binding IsError}"/>
<Path Grid.Column="0" Width="14" Height="14" Data="{StaticResource Icons.Info}" Fill="Green" IsVisible="{Binding !IsError}"/> <Path Grid.Column="0" Width="14" Height="14" Data="{StaticResource Icons.Info}" Fill="Green" IsVisible="{Binding !IsError}"/>
<TextBlock Grid.Column="1" Margin="8,0,0,0" FontWeight="Bold" FontSize="14" Text="{DynamicResource Text.Launcher.Error}" IsVisible="{Binding IsError}"/> <TextBlock Grid.Column="1" Margin="8,0,0,0" FontWeight="Bold" FontSize="14" Text="{DynamicResource Text.Launcher.Error}" IsVisible="{Binding IsError}"/>
<TextBlock Grid.Column="1" Margin="8,0,0,0" FontWeight="Bold" FontSize="14" Text="{DynamicResource Text.Launcher.Info}" IsVisible="{Binding !IsError}"/> <TextBlock Grid.Column="1" Margin="8,0,0,0" FontWeight="Bold" FontSize="14" Text="{DynamicResource Text.Launcher.Info}" IsVisible="{Binding !IsError}"/>
<Button Grid.Column="2" Classes="icon_button" Width="16" Height="16" Click="OnDismissNotification"> <Button Grid.Column="2" Classes="icon_button" Width="16" Height="16" Click="OnCopyNotification">
<Path Width="12" Height="12" Data="{StaticResource Icons.Copy}"/>
</Button>
<Button Grid.Column="3" Classes="icon_button" Width="16" Height="16" Margin="8,0,0,0" Click="OnDismissNotification">
<Path Width="10" Height="10" Data="{StaticResource Icons.Window.Close}"/> <Path Width="10" Height="10" Data="{StaticResource Icons.Window.Close}"/>
</Button> </Button>
</Grid> </Grid>
<ScrollViewer Grid.Row="1" Margin="8" MaxHeight="100" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto"> <Border Grid.Row="1" Margin="8" Background="{DynamicResource Brush.Contents}" BorderThickness="1" BorderBrush="{DynamicResource Brush.Border2}">
<SelectableTextBlock TextWrapping="Wrap" Text="{Binding Message}"/> <ScrollViewer MaxHeight="200" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
<TextBlock Margin="4,2" TextWrapping="NoWrap" Text="{Binding Message}"/>
</ScrollViewer> </ScrollViewer>
</Border>
</Grid> </Grid>
</Border> </Border>
</Border> </Border>

View file

@ -32,6 +32,14 @@ namespace SourceGit.Views
OnPopupCancel(sender, e); OnPopupCancel(sender, e);
} }
private void OnCopyNotification(object sender, RoutedEventArgs e)
{
if (sender is Button { DataContext: Models.Notification notice })
App.CopyText(notice.Message);
e.Handled = true;
}
private void OnDismissNotification(object sender, RoutedEventArgs e) private void OnDismissNotification(object sender, RoutedEventArgs e)
{ {
if (sender is Button { DataContext: Models.Notification notice } && if (sender is Button { DataContext: Models.Notification notice } &&