Skip to content

Commit

Permalink
feat(QuickMenu): The user can enable or disable the quick menu in the…
Browse files Browse the repository at this point in the history
… settings.

BREAKING CHANGE: Quick menu will appear when using hotkey akin to the Windows language menu.

Quick Menu is a new feature that changes the way you can interact with your selected devices. You can disable it in the Settings Menu.

Fixes #625
  • Loading branch information
Belphemur committed Aug 25, 2021
1 parent bb3e7d8 commit fd44ca3
Show file tree
Hide file tree
Showing 10 changed files with 99 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -84,5 +84,10 @@ public interface ISoundSwitchConfiguration : IConfiguration
/// Is telemetry enabled
/// </summary>
bool Telemetry { get; set; }

/// <summary>
/// Is the quick menu showed when using a hotkey
/// </summary>
bool QuickMenuEnabled { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ public SoundSwitchConfiguration()
/// </summary>
public bool Telemetry { get; set; } = true;

/// <summary>
/// Is the quick menu showed when using a hotkey
/// </summary>
public bool QuickMenuEnabled { get; set; } = true;

// Needed by Interface
[JsonIgnore]
public string FileLocation { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,11 @@ public bool CycleAudioDevice(DataFlow type)
bool CycleDevice()
{
var nextDevice = GetNextDevice(audioDevices, type);
QuickMenuManager<DeviceFullInfo>.Instance.DisplayMenu(audioDevices.Select(info => new DeviceDataContainer(info, info.Id == nextDevice.Id)), @event => SetActiveDevice(@event.Item.Payload));
if (AppModel.Instance.QuickMenuEnabled)
{
QuickMenuManager<DeviceFullInfo>.Instance.DisplayMenu(audioDevices.Select(info => new DeviceDataContainer(info, info.Id == nextDevice.Id)), @event => SetActiveDevice(@event.Item.Payload));
}

return SetActiveDevice(nextDevice);
}

Expand All @@ -61,11 +65,10 @@ bool CycleDevice()
/// <param name="audioDevices"></param>
/// <param name="type"></param>
/// <returns></returns>
private DeviceInfo GetNextDevice(IEnumerable<DeviceInfo> audioDevices, DataFlow type)
private DeviceInfo GetNextDevice(DeviceInfo[] audioDevices, DataFlow type)
{
var deviceInfos = audioDevices as DeviceInfo[] ?? audioDevices.ToArray();
var defaultDev = AudioSwitcher.Instance.GetDefaultAudioEndpoint((EDataFlow) type, ERole.eConsole) ?? deviceInfos.Last();
var next = deviceInfos.SkipWhile((device, _) => device.Id != defaultDev.Id).Skip(1).FirstOrDefault() ?? deviceInfos[0];
var defaultDev = AudioSwitcher.Instance.GetDefaultAudioEndpoint((EDataFlow) type, ERole.eConsole) ?? audioDevices.Last();
var next = audioDevices.SkipWhile((device, _) => device.Id != defaultDev.Id).Skip(1).FirstOrDefault() ?? audioDevices[0];
return next;
}

Expand Down
18 changes: 18 additions & 0 deletions SoundSwitch/Localization/SettingsStrings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions SoundSwitch/Localization/SettingsStrings.fr.resx
Original file line number Diff line number Diff line change
Expand Up @@ -448,4 +448,10 @@ Restaurer l'état du système quand l'application est fermée.</value>
<data name="telemetry" xml:space="preserve">
<value>Télémétrie</value>
</data>
<data name="quickMenu" xml:space="preserve">
<value>Menu rapide</value>
</data>
<data name="quickMenu.desc" xml:space="preserve">
<value>Affiche un menu sous la souris quand un raccourcis clavier est utilisé.</value>
</data>
</root>
6 changes: 6 additions & 0 deletions SoundSwitch/Localization/SettingsStrings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -468,4 +468,10 @@ Restore the state of the system when the application is closed.</value>
<data name="telemetry" xml:space="preserve">
<value>Telemetry</value>
</data>
<data name="quickMenu" xml:space="preserve">
<value>Quick Menu on hotkey</value>
</data>
<data name="quickMenu.desc" xml:space="preserve">
<value>Show a quick menu like Windows language when using a hotkey</value>
</data>
</root>
10 changes: 10 additions & 0 deletions SoundSwitch/Model/AppModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,16 @@ public bool Telemetry
AppConfigs.Configuration.Save();
}
}

