mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-08 04:07:40 +02:00
[VCM]Add options to hide after timeout and startup action (#28658)
* VideoConference add new option ToolbarHide After timeout * VideoConference add new behavior option startup action
This commit is contained in:
@@ -50,12 +50,12 @@ bool VideoConferenceModule::isHotkeyPressed(DWORD code, PowerToysSettings::Hotke
|
|||||||
|
|
||||||
void VideoConferenceModule::reverseMicrophoneMute()
|
void VideoConferenceModule::reverseMicrophoneMute()
|
||||||
{
|
{
|
||||||
bool muted = false;
|
// All controlled mic should same state with _microphoneTrackedInUI
|
||||||
|
// Avoid manually change in Control Panel make controlled mic has different state
|
||||||
|
bool muted = !getMicrophoneMuteState();
|
||||||
for (auto& controlledMic : instance->_controlledMicrophones)
|
for (auto& controlledMic : instance->_controlledMicrophones)
|
||||||
{
|
{
|
||||||
const bool was_muted = controlledMic->muted();
|
controlledMic->set_muted(muted);
|
||||||
controlledMic->toggle_muted();
|
|
||||||
muted = muted || !was_muted;
|
|
||||||
}
|
}
|
||||||
if (muted)
|
if (muted)
|
||||||
{
|
{
|
||||||
@@ -283,6 +283,10 @@ void VideoConferenceModule::onModuleSettingsChanged()
|
|||||||
{
|
{
|
||||||
toolbar.setToolbarHide(val.value());
|
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");
|
const auto selectedMic = values.get_string_value(L"selected_mic");
|
||||||
if (selectedMic && selectedMic != settings.selectedMicrophone)
|
if (selectedMic && selectedMic != settings.selectedMicrophone)
|
||||||
@@ -308,7 +312,7 @@ void VideoConferenceModule::onMicrophoneConfigurationChanged()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool mutedStateForNewMics = _microphoneTrackedInUI ? _microphoneTrackedInUI->muted() : _mic_muted_state_during_disconnect;
|
const bool mutedStateForNewMics = getMicrophoneMuteState();
|
||||||
std::unordered_set<std::wstring_view> currentlyTrackedMicsIds;
|
std::unordered_set<std::wstring_view> currentlyTrackedMicsIds;
|
||||||
for (const auto& controlledMic : _controlledMicrophones)
|
for (const auto& controlledMic : _controlledMicrophones)
|
||||||
{
|
{
|
||||||
@@ -338,6 +342,7 @@ void VideoConferenceModule::onMicrophoneConfigurationChanged()
|
|||||||
toolbar.setMicrophoneMute(muted);
|
toolbar.setMicrophoneMute(muted);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
setMuteChangedCallback();
|
||||||
}
|
}
|
||||||
|
|
||||||
VideoConferenceModule::VideoConferenceModule()
|
VideoConferenceModule::VideoConferenceModule()
|
||||||
@@ -401,6 +406,25 @@ void VideoConferenceModule::set_config(const wchar_t* config)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VideoConferenceModule::setMuteChangedCallback()
|
||||||
|
{
|
||||||
|
// Keep all controlledMic mute state same _microphoneTrackedInUI
|
||||||
|
// Should not change manually in Control Panel
|
||||||
|
for (const auto& controlledMic : _controlledMicrophones)
|
||||||
|
{
|
||||||
|
if (controlledMic->id() != _microphoneTrackedInUI->id())
|
||||||
|
{
|
||||||
|
controlledMic->set_mute_changed_callback([&](const bool muted) {
|
||||||
|
auto muteState = getMicrophoneMuteState();
|
||||||
|
if (muted != muteState)
|
||||||
|
{
|
||||||
|
controlledMic->set_muted(muteState);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void VideoConferenceModule::init_settings()
|
void VideoConferenceModule::init_settings()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -447,6 +471,10 @@ void VideoConferenceModule::init_settings()
|
|||||||
{
|
{
|
||||||
toolbar.setToolbarHide(val.value());
|
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)
|
if (const auto val = powerToysSettings.get_string_value(L"selected_mic"); val && *val != settings.selectedMicrophone)
|
||||||
{
|
{
|
||||||
settings.selectedMicrophone = *val;
|
settings.selectedMicrophone = *val;
|
||||||
@@ -509,6 +537,22 @@ void VideoConferenceModule::updateControlledMicrophones(const std::wstring_view
|
|||||||
});
|
});
|
||||||
toolbar.setMicrophoneMute(_microphoneTrackedInUI->muted());
|
toolbar.setMicrophoneMute(_microphoneTrackedInUI->muted());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (settings.startupAction == L"Unmute")
|
||||||
|
{
|
||||||
|
for (auto& controlledMic : _controlledMicrophones)
|
||||||
|
{
|
||||||
|
controlledMic->set_muted(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (settings.startupAction == L"Mute")
|
||||||
|
{
|
||||||
|
for (auto& controlledMic : _controlledMicrophones)
|
||||||
|
{
|
||||||
|
controlledMic->set_muted(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setMuteChangedCallback();
|
||||||
}
|
}
|
||||||
|
|
||||||
MicrophoneDevice* VideoConferenceModule::controlledDefaultMic()
|
MicrophoneDevice* VideoConferenceModule::controlledDefaultMic()
|
||||||
@@ -669,6 +713,14 @@ void VideoConferenceModule::sendSourceCameraNameUpdate()
|
|||||||
auto updatesChannel = reinterpret_cast<CameraSettingsUpdateChannel*>(memory._data);
|
auto updatesChannel = reinterpret_cast<CameraSettingsUpdateChannel*>(memory._data);
|
||||||
updatesChannel->sourceCameraName.emplace();
|
updatesChannel->sourceCameraName.emplace();
|
||||||
std::copy(begin(settings.selectedCamera), end(settings.selectedCamera), begin(*updatesChannel->sourceCameraName));
|
std::copy(begin(settings.selectedCamera), end(settings.selectedCamera), begin(*updatesChannel->sourceCameraName));
|
||||||
|
if (settings.startupAction == L"Unmute")
|
||||||
|
{
|
||||||
|
updatesChannel->useOverlayImage = false;
|
||||||
|
}
|
||||||
|
else if (settings.startupAction == L"Mute")
|
||||||
|
{
|
||||||
|
updatesChannel->useOverlayImage = true;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -30,6 +30,8 @@ struct VideoConferenceSettings
|
|||||||
std::wstring imageOverlayPath;
|
std::wstring imageOverlayPath;
|
||||||
std::wstring selectedMicrophone;
|
std::wstring selectedMicrophone;
|
||||||
|
|
||||||
|
std::wstring startupAction;
|
||||||
|
|
||||||
bool pushToReverseEnabled = false;
|
bool pushToReverseEnabled = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -71,6 +73,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
void setMuteChangedCallback();
|
||||||
void init_settings();
|
void init_settings();
|
||||||
void updateControlledMicrophones(const std::wstring_view new_mic);
|
void updateControlledMicrophones(const std::wstring_view new_mic);
|
||||||
MicrophoneDevice* controlledDefaultMic();
|
MicrophoneDevice* controlledDefaultMic();
|
||||||
|
|||||||
@@ -53,11 +53,6 @@ bool MicrophoneDevice::muted() const noexcept
|
|||||||
return muted;
|
return muted;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MicrophoneDevice::toggle_muted() noexcept
|
|
||||||
{
|
|
||||||
set_muted(!muted());
|
|
||||||
}
|
|
||||||
|
|
||||||
std::wstring_view MicrophoneDevice::id() const noexcept
|
std::wstring_view MicrophoneDevice::id() const noexcept
|
||||||
{
|
{
|
||||||
return _id ? _id.get() : FALLBACK_ID;
|
return _id ? _id.get() : FALLBACK_ID;
|
||||||
@@ -70,6 +65,10 @@ std::wstring_view MicrophoneDevice::name() const noexcept
|
|||||||
|
|
||||||
void MicrophoneDevice::set_mute_changed_callback(mute_changed_cb_t callback) noexcept
|
void MicrophoneDevice::set_mute_changed_callback(mute_changed_cb_t callback) noexcept
|
||||||
{
|
{
|
||||||
|
if (_notifier)
|
||||||
|
{
|
||||||
|
_endpoint->UnregisterControlChangeNotify(_notifier.get());
|
||||||
|
}
|
||||||
_mute_changed_callback = std::move(callback);
|
_mute_changed_callback = std::move(callback);
|
||||||
_notifier = winrt::make<VolumeNotifier>(this);
|
_notifier = winrt::make<VolumeNotifier>(this);
|
||||||
|
|
||||||
|
|||||||
@@ -54,7 +54,6 @@ public:
|
|||||||
bool active() const noexcept;
|
bool active() const noexcept;
|
||||||
void set_muted(const bool muted) noexcept;
|
void set_muted(const bool muted) noexcept;
|
||||||
bool muted() const noexcept;
|
bool muted() const noexcept;
|
||||||
void toggle_muted() noexcept;
|
|
||||||
|
|
||||||
std::wstring_view id() const noexcept;
|
std::wstring_view id() const noexcept;
|
||||||
std::wstring_view name() const noexcept;
|
std::wstring_view name() const noexcept;
|
||||||
|
|||||||
@@ -95,6 +95,9 @@ namespace Microsoft.PowerToys.Settings.UI.Library
|
|||||||
[JsonPropertyName("toolbar_hide")]
|
[JsonPropertyName("toolbar_hide")]
|
||||||
public StringProperty ToolbarHide { get; set; } = "When both camera and microphone are unmuted";
|
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.
|
// converts the current to a json string.
|
||||||
public string ToJsonString()
|
public string ToJsonString()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -37,6 +37,7 @@
|
|||||||
"selected_camera": { "value": "USB Video Device" },
|
"selected_camera": { "value": "USB Video Device" },
|
||||||
"theme": { "value": "light" },
|
"theme": { "value": "light" },
|
||||||
"toolbar_monitor": { "value": "All monitors" },
|
"toolbar_monitor": { "value": "All monitors" },
|
||||||
"toolbar_position": { "value": "Bottom center" }
|
"toolbar_position": { "value": "Bottom center" },
|
||||||
|
"startup_action": { "value": "Nothing" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -146,11 +146,22 @@
|
|||||||
<ComboBoxItem x:Uid="VideoConference_ToolbarHideNever" />
|
<ComboBoxItem x:Uid="VideoConference_ToolbarHideNever" />
|
||||||
<ComboBoxItem x:Uid="VideoConference_ToolbarHideUnmuted" />
|
<ComboBoxItem x:Uid="VideoConference_ToolbarHideUnmuted" />
|
||||||
<ComboBoxItem x:Uid="VideoConference_ToolbarHideMuted" />
|
<ComboBoxItem x:Uid="VideoConference_ToolbarHideMuted" />
|
||||||
|
<ComboBoxItem x:Uid="VideoConference_ToolbarHideTimeout" />
|
||||||
</ComboBox>
|
</ComboBox>
|
||||||
</controls:SettingsCard>
|
</controls:SettingsCard>
|
||||||
</controls:SettingsExpander.Items>
|
</controls:SettingsExpander.Items>
|
||||||
</controls:SettingsExpander>
|
</controls:SettingsExpander>
|
||||||
</custom:SettingsGroup>
|
</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>
|
</StackPanel>
|
||||||
</custom:SettingsPageControl.ModuleContent>
|
</custom:SettingsPageControl.ModuleContent>
|
||||||
|
|
||||||
|
|||||||
@@ -561,6 +561,9 @@
|
|||||||
<data name="VideoConference_ToolbarHideUnmuted.Content" xml:space="preserve">
|
<data name="VideoConference_ToolbarHideUnmuted.Content" xml:space="preserve">
|
||||||
<value>When both camera and microphone are unmuted</value>
|
<value>When both camera and microphone are unmuted</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="VideoConference_ToolbarHideTimeout.Content" xml:space="preserve">
|
||||||
|
<value>After timeout</value>
|
||||||
|
</data>
|
||||||
<data name="VideoConference.ModuleTitle" xml:space="preserve">
|
<data name="VideoConference.ModuleTitle" xml:space="preserve">
|
||||||
<value>Video Conference Mute</value>
|
<value>Video Conference Mute</value>
|
||||||
</data>
|
</data>
|
||||||
@@ -576,6 +579,21 @@
|
|||||||
<data name="VideoConference_Toolbar.Header" xml:space="preserve">
|
<data name="VideoConference_Toolbar.Header" xml:space="preserve">
|
||||||
<value>Toolbar</value>
|
<value>Toolbar</value>
|
||||||
</data>
|
</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">
|
<data name="VideoConference_Shortcuts.Header" xml:space="preserve">
|
||||||
<value>Shortcuts</value>
|
<value>Shortcuts</value>
|
||||||
</data>
|
</data>
|
||||||
|
|||||||
@@ -147,6 +147,22 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
|||||||
case "When both camera and microphone are muted":
|
case "When both camera and microphone are muted":
|
||||||
_toolbarHideIndex = 2;
|
_toolbarHideIndex = 2;
|
||||||
break;
|
break;
|
||||||
|
case "After timeout":
|
||||||
|
_toolbarHideIndex = 3;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (Settings.Properties.StartupAction.Value)
|
||||||
|
{
|
||||||
|
case "Nothing":
|
||||||
|
_startupActionIndex = 0;
|
||||||
|
break;
|
||||||
|
case "Unmute":
|
||||||
|
_startupActionIndex = 1;
|
||||||
|
break;
|
||||||
|
case "Mute":
|
||||||
|
_startupActionIndex = 2;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (shouldSaveSettings)
|
if (shouldSaveSettings)
|
||||||
@@ -176,6 +192,7 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
|||||||
private int _toolbarPositionIndex;
|
private int _toolbarPositionIndex;
|
||||||
private int _toolbarMonitorIndex;
|
private int _toolbarMonitorIndex;
|
||||||
private int _toolbarHideIndex;
|
private int _toolbarHideIndex;
|
||||||
|
private int _startupActionIndex;
|
||||||
private HotkeySettings _cameraAndMicrophoneMuteHotkey;
|
private HotkeySettings _cameraAndMicrophoneMuteHotkey;
|
||||||
private HotkeySettings _microphoneMuteHotkey;
|
private HotkeySettings _microphoneMuteHotkey;
|
||||||
private HotkeySettings _microphonePushToTalkHotkey;
|
private HotkeySettings _microphonePushToTalkHotkey;
|
||||||
@@ -497,6 +514,9 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
|||||||
case 2:
|
case 2:
|
||||||
Settings.Properties.ToolbarHide.Value = "When both camera and microphone are muted";
|
Settings.Properties.ToolbarHide.Value = "When both camera and microphone are muted";
|
||||||
break;
|
break;
|
||||||
|
case 3:
|
||||||
|
Settings.Properties.ToolbarHide.Value = "After timeout";
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
RaisePropertyChanged(nameof(ToolbarHideIndex));
|
RaisePropertyChanged(nameof(ToolbarHideIndex));
|
||||||
@@ -504,6 +524,36 @@ namespace Microsoft.PowerToys.Settings.UI.ViewModels
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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()
|
public string GetSettingsSubPath()
|
||||||
{
|
{
|
||||||
return _settingsConfigFileFolder + (string.IsNullOrEmpty(_settingsConfigFileFolder) ? string.Empty : "\\") + ModuleName;
|
return _settingsConfigFileFolder + (string.IsNullOrEmpty(_settingsConfigFileFolder) ? string.Empty : "\\") + ModuleName;
|
||||||
|
|||||||
Reference in New Issue
Block a user