Skip to content

Commit fd44ca3

Browse files
committed
feat(QuickMenu): The user can enable or disable the quick menu in the 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
1 parent bb3e7d8 commit fd44ca3

File tree

10 files changed

+99
-28
lines changed

10 files changed

+99
-28
lines changed

SoundSwitch/Framework/Configuration/ISoundSwitchConfiguration.cs

+5
Original file line numberDiff line numberDiff line change
@@ -84,5 +84,10 @@ public interface ISoundSwitchConfiguration : IConfiguration
8484
/// Is telemetry enabled
8585
/// </summary>
8686
bool Telemetry { get; set; }
87+
88+
/// <summary>
89+
/// Is the quick menu showed when using a hotkey
90+
/// </summary>
91+
bool QuickMenuEnabled { get; set; }
8792
}
8893
}

SoundSwitch/Framework/Configuration/SoundSwitchConfiguration.cs

+5
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,11 @@ public SoundSwitchConfiguration()
116116
/// </summary>
117117
public bool Telemetry { get; set; } = true;
118118

119+
/// <summary>
120+
/// Is the quick menu showed when using a hotkey
121+
/// </summary>
122+
public bool QuickMenuEnabled { get; set; } = true;
123+
119124
// Needed by Interface
120125
[JsonIgnore]
121126
public string FileLocation { get; set; }

SoundSwitch/Framework/DeviceCyclerManager/DeviceCycler/ADeviceCycler.cs

+8-5
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,11 @@ public bool CycleAudioDevice(DataFlow type)
4141
bool CycleDevice()
4242
{
4343
var nextDevice = GetNextDevice(audioDevices, type);
44-
QuickMenuManager<DeviceFullInfo>.Instance.DisplayMenu(audioDevices.Select(info => new DeviceDataContainer(info, info.Id == nextDevice.Id)), @event => SetActiveDevice(@event.Item.Payload));
44+
if (AppModel.Instance.QuickMenuEnabled)
45+
{
46+
QuickMenuManager<DeviceFullInfo>.Instance.DisplayMenu(audioDevices.Select(info => new DeviceDataContainer(info, info.Id == nextDevice.Id)), @event => SetActiveDevice(@event.Item.Payload));
47+
}
48+
4549
return SetActiveDevice(nextDevice);
4650
}
4751

@@ -61,11 +65,10 @@ bool CycleDevice()
6165
/// <param name="audioDevices"></param>
6266
/// <param name="type"></param>
6367
/// <returns></returns>
64-
private DeviceInfo GetNextDevice(IEnumerable<DeviceInfo> audioDevices, DataFlow type)
68+
private DeviceInfo GetNextDevice(DeviceInfo[] audioDevices, DataFlow type)
6569
{
66-
var deviceInfos = audioDevices as DeviceInfo[] ?? audioDevices.ToArray();
67-
var defaultDev = AudioSwitcher.Instance.GetDefaultAudioEndpoint((EDataFlow) type, ERole.eConsole) ?? deviceInfos.Last();
68-
var next = deviceInfos.SkipWhile((device, _) => device.Id != defaultDev.Id).Skip(1).FirstOrDefault() ?? deviceInfos[0];
70+
var defaultDev = AudioSwitcher.Instance.GetDefaultAudioEndpoint((EDataFlow) type, ERole.eConsole) ?? audioDevices.Last();
71+
var next = audioDevices.SkipWhile((device, _) => device.Id != defaultDev.Id).Skip(1).FirstOrDefault() ?? audioDevices[0];
6972
return next;
7073
}
7174

SoundSwitch/Localization/SettingsStrings.Designer.cs

+18
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

SoundSwitch/Localization/SettingsStrings.fr.resx

+6
Original file line numberDiff line numberDiff line change
@@ -448,4 +448,10 @@ Restaurer l'état du système quand l'application est fermée.</value>
448448
<data name="telemetry" xml:space="preserve">
449449
<value>Télémétrie</value>
450450
</data>
451+
<data name="quickMenu" xml:space="preserve">
452+
<value>Menu rapide</value>
453+
</data>
454+
<data name="quickMenu.desc" xml:space="preserve">
455+
<value>Affiche un menu sous la souris quand un raccourcis clavier est utilisé.</value>
456+
</data>
451457
</root>

