Compare commits
2 Commits
f109ed7d62
...
ce7f2ae8fa
Author | SHA1 | Date |
---|---|---|
ArgonarioD | ce7f2ae8fa | |
ArgonarioD | 6ce962b4c5 |
|
@ -197,6 +197,7 @@
|
||||||
<QtMoc Include="src\Editor\EditorWidgetComponent\LayerCreateWidget.h" />
|
<QtMoc Include="src\Editor\EditorWidgetComponent\LayerCreateWidget.h" />
|
||||||
<QtMoc Include="src\Editor\EditorWidgetComponent\LayerStyleDialog.h" />
|
<QtMoc Include="src\Editor\EditorWidgetComponent\LayerStyleDialog.h" />
|
||||||
<QtMoc Include="src\Editor\EditorWidgetComponent\ColorPicker.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\util\JsonUtil.hpp" />
|
||||||
<ClInclude Include="src\Editor\ElementManager.h" />
|
<ClInclude Include="src\Editor\ElementManager.h" />
|
||||||
<QtMoc Include="src\Editor\ElementPoolWidget.h" />
|
<QtMoc Include="src\Editor\ElementPoolWidget.h" />
|
||||||
|
|
|
@ -480,6 +480,9 @@
|
||||||
<ClInclude Include="src\Editor\util\JsonUtil.hpp">
|
<ClInclude Include="src\Editor\util\JsonUtil.hpp">
|
||||||
<Filter>Header Files\Editor\util</Filter>
|
<Filter>Header Files\Editor\util</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="src\Editor\util\EncodeUtil.hpp">
|
||||||
|
<Filter>Header Files\Editor\util</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<QtRcc Include="res\MainWindow.qrc">
|
<QtRcc Include="res\MainWindow.qrc">
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include "LayerStyle.h"
|
#include "LayerStyle.h"
|
||||||
#include "./EditorWidgetComponent/StrokeStyleWidget.h"
|
#include "./EditorWidgetComponent/StrokeStyleWidget.h"
|
||||||
#include "./util/JsonUtil.hpp"
|
#include "./util/EncodeUtil.hpp"
|
||||||
#include <qtmaterialcheckbox.h>
|
#include <qtmaterialcheckbox.h>
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QDialogButtonBox>
|
#include <QDialogButtonBox>
|
||||||
|
@ -124,8 +124,8 @@ QJsonObject StrokeElementLayerStyle::toJson() const
|
||||||
QJsonObject json;
|
QJsonObject json;
|
||||||
json.insert("type", "stroke");
|
json.insert("type", "stroke");
|
||||||
json.insert("enableEachSideIndependent", enableEachSideIndependent);
|
json.insert("enableEachSideIndependent", enableEachSideIndependent);
|
||||||
json.insert("left", JsonUtil::toQJsonArray<GLfloat>(strokePair.first->encoded()));
|
json.insert("left", EncodeUtil::toBase64<GLfloat>(strokePair.first->encoded()));
|
||||||
json.insert("right", JsonUtil::toQJsonArray<GLfloat>(strokePair.second->encoded()));
|
json.insert("right", EncodeUtil::toBase64<GLfloat>(strokePair.second->encoded()));
|
||||||
return json;
|
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