From f3c4120395ba2d96a0d6998ce52fe81df8cfb4e2 Mon Sep 17 00:00:00 2001
From: Vic <10308169+VictoriousRaptor@users.noreply.github.com>
Date: Sat, 8 Oct 2022 17:52:27 +0800
Subject: [PATCH] Shortcut settings dialog preview & text & bugfix
---
Flow.Launcher/CustomShortcutSetting.xaml | 23 ++++++++++----
Flow.Launcher/CustomShortcutSetting.xaml.cs | 35 +++++++++++++--------
Flow.Launcher/Languages/en.xaml | 1 -
Flow.Launcher/SettingWindow.xaml | 2 +-
Flow.Launcher/SettingWindow.xaml.cs | 4 +--
5 files changed, 42 insertions(+), 23 deletions(-)
diff --git a/Flow.Launcher/CustomShortcutSetting.xaml b/Flow.Launcher/CustomShortcutSetting.xaml
index 89268437b..1c87cfbe8 100644
--- a/Flow.Launcher/CustomShortcutSetting.xaml
+++ b/Flow.Launcher/CustomShortcutSetting.xaml
@@ -110,14 +110,25 @@
VerticalAlignment="Center"
FontSize="14"
Text="{DynamicResource customShortcutExpansion}" />
-
-
+ LastChildFill="True">
+
+
+
+
diff --git a/Flow.Launcher/CustomShortcutSetting.xaml.cs b/Flow.Launcher/CustomShortcutSetting.xaml.cs
index 87245d79d..25ce82424 100644
--- a/Flow.Launcher/CustomShortcutSetting.xaml.cs
+++ b/Flow.Launcher/CustomShortcutSetting.xaml.cs
@@ -1,29 +1,30 @@
-using System;
+using Flow.Launcher.Core.Resource;
+using Flow.Launcher.Infrastructure.UserSettings;
+using System;
using System.Windows;
using System.Windows.Input;
-using Flow.Launcher.Core.Resource;
-using Flow.Launcher.Infrastructure.UserSettings;
namespace Flow.Launcher
{
public partial class CustomShortcutSetting : Window
{
- private SettingWindow _settingWidow;
- private bool update;
private Settings _settings;
-
+ private bool update = false;
public string Key { get; set; }
public string Value { get; set; }
public CustomShortcutModel ShortCut => (Key, Value);
- public CustomShortcutSetting()
+ public CustomShortcutSetting(Settings settings)
{
+ _settings = settings;
InitializeComponent();
}
- public CustomShortcutSetting((string, string) shortcut)
+ public CustomShortcutSetting((string, string) shortcut, Settings settings)
{
(Key, Value) = shortcut;
+ _settings = settings;
+ update = true;
InitializeComponent();
}
@@ -35,17 +36,17 @@ namespace Flow.Launcher
private void btnAdd_OnClick(object sender, RoutedEventArgs e)
{
- DialogResult = true;
- if (_settings.CustomShortcuts.Contains(new CustomShortcutModel(Key, Value)))
+ if (!update && _settings.CustomShortcuts.Contains(new CustomShortcutModel(Key, Value)))
{
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("dulplicateShortcut"));
- DialogResult = false;
+ return;
}
- else if (String.IsNullOrEmpty(Key) || String.IsNullOrEmpty(Value))
+ if (String.IsNullOrEmpty(Key) || String.IsNullOrEmpty(Value))
{
MessageBox.Show(InternationalizationManager.Instance.GetTranslation("invalidShortcut"));
- DialogResult = false;
+ return;
}
+ DialogResult = true;
Close();
}
@@ -54,5 +55,13 @@ namespace Flow.Launcher
DialogResult = false;
Close();
}
+
+ private void BtnTestShortcut_OnClick(object sender, RoutedEventArgs e)
+ {
+ App.API.ChangeQuery(tbExpand.Text);
+ Application.Current.MainWindow.Show();
+ Application.Current.MainWindow.Opacity = 1;
+ Application.Current.MainWindow.Focus();
+ }
}
}
diff --git a/Flow.Launcher/Languages/en.xaml b/Flow.Launcher/Languages/en.xaml
index 9d34cff28..59a57ca80 100644
--- a/Flow.Launcher/Languages/en.xaml
+++ b/Flow.Launcher/Languages/en.xaml
@@ -215,7 +215,6 @@
Custom Query Shortcut
Enter a shortcut to automatically expand to the specified query.
- Preview
Shortcut is dulplicate, please enter a new Shortcut or edit the existing one.
Invalid Shortcut
diff --git a/Flow.Launcher/SettingWindow.xaml b/Flow.Launcher/SettingWindow.xaml
index 9d45e3862..dc290ccd6 100644
--- a/Flow.Launcher/SettingWindow.xaml
+++ b/Flow.Launcher/SettingWindow.xaml
@@ -2175,7 +2175,7 @@
VerticalAlignment="Center"
FontSize="14"
Foreground="{DynamicResource Color05B}"
- Text="Shortcut" />
+ Text="{DynamicResource customQueryShortcut}" />