Centralize legacy brush package import
This commit is contained in:
48
src/legacy_brush_package_import_services.cpp
Normal file
48
src/legacy_brush_package_import_services.cpp
Normal file
@@ -0,0 +1,48 @@
|
||||
#include "pch.h"
|
||||
|
||||
#include "legacy_brush_package_import_services.h"
|
||||
|
||||
#include "app.h"
|
||||
#include "node_panel_brush.h"
|
||||
|
||||
#include <string>
|
||||
#include <thread>
|
||||
|
||||
namespace pp::panopainter {
|
||||
namespace {
|
||||
|
||||
class LegacyBrushPackageImportServices final : public pp::app::BrushPackageImportServices {
|
||||
public:
|
||||
explicit LegacyBrushPackageImportServices(App& app) noexcept
|
||||
: app_(app)
|
||||
{
|
||||
}
|
||||
|
||||
void import_brush_package(pp::app::BrushPackageImportKind kind, std::string_view path) override
|
||||
{
|
||||
auto presets = app_.presets;
|
||||
const auto path_string = std::string(path);
|
||||
if (kind == pp::app::BrushPackageImportKind::abr) {
|
||||
std::thread(&NodePanelBrushPreset::import_abr, presets, path_string).detach();
|
||||
return;
|
||||
}
|
||||
|
||||
std::thread(&NodePanelBrushPreset::import_ppbr, presets, path_string).detach();
|
||||
}
|
||||
|
||||
private:
|
||||
App& app_;
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
pp::foundation::Status execute_legacy_brush_package_import(
|
||||
App& app,
|
||||
pp::app::BrushPackageImportKind kind,
|
||||
std::string_view path)
|
||||
{
|
||||
LegacyBrushPackageImportServices services(app);
|
||||
return pp::app::execute_brush_package_import(kind, path, services);
|
||||
}
|
||||
|
||||
} // namespace pp::panopainter
|
||||
Reference in New Issue
Block a user