[style] 将MaterialStyle的存储方式改为了Base64编码
parent
f109ed7d62
commit
6ce962b4c5
|
@ -197,6 +197,7 @@
|
|||
<QtMoc Include="src\Editor\EditorWidgetComponent\LayerCreateWidget.h" />
|
||||
<QtMoc Include="src\Editor\EditorWidgetComponent\LayerStyleDialog.h" />
|
||||
<QtMoc Include="src\Editor\EditorWidgetComponent\ColorPicker.h" />
|
||||
<ClInclude Include="src\Editor\util\EncodeUtil.hpp" />
|
||||
<ClInclude Include="src\Editor\util\JsonUtil.hpp" />
|
||||
<ClInclude Include="src\Editor\ElementManager.h" />
|
||||
<QtMoc Include="src\Editor\ElementPoolWidget.h" />
|
||||
|
|
|
@ -480,6 +480,9 @@
|
|||
<ClInclude Include="src\Editor\util\JsonUtil.hpp">
|
||||
<Filter>Header Files\Editor\util</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\Editor\util\EncodeUtil.hpp">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<QtRcc Include="res\MainWindow.qrc">
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "LayerStyle.h"
|
||||
#include "./EditorWidgetComponent/StrokeStyleWidget.h"
|
||||
#include "./util/JsonUtil.hpp"
|
||||
#include "./util/EncodeUtil.hpp"
|
||||
#include <qtmaterialcheckbox.h>
|
||||
#include <QHBoxLayout>
|
||||
#include <QDialogButtonBox>
|
||||
|
@ -124,8 +124,8 @@ QJsonObject StrokeElementLayerStyle::toJson() const
|
|||
QJsonObject json;
|
||||
json.insert("type", "stroke");
|
||||
json.insert("enableEachSideIndependent", enableEachSideIndependent);
|
||||
json.insert("left", JsonUtil::toQJsonArray<GLfloat>(strokePair.first->encoded()));
|
||||
json.insert("right", JsonUtil::toQJsonArray<GLfloat>(strokePair.second->encoded()));
|
||||
json.insert("left", EncodeUtil::toBase64<GLfloat>(strokePair.first->encoded()));
|
||||
json.insert("right", EncodeUtil::toBase64<GLfloat>(strokePair.second->encoded()));
|
||||
return json;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
#pragma once
|
||||
#include <QByteArray>
|
||||
|
||||
namespace EncodeUtil
|
||||
{
|
||||
#include <vector>
|
||||
template<typename S>
|
||||
QString toBase64(const std::vector<S>& vec)
|
||||
{
|
||||
QByteArray ba;
|
||||
ba.resize(vec.size() * sizeof(S));
|
||||
memcpy_s(ba.data(), ba.size(), vec.data(), vec.size());
|
||||
return ba.toBase64();
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
std::vector<T> fromBase64(const QString& str)
|
||||
{
|
||||
QByteArray ba = QByteArray::fromBase64(str.toUtf8());
|
||||
std::vector<T> vec;
|
||||
vec.resize(ba.size() / sizeof(T));
|
||||
memcpy_s(vec.data(), vec.size() * sizeof(T), ba.data(), ba.size());
|
||||
return vec;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue