Skip to content

Commit

Permalink
VCMute: refactor toolbar and settings
Browse files Browse the repository at this point in the history
- settings are not reset upon closing
- can't select virtual cam as physical
- win+N works reliably
- add missed telemetry call for mic muting
  • Loading branch information
yuyoyuppe committed Oct 12, 2020
1 parent a2b3020 commit 813fe15
Show file tree
Hide file tree
Showing 8 changed files with 161 additions and 145 deletions.
7 changes: 6 additions & 1 deletion src/common/interop/interop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,14 @@ public
auto names = gcnew List<String ^>();
VideoCaptureDeviceList vcdl;
vcdl.EnumerateDevices();

for (UINT32 i = 0; i < vcdl.Count(); ++i)
{
names->Add(gcnew String(vcdl.GetDeviceName(i).data()));
auto name = gcnew String(vcdl.GetDeviceName(i).data());
if (name != L"PowerToys VideoConference")
{
names->Add(name);
}
}
return names;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class SndVideoConferenceSettings

public SndVideoConferenceSettings(VideoConferenceSettings settings)
{
this.VideoConference = settings;
VideoConference = settings;
}

public string ToJsonString()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,14 @@ public VideoConferenceSettings()
[JsonPropertyName("properties")]
public VideoConferenceConfigProperties Properties { get; set; }

string ISettingsConfig.GetModuleName()
public string GetModuleName()
{
throw new System.NotImplementedException();
}

string ISettingsConfig.ToJsonString()
{
throw new System.NotImplementedException();
return Name;
}

bool ISettingsConfig.UpgradeSettingsConfiguration()
{
throw new System.NotImplementedException();
return false;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ public class VideoConferenceViewModel : Observable
private GeneralSettings GeneralSettingsConfig { get; set; }

private const string ModuleName = "Video Conference";
private const string ProxyCameraName = "PowerToys VideoConference";

private Func<string, int> SendConfigMSG { get; }

Expand Down Expand Up @@ -80,11 +79,6 @@ public VideoConferenceViewModel(ISettingsUtils settingsUtils, ISettingsRepositor
_selectedMicrophoneIndex = MicrophoneNames.FindIndex(name => name == Settings.Properties.SelectedMicrophone.Value);
}

if (shouldSaveSettings)
{
_settingsUtils.SaveSettings(Settings.ToJsonString(), ModuleName);
}

_isEnabled = GeneralSettingsConfig.Enabled.VideoConference;
_cameraAndMicrophoneMuteHotkey = Settings.Properties.MuteCameraAndMicrophoneHotkey.Value;
_mirophoneMuteHotkey = Settings.Properties.MuteMicrophoneHotkey.Value;
Expand Down Expand Up @@ -127,6 +121,11 @@ public VideoConferenceViewModel(ISettingsUtils settingsUtils, ISettingsRepositor
_toolbarMonitorIndex = 1;
break;
}

if (shouldSaveSettings)
{
_settingsUtils.SaveSettings(Settings.ToJsonString(), ModuleName);
}
}

private bool _isEnabled = false;
Expand Down Expand Up @@ -259,7 +258,7 @@ public HotkeySettings CameraAndMicrophoneMuteHotkey
{
_cameraAndMicrophoneMuteHotkey = value;
Settings.Properties.MuteCameraAndMicrophoneHotkey.Value = value;
RaisePropertyChanged();
RaisePropertyChanged("CameraAndMicrophoneMuteHotkey");
}
}
}
Expand All @@ -277,7 +276,7 @@ public HotkeySettings MicrophoneMuteHotkey
{
_mirophoneMuteHotkey = value;
Settings.Properties.MuteMicrophoneHotkey.Value = value;
RaisePropertyChanged();
RaisePropertyChanged("MicrophoneMuteHotkey");
}
}
}
Expand All @@ -295,7 +294,7 @@ public HotkeySettings CameraMuteHotkey
{
_cameraMuteHotkey = value;
Settings.Properties.MuteCameraHotkey.Value = value;
RaisePropertyChanged();
RaisePropertyChanged("CameraMuteHotkey");
}
}
}
Expand All @@ -316,34 +315,30 @@ public int ToolbarPostionIndex
{
case 0:
Settings.Properties.ToolbarPosition.Value = "Top left corner";
RaisePropertyChanged();
break;

case 1:
Settings.Properties.ToolbarPosition.Value = "Top center";
RaisePropertyChanged();
break;

case 2:
Settings.Properties.ToolbarPosition.Value = "Top right corner";
RaisePropertyChanged();
break;

case 3:
Settings.Properties.ToolbarPosition.Value = "Bottom left corner";
RaisePropertyChanged();
break;

case 4:
Settings.Properties.ToolbarPosition.Value = "Bottom center";
RaisePropertyChanged();
break;

case 5:
Settings.Properties.ToolbarPosition.Value = "Bottom right corner";
RaisePropertyChanged();
break;
}

RaisePropertyChanged("ToolbarPostionIndex");
}
}
}
Expand All @@ -364,14 +359,14 @@ public int ToolbarMonitorIndex
{
case 0:
Settings.Properties.ToolbarMonitor.Value = "Main monitor";
RaisePropertyChanged();
break;

case 1:
Settings.Properties.ToolbarMonitor.Value = "All monitors";
RaisePropertyChanged();
break;
}

RaisePropertyChanged("ToolbarMonitorIndex");
}
}
}
Expand All @@ -389,7 +384,7 @@ public bool HideToolbarWhenUnmuted
{
_hideToolbarWhenUnmuted = value;
Settings.Properties.HideToolbarWhenUnmuted.Value = value;
RaisePropertyChanged();
RaisePropertyChanged("HideToolbarWhenUnmuted");
}
}
}
Expand Down

0 comments on commit 813fe15

Please sign in to comment.