重写刷新信号及逻辑
parent
8bf6835c23
commit
b3bbf6c1be
|
@ -19,6 +19,15 @@ EditorWidgetItem::EditorWidgetItem(QString filePath,QWidget *parent) : QWidget(p
|
|||
elementInfoDisplayWidget->enableEdit();
|
||||
qDebug() << layerInfoDisplayWidget;
|
||||
qDebug() << elementInfoDisplayWidget;
|
||||
auto centralRefresh = [this]() {
|
||||
layerInfoDisplayWidget->refresh();
|
||||
elementInfoDisplayWidget->refresh();
|
||||
treeWidget->refresh();
|
||||
previewWindow->refresh();
|
||||
};
|
||||
connect(layerInfoDisplayWidget, &InfoDisplayWidget::triggerCentralRefresh, centralRefresh);
|
||||
connect(elementInfoDisplayWidget, &ElementPoolWidget::triggerCentralRefresh, centralRefresh);
|
||||
connect(treeWidget, &LayerTreeWidget::triggerCentralRefresh, centralRefresh);
|
||||
connect(editorSettingWidget, &EditorSettingWidget::backgroundColorChanged, this, &EditorWidgetItem::handleBackgroundColorChange);
|
||||
connect(editorSettingWidget, &EditorSettingWidget::projectNameChanged, this, &EditorWidgetItem::handleProjectNameChange);
|
||||
connect(previewWindow, &PreviewWindow::refreshElementPreviewByIndex, elementInfoDisplayWidget, &ElementPoolWidget::refreshPictureByIndex);
|
||||
|
|
|
@ -67,7 +67,6 @@ void ElementPoolWidget::setElementManager(ElementManager* element)
|
|||
|
||||
void ElementPoolWidget::refresh() {
|
||||
this->setElementList(this->elementManager->elements);
|
||||
emit refreshLayerTree();
|
||||
// update();
|
||||
}
|
||||
|
||||
|
@ -113,12 +112,12 @@ void ElementPoolWidget::popMenu(const QPoint& pos)
|
|||
if (bOk && !sName.isEmpty())
|
||||
{
|
||||
currentElement->name = sName;
|
||||
refresh();
|
||||
emit triggerCentralRefresh();
|
||||
}
|
||||
});
|
||||
menu->addAction(QString::fromLocal8Bit("ɾ³ý"), this, [this, currentElement]() {
|
||||
this->elementManager->removeElement(currentElement);
|
||||
refresh();
|
||||
emit triggerCentralRefresh();
|
||||
});
|
||||
menu->actions().last()->setDisabled(currentElement->referencedCount > 0);
|
||||
}
|
||||
|
@ -130,7 +129,7 @@ void ElementPoolWidget::popMenu(const QPoint& pos)
|
|||
QString fileName = fileInfo.fileName();
|
||||
qDebug() << fileName << " " << filePath;
|
||||
this->elementManager->createSimpleElement(fileName, filePath);
|
||||
refresh();
|
||||
emit triggerCentralRefresh();
|
||||
});
|
||||
}
|
||||
menu->popup(mapToGlobal(pos));
|
||||
|
|
|
@ -26,6 +26,7 @@ public:
|
|||
signals:
|
||||
void elementSelected(GraphicElement* element);
|
||||
void refreshLayerTree();
|
||||
void triggerCentralRefresh();
|
||||
|
||||
public slots:
|
||||
int pictureItemClicked(QListWidgetItem* item);
|
||||
|
|
|
@ -45,32 +45,27 @@ void InfoDisplayWidget::generateLayerForm()
|
|||
rotation->setValidator(new QIntValidator(-10000, 10000, this));
|
||||
connect(rotation, &QLineEdit::textChanged, [=](QString content) {
|
||||
this->displayLayer->property.rotation = content.toDouble();
|
||||
emit requireRefreshElementWidget();
|
||||
emit requireRefreshPreview();
|
||||
emit triggerCentralRefresh();
|
||||
});
|
||||
offsetX->setValidator(new QIntValidator(-10000, 10000, this));
|
||||
connect(offsetX, &QLineEdit::textChanged, [=](QString content) {
|
||||
this->displayLayer->property.offset = {content.toDouble(), this->displayLayer->property.offset.y()};
|
||||
emit requireRefreshElementWidget();
|
||||
emit requireRefreshPreview();
|
||||
emit triggerCentralRefresh();
|
||||
});
|
||||
offsetY->setValidator(new QIntValidator(-10000, 10000, this));
|
||||
connect(offsetY, &QLineEdit::textChanged, [=](QString content) {
|
||||
this->displayLayer->property.offset = {this->displayLayer->property.offset.x(), content.toDouble()};
|
||||
emit requireRefreshElementWidget();
|
||||
emit requireRefreshPreview();
|
||||
emit triggerCentralRefresh();
|
||||
});
|
||||
scaleX->setValidator(new QDoubleValidator(-1000, 1000, 4, this));
|
||||
connect(scaleX, &QLineEdit::textChanged, [=](QString content) {
|
||||
this->displayLayer->property.scale = {content.toDouble(), this->displayLayer->property.scale.y()};
|
||||
emit requireRefreshElementWidget();
|
||||
emit requireRefreshPreview();
|
||||
emit triggerCentralRefresh();
|
||||
});
|
||||
scaleY->setValidator(new QDoubleValidator(-1000, 1000, 4, this));
|
||||
connect(scaleY, &QLineEdit::textChanged, [=](QString content) {
|
||||
this->displayLayer->property.scale = {this->displayLayer->property.scale.x(), content.toDouble()};
|
||||
emit requireRefreshElementWidget();
|
||||
emit requireRefreshPreview();
|
||||
emit triggerCentralRefresh();
|
||||
});
|
||||
|
||||
layout->addRow("layer name:", name);
|
||||
|
@ -108,10 +103,7 @@ void InfoDisplayWidget::generateLayerForm()
|
|||
{
|
||||
leafP->styles.useStyle(dialog->layerStyle);
|
||||
leafP->styles.computeNewHash();
|
||||
|
||||
emit requireRefreshPreview();
|
||||
emit requireSelfRefresh();
|
||||
emit requireRefreshElementWidget();
|
||||
emit triggerCentralRefresh();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -153,10 +145,7 @@ void InfoDisplayWidget::generateLayerForm()
|
|||
{
|
||||
styleIterator->second = dialog->layerStyle;
|
||||
styles->computeNewHash();
|
||||
|
||||
emit requireRefreshPreview();
|
||||
emit requireSelfRefresh();
|
||||
emit requireRefreshElementWidget();
|
||||
emit triggerCentralRefresh();
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -165,10 +154,7 @@ void InfoDisplayWidget::generateLayerForm()
|
|||
{
|
||||
styles->dropStyle(styleIterator->first);
|
||||
styles->computeNewHash();
|
||||
|
||||
emit requireRefreshPreview();
|
||||
emit requireSelfRefresh();
|
||||
emit requireRefreshElementWidget();
|
||||
emit triggerCentralRefresh();
|
||||
});
|
||||
|
||||
QWidget* styleDisplayWidget = styleIterator->second->getListDisplayWidget();
|
||||
|
@ -190,6 +176,12 @@ void InfoDisplayWidget::generateLayerForm()
|
|||
}
|
||||
|
||||
void InfoDisplayWidget::triggerSelfRefresh()
|
||||
{
|
||||
if (this->displayLayer != nullptr)
|
||||
this->generateLayerForm();
|
||||
}
|
||||
|
||||
void InfoDisplayWidget::refresh()
|
||||
{
|
||||
if (this->displayLayer != nullptr)
|
||||
this->generateLayerForm();
|
||||
|
|
|
@ -16,11 +16,13 @@ class InfoDisplayWidget : public QWidget
|
|||
public:
|
||||
void setLayer(LayerWrapper *layer);
|
||||
void generateLayerForm();
|
||||
void refresh();
|
||||
|
||||
public slots:
|
||||
void triggerSelfRefresh();
|
||||
|
||||
signals:
|
||||
signals:
|
||||
void triggerCentralRefresh();
|
||||
void requireRefreshPreview();
|
||||
void requireSelfRefresh();
|
||||
void requireRefreshElementWidget();
|
||||
|
|
|
@ -24,7 +24,7 @@ LayerTreeWidget::LayerTreeWidget(QWidget *parent)
|
|||
else {
|
||||
emit displayLayerChange(nullptr);
|
||||
}
|
||||
emit requireRefreshPreview();
|
||||
emit triggerCentralRefresh();
|
||||
});
|
||||
// connect(this, &QTreeWidget::itemDoubleClicked, this, &LayerTreeWidget::onItemDoubleClicked);
|
||||
}
|
||||
|
@ -62,9 +62,7 @@ void LayerTreeWidget::popMenu(const QPoint &pos)
|
|||
folderLayer->addChild(std::shared_ptr<LayerWrapper>(newLayer));
|
||||
folderLayer->qTreeWidgetItem->addChild(newLayer->getQTreeItem());
|
||||
qDebug() << jsonObj<<"----------------------";
|
||||
this->refresh();
|
||||
emit requireRefreshPreview();
|
||||
emit requireRefreshElementWidget();
|
||||
emit triggerCentralRefresh();
|
||||
});
|
||||
dialog->exec();
|
||||
});
|
||||
|
@ -74,9 +72,7 @@ void LayerTreeWidget::popMenu(const QPoint &pos)
|
|||
auto layer = this->selectedItem->data(0, Qt::UserRole).value<LayerWrapper*>();
|
||||
layer->del();
|
||||
layer->getParent()->removeChild(layer);
|
||||
this->refresh();
|
||||
emit requireRefreshPreview();
|
||||
emit requireRefreshElementWidget();
|
||||
emit triggerCentralRefresh();
|
||||
});
|
||||
menu.actions().last()->setEnabled(layer->deleteable());
|
||||
menu.addAction(QString::fromLocal8Bit("ÖØÃüÃû"), this, &LayerTreeWidget::onRenameEvent);
|
||||
|
@ -86,9 +82,7 @@ void LayerTreeWidget::popMenu(const QPoint &pos)
|
|||
auto layer = this->selectedItem->data(0, Qt::UserRole).value<LayerWrapper*>();
|
||||
layer->delSelf();
|
||||
layer->getParent()->removeChild(layer);
|
||||
this->refresh();
|
||||
emit requireRefreshPreview();
|
||||
emit requireRefreshElementWidget();
|
||||
emit triggerCentralRefresh();
|
||||
});
|
||||
menu.actions().last()->setEnabled(layer->deleteable(true));
|
||||
}
|
||||
|
@ -103,7 +97,7 @@ void LayerTreeWidget::popMenu(const QPoint &pos)
|
|||
"", &ok);
|
||||
if (ok && !name.isEmpty()) {
|
||||
elementManager->createGroupElement(name, layer);
|
||||
emit requireRefreshElementWidget();
|
||||
emit triggerCentralRefresh();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
@ -21,6 +21,7 @@ class LayerTreeWidget : public QTreeWidget
|
|||
// void onItemDoubleClicked(QTreeWidgetItem *item, int column = 0);
|
||||
|
||||
signals:
|
||||
void triggerCentralRefresh();
|
||||
void displayLayerChange(LayerWrapper *);
|
||||
void requireRefreshPreview();
|
||||
void requireRefreshElementWidget();
|
||||
|
|
Loading…
Reference in New Issue