Compare commits

..

2 Commits

Author SHA1 Message Date
karlis 883fac3211 Merge branch 'main' of http://101.34.228.45:3000/BigC/ArchitectureColoredPainting 2023-02-14 21:34:12 +08:00
karlis 7d0ca047c1 添加了右侧栏的StyleList样例 2023-02-14 21:33:57 +08:00
1 changed files with 41 additions and 0 deletions

View File

@ -1,6 +1,9 @@
#include "InfoDisplayWidget.h"
#include <QLineEdit>
#include <QTextBlock>
#include <QListWidget>
#include <QPushButton>
void InfoDisplayWidget::setLayer(LayerWrapper *layer)
{
this->displayLayer = layer;
@ -72,9 +75,47 @@ void InfoDisplayWidget::generateLayerForm()
layout->addRow("scale-X:", scaleX);
layout->addRow("scale-Y:", scaleY);
layout->setRowWrapPolicy(QFormLayout::DontWrapRows);
bool styleEnabled = true;
if (styleEnabled) {
QListWidget* styleList = new QListWidget(this);
QListWidgetItem* item = new QListWidgetItem("样式列表");
item->setFlags(Qt::NoItemFlags);
styleList->addItem(item);
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* pushButton = new QPushButton(w);
QLabel* name = new QLabel(w);
name->setText(styleNames[index]);
pushButton->setText("×");
pushButton->setFixedSize(QSize(20, 20));
connect(pushButton, &QPushButton::clicked, [styleList,item,this]() {
styleList->removeItemWidget(item);
delete item;
// delete data in layer
emit requireRefreshPreview();
});
layout->addWidget(name);
layout->addWidget(pushButton);
w->setLayout(layout);
styleList->addItem(item);
styleList->setItemWidget(item, w);
};
for (int i = 0; i < styleNames.size(); i++)
createStyleItem(i);
layout->addRow(styleList);
}
}
this->setLayout(layout);
}
void InfoDisplayWidget::generateElementForm()
{
}