parent
293c1f3096
commit
b981056674
|
@ -18,10 +18,10 @@ LayerStyleDialog::LayerStyleDialog(
|
|||
|
||||
if (existedStyle)
|
||||
{
|
||||
this->layerStyle = existedStyle;
|
||||
this->modifyingStyle = std::make_unique<LayerStyle>(existedStyle->clonePtr());
|
||||
|
||||
this->styleContainer = nullptr;
|
||||
this->styleWidget = layerStyle->getInputWidget();
|
||||
this->styleWidget = modifyingStyle->getInputWidget();
|
||||
this->styleWidget->setParent(this);
|
||||
dialogLayout->addWidget(styleWidget);
|
||||
// do something
|
||||
|
@ -41,9 +41,9 @@ LayerStyleDialog::LayerStyleDialog(
|
|||
if (!excludeStyleNames.contains(pair.first))
|
||||
{
|
||||
typeSelector->addItem(pair.first);
|
||||
if (!this->layerStyle)
|
||||
if (!this->modifyingStyle)
|
||||
{
|
||||
this->layerStyle = pair.second();
|
||||
this->modifyingStyle = std::move(pair.second());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ LayerStyleDialog::LayerStyleDialog(
|
|||
this->styleContainer = new QGridLayout(this);
|
||||
dialogLayout->addLayout(styleContainer);
|
||||
|
||||
this->styleWidget = this->layerStyle->getInputWidget();
|
||||
this->styleWidget = this->modifyingStyle->getInputWidget();
|
||||
this->styleWidget->setParent(this);
|
||||
this->styleContainer->addWidget(styleWidget);
|
||||
connect(typeSelector, QOverload<int>::of(&QComboBox::currentIndexChanged),
|
||||
|
@ -67,6 +67,12 @@ LayerStyleDialog::LayerStyleDialog(
|
|||
dialogLayout->addWidget(buttonBox);
|
||||
}
|
||||
|
||||
void LayerStyleDialog::accept()
|
||||
{
|
||||
this->layerStyle = std::move(this->modifyingStyle);
|
||||
QDialog::accept();
|
||||
}
|
||||
|
||||
void LayerStyleDialog::onStyleTypeSelectorChanged(int index)
|
||||
{
|
||||
if (this->styleWidget)
|
||||
|
@ -75,8 +81,8 @@ void LayerStyleDialog::onStyleTypeSelectorChanged(int index)
|
|||
this->styleWidget->setParent(nullptr);
|
||||
delete styleWidget;
|
||||
}
|
||||
this->layerStyle = std::move(LayerStyle::types[index].second());
|
||||
this->styleWidget = this->layerStyle->getInputWidget();
|
||||
this->modifyingStyle = std::move(LayerStyle::types[index].second());
|
||||
this->styleWidget = this->modifyingStyle->getInputWidget();
|
||||
this->styleWidget->setParent(this);
|
||||
this->styleContainer->addWidget(styleWidget, 0, 0, 1, 1);
|
||||
}
|
||||
|
|
|
@ -9,6 +9,7 @@ class LayerStyleDialog : public QDialog
|
|||
private:
|
||||
QWidget* styleWidget;
|
||||
QGridLayout* styleContainer;
|
||||
std::unique_ptr<LayerStyle> modifyingStyle;
|
||||
public:
|
||||
LayerStyleDialog(
|
||||
QWidget* parent = nullptr,
|
||||
|
@ -17,5 +18,6 @@ public:
|
|||
std::shared_ptr<LayerStyle> layerStyle;
|
||||
private slots:
|
||||
void onStyleTypeSelectorChanged(int index);
|
||||
void accept() override;
|
||||
};
|
||||
|
||||
|
|
|
@ -5,14 +5,14 @@
|
|||
#include <QLabel>
|
||||
#include <QLineEdit>
|
||||
|
||||
const std::vector<std::pair<QString, std::function<std::shared_ptr<LayerStyle>()>>> LayerStyle::types = {
|
||||
const std::vector<std::pair<QString, std::function<std::unique_ptr<LayerStyle>()>>> LayerStyle::types = {
|
||||
{
|
||||
QStringLiteral("Ãè±ß"),
|
||||
[]() { return std::make_shared<StrokeElementLayerStyle>(); }
|
||||
[]() { return std::make_unique<StrokeElementLayerStyle>(); }
|
||||
},
|
||||
{
|
||||
QStringLiteral("Ìî³ä"),
|
||||
[]() { return std::make_shared<FillElementLayerStyle>(); }
|
||||
[]() { return std::make_unique<FillElementLayerStyle>(); }
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -45,7 +45,7 @@ QWidget* StrokeElementLayerStyle::getListDisplayWidget() const
|
|||
return w;
|
||||
}
|
||||
|
||||
StrokeElementLayerStyle::StrokeElementLayerStyle(StrokeElementLayerStyle& other)
|
||||
StrokeElementLayerStyle::StrokeElementLayerStyle(const StrokeElementLayerStyle& other)
|
||||
{
|
||||
materialStyles = std::vector<std::shared_ptr<Renderer::MaterialStyleStroke>>(other.materialStyles.size());
|
||||
for (size_t i = 0; i < other.materialStyles.size(); i++)
|
||||
|
@ -54,6 +54,11 @@ StrokeElementLayerStyle::StrokeElementLayerStyle(StrokeElementLayerStyle& other)
|
|||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<LayerStyle> StrokeElementLayerStyle::clonePtr() const
|
||||
{
|
||||
return std::make_shared<LayerStyle>(StrokeElementLayerStyle(*this));
|
||||
}
|
||||
|
||||
std::vector<Renderer::BaseStyle> FillElementLayerStyle::toBaseStyles() const
|
||||
{
|
||||
return std::vector<Renderer::BaseStyle>();
|
||||
|
@ -83,7 +88,7 @@ QWidget* FillElementLayerStyle::getListDisplayWidget() const
|
|||
return w;
|
||||
}
|
||||
|
||||
FillElementLayerStyle::FillElementLayerStyle(FillElementLayerStyle& other)
|
||||
FillElementLayerStyle::FillElementLayerStyle(const FillElementLayerStyle& other)
|
||||
{
|
||||
materialStyles = std::vector<std::shared_ptr<Renderer::MaterialStyleFill>>(other.materialStyles.size());
|
||||
for (size_t i = 0; i < other.materialStyles.size(); i++)
|
||||
|
@ -91,3 +96,8 @@ FillElementLayerStyle::FillElementLayerStyle(FillElementLayerStyle& other)
|
|||
materialStyles[i] = std::make_shared<Renderer::MaterialStyleFill>(*other.materialStyles[i]);
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<LayerStyle> FillElementLayerStyle::clonePtr() const
|
||||
{
|
||||
return std::make_shared<LayerStyle>(FillElementLayerStyle(*this));
|
||||
}
|
||||
|
|
|
@ -19,11 +19,12 @@
|
|||
class LayerStyle
|
||||
{
|
||||
public:
|
||||
const static std::vector<std::pair<QString, std::function<std::shared_ptr<LayerStyle>()>>> types;
|
||||
const static std::vector<std::pair<QString, std::function<std::unique_ptr<LayerStyle>()>>> types;
|
||||
virtual QString getStyleName() const = 0;
|
||||
virtual QWidget* getInputWidget() const = 0;
|
||||
virtual QWidget* getListDisplayWidget() const = 0;
|
||||
virtual ~LayerStyle() {};
|
||||
virtual std::shared_ptr<LayerStyle> clonePtr() const = 0;
|
||||
};
|
||||
|
||||
class StrokeElementLayerStyle : public Renderer::ElementStyle, public LayerStyle
|
||||
|
@ -34,9 +35,10 @@ public:
|
|||
QWidget* getInputWidget() const override;
|
||||
QWidget* getListDisplayWidget() const override;
|
||||
StrokeElementLayerStyle() = default;
|
||||
StrokeElementLayerStyle(StrokeElementLayerStyle& other);
|
||||
StrokeElementLayerStyle(const StrokeElementLayerStyle& other);
|
||||
~StrokeElementLayerStyle() = default;
|
||||
std::vector<std::shared_ptr<Renderer::MaterialStyleStroke>> materialStyles;
|
||||
std::shared_ptr<LayerStyle> clonePtr() const override;
|
||||
};
|
||||
|
||||
class FillElementLayerStyle : public Renderer::ElementStyle, public LayerStyle
|
||||
|
@ -47,7 +49,8 @@ public:
|
|||
QWidget* getInputWidget() const override;
|
||||
QWidget* getListDisplayWidget() const override;
|
||||
FillElementLayerStyle() = default;
|
||||
FillElementLayerStyle(FillElementLayerStyle& other);
|
||||
FillElementLayerStyle(const FillElementLayerStyle& other);
|
||||
~FillElementLayerStyle() = default;
|
||||
std::vector<std::shared_ptr<Renderer::MaterialStyleFill>> materialStyles;
|
||||
std::shared_ptr<LayerStyle> clonePtr() const override;
|
||||
};
|
|
@ -198,6 +198,7 @@ void InfoDisplayWidget::generateLayerForm()
|
|||
|
||||
if (dialog->layerStyle)
|
||||
{
|
||||
(*styleIterator) = dialog->layerStyle;
|
||||
emit requireRefreshPreview();
|
||||
emit requireSelfRefresh();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue