mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Merge pull request #2488 from flooxo/volume
feat: Add sound effect volume
This commit is contained in:
commit
0cb80c4442
6 changed files with 86 additions and 13 deletions
|
|
@ -54,6 +54,8 @@ namespace Flow.Launcher.Infrastructure.UserSettings
|
|||
public bool UseGlyphIcons { get; set; } = true;
|
||||
public bool UseAnimation { get; set; } = true;
|
||||
public bool UseSound { get; set; } = true;
|
||||
public double SoundVolume { get; set; } = 50;
|
||||
|
||||
public bool UseClock { get; set; } = true;
|
||||
public bool UseDate { get; set; } = false;
|
||||
public string TimeFormat { get; set; } = "hh:mm tt";
|
||||
|
|
|
|||
|
|
@ -156,6 +156,8 @@
|
|||
<system:String x:Key="ColorSchemeDark">Dark</system:String>
|
||||
<system:String x:Key="SoundEffect">Sound Effect</system:String>
|
||||
<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="Animation">Animation</system:String>
|
||||
<system:String x:Key="AnimationTip">Use Animation in UI</system:String>
|
||||
<system:String x:Key="AnimationSpeed">Animation Speed</system:String>
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ using Key = System.Windows.Input.Key;
|
|||
using System.Media;
|
||||
using static Flow.Launcher.ViewModel.SettingWindowViewModel;
|
||||
using DataObject = System.Windows.DataObject;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace Flow.Launcher
|
||||
{
|
||||
|
|
@ -40,7 +41,7 @@ namespace Flow.Launcher
|
|||
private ContextMenu contextMenu;
|
||||
private MainViewModel _viewModel;
|
||||
private bool _animating;
|
||||
SoundPlayer animationSound = new SoundPlayer(AppDomain.CurrentDomain.BaseDirectory + "Resources\\open.wav");
|
||||
MediaPlayer animationSound = new MediaPlayer();
|
||||
|
||||
#endregion
|
||||
|
||||
|
|
@ -52,6 +53,9 @@ namespace Flow.Launcher
|
|||
|
||||
InitializeComponent();
|
||||
InitializePosition();
|
||||
|
||||
animationSound.Open(new Uri(AppDomain.CurrentDomain.BaseDirectory + "Resources\\open.wav"));
|
||||
|
||||
DataObject.AddPastingHandler(QueryTextBox, OnPaste);
|
||||
}
|
||||
|
||||
|
|
@ -128,6 +132,8 @@ namespace Flow.Launcher
|
|||
{
|
||||
if (_settings.UseSound)
|
||||
{
|
||||
animationSound.Position = TimeSpan.Zero;
|
||||
animationSound.Volume = _settings.SoundVolume / 100.0;
|
||||
animationSound.Play();
|
||||
}
|
||||
UpdatePosition();
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -2474,27 +2474,81 @@
|
|||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
|
||||
<Border
|
||||
Margin="0"
|
||||
BorderThickness="0"
|
||||
Margin="0,12,0,12"
|
||||
Padding="0"
|
||||
CornerRadius="5"
|
||||
Style="{DynamicResource SettingGroupBox}">
|
||||
<ItemsControl Style="{StaticResource SettingGrid}">
|
||||
<StackPanel Style="{StaticResource TextPanel}">
|
||||
<TextBlock Style="{DynamicResource SettingTitleLabel}" Text="{DynamicResource SoundEffect}" />
|
||||
<TextBlock Style="{DynamicResource SettingSubTitleLabel}" Text="{DynamicResource SoundEffectTip}" />
|
||||
</StackPanel>
|
||||
<ui:ToggleSwitch
|
||||
<StackPanel Orientation="Vertical">
|
||||
<Border
|
||||
Margin="0"
|
||||
BorderThickness="0"
|
||||
Style="{DynamicResource SettingGroupBox}">
|
||||
<ItemsControl Style="{StaticResource SettingGrid}">
|
||||
<StackPanel Style="{StaticResource TextPanel}">
|
||||
<TextBlock Style="{DynamicResource SettingTitleLabel}" Text="{DynamicResource SoundEffect}" />
|
||||
<TextBlock Style="{DynamicResource SettingSubTitleLabel}" Text="{DynamicResource SoundEffectTip}" />
|
||||
</StackPanel>
|
||||
<ui:ToggleSwitch
|
||||
x:Name="SoundEffect"
|
||||
Grid.Row="0"
|
||||
Grid.Column="2"
|
||||
IsOn="{Binding UseSound, Mode=TwoWay}"
|
||||
OffContent="{DynamicResource disable}"
|
||||
OnContent="{DynamicResource enable}"
|
||||
Style="{DynamicResource SideToggleSwitch}" />
|
||||
<TextBlock Style="{StaticResource Glyph}">
|
||||
<TextBlock Style="{StaticResource Glyph}">
|
||||

|
||||
</TextBlock>
|
||||
</ItemsControl>
|
||||
</Border>
|
||||
<Separator
|
||||
Width="Auto"
|
||||
BorderThickness="1"
|
||||
Style="{StaticResource SettingSeparatorStyle}" />
|
||||
<Border Margin="0" BorderThickness="0">
|
||||
<Border.Style>
|
||||
<Style BasedOn="{StaticResource SettingGroupBox}" TargetType="Border">
|
||||
<Setter Property="Visibility" Value="Collapsed" />
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding ElementName=SoundEffect, Path=IsOn}" Value="True">
|
||||
<Setter Property="Visibility" Value="Visible" />
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</Border.Style>
|
||||
|
||||
<ItemsControl Style="{StaticResource SettingGrid}">
|
||||
<StackPanel Style="{StaticResource TextPanel}">
|
||||
<TextBlock Style="{DynamicResource SettingTitleLabel}" Text="{DynamicResource SoundEffectVolume}" />
|
||||
<TextBlock Style="{DynamicResource SettingSubTitleLabel}" Text="{DynamicResource SoundEffectVolumeTip}" />
|
||||
</StackPanel>
|
||||
<StackPanel Grid.Column="2" Orientation="Horizontal">
|
||||
<TextBlock
|
||||
Width="Auto"
|
||||
Margin="0,0,8,2"
|
||||
VerticalAlignment="Center"
|
||||
Foreground="{DynamicResource Color05B}"
|
||||
Text="{Binding ElementName=SoundEffectValue, Path=Value, UpdateSourceTrigger=PropertyChanged}"
|
||||
TextAlignment="Right" />
|
||||
<Slider
|
||||
Name="SoundEffectValue"
|
||||
Width="250"
|
||||
Margin="0,0,18,0"
|
||||
VerticalAlignment="Center"
|
||||
IsMoveToPointEnabled="True"
|
||||
IsSnapToTickEnabled="True"
|
||||
Maximum="100"
|
||||
Minimum="0"
|
||||
TickFrequency="1"
|
||||
Value="{Binding SoundEffectVolume, Mode=TwoWay}" />
|
||||
</StackPanel>
|
||||
<TextBlock Style="{StaticResource Glyph}">
|
||||

|
||||
</TextBlock>
|
||||
</ItemsControl>
|
||||
</TextBlock>
|
||||
</ItemsControl>
|
||||
</Border>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
<Border Margin="0,12,0,12" Style="{DynamicResource SettingGroupBox}">
|
||||
|
|
|
|||
|
|
@ -63,6 +63,9 @@ namespace Flow.Launcher.ViewModel
|
|||
case nameof(Settings.PreviewHotkey):
|
||||
OnPropertyChanged(nameof(AlwaysPreviewToolTip));
|
||||
break;
|
||||
case nameof(Settings.SoundVolume):
|
||||
OnPropertyChanged(nameof(SoundEffectVolume));
|
||||
break;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -631,6 +634,12 @@ namespace Flow.Launcher.ViewModel
|
|||
set => Settings.UseSound = value;
|
||||
}
|
||||
|
||||
public double SoundEffectVolume
|
||||
{
|
||||
get => Settings.SoundVolume;
|
||||
set => Settings.SoundVolume = value;
|
||||
}
|
||||
|
||||
public bool UseClock
|
||||
{
|
||||
get => Settings.UseClock;
|
||||
|
|
|
|||
Loading…
Reference in a new issue