SoundSwitch/Localization/SettingsStrings.resx

+6
Original file line numberDiff line numberDiff line change
@@ -468,4 +468,10 @@ Restore the state of the system when the application is closed.</value>
468468
<data name="telemetry" xml:space="preserve">
469469
<value>Telemetry</value>
470470
</data>
471+
<data name="quickMenu" xml:space="preserve">
472+
<value>Quick Menu on hotkey</value>
473+
</data>
474+
<data name="quickMenu.desc" xml:space="preserve">
475+
<value>Show a quick menu like Windows language when using a hotkey</value>
476+
</data>
471477
</root>

SoundSwitch/Model/AppModel.cs

+10
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,16 @@ public bool Telemetry
129129
AppConfigs.Configuration.Save();
130130
}
131131
}
132+
133+
public bool QuickMenuEnabled
134+
{
135+
get => AppConfigs.Configuration.QuickMenuEnabled;
136+
set
137+
{
138+
AppConfigs.Configuration.QuickMenuEnabled = value;
139+
AppConfigs.Configuration.Save();
140+
}
141+
}
132142

133143

134144
public IEnumerable<DeviceInfo> SelectedDevices => AppConfigs.Configuration.SelectedDevices.OrderBy(info => info.DiscoveredAt);

SoundSwitch/Model/IAppModel.cs

+1
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ public interface IAppModel : IDisposable
115115
IAudioDeviceLister ActiveUnpluggedAudioLister { get; set; }
116116

117117
bool Telemetry { get; set; }
118+
bool QuickMenuEnabled { get; set; }
118119

119120
#endregion
120121

SoundSwitch/UI/Forms/Settings.Designer.cs

+32-19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

SoundSwitch/UI/Forms/Settings.cs

+8-4
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,7 @@ public SettingsForm(IAudioDeviceLister audioDeviceLister)
168168
updateNeverToolTip.SetToolTip(updateNeverRadioButton, SettingsStrings.updateNeverTooltip);
169169

170170
var includeBetaVersionsToolTip = new ToolTip();
171-
includeBetaVersionsToolTip.SetToolTip(includeBetaVersionsCheckBox,
172-
SettingsStrings.updateIncludeBetaVersionsTooltip);
171+
includeBetaVersionsToolTip.SetToolTip(includeBetaVersionsCheckBox, SettingsStrings.updateIncludeBetaVersionsTooltip);
173172

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

182181
telemetryCheckbox.DataBindings.Add(nameof(CheckBox.Checked), AppModel.Instance, nameof(AppModel.Telemetry), false, DataSourceUpdateMode.OnPropertyChanged);
183-
telemetryCheckbox.Text = SettingsStrings.telemetry;
184-
182+
quickMenuCheckbox.DataBindings.Add(nameof(CheckBox.Checked), AppModel.Instance, nameof(AppModel.QuickMenuEnabled), false, DataSourceUpdateMode.OnPropertyChanged);
183+
var quickMenuCheckboxToolTip = new ToolTip();
184+
quickMenuCheckboxToolTip.SetToolTip(quickMenuCheckbox, SettingsStrings.quickMenu_desc);
185+
185186
PopulateSettings();
186187

187188
_loaded = true;
@@ -316,13 +317,16 @@ private void LocalizeForm()
316317
cycleThroughLabel.Text = SettingsStrings.cycleThrough;
317318
foregroundAppCheckbox.Text = SettingsStrings.foregroundApp;
318319
usePrimaryScreenCheckbox.Text = SettingsStrings.usePrimaryScreen;
320+
quickMenuCheckbox.Text = SettingsStrings.quickMenu;
319321

320322
// Settings - Update
321323
updateSettingsGroupBox.Text = SettingsStrings.updateSettings;
322324
updateSilentRadioButton.Text = SettingsStrings.updateInstallAutomatically;
323325
updateNotifyRadioButton.Text = SettingsStrings.updateNotify;
324326
updateNeverRadioButton.Text = SettingsStrings.updateNever;
325327
includeBetaVersionsCheckBox.Text = SettingsStrings.updateIncludeBetaVersions;
328+
telemetryCheckbox.Text = SettingsStrings.telemetry;
329+
326330

327331
// Settings - Language
328332
languageGroupBox.Text = SettingsStrings.language;

0 commit comments

Comments
 (0)