[PowerPreview] simplify and use modulesRegistry API

This commit is contained in:
yuyoyuppe
2021-10-05 18:54:42 +03:00
committed by Andrey Nekrasov
parent c324cd5953
commit 092ee49139
28 changed files with 217 additions and 1399 deletions

View File

@@ -1,15 +1,19 @@
#include "pch.h"
#include <interface/powertoy_module_interface.h>
#include "trace.h"
#include "settings.h"
#include "thumbnail_provider.h"
#include "preview_handler.h"
#include "registry_wrapper.h"
#include <powerpreview/powerpreviewConstants.h>
#include <functional>
using namespace PowerPreviewSettings;
#include <common/utils/modulesRegistry.h>
#include <common/SettingsAPI/settings_objects.h>
struct FileExplorerModule
{
std::wstring settingName;
std::wstring settingDescription;
registry::Changeset registryChanges;
};
// Implement the PowerToy Module Interface and all the required methods.
class PowerPreviewModule : public PowertoyModuleIface
@@ -18,25 +22,13 @@ private:
// The PowerToy state.
bool m_enabled = false;
std::wstring m_moduleName;
//contains the non localized key of the powertoy
// Contains the non localized key of the powertoy
std::wstring app_key;
std::vector<std::unique_ptr<FileExplorerPreviewSettings>> m_fileExplorerModules;
// Function to check if the registry states need to be updated
bool is_registry_update_required();
std::vector<FileExplorerModule> m_fileExplorerModules;
// 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();
void apply_settings(const PowerToysSettings::PowerToyValues& settings);
public:
PowerPreviewModule();
@@ -48,5 +40,4 @@ public:
virtual void enable();
virtual void disable();
virtual bool is_enabled();
virtual void init_settings();
};