mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-07 19:57:07 +02:00
[File Explorer] Fix enable/disable for File Explorer PowerToy (#6883)
* Commented out enable/disable for File Explorer * Revert UI changes * Disable the toggles if PT is not running elevated * Fixed compilation errors in tests * Cleaned up preview pane code to separate thumbnail and preview panes as separate classes * Fixed broken settings format and added elevation check and registry updated required logic. Preview Handler tested manually working, Thumbnail Enable/Disable needs to be fixed * Updated Thumbnail enable/disable logic and added warning messages * Update tests for File Explorer * Fixed RegGetValue failing in Release config * Renamed new classes * Split wrappers for disable to work * Modified enabled flag check to also check if user is on new settings. Fixed casing issue in powerpreview.h that caused a dialog prompt on first launch after install * Update fontweight and margin * Fixed release build not working * Move UseNewSettings usage to powerpreview.cpp to avoid tests breaking. For new settings the enable check is done in constructor and for old settings it is done in enable * Update src/core/Microsoft.PowerToys.Settings.UI/Strings/en-us/Resources.resw Co-authored-by: htcfreek <61519853+htcfreek@users.noreply.github.com> * Update src/core/Microsoft.PowerToys.Settings.UI/Strings/en-us/Resources.resw Co-authored-by: htcfreek <61519853+htcfreek@users.noreply.github.com> * Update src/core/Microsoft.PowerToys.Settings.UI/Strings/en-us/Resources.resw Co-authored-by: htcfreek <61519853+htcfreek@users.noreply.github.com> * Moved dup code to method * Use correct versions of general settings for backwards compat test Co-authored-by: htcfreek <61519853+htcfreek@users.noreply.github.com>
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
#include <common.h>
|
||||
#include "trace.h"
|
||||
#include "settings.h"
|
||||
#include "thumbnail_provider.h"
|
||||
#include "preview_handler.h"
|
||||
#include "registry_wrapper.h"
|
||||
|
||||
using namespace PowerPreviewSettings;
|
||||
@@ -16,42 +18,25 @@ private:
|
||||
// The PowerToy state.
|
||||
bool m_enabled = false;
|
||||
std::wstring m_moduleName;
|
||||
std::vector<FileExplorerPreviewSettings*> m_previewHandlers;
|
||||
std::vector<FileExplorerPreviewSettings*> m_thumbnailProviders;
|
||||
std::vector<FileExplorerPreviewSettings*> m_fileExplorerModules;
|
||||
|
||||
// Function to check if the registry states need to be updated
|
||||
bool is_registry_update_required();
|
||||
|
||||
// Function to warn the user that PowerToys needs to run as administrator for changes to take effect
|
||||
void show_update_warning_message();
|
||||
|
||||
// Function that checks if a registry method is required and if so checks if the process is elevated and accordingly executes the method or shows a warning
|
||||
void registry_and_elevation_check_wrapper(std::function<void()> method);
|
||||
|
||||
// Function that checks if the process is elevated and accordingly executes the method or shows a warning
|
||||
void elevation_check_wrapper(std::function<void()> method);
|
||||
|
||||
// Function that updates the registry state to match the toggle states
|
||||
void update_registry_to_match_toggles();
|
||||
|
||||
public:
|
||||
PowerPreviewModule() :
|
||||
m_moduleName(GET_RESOURCE_STRING(IDS_MODULE_NAME)),
|
||||
m_previewHandlers(
|
||||
{ // SVG Preview Handler settings object.
|
||||
new FileExplorerPreviewSettings(
|
||||
true,
|
||||
L"svg-previewer-toggle-setting",
|
||||
GET_RESOURCE_STRING(IDS_PREVPANE_SVG_SETTINGS_DESCRIPTION),
|
||||
L"{ddee2b8a-6807-48a6-bb20-2338174ff779}",
|
||||
L"SVG Preview Handler",
|
||||
new RegistryWrapper()),
|
||||
|
||||
// MarkDown Preview Handler Settings Object.
|
||||
new FileExplorerPreviewSettings(
|
||||
true,
|
||||
L"md-previewer-toggle-setting",
|
||||
GET_RESOURCE_STRING(IDS_PREVPANE_MD_SETTINGS_DESCRIPTION),
|
||||
L"{45769bcc-e8fd-42d0-947e-02beef77a1f5}",
|
||||
L"Markdown Preview Handler",
|
||||
new RegistryWrapper()) }),
|
||||
m_thumbnailProviders(
|
||||
{ // TODO: MOVE THIS SVG Thumbnail Provider settings object.
|
||||
new FileExplorerPreviewSettings(
|
||||
true,
|
||||
L"svg-thumbnail-toggle-setting",
|
||||
GET_RESOURCE_STRING(IDS_SVG_THUMBNAIL_PROVIDER_SETTINGS_DESCRIPTION),
|
||||
L"{36B27788-A8BB-4698-A756-DF9F11F64F84}",
|
||||
L"SVG Thumbnail Provider",
|
||||
new RegistryWrapper()) })
|
||||
{
|
||||
init_settings();
|
||||
};
|
||||
PowerPreviewModule();
|
||||
|
||||
virtual void destroy();
|
||||
virtual const wchar_t* get_name();
|
||||
|
||||
Reference in New Issue
Block a user