public bool QuickMenuEnabled
{
get => AppConfigs.Configuration.QuickMenuEnabled;
set
{
AppConfigs.Configuration.QuickMenuEnabled = value;
AppConfigs.Configuration.Save();
}
}


public IEnumerable<DeviceInfo> SelectedDevices => AppConfigs.Configuration.SelectedDevices.OrderBy(info => info.DiscoveredAt);
Expand Down
1 change: 1 addition & 0 deletions SoundSwitch/Model/IAppModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ public interface IAppModel : IDisposable
IAudioDeviceLister ActiveUnpluggedAudioLister { get; set; }

bool Telemetry { get; set; }
bool QuickMenuEnabled { get; set; }

#endregion

Expand Down
51 changes: 32 additions & 19 deletions SoundSwitch/UI/Forms/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 8 additions & 4 deletions SoundSwitch/UI/Forms/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,7 @@ public SettingsForm(IAudioDeviceLister audioDeviceLister)
updateNeverToolTip.SetToolTip(updateNeverRadioButton, SettingsStrings.updateNeverTooltip);

var includeBetaVersionsToolTip = new ToolTip();
includeBetaVersionsToolTip.SetToolTip(includeBetaVersionsCheckBox,
SettingsStrings.updateIncludeBetaVersionsTooltip);
includeBetaVersionsToolTip.SetToolTip(includeBetaVersionsCheckBox, SettingsStrings.updateIncludeBetaVersionsTooltip);

// Settings - Language
new LanguageFactory().ConfigureListControl(languageComboBox);
Expand All @@ -180,8 +179,10 @@ public SettingsForm(IAudioDeviceLister audioDeviceLister)
toggleMuteLabel.Visible = false;

telemetryCheckbox.DataBindings.Add(nameof(CheckBox.Checked), AppModel.Instance, nameof(AppModel.Telemetry), false, DataSourceUpdateMode.OnPropertyChanged);
telemetryCheckbox.Text = SettingsStrings.telemetry;

quickMenuCheckbox.DataBindings.Add(nameof(CheckBox.Checked), AppModel.Instance, nameof(AppModel.QuickMenuEnabled), false, DataSourceUpdateMode.OnPropertyChanged);
var quickMenuCheckboxToolTip = new ToolTip();
quickMenuCheckboxToolTip.SetToolTip(quickMenuCheckbox, SettingsStrings.quickMenu_desc);

PopulateSettings();

_loaded = true;
Expand Down Expand Up @@ -316,13 +317,16 @@ private void LocalizeForm()
cycleThroughLabel.Text = SettingsStrings.cycleThrough;
foregroundAppCheckbox.Text = SettingsStrings.foregroundApp;
usePrimaryScreenCheckbox.Text = SettingsStrings.usePrimaryScreen;
quickMenuCheckbox.Text = SettingsStrings.quickMenu;

// Settings - Update
updateSettingsGroupBox.Text = SettingsStrings.updateSettings;
updateSilentRadioButton.Text = SettingsStrings.updateInstallAutomatically;
updateNotifyRadioButton.Text = SettingsStrings.updateNotify;
updateNeverRadioButton.Text = SettingsStrings.updateNever;
includeBetaVersionsCheckBox.Text = SettingsStrings.updateIncludeBetaVersions;
telemetryCheckbox.Text = SettingsStrings.telemetry;


// Settings - Language
languageGroupBox.Text = SettingsStrings.language;
Expand Down

0 comments on commit fd44ca3

Please sign in to comment.