style dialog

TaoZhang-Branch
karlis 2023-02-20 13:48:39 +08:00
parent 41080b1c1e
commit fef7668351
1 changed files with 24 additions and 6 deletions

View File

@ -3,6 +3,8 @@
#include <QTextBlock>
#include <QListWidget>
#include <QPushButton>
#include <QDialog>
#include <QDialogButtonBox>
void InfoDisplayWidget::setLayer(LayerWrapper *layer)
{
@ -88,19 +90,35 @@ void InfoDisplayWidget::generateLayerForm()
QWidget* w = new QWidget;
item->setSizeHint(QSize(50, 40));
QHBoxLayout* layout = new QHBoxLayout;
QPushButton* pushButton = new QPushButton(w);
QPushButton* deleteButton = new QPushButton(w);
QPushButton* detailButton = 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]() {
detailButton->setText("...");
detailButton->setFixedSize(QSize(20, 20));
deleteButton->setText("×");
deleteButton->setFixedSize(QSize(20, 20));
connect(detailButton, &QPushButton::clicked, [styleList, item, this]() {
QDialog dlg(this);
dlg.setWindowTitle("样式详情");
dlg.resize(400, 200);
auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Save | QDialogButtonBox::Cancel, &dlg);
connect(buttonBox, &QDialogButtonBox::accepted, &dlg, &QDialog::accept);
connect(buttonBox, &QDialogButtonBox::rejected, &dlg, &QDialog::reject);
bool updateStyle = dlg.exec();
if (updateStyle) {
// 在此处修改新样式信息至内存
}
});
connect(deleteButton, &QPushButton::clicked, [styleList,item,this]() {
styleList->removeItemWidget(item);
delete item;
// delete data in layer
// 删除layer对应样式
emit requireRefreshPreview();
});
layout->addWidget(name);
layout->addWidget(pushButton);
layout->addWidget(detailButton);
layout->addWidget(deleteButton);
w->setLayout(layout);
styleList->addItem(item);
styleList->setItemWidget(item, w);