Compare commits

..

No commits in common. "15e2522591590cc378b7d7cce11ee6f8f161cf2f" and "fedb147dd30e7f643e15101d92475c3e32cebb38" have entirely different histories.

6 changed files with 55 additions and 113 deletions

View File

@ -16,19 +16,24 @@ const std::vector<std::pair<QString, std::function<std::shared_ptr<LayerStyle>()
}
};
//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>();
}
QString StrokeElementLayerStyle::getStyleName() const
{
return QStringLiteral("Ãè±ß");
}
QWidget* StrokeElementLayerStyle::getInputWidget() const
{
// TODO
QLabel* le = new QLabel;
le->setText(QStringLiteral("Ãè±ß"));
return le;
@ -50,14 +55,8 @@ std::vector<Renderer::BaseStyle> FillElementLayerStyle::toBaseStyles() const
return std::vector<Renderer::BaseStyle>();
}
QString FillElementLayerStyle::getStyleName() const
{
return QStringLiteral("Ìî³ä");
}
QWidget* FillElementLayerStyle::getInputWidget() const
{
// TODO
QLineEdit* name = new QLineEdit;
name->setText(QStringLiteral("Ìî³ä"));
return name;
@ -65,11 +64,5 @@ QWidget* FillElementLayerStyle::getInputWidget() const
QWidget* FillElementLayerStyle::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;
return nullptr;
}

View File

