Improve report window with dark theme & localization support

This commit is contained in:
Jack251970 2025-02-21 21:17:00 +08:00
parent 41733615fd
commit 44aa17d7c9
3 changed files with 134 additions and 37 deletions

View file

@ -383,6 +383,12 @@
<system:String x:Key="reportWindow_report_succeed">Report sent successfully</system:String> <system:String x:Key="reportWindow_report_succeed">Report sent successfully</system:String>
<system:String x:Key="reportWindow_report_failed">Failed to send report</system:String> <system:String x:Key="reportWindow_report_failed">Failed to send report</system:String>
<system:String x:Key="reportWindow_flowlauncher_got_an_error">Flow Launcher got an error</system:String> <system:String x:Key="reportWindow_flowlauncher_got_an_error">Flow Launcher got an error</system:String>
<system:String x:Key="reportWindow_please_open_issue">Please open new issue in</system:String>
<system:String x:Key="reportWindow_upload_log">1. Upload log file: {0}</system:String>
<system:String x:Key="reportWindow_copy_below">2. Copy below exception message</system:String>
<system:String x:Key="reportWindow_date">Date: {0}</system:String>
<system:String x:Key="reportWindow_exception">Exception:</system:String>
<system:String x:Key="reportWindow_length">Length</system:String>
<!-- General Notice --> <!-- General Notice -->
<system:String x:Key="pleaseWait">Please wait...</system:String> <system:String x:Key="pleaseWait">Please wait...</system:String>

View file

@ -1,23 +1,82 @@
<Window x:Class="Flow.Launcher.ReportWindow" <Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" x:Class="Flow.Launcher.ReportWindow"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
WindowStartupLocation="CenterScreen" Title="{DynamicResource reportWindow_flowlauncher_got_an_error}"
Icon="Images/app_error.png" Width="600"
Topmost="True" Height="455"
ResizeMode="NoResize" d:DesignHeight="300"
Width="600" d:DesignWidth="600"
Height="455" x:ClassModifier="internal"
Title="{DynamicResource reportWindow_flowlauncher_got_an_error}" Background="{DynamicResource PopuBGColor}"
d:DesignHeight="300" d:DesignWidth="600" x:ClassModifier="internal"> Foreground="{DynamicResource PopupTextColor}"
<RichTextBox x:Name="ErrorTextbox" Icon="/Images/app_error.png"
IsDocumentEnabled="True" ResizeMode="NoResize"
VerticalScrollBarVisibility="Auto" Topmost="True"
HorizontalScrollBarVisibility="Auto" WindowStartupLocation="CenterScreen"
FontSize="14" mc:Ignorable="d">
Margin="10" <WindowChrome.WindowChrome>
BorderThickness="0"/> <WindowChrome CaptionHeight="32" ResizeBorderThickness="{x:Static SystemParameters.WindowResizeBorderThickness}" />
</WindowChrome.WindowChrome>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Image
Grid.Column="0"
Width="16"
Height="16"
Margin="10 4 4 4"
RenderOptions.BitmapScalingMode="HighQuality"
Source="/Images/app_error.png" />
<TextBlock
Grid.Column="1"
Margin="4 0 0 0"
VerticalAlignment="Center"
FontSize="12"
Foreground="{DynamicResource Color05B}"
Text="{DynamicResource reportWindow_flowlauncher_got_an_error}" />
<Button
Grid.Column="2"
Click="BtnCancel_OnClick"
Style="{StaticResource TitleBarCloseButtonStyle}">
<Path
Width="46"
Height="32"
Data="M 18,11 27,20 M 18,20 27,11"
Stroke="{Binding Path=Foreground, RelativeSource={RelativeSource AncestorType={x:Type Button}}}"
StrokeThickness="1">
<Path.Style>
<Style TargetType="Path">
<Style.Triggers>
<DataTrigger Binding="{Binding Path=IsActive, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}" Value="False">
<Setter Property="Opacity" Value="0.5" />
</DataTrigger>
</Style.Triggers>
</Style>
</Path.Style>
</Path>
</Button>
</Grid>
<RichTextBox
x:Name="ErrorTextbox"
Grid.Row="1"
Margin="10"
BorderThickness="0"
FontSize="14"
HorizontalScrollBarVisibility="Auto"
IsDocumentEnabled="True"
VerticalScrollBarVisibility="Auto" />
</Grid>
</Window> </Window>

View file

