Skip to content

Commit 44aa17d

Browse files
committed
Improve report window with dark theme & localization support
1 parent 4173361 commit 44aa17d

File tree

3 files changed

+134
-37
lines changed

3 files changed

+134
-37
lines changed

Flow.Launcher/Languages/en.xaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,12 @@
383383
<system:String x:Key="reportWindow_report_succeed">Report sent successfully</system:String>
384384
<system:String x:Key="reportWindow_report_failed">Failed to send report</system:String>
385385
<system:String x:Key="reportWindow_flowlauncher_got_an_error">Flow Launcher got an error</system:String>
386+
<system:String x:Key="reportWindow_please_open_issue">Please open new issue in</system:String>
387+
<system:String x:Key="reportWindow_upload_log">1. Upload log file: {0}</system:String>
388+
<system:String x:Key="reportWindow_copy_below">2. Copy below exception message</system:String>
389+
<system:String x:Key="reportWindow_date">Date: {0}</system:String>
390+
<system:String x:Key="reportWindow_exception">Exception:</system:String>
391+
<system:String x:Key="reportWindow_length">Length</system:String>
386392

387393
<!-- General Notice -->
388394
<system:String x:Key="pleaseWait">Please wait...</system:String>

Flow.Launcher/ReportWindow.xaml

Lines changed: 80 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,82 @@
1-
<Window x:Class="Flow.Launcher.ReportWindow"
2-
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3-
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4-
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5-
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6-
mc:Ignorable="d"
7-
WindowStartupLocation="CenterScreen"
8-
Icon="Images/app_error.png"
9-
Topmost="True"
10-
ResizeMode="NoResize"
11-
Width="600"
12-
Height="455"
13-
Title="{DynamicResource reportWindow_flowlauncher_got_an_error}"
14-
d:DesignHeight="300" d:DesignWidth="600" x:ClassModifier="internal">
15-
<RichTextBox x:Name="ErrorTextbox"
16-
IsDocumentEnabled="True"
17-
VerticalScrollBarVisibility="Auto"
18-
HorizontalScrollBarVisibility="Auto"
19-
FontSize="14"
20-
Margin="10"
21-
BorderThickness="0"/>
1+
<Window
2+
x:Class="Flow.Launcher.ReportWindow"
3+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
7+
Title="{DynamicResource reportWindow_flowlauncher_got_an_error}"
8+
Width="600"
9+
Height="455"
10+
d:DesignHeight="300"
11+
d:DesignWidth="600"
12+
x:ClassModifier="internal"
13+
Background="{DynamicResource PopuBGColor}"
14+
Foreground="{DynamicResource PopupTextColor}"
15+
Icon="/Images/app_error.png"
16+
ResizeMode="NoResize"
17+
Topmost="True"
18+
WindowStartupLocation="CenterScreen"
19+
mc:Ignorable="d">
20+
<WindowChrome.WindowChrome>
21+
<WindowChrome CaptionHeight="32" ResizeBorderThickness="{x:Static SystemParameters.WindowResizeBorderThickness}" />
22+
</WindowChrome.WindowChrome>
23+
24+
<Grid>
25+
<Grid.RowDefinitions>
26+
<RowDefinition Height="Auto" />
27+
<RowDefinition Height="*" />
28+
</Grid.RowDefinitions>
29+
<Grid>
30+
<Grid.ColumnDefinitions>
31+
<ColumnDefinition Width="Auto" />
32+
<ColumnDefinition Width="*" />
33+
<ColumnDefinition Width="Auto" />
34+
</Grid.ColumnDefinitions>
35+
<Image
36+
Grid.Column="0"
37+
Width="16"
38+
Height="16"
39+
Margin="10 4 4 4"
40+
RenderOptions.BitmapScalingMode="HighQuality"
41+
Source="/Images/app_error.png" />
42+
<TextBlock
43+
Grid.Column="1"
44+
Margin="4 0 0 0"
45+
VerticalAlignment="Center"
46+
FontSize="12"
47+
Foreground="{DynamicResource Color05B}"
48+
Text="{DynamicResource reportWindow_flowlauncher_got_an_error}" />
49+
<Button
50+
Grid.Column="2"
51+
Click="BtnCancel_OnClick"
52+
Style="{StaticResource TitleBarCloseButtonStyle}">
53+
<Path
54+
Width="46"
55+
Height="32"
56+
Data="M 18,11 27,20 M 18,20 27,11"
57+
Stroke="{Binding Path=Foreground, RelativeSource={RelativeSource AncestorType={x:Type Button}}}"
58+
StrokeThickness="1">
59+
<Path.Style>
60+
<Style TargetType="Path">
61+
<Style.Triggers>
62+
<DataTrigger Binding="{Binding Path=IsActive, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}" Value="False">
63+
<Setter Property="Opacity" Value="0.5" />
64+
</DataTrigger>
65+
</Style.Triggers>
66+
</Style>
67+
</Path.Style>
68+
</Path>
69+
</Button>
70+
</Grid>
71+
<RichTextBox
72+
x:Name="ErrorTextbox"
73+
Grid.Row="1"
74+
Margin="10"
75+
BorderThickness="0"
76+
FontSize="14"
77+
HorizontalScrollBarVisibility="Auto"
78+
IsDocumentEnabled="True"
79+
VerticalScrollBarVisibility="Auto" />
80+
</Grid>
2281