@ -20,7 +20,7 @@ class LayerStyle
{
public:
const static std::vector<std::pair<QString, std::function<std::shared_ptr<LayerStyle>()>>> types;
virtual QString getStyleName() const = 0;
//const static std::vector<std::pair<QString, std::function<LayerStyle*()>>> types;
virtual QWidget* getInputWidget() const = 0;
virtual QWidget* getListDisplayWidget() const = 0;
virtual ~LayerStyle() {};
@ -30,22 +30,20 @@ class StrokeElementLayerStyle : public Renderer::ElementStyle, public LayerStyle
{
public:
std::vector<Renderer::BaseStyle> toBaseStyles() const override;
QString getStyleName() const override;
QWidget* getInputWidget() const override;
QWidget* getListDisplayWidget() const override;
StrokeElementLayerStyle() = default;
~StrokeElementLayerStyle() = default;
std::vector<std::shared_ptr<Renderer::MaterialStroke>> materialStyles;
std::vector<std::unique_ptr<Renderer::MaterialStroke>> materialStyles;
};
class FillElementLayerStyle : public Renderer::ElementStyle, public LayerStyle
{
public:
std::vector<Renderer::BaseStyle> toBaseStyles() const override;
QString getStyleName() const override;
QWidget* getInputWidget() const override;
QWidget* getListDisplayWidget() const override;
FillElementLayerStyle() = default;
~FillElementLayerStyle() = default;
std::vector<std::shared_ptr<Renderer::MaterialFill>> materialStyles;
std::vector<std::unique_ptr<Renderer::MaterialFill>> materialStyles;
};

View File

@ -3,13 +3,8 @@
#include <QHBoxLayout>
#include <QGridLayout>
#include <QDebug>
#include <unordered_set>
LayerStyleDialog::LayerStyleDialog(
QWidget* parent,
std::shared_ptr<LayerStyle> existedStyle,
std::vector<std::shared_ptr<LayerStyle>>* excludeStyles
) : QDialog(parent)
LayerStyleDialog::LayerStyleDialog(QWidget* parent, std::shared_ptr<LayerStyle> existedStyle) : QDialog(parent)
{
QVBoxLayout* dialogLayout = new QVBoxLayout(this);
dialogLayout->setAlignment(Qt::AlignmentFlag::AlignHCenter);
@ -26,28 +21,12 @@ LayerStyleDialog::LayerStyleDialog(
}
else
{
std::unordered_set<QString> excludeStyleNames;
for(auto &style : *excludeStyles)
{
excludeStyleNames.insert(style->getStyleName());
}
this->layerStyle = LayerStyle::types[0].second();
QComboBox* typeSelector = new QComboBox(this);
for (auto& pair : LayerStyle::types)
{
if (!excludeStyleNames.contains(pair.first))
{
for (auto& pair : LayerStyle::types) {
typeSelector->addItem(pair.first);
if (!this->layerStyle)
{
this->layerStyle = pair.second();
}
}
}
if (typeSelector->count() > 0)
{
dialogLayout->addWidget(typeSelector);
this->styleContainer = new QGridLayout(this);
dialogLayout->addLayout(styleContainer);
@ -55,9 +34,7 @@ LayerStyleDialog::LayerStyleDialog(
this->styleWidget = this->layerStyle->getInputWidget();
this->styleWidget->setParent(this);
this->styleContainer->addWidget(styleWidget);
connect(typeSelector, QOverload<int>::of(&QComboBox::currentIndexChanged),
this, &LayerStyleDialog::onStyleTypeSelectorChanged);
}
connect(typeSelector, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &LayerStyleDialog::onStyleTypeSelectorChanged);
}
}

View File

@ -10,10 +10,7 @@ private:
QWidget* styleWidget;
QGridLayout* styleContainer;
public:
LayerStyleDialog(
QWidget* parent = nullptr,
std::shared_ptr<LayerStyle> existedStyle = nullptr,
std::vector<std::shared_ptr<LayerStyle>>* excludeStyles = nullptr);
LayerStyleDialog(QWidget* parent = nullptr, std::shared_ptr<LayerStyle> existedStyle = nullptr);
std::shared_ptr<LayerStyle> layerStyle;
private slots:
void onStyleTypeSelectorChanged(int index);

View File

@ -168,7 +168,7 @@ QTreeWidgetItem* LayerWrapper::getQTreeItem()
{
this->qTreeWidgetItem.setText(0, this->property.name);
this->qTreeWidgetItem.setData(0, Qt::UserRole, QVariant::fromValue(this));
return &this->qTreeWidgetItem;
return new QTreeWidgetItem(this->qTreeWidgetItem);
}
QTreeWidgetItem* FolderLayerWrapper::getQTreeItem()

View File

@ -3,11 +3,10 @@
#include <QLineEdit>
#include <QTextBlock>
#include <QListWidget>
#include <QPushButton>
#include <QDialog>
#include <QComboBox>
#include <QDialogButtonBox>
#include <qtmaterialraisedbutton.h>
#include <qtmaterialflatbutton.h>
void InfoDisplayWidget::setLayer(LayerWrapper *layer)
{
@ -89,27 +88,12 @@ void InfoDisplayWidget::generateLayerForm()
headerLabel->setText("样式列表");
headerLabel->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
//QtMaterialRaisedButton* addStyleButton = new QtMaterialRaisedButton("+", headerWidget);
QPushButton* addStyleButton = new QPushButton("+", headerWidget);
addStyleButton->setFixedSize(QSize(20, 20));
if (leafP->styles.size() >= LayerStyle::types.size())
{
addStyleButton->setDisabled(true);
}
else
{
connect(addStyleButton, &QPushButton::clicked, [&, leafP]() {
LayerStyleDialog* dialog = new LayerStyleDialog(nullptr, nullptr, &(leafP->styles));
connect(addStyleButton, &QPushButton::clicked, [this]() {
QDialog* dialog = new LayerStyleDialog(this);
dialog->exec();
if (dialog->layerStyle)
{
leafP->styles.push_back(dialog->layerStyle);
emit requireRefreshPreview();
emit requireSelfRefresh();
}
dialog->deleteLater();
});
}
headerLayout->addWidget(headerLabel);
headerLayout->addWidget(addStyleButton);
@ -169,60 +153,53 @@ void InfoDisplayWidget::generateLayerForm()
// for (int i = 0; i < styleNames.size(); i++)
// createStyleItem(i);
/*if (leafP->styles.empty())
if (leafP->styles.empty())
{
leafP->styles.push_back(std::shared_ptr<LayerStyle>(new StrokeElementLayerStyle()));
}*/
std::vector<std::shared_ptr<LayerStyle>>* styles = &(leafP->styles);
for (auto styleIterator = styles->begin(); styleIterator != styles->end(); styleIterator++)
}
for (auto& style : leafP->styles)
{
QListWidgetItem* item = new QListWidgetItem;
QWidget* w = new QWidget;
item->setSizeHint(QSize(50, 40));
QHBoxLayout* layout = new QHBoxLayout;
layout->setAlignment(Qt::AlignmentFlag::AlignRight);
//QtMaterialFlatButton* detailButton = new QtMaterialFlatButton(w);
//QtMaterialFlatButton* removeButton = new QtMaterialFlatButton(w);
QPushButton* detailButton = new QPushButton(w);
QPushButton* removeButton = new QPushButton(w);
QPushButton* deleteButton = new QPushButton(w);
detailButton->setText("...");
detailButton->setFixedSize(QSize(20, 20));
removeButton->setText("×");
removeButton->setFixedSize(QSize(20, 20));
deleteButton->setText("×");
deleteButton->setFixedSize(QSize(20, 20));
connect(detailButton, &QPushButton::clicked, this,
[=]()
{
LayerStyleDialog* dialog = new LayerStyleDialog(nullptr, *styleIterator);
dialog->exec();
connect(detailButton, &QPushButton::clicked, [this, &style]() {
LayerStyleDialog* dialog = new LayerStyleDialog(this, style);
/*dialog->setAttribute(Qt::WA_DeleteOnClose);
QVBoxLayout* layout = new QVBoxLayout(dialog);
if (dialog->layerStyle)
{
emit requireRefreshPreview();
emit requireSelfRefresh();
QComboBox* typeSelector = new QComboBox(dialog);
for (auto &pair : LayerStyle::types) {
typeSelector->addItem(pair.first);
}
dialog->deleteLater();
layout->addWidget(typeSelector);
QWidget* styleWidget = style->getInputWidget();
styleWidget->setParent(dialog);
layout->addWidget(styleWidget);*/
dialog->exec();
});
connect(removeButton, &QPushButton::clicked, this,
[this, styleIterator, styles]()
{
styles->erase(styleIterator);
emit requireRefreshPreview();
emit requireSelfRefresh();
});
QWidget* styleDisplayWidget = (*styleIterator)->getListDisplayWidget();
QWidget* styleDisplayWidget = style->getListDisplayWidget();
styleDisplayWidget->setParent(w);
styleDisplayWidget->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
layout->addWidget(styleDisplayWidget);
layout->addWidget(detailButton);
layout->addWidget(removeButton);
layout->addWidget(deleteButton);
w->setLayout(layout);
styleList->addItem(item);
styleList->setItemWidget(item, w);
//style->addListItem(styleList);
}
layout->addRow(styleList);
}