diff --git a/src/modules/interface/powertoy_module_interface.h b/src/modules/interface/powertoy_module_interface.h index e9e51d1180..4bc44e4967 100644 --- a/src/modules/interface/powertoy_module_interface.h +++ b/src/modules/interface/powertoy_module_interface.h @@ -47,7 +47,7 @@ public: std::strong_ordering operator<=>(const Hotkey&) const = default; }; - + struct HotkeyEx { WORD modifiersMask = 0; @@ -98,7 +98,7 @@ public: */ virtual bool on_hotkey(size_t hotkeyId) { return false; } - /* These are for enabling the legacy behavior of showing the shortcut guide after pressing the win key. + /* These are for enabling the legacy behavior of showing the shortcut guide after pressing the win key. * keep_track_of_pressed_win_key returns true if the module wants to keep track of the win key being pressed. * milliseconds_win_key_must_be_pressed returns the number of milliseconds the win key should be pressed before triggering the module. * Don't use these for new modules. @@ -110,6 +110,8 @@ public: { } + virtual bool is_enabled_by_default() const { return true; } + protected: HANDLE CreateDefaultEvent(const wchar_t* eventName) { diff --git a/src/modules/videoconference/VideoConferenceModule/VideoConferenceModule.cpp b/src/modules/videoconference/VideoConferenceModule/VideoConferenceModule.cpp index b310315648..77560038e1 100644 --- a/src/modules/videoconference/VideoConferenceModule/VideoConferenceModule.cpp +++ b/src/modules/videoconference/VideoConferenceModule/VideoConferenceModule.cpp @@ -527,6 +527,11 @@ void VideoConferenceModule::destroy() instance = nullptr; } +bool VideoConferenceModule::is_enabled_by_default() const +{ + return false; +} + void VideoConferenceModule::sendSourceCameraNameUpdate() { if (!_settingsUpdateChannel.has_value() || settings.selectedCamera.empty()) diff --git a/src/modules/videoconference/VideoConferenceModule/VideoConferenceModule.h b/src/modules/videoconference/VideoConferenceModule/VideoConferenceModule.h index 2a37546362..fc9ee38fb6 100644 --- a/src/modules/videoconference/VideoConferenceModule/VideoConferenceModule.h +++ b/src/modules/videoconference/VideoConferenceModule/VideoConferenceModule.h @@ -45,6 +45,7 @@ public: virtual void disable() override; virtual bool is_enabled() override; virtual void destroy() override; + virtual bool is_enabled_by_default() const override; virtual const wchar_t * get_key() override; diff --git a/src/runner/general_settings.cpp b/src/runner/general_settings.cpp index 99ee57a3b4..2833b59d51 100644 --- a/src/runner/general_settings.cpp +++ b/src/runner/general_settings.cpp @@ -179,9 +179,15 @@ void apply_general_settings(const json::JsonObject& general_configs, bool save) } } -void start_initial_powertoys() +void start_enabled_powertoys() { std::unordered_set powertoys_to_disable; + // Take into account default values supplied by modules themselves + for (auto& [name, powertoy] : modules()) + { + if (!powertoy->is_enabled_by_default()) + powertoys_to_disable.emplace(name); + } json::JsonObject general_settings; try @@ -192,9 +198,16 @@ void start_initial_powertoys() json::JsonObject enabled = general_settings.GetNamedObject(L"enabled"); for (const auto& disabled_element : enabled) { + std::wstring disable_module_name{ static_cast(disabled_element.Key()) }; + // Disable explicitly disabled modules if (!disabled_element.Value().GetBoolean()) { - powertoys_to_disable.emplace(disabled_element.Key()); + powertoys_to_disable.emplace(std::move(disable_module_name)); + } + // If module was scheduled for disable, but it's enabled in the settings - override default value + else if (auto it = powertoys_to_disable.find(disable_module_name); it != end(powertoys_to_disable)) + { + powertoys_to_disable.erase(it); } } } @@ -203,21 +216,11 @@ void start_initial_powertoys() { } - if (powertoys_to_disable.empty()) + for (auto& [name, powertoy] : modules()) { - for (auto& [name, powertoy] : modules()) + if (!powertoys_to_disable.contains(name)) { powertoy->enable(); } } - else - { - for (auto& [name, powertoy] : modules()) - { - if (powertoys_to_disable.find(name) == powertoys_to_disable.end()) - { - powertoy->enable(); - } - } - } } diff --git a/src/runner/general_settings.h b/src/runner/general_settings.h index 5cbe1fefab..bc7f59cae6 100644 --- a/src/runner/general_settings.h +++ b/src/runner/general_settings.h @@ -21,4 +21,4 @@ struct GeneralSettings json::JsonObject load_general_settings(); GeneralSettings get_general_settings(); void apply_general_settings(const json::JsonObject& general_configs, bool save = true); -void start_initial_powertoys(); \ No newline at end of file +void start_enabled_powertoys(); \ No newline at end of file diff --git a/src/runner/main.cpp b/src/runner/main.cpp index 1147b38939..fc58e634b2 100644 --- a/src/runner/main.cpp +++ b/src/runner/main.cpp @@ -177,7 +177,7 @@ int runner(bool isProcessElevated, bool openSettings, std::string settingsWindow } } // Start initial powertoys - start_initial_powertoys(); + start_enabled_powertoys(); Trace::EventLaunch(get_product_version(), isProcessElevated); diff --git a/src/settings-ui/Microsoft.PowerToys.Settings.UI.Library/EnabledModules.cs b/src/settings-ui/Microsoft.PowerToys.Settings.UI.Library/EnabledModules.cs index 910a4dd78f..6d652df912 100644 --- a/src/settings-ui/Microsoft.PowerToys.Settings.UI.Library/EnabledModules.cs +++ b/src/settings-ui/Microsoft.PowerToys.Settings.UI.Library/EnabledModules.cs @@ -80,7 +80,7 @@ namespace Microsoft.PowerToys.Settings.UI.Library } } - private bool videoConference = true; + private bool videoConference; // defaulting to off https://github.com/microsoft/PowerToys/issues/14507 [JsonPropertyName("Video Conference")] public bool VideoConference diff --git a/src/settings-ui/Microsoft.PowerToys.Settings.UI/Strings/en-us/Resources.resw b/src/settings-ui/Microsoft.PowerToys.Settings.UI/Strings/en-us/Resources.resw index 748a30e6c7..1f11a31383 100644 --- a/src/settings-ui/Microsoft.PowerToys.Settings.UI/Strings/en-us/Resources.resw +++ b/src/settings-ui/Microsoft.PowerToys.Settings.UI/Strings/en-us/Resources.resw @@ -1825,4 +1825,7 @@ From there, simply click on a Markdown file, PDF file or SVG icon in the File Ex Zone appearance + + You need to run as administrator to modify these settings. + \ No newline at end of file diff --git a/src/settings-ui/Microsoft.PowerToys.Settings.UI/Views/VideoConference.xaml b/src/settings-ui/Microsoft.PowerToys.Settings.UI/Views/VideoConference.xaml index a641adaac6..15396b9821 100644 --- a/src/settings-ui/Microsoft.PowerToys.Settings.UI/Views/VideoConference.xaml +++ b/src/settings-ui/Microsoft.PowerToys.Settings.UI/Views/VideoConference.xaml @@ -5,11 +5,13 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:controls="using:Microsoft.PowerToys.Settings.UI.Controls" - xmlns:converters="using:Microsoft.Toolkit.Uwp.UI.Converters" + xmlns:converters="using:Microsoft.Toolkit.Uwp.UI.Converters" + xmlns:muxc="using:Microsoft.UI.Xaml.Controls" mc:Ignorable="d"> + - +