Skip to content

Commit a463873

Browse files
committed
feat(AutoAdd): Auto select new device when they are connected and SoundSwitch is running
Fixes #924
1 parent a2c4228 commit a463873

File tree

4 files changed

+20
-1
lines changed

4 files changed

+20
-1
lines changed

SoundSwitch/Framework/Configuration/ISoundSwitchConfiguration.cs

+2
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ public interface ISoundSwitchConfiguration : IConfiguration
5555

5656
bool SwitchForegroundProgram { get; set; }
5757
bool NotifyUsingPrimaryScreen { get; set; }
58+
59+
bool AutoAddNewConnectedDevices { get; set; }
5860

5961
/// <summary>
6062
/// What to do with the TrayIcon when changing default device

SoundSwitch/Framework/Configuration/SoundSwitchConfiguration.cs

+6-1
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ public SoundSwitchConfiguration()
6060
RecordingHotKey = new HotKey(Keys.F7, HotKey.ModifierKeys.Alt | HotKey.ModifierKeys.Control);
6161
MuteRecordingHotKey = new HotKey(Keys.M, HotKey.ModifierKeys.Control | HotKey.ModifierKeys.Alt);
6262

63+
AutoAddNewConnectedDevices = true;
64+
6365
SelectedDevices = new HashSet<DeviceInfo>();
6466
SwitchIcon = IconChangerFactory.ActionEnum.Never;
6567
MigratedFields = new HashSet<string>();
@@ -85,6 +87,8 @@ public SoundSwitchConfiguration()
8587
public string CustomNotificationFilePath { get; set; }
8688
public bool NotifyUsingPrimaryScreen { get; set; }
8789

90+
public bool AutoAddNewConnectedDevices { get; set; }
91+
8892

8993
public DateTime LastDonationNagTime { get; set; }
9094

@@ -190,7 +194,8 @@ public bool Migrate()
190194
}
191195

192196
return profile;
193-
}).ToHashSet();
197+
})
198+
.ToHashSet();
194199
MigratedFields.Add(nameof(ProfileSettings) + "_final");
195200
migrated = true;
196201
}

SoundSwitch/Model/AppModel.cs

+11
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,17 @@ public bool NotifyUsingPrimaryScreen
248248
}
249249
}
250250

251+
252+
public bool AutoAddNewDevice
253+
{
254+
get => AppConfigs.Configuration.AutoAddNewConnectedDevices;
255+
set
256+
{
257+
AppConfigs.Configuration.AutoAddNewConnectedDevices = value;
258+
AppConfigs.Configuration.Save();
259+
}
260+
}
261+
251262
#region Misc settings
252263

253264
/// <summary>

SoundSwitch/Model/IAppModel.cs

+1
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ public interface IAppModel : IDisposable
117117

118118
bool Telemetry { get; set; }
119119
bool QuickMenuEnabled { get; set; }
120+
bool AutoAddNewDevice { get; set; }
120121

121122
#endregion
122123

0 commit comments

Comments
 (0)