Mute shortcut

This commit is contained in:
Théo Marchal 2021-10-04 19:20:41 +02:00
parent 7b2a7bae21
commit 6e4ed82211
6 changed files with 41 additions and 2 deletions

View File

@ -28,6 +28,7 @@ namespace unison
private const uint VK_MEDIA_PLAY_PAUSE = 0xB3;
private const uint VK_VOLUME_UP = 0xAF;
private const uint VK_VOLUME_DOWN = 0xAE;
private const uint VK_VOLUME_MUTE = 0xAD;
private const uint VK_ENTER = 0x0D;
private MainWindow _appWindow;
@ -54,6 +55,7 @@ namespace unison
RegisterHotKey(_windowHandle, HOTKEY_ID, MOD_CONTROL, VK_MEDIA_PLAY_PAUSE);
RegisterHotKey(_windowHandle, HOTKEY_ID, MOD_CONTROL, VK_VOLUME_UP);
RegisterHotKey(_windowHandle, HOTKEY_ID, MOD_CONTROL, VK_VOLUME_DOWN);
RegisterHotKey(_windowHandle, HOTKEY_ID, MOD_CONTROL, VK_VOLUME_MUTE);
RegisterHotKey(_windowHandle, HOTKEY_ID, MOD_CONTROL | MOD_ALT, VK_ENTER);
}
}
@ -79,6 +81,9 @@ namespace unison
case VK_VOLUME_UP:
_mpd.VolumeUp();
break;
case VK_VOLUME_MUTE:
_mpd.VolumeMute();
break;
case VK_MEDIA_PLAY_PAUSE:
_mpd.PlayPause();
break;

View File

@ -25,6 +25,7 @@ namespace unison
private bool _connected;
public string _version;
private int _currentVolume;
private int _previousVolume;
private bool _currentRandom;
private bool _currentRepeat;
private bool _currentSingle;
@ -449,6 +450,21 @@ namespace unison
SetVolume(_currentVolume);
}
public void VolumeMute()
{
if (_currentVolume == 0)
{
_currentVolume = _previousVolume;
_previousVolume = 0;
}
else
{
_previousVolume = _currentVolume;
_currentVolume = 0;
}
SetVolume(_currentVolume);
}
public void ClearQueue() => SendCommand(new ClearCommand());
public void PlayCommand() => SendCommand(new PlayCommand(0));

View File

@ -420,6 +420,15 @@ namespace unison.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Volume mute.
/// </summary>
public static string Settings_VolumeMute {
get {
return ResourceManager.GetString("Settings_VolumeMute", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Volume offset.
/// </summary>

View File

@ -237,6 +237,9 @@
<data name="Settings_VolumeDown" xml:space="preserve">
<value>Baisse de volume</value>
</data>
<data name="Settings_VolumeMute" xml:space="preserve">
<value>Volume en sourdine</value>
</data>
<data name="Settings_VolumeOffset" xml:space="preserve">
<value>Écart de volume</value>
</data>

View File

@ -237,6 +237,9 @@
<data name="Settings_VolumeDown" xml:space="preserve">
<value>Volume down</value>
</data>
<data name="Settings_VolumeMute" xml:space="preserve">
<value>Volume mute</value>
</data>
<data name="Settings_VolumeOffset" xml:space="preserve">
<value>Volume offset</value>
</data>

View File

@ -107,20 +107,23 @@
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<TextBlock Text="{x:Static properties:Resources.Settings_NextTrack}" TextWrapping="Wrap" Grid.Column="0" Grid.Row="0" Margin="1"/>
<TextBlock Text="{x:Static properties:Resources.Settings_PreviousTrack}" TextWrapping="Wrap" Grid.Column="0" Grid.Row="1" Margin="1"/>
<TextBlock Text="{x:Static properties:Resources.Settings_PlayPause}" TextWrapping="Wrap" Grid.Column="0" Grid.Row="2" Margin="1"/>
<TextBlock Text="{x:Static properties:Resources.Settings_VolumeUp}" TextWrapping="Wrap" Grid.Column="0" Grid.Row="3" Margin="1"/>
<TextBlock Text="{x:Static properties:Resources.Settings_VolumeDown}" TextWrapping="Wrap" Grid.Column="0" Grid.Row="4" Margin="1"/>
<TextBlock Text="{x:Static properties:Resources.Settings_ShowWindow}" TextWrapping="Wrap" Grid.Column="0" Grid.Row="5" Margin="1"/>
<TextBlock Text="{x:Static properties:Resources.Settings_VolumeMute}" TextWrapping="Wrap" Grid.Column="0" Grid.Row="5" Margin="1"/>
<TextBlock Text="{x:Static properties:Resources.Settings_ShowWindow}" TextWrapping="Wrap" Grid.Column="0" Grid.Row="6" Margin="1"/>
<TextBlock Text="ctrl + media_next" TextWrapping="Wrap" Grid.Column="1" Grid.Row="0" Margin="1" HorizontalAlignment="Right" FontWeight="Bold"/>
<TextBlock Text="ctrl + media_prev" TextWrapping="Wrap" Grid.Column="1" Grid.Row="1" Margin="1" HorizontalAlignment="Right" FontWeight="Bold"/>
<TextBlock Text="ctrl + media_play" TextWrapping="Wrap" Grid.Column="1" Grid.Row="2" Margin="1" HorizontalAlignment="Right" FontWeight="Bold"/>
<TextBlock Text="ctrl + volume_up" TextWrapping="Wrap" Grid.Column="1" Grid.Row="3" Margin="1" HorizontalAlignment="Right" FontWeight="Bold"/>
<TextBlock Text="ctrl + volume_down" TextWrapping="Wrap" Grid.Column="1" Grid.Row="4" Margin="1" HorizontalAlignment="Right" FontWeight="Bold"/>
<TextBlock Text="ctrl + alt + enter" TextWrapping="Wrap" Grid.Column="1" Grid.Row="5" Margin="1" HorizontalAlignment="Right" FontWeight="Bold"/>
<TextBlock Text="ctrl + volume_mute" TextWrapping="Wrap" Grid.Column="1" Grid.Row="5" Margin="1" HorizontalAlignment="Right" FontWeight="Bold"/>
<TextBlock Text="ctrl + alt + enter" TextWrapping="Wrap" Grid.Column="1" Grid.Row="6" Margin="1" HorizontalAlignment="Right" FontWeight="Bold"/>
</Grid>
</StackPanel>
</Grid>