mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-07-15 15:03:49 +00:00
51 lines
2.3 KiB
C++
51 lines
2.3 KiB
C++
#pragma once
|
|
|
|
#include <slic3r/GUI/Widgets/WebViewHostDialog.hpp>
|
|
#include <libslic3r/Preset.hpp>
|
|
#include <slic3r/plugin/PresetPluginConfig.hpp>
|
|
|
|
#include <string>
|
|
|
|
namespace Slic3r { namespace GUI {
|
|
|
|
// The config half of the Plugins dialog, scoped to one preset instead of one plugin: it lists the
|
|
// capabilities the edited preset of `m_type` actually uses (see capabilities_in_use) and edits each
|
|
// one's stored config, falling back to the global config where the preset has no override.
|
|
//
|
|
// It is a pure editor over a JSON document: it never writes to the preset and never writes to the
|
|
// base config file. The caller seeds it with the preset's raw override text and reads the edited
|
|
// text back from overrides_json(). PluginConfigField, which owns the value, then feeds that through
|
|
// the normal field/dirty pipeline — which is what makes the revert arrow behave like any other
|
|
// setting. The capability list and config payloads are shared with PluginsDialog's Config tab
|
|
// through PluginConfig's statics.
|
|
class PluginsConfigDialog : public WebViewHostDialog
|
|
{
|
|
public:
|
|
PluginsConfigDialog(wxWindow* parent, Preset::Type type, const std::string& overrides_json);
|
|
~PluginsConfigDialog() override;
|
|
|
|
// The edited overrides as compact JSON text; "" once no override remains.
|
|
std::string overrides_json() const { return serialize_plugin_overrides(m_overrides); }
|
|
|
|
private:
|
|
void on_script_message(const nlohmann::json& payload) override;
|
|
|
|
const Preset* current_preset() const;
|
|
void send_capabilities();
|
|
void send_capability_config(const PluginCapabilityIdentifier& id);
|
|
void send_save_error(const PluginCapabilityIdentifier& id, const std::string& error);
|
|
void show_status(const wxString& message, const char* level);
|
|
|
|
PluginCapabilityIdentifier identifier_from(const nlohmann::json& payload) const;
|
|
|
|
Preset::Type m_type = Preset::TYPE_INVALID;
|
|
PresetPluginConfigService m_service;
|
|
// The working copy the dialog edits. Seeded from the preset's raw text, read back by the caller.
|
|
CapabilityConfigDocument m_overrides;
|
|
// Set when the preset's stored text could not be parsed: the rows are shown read-only rather
|
|
// than silently replacing data we did not understand.
|
|
std::string m_parse_error;
|
|
};
|
|
|
|
}} // namespace Slic3r::GUI
|