2382
</Window>

Flow.Launcher/ReportWindow.xaml.cs

Lines changed: 48 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
using System.Linq;
77
using System.Windows;
88
using System.Windows.Documents;
9-
using Flow.Launcher.Helper;
109
using Flow.Launcher.Infrastructure;
1110
using Flow.Launcher.Infrastructure.Logger;
1211
using Flow.Launcher.Plugin.SharedCommands;
12+
using Flow.Launcher.Infrastructure.Exception;
1313

1414
namespace Flow.Launcher
1515
{
@@ -43,32 +43,36 @@ private void SetException(Exception exception)
4343
var log = directory.GetFiles().OrderByDescending(f => f.LastWriteTime).First();
4444

4545
var websiteUrl = exception switch
46-
{
47-
FlowPluginException pluginException =>GetIssuesUrl(pluginException.Metadata.Website),
48-
_ => Constant.IssuesUrl
49-
};
50-
46+
{
47+
FlowPluginException pluginException =>GetIssuesUrl(pluginException.Metadata.Website),
48+
_ => Constant.IssuesUrl
49+
};
5150

52-
var paragraph = Hyperlink("Please open new issue in: ", websiteUrl);
53-
paragraph.Inlines.Add($"1. upload log file: {log.FullName}\n");
54-
paragraph.Inlines.Add($"2. copy below exception message");
51+
var paragraph = Hyperlink(App.API.GetTranslation("reportWindow_please_open_issue"), websiteUrl);
52+
paragraph.Inlines.Add(string.Format(App.API.GetTranslation("reportWindow_upload_log"), log.FullName));
53+
paragraph.Inlines.Add("\n");
54+
paragraph.Inlines.Add(App.API.GetTranslation("reportWindow_copy_below"));
5555
ErrorTextbox.Document.Blocks.Add(paragraph);
5656

5757
StringBuilder content = new StringBuilder();
58-
content.AppendLine(ErrorReporting.RuntimeInfo());
59-
content.AppendLine(ErrorReporting.DependenciesInfo());
60-
content.AppendLine($"Date: {DateTime.Now.ToString(CultureInfo.InvariantCulture)}");
61-
content.AppendLine("Exception:");
58+
content.AppendLine(RuntimeInfo());
59+
content.AppendLine();
60+
content.AppendLine(DependenciesInfo());
61+
content.AppendLine();
62+
content.AppendLine(string.Format(App.API.GetTranslation("reportWindow_date"), DateTime.Now.ToString(CultureInfo.InvariantCulture)));
63+
content.AppendLine(App.API.GetTranslation("reportWindow_exception"));
6264
content.AppendLine(exception.ToString());
6365
paragraph = new Paragraph();
6466
paragraph.Inlines.Add(content.ToString());
6567
ErrorTextbox.Document.Blocks.Add(paragraph);
6668
}
6769

68-
private Paragraph Hyperlink(string textBeforeUrl, string url)
70+
private static Paragraph Hyperlink(string textBeforeUrl, string url)
6971
{
70-
var paragraph = new Paragraph();
71-
paragraph.Margin = new Thickness(0);
72+
var paragraph = new Paragraph
73+
{
74+
Margin = new Thickness(0)
75+
};
7276

7377
var link = new Hyperlink
7478
{
@@ -79,10 +83,38 @@ private Paragraph Hyperlink(string textBeforeUrl, string url)
7983
link.Click += (s, e) => SearchWeb.OpenInBrowserTab(url);
8084

8185
paragraph.Inlines.Add(textBeforeUrl);
86+
paragraph.Inlines.Add(" ");
8287
paragraph.Inlines.Add(link);
8388
paragraph.Inlines.Add("\n");
8489

8590
return paragraph;
8691
}
92+
93+
private void BtnCancel_OnClick(object sender, RoutedEventArgs e)
94+
{
95+
Close();
96+
}
97+
98+
private static string RuntimeInfo()
99+
{
100+
var info =
101+
$"""
102+
Flow Launcher {App.API.GetTranslation("reportWindow_version")}: {Constant.Version}
103+
OS {App.API.GetTranslation("reportWindow_version")}: {ExceptionFormatter.GetWindowsFullVersionFromRegistry()}
104+
IntPtr {App.API.GetTranslation("reportWindow_length")}: {IntPtr.Size}
105+
x64: {Environment.Is64BitOperatingSystem}
106+
""";
107+
return info;
108+
}
109+
110+
private static string DependenciesInfo()
111+
{
112+
var info =
113+
$"""
114+
{App.API.GetTranslation("pythonFilePath")}: {Constant.PythonPath}
115+
{App.API.GetTranslation("nodeFilePath")}: {Constant.NodePath}
116+
""";
117+
return info;
118+
}
87119
}
88120
}

0 commit comments

Comments
 (0)