添加InfoDisplay窗口自我刷新

TaoZhang-Branch
karlis 2023-02-20 20:09:00 +08:00
parent fef7668351
commit 21a973babd
3 changed files with 25 additions and 2 deletions

View File

@ -14,6 +14,7 @@ EditorWidget::EditorWidget(QWidget *parent) : QWidget(parent)
connect(treeWidget, &LayerTreeWidget::displayLayerChange, this, &EditorWidget::onLayerChange); connect(treeWidget, &LayerTreeWidget::displayLayerChange, this, &EditorWidget::onLayerChange);
connect(layerInfoDisplayWidget, &InfoDisplayWidget::requireRefreshPreview, this, connect(layerInfoDisplayWidget, &InfoDisplayWidget::requireRefreshPreview, this,
&EditorWidget::triggerRefreshPreview); &EditorWidget::triggerRefreshPreview);
connect(layerInfoDisplayWidget, &InfoDisplayWidget::requireSelfRefresh, layerInfoDisplayWidget, &InfoDisplayWidget::triggerSelfRefresh);
// &EditorWidget::triggerRefreshPreview); // &EditorWidget::triggerRefreshPreview);
// test // test
QFile settingFile; QFile settingFile;

View File

@ -98,16 +98,23 @@ void InfoDisplayWidget::generateLayerForm()
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]() { connect(detailButton, &QPushButton::clicked, [styleList, item, this, index]() {
QDialog dlg(this); QDialog dlg(this);
dlg.setWindowTitle("样式详情"); dlg.setWindowTitle("样式详情");
dlg.resize(400, 200); dlg.resize(400, 200);
auto buttonBox = new QDialogButtonBox(QDialogButtonBox::Save | QDialogButtonBox::Cancel, &dlg); 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::accepted, &dlg, &QDialog::accept);
connect(buttonBox, &QDialogButtonBox::rejected, &dlg, &QDialog::reject); connect(buttonBox, &QDialogButtonBox::rejected, &dlg, &QDialog::reject);
bool updateStyle = dlg.exec(); bool updateStyle = dlg.exec();
if (updateStyle) { if (updateStyle) {
styleNames[index] = name->text();
qDebug() << name->text();
// 在此处修改新样式信息至内存 // 在此处修改新样式信息至内存
emit requireRefreshPreview();
emit requireSelfRefresh();
} }
}); });
connect(deleteButton, &QPushButton::clicked, [styleList,item,this]() { connect(deleteButton, &QPushButton::clicked, [styleList,item,this]() {
@ -115,6 +122,7 @@ void InfoDisplayWidget::generateLayerForm()
delete item; delete item;
// 删除layer对应样式 // 删除layer对应样式
emit requireRefreshPreview(); emit requireRefreshPreview();
emit requireSelfRefresh();
}); });
layout->addWidget(name); layout->addWidget(name);
layout->addWidget(detailButton); layout->addWidget(detailButton);
@ -137,3 +145,11 @@ void InfoDisplayWidget::generateLayerForm()
void InfoDisplayWidget::generateElementForm() void InfoDisplayWidget::generateElementForm()
{ {
} }
void InfoDisplayWidget::triggerSelfRefresh()
{
if (this->displayLayer != nullptr)
this->generateLayerForm();
else
this->generateElementForm();
}

View File

@ -18,6 +18,12 @@ class InfoDisplayWidget : public QWidget
void generateLayerForm(); void generateLayerForm();
void generateElementForm(); void generateElementForm();
public slots:
void triggerSelfRefresh();
signals: signals:
void requireRefreshPreview(); void requireRefreshPreview();
void requireSelfRefresh();
}; };