@ -6,10 +6,10 @@ using System.Text;
using System.Linq; using System.Linq;
using System.Windows; using System.Windows;
using System.Windows.Documents; using System.Windows.Documents;
using Flow.Launcher.Helper;
using Flow.Launcher.Infrastructure; using Flow.Launcher.Infrastructure;
using Flow.Launcher.Infrastructure.Logger; using Flow.Launcher.Infrastructure.Logger;
using Flow.Launcher.Plugin.SharedCommands; using Flow.Launcher.Plugin.SharedCommands;
using Flow.Launcher.Infrastructure.Exception;
namespace Flow.Launcher namespace Flow.Launcher
{ {
@ -43,32 +43,36 @@ namespace Flow.Launcher
var log = directory.GetFiles().OrderByDescending(f => f.LastWriteTime).First(); var log = directory.GetFiles().OrderByDescending(f => f.LastWriteTime).First();
var websiteUrl = exception switch var websiteUrl = exception switch
{ {
FlowPluginException pluginException =>GetIssuesUrl(pluginException.Metadata.Website), FlowPluginException pluginException =>GetIssuesUrl(pluginException.Metadata.Website),
_ => Constant.IssuesUrl _ => Constant.IssuesUrl
}; };
var paragraph = Hyperlink("Please open new issue in: ", websiteUrl); var paragraph = Hyperlink(App.API.GetTranslation("reportWindow_please_open_issue"), websiteUrl);
paragraph.Inlines.Add($"1. upload log file: {log.FullName}\n"); paragraph.Inlines.Add(string.Format(App.API.GetTranslation("reportWindow_upload_log"), log.FullName));
paragraph.Inlines.Add($"2. copy below exception message"); paragraph.Inlines.Add("\n");
paragraph.Inlines.Add(App.API.GetTranslation("reportWindow_copy_below"));
ErrorTextbox.Document.Blocks.Add(paragraph); ErrorTextbox.Document.Blocks.Add(paragraph);
StringBuilder content = new StringBuilder(); StringBuilder content = new StringBuilder();
content.AppendLine(ErrorReporting.RuntimeInfo()); content.AppendLine(RuntimeInfo());
content.AppendLine(ErrorReporting.DependenciesInfo()); content.AppendLine();
content.AppendLine($"Date: {DateTime.Now.ToString(CultureInfo.InvariantCulture)}"); content.AppendLine(DependenciesInfo());
content.AppendLine("Exception:"); content.AppendLine();
content.AppendLine(string.Format(App.API.GetTranslation("reportWindow_date"), DateTime.Now.ToString(CultureInfo.InvariantCulture)));
content.AppendLine(App.API.GetTranslation("reportWindow_exception"));
content.AppendLine(exception.ToString()); content.AppendLine(exception.ToString());
paragraph = new Paragraph(); paragraph = new Paragraph();
paragraph.Inlines.Add(content.ToString()); paragraph.Inlines.Add(content.ToString());
ErrorTextbox.Document.Blocks.Add(paragraph); ErrorTextbox.Document.Blocks.Add(paragraph);
} }
private Paragraph Hyperlink(string textBeforeUrl, string url) private static Paragraph Hyperlink(string textBeforeUrl, string url)
{ {
var paragraph = new Paragraph(); var paragraph = new Paragraph
paragraph.Margin = new Thickness(0); {
Margin = new Thickness(0)
};
var link = new Hyperlink var link = new Hyperlink
{ {
@ -79,10 +83,38 @@ namespace Flow.Launcher
link.Click += (s, e) => SearchWeb.OpenInBrowserTab(url); link.Click += (s, e) => SearchWeb.OpenInBrowserTab(url);
paragraph.Inlines.Add(textBeforeUrl); paragraph.Inlines.Add(textBeforeUrl);
paragraph.Inlines.Add(" ");
paragraph.Inlines.Add(link); paragraph.Inlines.Add(link);
paragraph.Inlines.Add("\n"); paragraph.Inlines.Add("\n");
return paragraph; return paragraph;
} }
private void BtnCancel_OnClick(object sender, RoutedEventArgs e)
{
Close();
}
private static string RuntimeInfo()
{
var info =
$"""
Flow Launcher {App.API.GetTranslation("reportWindow_version")}: {Constant.Version}
OS {App.API.GetTranslation("reportWindow_version")}: {ExceptionFormatter.GetWindowsFullVersionFromRegistry()}
IntPtr {App.API.GetTranslation("reportWindow_length")}: {IntPtr.Size}
x64: {Environment.Is64BitOperatingSystem}
""";
return info;
}
private static string DependenciesInfo()
{
var info =
$"""
{App.API.GetTranslation("pythonFilePath")}: {Constant.PythonPath}
{App.API.GetTranslation("nodeFilePath")}: {Constant.NodePath}
""";
return info;
}
} }
} }