Skip to content

Commit

Permalink
VideoConference add new behavior option startup action
Browse files Browse the repository at this point in the history
  • Loading branch information
quyenvsp committed Sep 20, 2023
1 parent 644c158 commit fc50274
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,10 @@ void VideoConferenceModule::onModuleSettingsChanged()
{
toolbar.setToolbarHide(val.value());
}
if (const auto val = values.get_string_value(L"startup_action"))
{
settings.startupAction = val.value();
}

const auto selectedMic = values.get_string_value(L"selected_mic");
if (selectedMic && selectedMic != settings.selectedMicrophone)
Expand Down Expand Up @@ -447,6 +451,10 @@ void VideoConferenceModule::init_settings()
{
toolbar.setToolbarHide(val.value());
}
if (const auto val = powerToysSettings.get_string_value(L"startup_action"))
{
settings.startupAction = val.value();
}
if (const auto val = powerToysSettings.get_string_value(L"selected_mic"); val && *val != settings.selectedMicrophone)
{
settings.selectedMicrophone = *val;
Expand Down Expand Up @@ -573,6 +581,14 @@ void VideoConferenceModule::enable()
});

toggleProxyCamRegistration(true);
if (settings.startupAction == L"Unmute")
{
unmuteAll();
}
else if (settings.startupAction == L"Mute")
{
muteAll();
}
toolbar.setMicrophoneMute(getMicrophoneMuteState());
toolbar.setCameraMute(getVirtualCameraMuteState());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ struct VideoConferenceSettings
std::wstring imageOverlayPath;
std::wstring selectedMicrophone;

std::wstring startupAction;

bool pushToReverseEnabled = false;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ public VideoConferenceConfigProperties()
[JsonPropertyName("toolbar_hide")]
public StringProperty ToolbarHide { get; set; } = "When both camera and microphone are unmuted";

[JsonPropertyName("startup_action")]
public StringProperty StartupAction { get; set; } = "Nothing";

// converts the current to a json string.
public string ToJsonString()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"selected_camera": { "value": "USB Video Device" },
"theme": { "value": "light" },
"toolbar_monitor": { "value": "All monitors" },
"toolbar_position": { "value": "Bottom center" }
"toolbar_position": { "value": "Bottom center" },
"startup_action": { "value": "Nothing" }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,16 @@
</controls:SettingsExpander.Items>
</controls:SettingsExpander>
</custom:SettingsGroup>

<custom:SettingsGroup x:Uid="VideoConference_Behavior" IsEnabled="{Binding Mode=OneWay, Path=IsEnabled}">
<controls:SettingsCard x:Uid="VideoConference_StartupAction">
<ComboBox MinWidth="{StaticResource SettingActionControlMinWidth}" SelectedIndex="{Binding Mode=TwoWay, Path=StartupActionIndex}">
<ComboBoxItem x:Uid="VideoConference_StartupActionNothing" />
<ComboBoxItem x:Uid="VideoConference_StartupActionUnmute" />
<ComboBoxItem x:Uid="VideoConference_StartupActionMute" />
</ComboBox>
</controls:SettingsCard>
</custom:SettingsGroup>
</StackPanel>
</custom:SettingsPageControl.ModuleContent>

Expand Down
15 changes: 15 additions & 0 deletions src/settings-ui/Settings.UI/Strings/en-us/Resources.resw
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,21 @@
<data name="VideoConference_Toolbar.Header" xml:space="preserve">
<value>Toolbar</value>
</data>
<data name="VideoConference_Behavior.Header" xml:space="preserve">
<value>Behavior</value>
</data>
<data name="VideoConference_StartupAction.Header" xml:space="preserve">
<value>Startup action</value>
</data>
<data name="VideoConference_StartupActionNothing.Content" xml:space="preserve">
<value>Nothing</value>
</data>
<data name="VideoConference_StartupActionUnmute.Content" xml:space="preserve">
<value>Unmute</value>
</data>
<data name="VideoConference_StartupActionMute.Content" xml:space="preserve">
<value>Mute</value>
</data>
<data name="VideoConference_Shortcuts.Header" xml:space="preserve">
<value>Shortcuts</value>
</data>
Expand Down
44 changes: 44 additions & 0 deletions src/settings-ui/Settings.UI/ViewModels/VideoConferenceViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,19 @@ public VideoConferenceViewModel(
break;
}

switch (Settings.Properties.StartupAction.Value)
{
case "Nothing":
_startupActionIndex = 0;
break;
case "Unmute":
_startupActionIndex = 1;
break;
case "Mute":
_startupActionIndex = 2;
break;
}

if (shouldSaveSettings)
{
_settingsUtils.SaveSettings(Settings.ToJsonString(), ModuleName);
Expand Down Expand Up @@ -179,6 +192,7 @@ private void InitializeEnabledValue()
private int _toolbarPositionIndex;
private int _toolbarMonitorIndex;
private int _toolbarHideIndex;
private int _startupActionIndex;
private HotkeySettings _cameraAndMicrophoneMuteHotkey;
private HotkeySettings _microphoneMuteHotkey;
private HotkeySettings _microphonePushToTalkHotkey;
Expand Down Expand Up @@ -510,6 +524,36 @@ public int ToolbarHideIndex
}
}

public int StartupActionIndex
{
get
{
return _startupActionIndex;
}

set
{
if (value != _startupActionIndex)
{
_startupActionIndex = value;
switch (_startupActionIndex)
{
case 0:
Settings.Properties.StartupAction.Value = "Nothing";
break;
case 1:
Settings.Properties.StartupAction.Value = "Unmute";
break;
case 2:
Settings.Properties.StartupAction.Value = "Mute";
break;
}

RaisePropertyChanged(nameof(_startupActionIndex));
}
}
}

public string GetSettingsSubPath()
{
return _settingsConfigFileFolder + (string.IsNullOrEmpty(_settingsConfigFileFolder) ? string.Empty : "\\") + ModuleName;
Expand Down

0 comments on commit fc50274

Please sign in to comment.