33 lines
771 B
C++
33 lines
771 B
C++
#include "MediaResourceManager.h"
|
|
|
|
#include "SvgReader.h"
|
|
#include "SvgDocument.h"
|
|
#include "SvgNode.h"
|
|
|
|
const Path MediaResourceManager::mResourceLocation = "C:\\dev\\MediaResources";
|
|
|
|
Path MediaResourceManager::getSvgIconPath(Resource::Icon::Svg icon)
|
|
{
|
|
return mResourceLocation / MediaResources::getPath(icon);
|
|
}
|
|
|
|
std::unique_ptr<SvgNode> MediaResourceManager::getSvgIconNode(Resource::Icon::Svg icon)
|
|
{
|
|
const auto path = getSvgIconPath(icon);
|
|
|
|
if (path.empty())
|
|
{
|
|
return nullptr;
|
|
}
|
|
|
|
SvgReader svg_reader;
|
|
auto svg_doc = svg_reader.read(path);
|
|
if (!svg_doc)
|
|
{
|
|
return nullptr;
|
|
}
|
|
|
|
auto svg_node = std::make_unique<SvgNode>(Point(0.0, 0.0));
|
|
svg_node->setContent(std::move(svg_doc));
|
|
return svg_node;
|
|
}
|