Compare commits
3 Commits
25eec60e5c
...
52734adda8
Author | SHA1 | Date |
---|---|---|
ArgonarioD | 52734adda8 | |
ArgonarioD | e7bce3f93e | |
ArgonarioD | 652fa483ba |
|
@ -105,6 +105,7 @@
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="src\Editor\EditorWidgetComponent\LayerCreateWidget.cpp" />
|
<ClCompile Include="src\Editor\EditorWidgetComponent\LayerCreateWidget.cpp" />
|
||||||
|
<ClCompile Include="src\Editor\LayerStyleDialog.cpp" />
|
||||||
<ClCompile Include="src\Editor\EditorWidget.cpp" />
|
<ClCompile Include="src\Editor\EditorWidget.cpp" />
|
||||||
<ClCompile Include="src\Editor\EditorWidgetItem.cpp" />
|
<ClCompile Include="src\Editor\EditorWidgetItem.cpp" />
|
||||||
<ClCompile Include="src\Editor\ElementManager.cpp" />
|
<ClCompile Include="src\Editor\ElementManager.cpp" />
|
||||||
|
@ -191,6 +192,7 @@
|
||||||
<QtMoc Include="src\MainWindow.h" />
|
<QtMoc Include="src\MainWindow.h" />
|
||||||
<QtMoc Include="src\Editor\EditorWidget.h" />
|
<QtMoc Include="src\Editor\EditorWidget.h" />
|
||||||
<QtMoc Include="src\Editor\EditorWidgetComponent\LayerCreateWidget.h" />
|
<QtMoc Include="src\Editor\EditorWidgetComponent\LayerCreateWidget.h" />
|
||||||
|
<QtMoc Include="src\Editor\LayerStyleDialog.h" />
|
||||||
<ClInclude Include="src\Editor\ElementManager.h" />
|
<ClInclude Include="src\Editor\ElementManager.h" />
|
||||||
<QtMoc Include="src\Editor\ElementPoolWidget.h" />
|
<QtMoc Include="src\Editor\ElementPoolWidget.h" />
|
||||||
<ClInclude Include="src\Editor\GraphicElement.h" />
|
<ClInclude Include="src\Editor\GraphicElement.h" />
|
||||||
|
|
|
@ -219,6 +219,9 @@
|
||||||
<ClCompile Include="src\Editor\EditorWidgetComponent\LayerCreateWidget.cpp">
|
<ClCompile Include="src\Editor\EditorWidgetComponent\LayerCreateWidget.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="src\Editor\LayerStyleDialog.cpp">
|
||||||
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<QtMoc Include="src\Renderer\RendererGLWidget.h">
|
<QtMoc Include="src\Renderer\RendererGLWidget.h">
|
||||||
|
@ -257,6 +260,9 @@
|
||||||
<QtMoc Include="src\Editor\EditorWidgetComponent\LayerCreateWidget.h">
|
<QtMoc Include="src\Editor\EditorWidgetComponent\LayerCreateWidget.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</QtMoc>
|
</QtMoc>
|
||||||
|
<QtMoc Include="src\Editor\LayerStyleDialog.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</QtMoc>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="..\data.json" />
|
<None Include="..\data.json" />
|
||||||
|
@ -390,9 +396,6 @@
|
||||||
<ClInclude Include="src\Editor\GraphicElement.h">
|
<ClInclude Include="src\Editor\GraphicElement.h">
|
||||||
<Filter>Header Files\Editor</Filter>
|
<Filter>Header Files\Editor</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="src\Editor\LayerStyle.h">
|
|
||||||
<Filter>Header Files\Editor</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="src\Editor\LayerManager.h">
|
<ClInclude Include="src\Editor\LayerManager.h">
|
||||||
<Filter>Header Files\Editor</Filter>
|
<Filter>Header Files\Editor</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
@ -453,6 +456,9 @@
|
||||||
<ClInclude Include="src\Editor\util\PaintingUtil.h">
|
<ClInclude Include="src\Editor\util\PaintingUtil.h">
|
||||||
<Filter>Header Files\Editor\util</Filter>
|
<Filter>Header Files\Editor\util</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="src\Editor\LayerStyle.h">
|
||||||
|
<Filter>Header Files\Editor</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<QtRcc Include="res\MainWindow.qrc">
|
<QtRcc Include="res\MainWindow.qrc">
|
||||||
|
|
|
@ -43,7 +43,7 @@ PixelPath GroupElement::getPaintObject() const
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO: apply styles and send back
|
//TODO: apply styles and send back
|
||||||
PixelPath SimpleElement::getPaintObject(std::vector<Renderer::ElementStyleStrokeDemo> styles) const {
|
PixelPath SimpleElement::getPaintObject(std::vector<std::shared_ptr<LayerStyle>>* styles) const {
|
||||||
PixelPath result;
|
PixelPath result;
|
||||||
Renderer::ElementStyleStrokeDemo demo(2);
|
Renderer::ElementStyleStrokeDemo demo(2);
|
||||||
auto [img, mov] = renderer->drawElement(painterPath, demo, 1.0);
|
auto [img, mov] = renderer->drawElement(painterPath, demo, 1.0);
|
||||||
|
@ -59,7 +59,7 @@ PixelPath SimpleElement::getPaintObject(std::vector<Renderer::ElementStyleStroke
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
PixelPath GroupElement::getPaintObject(std::vector<Renderer::ElementStyleStrokeDemo> styles) const {
|
PixelPath GroupElement::getPaintObject(std::vector<std::shared_ptr<LayerStyle>>* styles) const {
|
||||||
return getPaintObject();
|
return getPaintObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "LayerWrapper.h"
|
#include "LayerWrapper.h"
|
||||||
|
#include "LayerStyle.h"
|
||||||
#include <QJsonArray>
|
#include <QJsonArray>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
#include <QPainterPath>
|
#include <QPainterPath>
|
||||||
|
@ -26,7 +27,7 @@ public:
|
||||||
// TODO: ¸ÄΪBitmapPath
|
// TODO: ¸ÄΪBitmapPath
|
||||||
virtual QJsonObject toJson() const;
|
virtual QJsonObject toJson() const;
|
||||||
virtual PixelPath getPaintObject() const = 0;
|
virtual PixelPath getPaintObject() const = 0;
|
||||||
virtual PixelPath getPaintObject(std::vector<Renderer::ElementStyleStrokeDemo>) const = 0;
|
virtual PixelPath getPaintObject(std::vector<std::shared_ptr<LayerStyle>>*) const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class SimpleElement : public GraphicElement
|
class SimpleElement : public GraphicElement
|
||||||
|
@ -41,7 +42,7 @@ public:
|
||||||
SimpleElement(QJsonObject jsonSource);
|
SimpleElement(QJsonObject jsonSource);
|
||||||
~SimpleElement() = default;
|
~SimpleElement() = default;
|
||||||
PixelPath getPaintObject() const override;
|
PixelPath getPaintObject() const override;
|
||||||
PixelPath getPaintObject(std::vector<Renderer::ElementStyleStrokeDemo>) const override;
|
PixelPath getPaintObject(std::vector<std::shared_ptr<LayerStyle>>*) const override;
|
||||||
};
|
};
|
||||||
|
|
||||||
class GroupElement : public GraphicElement
|
class GroupElement : public GraphicElement
|
||||||
|
@ -54,7 +55,7 @@ public:
|
||||||
GroupElement(FolderLayerWrapper* mSourceLayer);
|
GroupElement(FolderLayerWrapper* mSourceLayer);
|
||||||
~GroupElement() = default;
|
~GroupElement() = default;
|
||||||
PixelPath getPaintObject() const override;
|
PixelPath getPaintObject() const override;
|
||||||
PixelPath getPaintObject(std::vector<Renderer::ElementStyleStrokeDemo>) const override;
|
PixelPath getPaintObject(std::vector<std::shared_ptr<LayerStyle>>*) const override;
|
||||||
void setSourceLayer(FolderLayerWrapper* sourceLayer);
|
void setSourceLayer(FolderLayerWrapper* sourceLayer);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,68 @@
|
||||||
#include "LayerStyle.h"
|
#include "LayerStyle.h"
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
#include <QDialogButtonBox>
|
||||||
|
#include <QPushButton>
|
||||||
|
#include <QLabel>
|
||||||
|
#include <QLineEdit>
|
||||||
|
|
||||||
std::vector<Renderer::BaseStyle> StrokeElementStyle::toBaseStyles() const
|
const std::vector<std::pair<QString, std::function<std::shared_ptr<LayerStyle>()>>> LayerStyle::types = {
|
||||||
|
{
|
||||||
|
QStringLiteral("Ãè±ß"),
|
||||||
|
[]() { return std::make_shared<StrokeElementLayerStyle>(); }
|
||||||
|
},
|
||||||
|
{
|
||||||
|
QStringLiteral("Ìî³ä"),
|
||||||
|
[]() { return std::make_shared<FillElementLayerStyle>(); }
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
//const std::vector<std::pair<QString, std::function<LayerStyle*()>>> LayerStyle::types = {
|
||||||
|
// {
|
||||||
|
// QStringLiteral("Ãè±ß"),
|
||||||
|
// []() { return new StrokeElementLayerStyle; }
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// QStringLiteral("Ìî³ä"),
|
||||||
|
// []() { return new FillElementLayerStyle; }
|
||||||
|
// }
|
||||||
|
//};
|
||||||
|
|
||||||
|
std::vector<Renderer::BaseStyle> StrokeElementLayerStyle::toBaseStyles() const
|
||||||
{
|
{
|
||||||
return std::vector<Renderer::BaseStyle>();
|
return std::vector<Renderer::BaseStyle>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QWidget* StrokeElementLayerStyle::getInputWidget() const
|
||||||
|
{
|
||||||
|
QLabel* le = new QLabel;
|
||||||
|
le->setText(QStringLiteral("Ãè±ß"));
|
||||||
|
return le;
|
||||||
|
}
|
||||||
|
|
||||||
|
QWidget* StrokeElementLayerStyle::getListDisplayWidget() const
|
||||||
|
{
|
||||||
|
QWidget* w = new QWidget;
|
||||||
|
QLabel* name = new QLabel(w);
|
||||||
|
name->setText(QStringLiteral("Ãè±ß"));
|
||||||
|
QHBoxLayout* layout = new QHBoxLayout(w);
|
||||||
|
layout->setMargin(0);
|
||||||
|
layout->addWidget(name);
|
||||||
|
return w;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<Renderer::BaseStyle> FillElementLayerStyle::toBaseStyles() const
|
||||||
|
{
|
||||||
|
return std::vector<Renderer::BaseStyle>();
|
||||||
|
}
|
||||||
|
|
||||||
|
QWidget* FillElementLayerStyle::getInputWidget() const
|
||||||
|
{
|
||||||
|
QLineEdit* name = new QLineEdit;
|
||||||
|
name->setText(QStringLiteral("Ìî³ä"));
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
QWidget* FillElementLayerStyle::getListDisplayWidget() const
|
||||||
|
{
|
||||||
|
return nullptr;
|
||||||
|
}
|
|
@ -1,24 +1,49 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include <map>
|
||||||
|
#include <functional>
|
||||||
|
#include <utility>
|
||||||
|
#include <QWidget>
|
||||||
|
#include <QObject>
|
||||||
|
#include <QListWidget>
|
||||||
#include "../Renderer/Painting/ElementStyle.h"
|
#include "../Renderer/Painting/ElementStyle.h"
|
||||||
#include "../Renderer/Painting/MaterialStyleStroke.h"
|
#include "../Renderer/Painting/MaterialStyleStroke.h"
|
||||||
|
#include "../Renderer/Painting/MaterialStyleFill.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 在进行Style的添加时,首先创建空对象,然后直接调用getInputWidget()方法
|
||||||
|
* 在进行Style的修改时,直接调用getInputWidget()方法
|
||||||
|
*
|
||||||
|
* 对于LayerStyle的实现类,应该同时实现ElementStyle,并将相同种类的(如描边或填充)的style整合成一个类,
|
||||||
|
* 对于相同的类,一个图层应该只拥有一个
|
||||||
|
*/
|
||||||
class LayerStyle
|
class LayerStyle
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual void apply() = 0;
|
const static std::vector<std::pair<QString, std::function<std::shared_ptr<LayerStyle>()>>> types;
|
||||||
|
//const static std::vector<std::pair<QString, std::function<LayerStyle*()>>> types;
|
||||||
|
virtual QWidget* getInputWidget() const = 0;
|
||||||
|
virtual QWidget* getListDisplayWidget() const = 0;
|
||||||
|
virtual ~LayerStyle() {};
|
||||||
};
|
};
|
||||||
|
|
||||||
struct EditorStrokeMaterialStyle
|
class StrokeElementLayerStyle : public Renderer::ElementStyle, public LayerStyle
|
||||||
{
|
|
||||||
float applyWidth;
|
|
||||||
Renderer::StrokeType strokeType;
|
|
||||||
Renderer::StrokeEndType endType;
|
|
||||||
std::shared_ptr<Renderer::MaterialStroke> materialStroke;
|
|
||||||
};
|
|
||||||
|
|
||||||
class StrokeElementStyle : Renderer::ElementStyle
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual std::vector<Renderer::BaseStyle> toBaseStyles() const override;
|
std::vector<Renderer::BaseStyle> toBaseStyles() const override;
|
||||||
std::vector<EditorStrokeMaterialStyle> materialStyles;
|
QWidget* getInputWidget() const override;
|
||||||
|
QWidget* getListDisplayWidget() const override;
|
||||||
|
StrokeElementLayerStyle() = default;
|
||||||
|
~StrokeElementLayerStyle() = default;
|
||||||
|
std::vector<std::unique_ptr<Renderer::MaterialStroke>> materialStyles;
|
||||||
|
};
|
||||||
|
|
||||||
|
class FillElementLayerStyle : public Renderer::ElementStyle, public LayerStyle
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
std::vector<Renderer::BaseStyle> toBaseStyles() const override;
|
||||||
|
QWidget* getInputWidget() const override;
|
||||||
|
QWidget* getListDisplayWidget() const override;
|
||||||
|
FillElementLayerStyle() = default;
|
||||||
|
~FillElementLayerStyle() = default;
|
||||||
|
std::vector<std::unique_ptr<Renderer::MaterialFill>> materialStyles;
|
||||||
};
|
};
|
|
@ -0,0 +1,53 @@
|
||||||
|
#include "LayerStyleDialog.h"
|
||||||
|
#include <QComboBox>
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
#include <QGridLayout>
|
||||||
|
#include <QDebug>
|
||||||
|
|
||||||
|
LayerStyleDialog::LayerStyleDialog(QWidget* parent, std::shared_ptr<LayerStyle> existedStyle) : QDialog(parent)
|
||||||
|
{
|
||||||
|
QVBoxLayout* dialogLayout = new QVBoxLayout(this);
|
||||||
|
dialogLayout->setAlignment(Qt::AlignmentFlag::AlignHCenter);
|
||||||
|
this->setLayout(dialogLayout);
|
||||||
|
|
||||||
|
if (existedStyle)
|
||||||
|
{
|
||||||
|
this->layerStyle = existedStyle;
|
||||||
|
|
||||||
|
QWidget* styleWidget = layerStyle->getInputWidget();
|
||||||
|
styleWidget->setParent(this);
|
||||||
|
dialogLayout->addWidget(styleWidget);
|
||||||
|
// do something
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this->layerStyle = LayerStyle::types[0].second();
|
||||||
|
|
||||||
|
QComboBox* typeSelector = new QComboBox(this);
|
||||||
|
for (auto& pair : LayerStyle::types) {
|
||||||
|
typeSelector->addItem(pair.first);
|
||||||
|
}
|
||||||
|
dialogLayout->addWidget(typeSelector);
|
||||||
|
this->styleContainer = new QGridLayout(this);
|
||||||
|
dialogLayout->addLayout(styleContainer);
|
||||||
|
|
||||||
|
this->styleWidget = this->layerStyle->getInputWidget();
|
||||||
|
this->styleWidget->setParent(this);
|
||||||
|
this->styleContainer->addWidget(styleWidget);
|
||||||
|
connect(typeSelector, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &LayerStyleDialog::onStyleTypeSelectorChanged);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void LayerStyleDialog::onStyleTypeSelectorChanged(int index)
|
||||||
|
{
|
||||||
|
if (this->styleWidget)
|
||||||
|
{
|
||||||
|
this->styleContainer->removeWidget(this->styleWidget);
|
||||||
|
this->styleWidget->setParent(nullptr);
|
||||||
|
delete styleWidget;
|
||||||
|
}
|
||||||
|
this->layerStyle = std::move(LayerStyle::types[index].second());
|
||||||
|
this->styleWidget = this->layerStyle->getInputWidget();
|
||||||
|
this->styleWidget->setParent(this);
|
||||||
|
this->styleContainer->addWidget(styleWidget, 0, 0, 1, 1);
|
||||||
|
}
|
|
@ -0,0 +1,18 @@
|
||||||
|
#pragma once
|
||||||
|
#include "LayerStyle.h"
|
||||||
|
#include <QDialog>
|
||||||
|
#include <QGridLayout>
|
||||||
|
|
||||||
|
class LayerStyleDialog : public QDialog
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
private:
|
||||||
|
QWidget* styleWidget;
|
||||||
|
QGridLayout* styleContainer;
|
||||||
|
public:
|
||||||
|
LayerStyleDialog(QWidget* parent = nullptr, std::shared_ptr<LayerStyle> existedStyle = nullptr);
|
||||||
|
std::shared_ptr<LayerStyle> layerStyle;
|
||||||
|
private slots:
|
||||||
|
void onStyleTypeSelectorChanged(int index);
|
||||||
|
};
|
||||||
|
|
|
@ -106,7 +106,7 @@ void LeafLayerWrapper::refresh()
|
||||||
cache.clear();
|
cache.clear();
|
||||||
if (wrappedElement != nullptr)
|
if (wrappedElement != nullptr)
|
||||||
{
|
{
|
||||||
cache.addPath(wrappedElement->getPaintObject(this->styles));
|
cache.addPath(wrappedElement->getPaintObject(&(this->styles)));
|
||||||
}
|
}
|
||||||
LayerWrapper::refresh();
|
LayerWrapper::refresh();
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,7 +90,8 @@ class LeafLayerWrapper : public LayerWrapper
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GraphicElement *wrappedElement;
|
GraphicElement *wrappedElement;
|
||||||
const vector<Renderer::ElementStyleStrokeDemo> styles;
|
//const vector<Renderer::ElementStyleStrokeDemo> styles;
|
||||||
|
vector<std::shared_ptr<LayerStyle>> styles;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
~LeafLayerWrapper() = default;
|
~LeafLayerWrapper() = default;
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
#include "InfoDisplayWidget.h"
|
#include "InfoDisplayWidget.h"
|
||||||
|
#include "LayerStyleDialog.h"
|
||||||
#include <QLineEdit>
|
#include <QLineEdit>
|
||||||
#include <QTextBlock>
|
#include <QTextBlock>
|
||||||
#include <QListWidget>
|
#include <QListWidget>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
#include <QComboBox>
|
||||||
#include <QDialogButtonBox>
|
#include <QDialogButtonBox>
|
||||||
|
|
||||||
void InfoDisplayWidget::setLayer(LayerWrapper *layer)
|
void InfoDisplayWidget::setLayer(LayerWrapper *layer)
|
||||||
|
@ -74,63 +76,131 @@ void InfoDisplayWidget::generateLayerForm()
|
||||||
layout->addRow("scale-Y:", scaleY);
|
layout->addRow("scale-Y:", scaleY);
|
||||||
layout->setRowWrapPolicy(QFormLayout::DontWrapRows);
|
layout->setRowWrapPolicy(QFormLayout::DontWrapRows);
|
||||||
|
|
||||||
bool styleEnabled = true;
|
LeafLayerWrapper* leafP = dynamic_cast<LeafLayerWrapper*>(this->displayLayer);
|
||||||
if (styleEnabled) {
|
if (leafP) {
|
||||||
QListWidget* styleList = new QListWidget(this);
|
QListWidget* styleList = new QListWidget(this);
|
||||||
QListWidgetItem* item = new QListWidgetItem("样式列表");
|
|
||||||
item->setFlags(Qt::NoItemFlags);
|
QListWidgetItem* header = new QListWidgetItem;
|
||||||
styleList->addItem(item);
|
QWidget* headerWidget = new QWidget(styleList);
|
||||||
static vector<QString> styleNames = { "样例1", "样例2", "样例3" , "样例4" , "样例5" , "样例6" , "样例7" , "样例8" };
|
QHBoxLayout* headerLayout = new QHBoxLayout;
|
||||||
auto createStyleItem = [this, styleList](int index) {
|
|
||||||
|
QLabel* headerLabel = new QLabel(headerWidget);
|
||||||
|
headerLabel->setText("样式列表");
|
||||||
|
headerLabel->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
|
||||||
|
|
||||||
|
QPushButton* addStyleButton = new QPushButton("+", headerWidget);
|
||||||
|
addStyleButton->setFixedSize(QSize(20, 20));
|
||||||
|
connect(addStyleButton, &QPushButton::clicked, [this]() {
|
||||||
|
QDialog* dialog = new LayerStyleDialog(this);
|
||||||
|
dialog->exec();
|
||||||
|
});
|
||||||
|
|
||||||
|
headerLayout->addWidget(headerLabel);
|
||||||
|
headerLayout->addWidget(addStyleButton);
|
||||||
|
headerLayout->setContentsMargins(5, 0, 5, 0);
|
||||||
|
headerWidget->setLayout(headerLayout);
|
||||||
|
|
||||||
|
header->setFlags(Qt::NoItemFlags);
|
||||||
|
styleList->addItem(header);
|
||||||
|
styleList->setItemWidget(header, headerWidget);
|
||||||
|
//static vector<QString> styleNames = { "样例1", "样例2", "样例3" };
|
||||||
|
// auto createStyleItem = [this, styleList](int index) {
|
||||||
|
// QListWidgetItem* item = new QListWidgetItem;
|
||||||
|
// QWidget* w = new QWidget;
|
||||||
|
// item->setSizeHint(QSize(50, 40));
|
||||||
|
// QHBoxLayout* layout = new QHBoxLayout;
|
||||||
|
// QPushButton* deleteButton = new QPushButton(w);
|
||||||
|
// QPushButton* detailButton = new QPushButton(w);
|
||||||
|
// QLabel* name = new QLabel(w);
|
||||||
|
// name->setText(styleNames[index]);
|
||||||
|
// detailButton->setText("...");
|
||||||
|
// detailButton->setFixedSize(QSize(20, 20));
|
||||||
|
// deleteButton->setText("×");
|
||||||
|
// deleteButton->setFixedSize(QSize(20, 20));
|
||||||
|
// connect(detailButton, &QPushButton::clicked, [styleList, item, this, index]() {
|
||||||
|
// QDialog dlg(this);
|
||||||
|
// dlg.setWindowTitle("样式详情");
|
||||||
|
// dlg.resize(400, 200);
|
||||||
|
// QGridLayout *contentLayout = new QGridLayout(&dlg);
|
||||||
|
// QLineEdit* name = new QLineEdit(styleNames[index], &dlg);
|
||||||
|
// auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Save | QDialogButtonBox::Cancel);
|
||||||
|
// contentLayout->addWidget(buttonBox);
|
||||||
|
// connect(buttonBox, &QDialogButtonBox::accepted, &dlg, &QDialog::accept);
|
||||||
|
// connect(buttonBox, &QDialogButtonBox::rejected, &dlg, &QDialog::reject);
|
||||||
|
// bool updateStyle = dlg.exec();
|
||||||
|
// if (updateStyle) {
|
||||||
|
// styleNames[index] = name->text();
|
||||||
|
// qDebug() << name->text();
|
||||||
|
// // 在此处修改新样式信息至内存
|
||||||
|
// emit requireRefreshPreview();
|
||||||
|
// emit requireSelfRefresh();
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// connect(deleteButton, &QPushButton::clicked, [styleList,item,this]() {
|
||||||
|
// styleList->removeItemWidget(item);
|
||||||
|
// delete item;
|
||||||
|
// // 删除layer对应样式
|
||||||
|
// emit requireRefreshPreview();
|
||||||
|
// emit requireSelfRefresh();
|
||||||
|
// });
|
||||||
|
// layout->addWidget(name);
|
||||||
|
// layout->addWidget(detailButton);
|
||||||
|
// layout->addWidget(deleteButton);
|
||||||
|
// w->setLayout(layout);
|
||||||
|
// styleList->addItem(item);
|
||||||
|
// styleList->setItemWidget(item, w);
|
||||||
|
// };
|
||||||
|
// for (int i = 0; i < styleNames.size(); i++)
|
||||||
|
// createStyleItem(i);
|
||||||
|
|
||||||
|
if (leafP->styles.empty())
|
||||||
|
{
|
||||||
|
leafP->styles.push_back(std::shared_ptr<LayerStyle>(new StrokeElementLayerStyle()));
|
||||||
|
}
|
||||||
|
for (auto& style : leafP->styles)
|
||||||
|
{
|
||||||
QListWidgetItem* item = new QListWidgetItem;
|
QListWidgetItem* item = new QListWidgetItem;
|
||||||
QWidget* w = new QWidget;
|
QWidget* w = new QWidget;
|
||||||
item->setSizeHint(QSize(50, 40));
|
item->setSizeHint(QSize(50, 40));
|
||||||
QHBoxLayout* layout = new QHBoxLayout;
|
QHBoxLayout* layout = new QHBoxLayout;
|
||||||
QPushButton* deleteButton = new QPushButton(w);
|
layout->setAlignment(Qt::AlignmentFlag::AlignRight);
|
||||||
QPushButton* detailButton = new QPushButton(w);
|
QPushButton* detailButton = new QPushButton(w);
|
||||||
QLabel* name = new QLabel(w);
|
QPushButton* deleteButton = new QPushButton(w);
|
||||||
name->setText(styleNames[index]);
|
|
||||||
detailButton->setText("...");
|
detailButton->setText("...");
|
||||||
detailButton->setFixedSize(QSize(20, 20));
|
detailButton->setFixedSize(QSize(20, 20));
|
||||||
deleteButton->setText("×");
|
deleteButton->setText("×");
|
||||||
deleteButton->setFixedSize(QSize(20, 20));
|
deleteButton->setFixedSize(QSize(20, 20));
|
||||||
connect(detailButton, &QPushButton::clicked, [styleList, item, this, index]() {
|
|
||||||
QDialog dlg(this);
|
connect(detailButton, &QPushButton::clicked, [this, &style]() {
|
||||||
dlg.setWindowTitle("样式详情");
|
LayerStyleDialog* dialog = new LayerStyleDialog(this, style);
|
||||||
dlg.resize(400, 200);
|
/*dialog->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
QGridLayout *contentLayout = new QGridLayout(&dlg);
|
QVBoxLayout* layout = new QVBoxLayout(dialog);
|
||||||
QLineEdit* name = new QLineEdit(styleNames[index], &dlg);
|
|
||||||
auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Save | QDialogButtonBox::Cancel);
|
QComboBox* typeSelector = new QComboBox(dialog);
|
||||||
contentLayout->addWidget(buttonBox);
|
for (auto &pair : LayerStyle::types) {
|
||||||
connect(buttonBox, &QDialogButtonBox::accepted, &dlg, &QDialog::accept);
|
typeSelector->addItem(pair.first);
|
||||||
connect(buttonBox, &QDialogButtonBox::rejected, &dlg, &QDialog::reject);
|
|
||||||
bool updateStyle = dlg.exec();
|
|
||||||
if (updateStyle) {
|
|
||||||
styleNames[index] = name->text();
|
|
||||||
qDebug() << name->text();
|
|
||||||
// 在此处修改新样式信息至内存
|
|
||||||
emit requireRefreshPreview();
|
|
||||||
emit requireSelfRefresh();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
layout->addWidget(typeSelector);
|
||||||
|
QWidget* styleWidget = style->getInputWidget();
|
||||||
|
styleWidget->setParent(dialog);
|
||||||
|
layout->addWidget(styleWidget);*/
|
||||||
|
dialog->exec();
|
||||||
});
|
});
|
||||||
connect(deleteButton, &QPushButton::clicked, [styleList,item,this]() {
|
|
||||||
styleList->removeItemWidget(item);
|
QWidget* styleDisplayWidget = style->getListDisplayWidget();
|
||||||
delete item;
|
styleDisplayWidget->setParent(w);
|
||||||
// 删除layer对应样式
|
styleDisplayWidget->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
|
||||||
emit requireRefreshPreview();
|
|
||||||
emit requireSelfRefresh();
|
layout->addWidget(styleDisplayWidget);
|
||||||
});
|
|
||||||
layout->addWidget(name);
|
|
||||||
layout->addWidget(detailButton);
|
layout->addWidget(detailButton);
|
||||||
layout->addWidget(deleteButton);
|
layout->addWidget(deleteButton);
|
||||||
w->setLayout(layout);
|
w->setLayout(layout);
|
||||||
|
|
||||||
styleList->addItem(item);
|
styleList->addItem(item);
|
||||||
styleList->setItemWidget(item, w);
|
styleList->setItemWidget(item, w);
|
||||||
};
|
//style->addListItem(styleList);
|
||||||
for (int i = 0; i < styleNames.size(); i++)
|
}
|
||||||
createStyleItem(i);
|
|
||||||
|
|
||||||
|
|
||||||
layout->addRow(styleList);
|
layout->addRow(styleList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue