mirror of
https://github.com/aaru-dps/RedBookPlayer.git
synced 2025-12-16 19:24:41 +00:00
Move hardcoded key values to settings
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
| Key | Action |
|
||||
| --- | ------ |
|
||||
| `F1` | Open Settings Window |
|
||||
| `F2` / `Enter` | Load New Image |
|
||||
| `F2` | Load New Image |
|
||||
| `Space` | Toggle Play / Pause |
|
||||
| `Esc` | Stop Playback |
|
||||
| `→` | Next Track |
|
||||
|
||||
@@ -118,68 +118,68 @@ namespace RedBookPlayer.GUI
|
||||
PlayerView playerView = ContentControl.Content as PlayerView;
|
||||
|
||||
// Open settings window
|
||||
if(e.Key == Key.F1)
|
||||
if(e.Key == App.Settings.OpenSettingsKey)
|
||||
{
|
||||
settingsWindow = new SettingsWindow(App.Settings);
|
||||
settingsWindow.Show();
|
||||
}
|
||||
|
||||
// Load image
|
||||
else if (e.Key == Key.F2 || e.Key == Key.Enter)
|
||||
else if (e.Key == App.Settings.LoadImageKey)
|
||||
{
|
||||
playerView?.LoadButton_Click(this, null);
|
||||
}
|
||||
|
||||
// Toggle playback
|
||||
else if(e.Key == Key.Space || e.Key == Key.MediaPlayPause)
|
||||
else if(e.Key == App.Settings.TogglePlaybackKey || e.Key == Key.MediaPlayPause)
|
||||
{
|
||||
playerView?.PlayPauseButton_Click(this, null);
|
||||
}
|
||||
|
||||
// Stop playback
|
||||
else if(e.Key == Key.Escape || e.Key == Key.MediaStop)
|
||||
else if(e.Key == App.Settings.StopPlaybackKey || e.Key == Key.MediaStop)
|
||||
{
|
||||
playerView?.StopButton_Click(this, null);
|
||||
}
|
||||
|
||||
// Next Track
|
||||
else if(e.Key == Key.Right || e.Key == Key.MediaNextTrack)
|
||||
else if(e.Key == App.Settings.NextTrackKey || e.Key == Key.MediaNextTrack)
|
||||
{
|
||||
playerView?.NextTrackButton_Click(this, null);
|
||||
}
|
||||
|
||||
// Previous Track
|
||||
else if(e.Key == Key.Left || e.Key == Key.MediaPreviousTrack)
|
||||
else if(e.Key == App.Settings.PreviousTrackKey || e.Key == Key.MediaPreviousTrack)
|
||||
{
|
||||
playerView?.PreviousTrackButton_Click(this, null);
|
||||
}
|
||||
|
||||
// Next Index
|
||||
else if(e.Key == Key.OemCloseBrackets)
|
||||
else if(e.Key == App.Settings.NextIndexKey)
|
||||
{
|
||||
playerView?.NextIndexButton_Click(this, null);
|
||||
}
|
||||
|
||||
// Previous Index
|
||||
else if(e.Key == Key.OemOpenBrackets)
|
||||
else if(e.Key == App.Settings.PreviousIndexKey)
|
||||
{
|
||||
playerView?.PreviousIndexButton_Click(this, null);
|
||||
}
|
||||
|
||||
// Fast Foward
|
||||
else if(e.Key == Key.OemPeriod)
|
||||
else if(e.Key == App.Settings.FastForwardPlaybackKey)
|
||||
{
|
||||
playerView?.FastForwardButton_Click(this, null);
|
||||
}
|
||||
|
||||
// Rewind
|
||||
else if(e.Key == Key.OemComma)
|
||||
else if(e.Key == App.Settings.RewindPlaybackKey)
|
||||
{
|
||||
playerView?.RewindButton_Click(this, null);
|
||||
}
|
||||
|
||||
// Emphasis Toggle
|
||||
else if(e.Key == Key.E)
|
||||
else if(e.Key == App.Settings.ToggleDeEmphasisKey)
|
||||
{
|
||||
playerView?.EnableDisableDeEmphasisButton_Click(this, null);
|
||||
}
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text.Json;
|
||||
using Avalonia.Input;
|
||||
using RedBookPlayer.GUI;
|
||||
|
||||
namespace RedBookPlayer
|
||||
{
|
||||
public class Settings
|
||||
{
|
||||
#region Player Settings
|
||||
|
||||
/// <summary>
|
||||
/// Indicates if discs should start playing on load
|
||||
/// </summary>
|
||||
@@ -42,6 +45,67 @@ namespace RedBookPlayer
|
||||
/// </summary>
|
||||
public string SelectedTheme { get; set; } = "default";
|
||||
|
||||
#endregion
|
||||
|
||||
#region Key Mappings
|
||||
|
||||
/// <summary>
|
||||
/// Key assigned to open settings
|
||||
/// </summary>
|
||||
public Key OpenSettingsKey { get; set; } = Key.F1;
|
||||
|
||||
/// <summary>
|
||||
/// Key assigned to load a new image
|
||||
/// </summary>
|
||||
public Key LoadImageKey { get; set; } = Key.F2;
|
||||
|
||||
/// <summary>
|
||||
/// Key assigned to toggle play and pause
|
||||
/// </summary>
|
||||
public Key TogglePlaybackKey { get; set; } = Key.Space;
|
||||
|
||||
/// <summary>
|
||||
/// Key assigned to stop playback
|
||||
/// </summary>
|
||||
public Key StopPlaybackKey { get; set; } = Key.Escape;
|
||||
|
||||
/// <summary>
|
||||
/// Key assigned to move to the next track
|
||||
/// </summary>
|
||||
public Key NextTrackKey { get; set; } = Key.Right;
|
||||
|
||||
/// <summary>
|
||||
/// Key assigned to move to the previous track
|
||||
/// </summary>
|
||||
public Key PreviousTrackKey { get; set; } = Key.Left;
|
||||
|
||||
/// <summary>
|
||||
/// Key assigned to move to the next index
|
||||
/// </summary>
|
||||
public Key NextIndexKey { get; set; } = Key.OemCloseBrackets;
|
||||
|
||||
/// <summary>
|
||||
/// Key assigned to move to the previous index
|
||||
/// </summary>
|
||||
public Key PreviousIndexKey { get; set; } = Key.OemOpenBrackets;
|
||||
|
||||
/// <summary>
|
||||
/// Key assigned to fast forward playback
|
||||
/// </summary>
|
||||
public Key FastForwardPlaybackKey { get; set; } = Key.OemPeriod;
|
||||
|
||||
/// <summary>
|
||||
/// Key assigned to rewind playback
|
||||
/// </summary>
|
||||
public Key RewindPlaybackKey { get; set; } = Key.OemComma;
|
||||
|
||||
/// <summary>
|
||||
/// Key assigned to toggle de-emphasis
|
||||
/// </summary>
|
||||
public Key ToggleDeEmphasisKey { get; set; } = Key.E;
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Path to the settings file
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user