mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Merge branch 'dev' into 240513FixBindingErrors
This commit is contained in:
commit
f8d6f12456
7 changed files with 93 additions and 9 deletions
|
|
@ -273,6 +273,9 @@ namespace Flow.Launcher.Infrastructure.UserSettings
|
|||
public AnimationSpeeds AnimationSpeed { get; set; } = AnimationSpeeds.Medium;
|
||||
public int CustomAnimationLength { get; set; } = 360;
|
||||
|
||||
[JsonIgnore]
|
||||
public bool WMPInstalled { get; set; } = true;
|
||||
|
||||
|
||||
// This needs to be loaded last by staying at the bottom
|
||||
public PluginsSettings PluginSettings { get; set; } = new PluginsSettings();
|
||||
|
|
|
|||
|
|
@ -62,6 +62,7 @@ namespace Flow.Launcher
|
|||
|
||||
_settingsVM = new SettingWindowViewModel(_updater, _portable);
|
||||
_settings = _settingsVM.Settings;
|
||||
_settings.WMPInstalled = WindowsMediaPlayerHelper.IsWindowsMediaPlayerInstalled();
|
||||
|
||||
AbstractPluginEnvironment.PreStartPluginExecutablePathUpdate(_settings);
|
||||
|
||||
|
|
|
|||
11
Flow.Launcher/Helper/WindowsMediaPlayerHelper.cs
Normal file
11
Flow.Launcher/Helper/WindowsMediaPlayerHelper.cs
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
using Microsoft.Win32;
|
||||
|
||||
namespace Flow.Launcher.Helper;
|
||||
internal static class WindowsMediaPlayerHelper
|
||||
{
|
||||
internal static bool IsWindowsMediaPlayerInstalled()
|
||||
{
|
||||
using var key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\MediaPlayer");
|
||||
return key.GetValue("Installation Directory") != null;
|
||||
}
|
||||
}
|
||||
|
|
@ -158,6 +158,7 @@
|
|||
<system:String x:Key="SoundEffectTip">Play a small sound when the search window opens</system:String>
|
||||
<system:String x:Key="SoundEffectVolume">Sound Effect Volume</system:String>
|
||||
<system:String x:Key="SoundEffectVolumeTip">Adjust the volume of the sound effect</system:String>
|
||||
<system:String x:Key="SoundEffectWarning">Windows Media Player is unavailable and is required for Flow's volume adjustment. Please check your installation if you need to adjust volume.</system:String>
|
||||
<system:String x:Key="Animation">Animation</system:String>
|
||||
<system:String x:Key="AnimationTip">Use Animation in UI</system:String>
|
||||
<system:String x:Key="AnimationSpeed">Animation Speed</system:String>
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ using Flow.Launcher.Helper;
|
|||
using Flow.Launcher.Infrastructure.UserSettings;
|
||||
using Flow.Launcher.ViewModel;
|
||||
using Screen = System.Windows.Forms.Screen;
|
||||
using ContextMenuStrip = System.Windows.Forms.ContextMenuStrip;
|
||||
using DragEventArgs = System.Windows.DragEventArgs;
|
||||
using KeyEventArgs = System.Windows.Input.KeyEventArgs;
|
||||
using NotifyIcon = System.Windows.Forms.NotifyIcon;
|
||||
|
|
@ -24,7 +23,6 @@ using System.Windows.Data;
|
|||
using ModernWpf.Controls;
|
||||
using Key = System.Windows.Input.Key;
|
||||
using System.Media;
|
||||
using static Flow.Launcher.ViewModel.SettingWindowViewModel;
|
||||
using DataObject = System.Windows.DataObject;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Interop;
|
||||
|
|
@ -46,9 +44,11 @@ namespace Flow.Launcher
|
|||
private ContextMenu contextMenu = new ContextMenu();
|
||||
private MainViewModel _viewModel;
|
||||
private bool _animating;
|
||||
MediaPlayer animationSound = new MediaPlayer();
|
||||
private bool isArrowKeyPressed = false;
|
||||
|
||||
private MediaPlayer animationSoundWMP;
|
||||
private SoundPlayer animationSoundWPF;
|
||||
|
||||
#endregion
|
||||
|
||||
public MainWindow(Settings settings, MainViewModel mainVM)
|
||||
|
|
@ -60,7 +60,7 @@ namespace Flow.Launcher
|
|||
InitializeComponent();
|
||||
InitializePosition();
|
||||
|
||||
animationSound.Open(new Uri(AppDomain.CurrentDomain.BaseDirectory + "Resources\\open.wav"));
|
||||
InitSoundEffects();
|
||||
|
||||
DataObject.AddPastingHandler(QueryTextBox, OnPaste);
|
||||
}
|
||||
|
|
@ -140,9 +140,7 @@ namespace Flow.Launcher
|
|||
{
|
||||
if (_settings.UseSound)
|
||||
{
|
||||
animationSound.Position = TimeSpan.Zero;
|
||||
animationSound.Volume = _settings.SoundVolume / 100.0;
|
||||
animationSound.Play();
|
||||
SoundPlay();
|
||||
}
|
||||
UpdatePosition();
|
||||
PreviewReset();
|
||||
|
|
@ -508,6 +506,33 @@ namespace Flow.Launcher
|
|||
windowsb.Begin(FlowMainWindow);
|
||||
}
|
||||
|
||||
private void InitSoundEffects()
|
||||
{
|
||||
if (_settings.WMPInstalled)
|
||||
{
|
||||
animationSoundWMP = new MediaPlayer();
|
||||
animationSoundWMP.Open(new Uri(AppDomain.CurrentDomain.BaseDirectory + "Resources\\open.wav"));
|
||||
}
|
||||
else
|
||||
{
|
||||
animationSoundWPF = new SoundPlayer(AppDomain.CurrentDomain.BaseDirectory + "Resources\\open.wav");
|
||||
}
|
||||
}
|
||||
|
||||
private void SoundPlay()
|
||||
{
|
||||
if (_settings.WMPInstalled)
|
||||
{
|
||||
animationSoundWMP.Position = TimeSpan.Zero;
|
||||
animationSoundWMP.Volume = _settings.SoundVolume / 100.0;
|
||||
animationSoundWMP.Play();
|
||||
}
|
||||
else
|
||||
{
|
||||
animationSoundWPF.Play();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnMouseDown(object sender, MouseButtonEventArgs e)
|
||||
{
|
||||
if (e.ChangedButton == MouseButton.Left) DragMove();
|
||||
|
|
|
|||
|
|
@ -181,13 +181,22 @@ public partial class SettingsPaneThemeViewModel : BaseModel
|
|||
return speeds;
|
||||
}
|
||||
}
|
||||
|
||||
public bool UseSound
|
||||
{
|
||||
get => Settings.UseSound;
|
||||
set => Settings.UseSound = value;
|
||||
}
|
||||
|
||||
public bool ShowWMPWarning
|
||||
{
|
||||
get => !Settings.WMPInstalled && UseSound;
|
||||
}
|
||||
|
||||
public bool EnableVolumeAdjustment
|
||||
{
|
||||
get => Settings.WMPInstalled;
|
||||
}
|
||||
|
||||
public double SoundEffectVolume
|
||||
{
|
||||
get => Settings.SoundVolume;
|
||||
|
|
|
|||
|
|
@ -442,6 +442,7 @@
|
|||
<cc:Card
|
||||
Title="{DynamicResource SoundEffectVolume}"
|
||||
Icon=""
|
||||
IsEnabled="{Binding EnableVolumeAdjustment}"
|
||||
Sub="{DynamicResource SoundEffectVolumeTip}"
|
||||
Visibility="{Binding UseSound, Converter={StaticResource BoolToVisibilityConverter}}">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
|
|
@ -449,7 +450,6 @@
|
|||
Margin="0,0,8,0"
|
||||
VerticalAlignment="Center"
|
||||
Text="{Binding SoundEffectVolume}" />
|
||||
|
||||
<Slider
|
||||
Width="250"
|
||||
VerticalAlignment="Center"
|
||||
|
|
@ -462,6 +462,40 @@
|
|||
</StackPanel>
|
||||
</cc:Card>
|
||||
</cc:CardGroup>
|
||||
<Border
|
||||
Name="WMPWarning"
|
||||
Padding="0,10"
|
||||
HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Center"
|
||||
Background="{DynamicResource InfoBarWarningBG}"
|
||||
BorderBrush="{DynamicResource Color03B}"
|
||||
BorderThickness="0,1,0,0"
|
||||
CornerRadius="5 5 5 5"
|
||||
Visibility="{Binding ShowWMPWarning, Converter={StaticResource BoolToVisibilityConverter}}">
|
||||
<Grid VerticalAlignment="Center">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="58" />
|
||||
<ColumnDefinition Width="*" />
|
||||
</Grid.ColumnDefinitions>
|
||||
<ui:FontIcon
|
||||
Grid.Column="0"
|
||||
Margin="20,0,14,0"
|
||||
VerticalAlignment="Center"
|
||||
FontSize="15"
|
||||
Foreground="{DynamicResource InfoBarWarningIcon}"
|
||||
Glyph="" />
|
||||
<TextBlock
|
||||
Grid.Column="1"
|
||||
Margin="0,0,0,2"
|
||||
Padding="0,0,8,0"
|
||||
HorizontalAlignment="Left"
|
||||
FontSize="13"
|
||||
FontWeight="SemiBold"
|
||||
Foreground="{DynamicResource Color05B}"
|
||||
Text="{DynamicResource SoundEffectWarning}"
|
||||
TextWrapping="Wrap" />
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
<!-- Settings color scheme -->
|
||||
<cc:Card
|
||||
|
|
|
|||
Loading…
Reference in a new issue