Merge branch 'main' into dev-LayerStyle
commit
43719bc81a
|
@ -180,6 +180,12 @@
|
|||
<property name="accessibleName">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="iconSize">
|
||||
<size>
|
||||
<width>10</width>
|
||||
<height>10</height>
|
||||
</size>
|
||||
</property>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>图层名</string>
|
||||
|
@ -190,6 +196,11 @@
|
|||
<string>关联图元</string>
|
||||
</property>
|
||||
</column>
|
||||
<column>
|
||||
<property name="text">
|
||||
<string>可见</string>
|
||||
</property>
|
||||
</column>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
|
|
@ -25,6 +25,7 @@ EditorWidgetItem::EditorWidgetItem(QString filePath,QWidget *parent) : QWidget(p
|
|||
treeWidget->refresh();
|
||||
previewWindow->refresh();
|
||||
};
|
||||
connect(previewWindow, &PreviewWindow::triggerCentralRefresh, centralRefresh);
|
||||
connect(layerInfoDisplayWidget, &InfoDisplayWidget::triggerCentralRefresh, centralRefresh);
|
||||
connect(elementInfoDisplayWidget, &ElementPoolWidget::triggerCentralRefresh, centralRefresh);
|
||||
connect(treeWidget, &LayerTreeWidget::triggerCentralRefresh, centralRefresh);
|
||||
|
@ -33,15 +34,15 @@ EditorWidgetItem::EditorWidgetItem(QString filePath,QWidget *parent) : QWidget(p
|
|||
connect(previewWindow, &PreviewWindow::refreshElementPreviewByIndex, elementInfoDisplayWidget, &ElementPoolWidget::refreshPictureByIndex);
|
||||
connect(previewWindow, &PreviewWindow::layerInfoChanged, layerInfoDisplayWidget, &InfoDisplayWidget::triggerSelfRefresh);
|
||||
connect(treeWidget, &LayerTreeWidget::displayLayerChange, previewWindow, &PreviewWindow::currentLayerChanged);
|
||||
connect(treeWidget, &LayerTreeWidget::requireRefreshElementWidget, elementInfoDisplayWidget, &ElementPoolWidget::refresh);
|
||||
connect(layerInfoDisplayWidget, &InfoDisplayWidget::requireRefreshElementWidget, elementInfoDisplayWidget, &ElementPoolWidget::refresh);
|
||||
//connect(treeWidget, &LayerTreeWidget::requireRefreshElementWidget, elementInfoDisplayWidget, &ElementPoolWidget::refresh);
|
||||
// connect(layerInfoDisplayWidget, &InfoDisplayWidget::requireRefreshElementWidget, elementInfoDisplayWidget, &ElementPoolWidget::refresh);
|
||||
connect(treeWidget, &LayerTreeWidget::displayLayerChange, this, &EditorWidgetItem::onLayerChange);
|
||||
connect(layerInfoDisplayWidget, &InfoDisplayWidget::requireRefreshPreview, this,
|
||||
&EditorWidgetItem::triggerRefreshPreview);
|
||||
connect(treeWidget, &LayerTreeWidget::requireRefreshPreview, this,
|
||||
&EditorWidgetItem::triggerRefreshPreview);
|
||||
connect(layerInfoDisplayWidget, &InfoDisplayWidget::requireSelfRefresh, layerInfoDisplayWidget, &InfoDisplayWidget::triggerSelfRefresh);
|
||||
connect(elementInfoDisplayWidget, &ElementPoolWidget::refreshLayerTree, treeWidget, &LayerTreeWidget::refresh);
|
||||
// connect(layerInfoDisplayWidget, &InfoDisplayWidget::requireRefreshPreview, this,
|
||||
// &EditorWidgetItem::triggerRefreshPreview);
|
||||
// connect(treeWidget, &LayerTreeWidget::requireRefreshPreview, this,
|
||||
// &EditorWidgetItem::triggerRefreshPreview);
|
||||
//connect(layerInfoDisplayWidget, &InfoDisplayWidget::requireSelfRefresh, layerInfoDisplayWidget, &InfoDisplayWidget::triggerSelfRefresh);
|
||||
// connect(elementInfoDisplayWidget, &ElementPoolWidget::refreshLayerTree, treeWidget, &LayerTreeWidget::refresh);
|
||||
// &EditorWidget::triggerRefreshPreview);
|
||||
// test
|
||||
QFile settingFile;
|
||||
|
@ -73,9 +74,10 @@ EditorWidgetItem::EditorWidgetItem(QString filePath,QWidget *parent) : QWidget(p
|
|||
this->projectName = source.value("project-name").toString();
|
||||
qDebug() << this->backgroundColor;
|
||||
qDebug() << this->projectName;
|
||||
QTimer::singleShot(300, this, [this]() {
|
||||
QTimer::singleShot(300, this, [this, centralRefresh]() {
|
||||
handleBackgroundColorChange(this->backgroundColor);
|
||||
handleProjectNameChange(this->projectName);
|
||||
centralRefresh();
|
||||
});
|
||||
|
||||
}
|
||||
|
|
|
@ -127,7 +127,7 @@ bool SimpleElement::isClosed() const
|
|||
|
||||
void GroupElement::paint(QPainter* painter, QTransform transform, const LayerStyleContainer& styles)
|
||||
{
|
||||
sourceLayer->paint(painter, transform);
|
||||
sourceLayer->paint(painter, transform, true);
|
||||
}
|
||||
|
||||
bool GroupElement::isClosed() const
|
||||
|
|
|
@ -47,6 +47,7 @@ LayerWrapper::LayerWrapper(QJsonObject json, FolderLayerWrapper*parent, ElementM
|
|||
transformJson.value("scale").toObject().value("y").toDouble()};
|
||||
property.rotation = {transformJson.value("rotation").toDouble()};
|
||||
selected = false;
|
||||
hidden = false;
|
||||
}
|
||||
|
||||
FolderLayerWrapper::FolderLayerWrapper(QJsonObject json, ElementManager *elementManager, FolderLayerWrapper*parent)
|
||||
|
@ -199,6 +200,7 @@ void FolderLayerWrapper::delSelf() {
|
|||
QTreeWidgetItem* LayerWrapper::getQTreeItem()
|
||||
{
|
||||
this->qTreeWidgetItem->setData(0, Qt::UserRole, QVariant::fromValue(this));
|
||||
this->qTreeWidgetItem->setCheckState(0, Qt::Checked);
|
||||
return this->qTreeWidgetItem;
|
||||
}
|
||||
|
||||
|
@ -280,31 +282,27 @@ int FolderLayerWrapper::getReferencedBy()const
|
|||
return -1;
|
||||
}
|
||||
|
||||
void LayerWrapper::paint(QPainter* painter, QTransform transform, bool ignoreSelected)
|
||||
void LayerWrapper::paint(QPainter* painter, QTransform transform, bool force)
|
||||
{
|
||||
if (!ignoreSelected && this->selected)
|
||||
{
|
||||
painter->save();
|
||||
painter->setTransform(transform, ignoreSelected);
|
||||
painter->setPen(QPen(Qt::gray, 2));
|
||||
painter->setPen(Qt::DashLine);
|
||||
painter->drawRect(cache.getBoundingRect());
|
||||
painter->restore();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void FolderLayerWrapper::paint(QPainter* painter, QTransform transform, bool ignoreSelected)
|
||||
void FolderLayerWrapper::paint(QPainter* painter, QTransform transform, bool force)
|
||||
{
|
||||
LayerWrapper::paint(painter, transform, ignoreSelected);
|
||||
if (hidden && !force)
|
||||
return;
|
||||
LayerWrapper::paint(painter, transform, force);
|
||||
transform = property.transform * transform;
|
||||
//qDebug() << transform;
|
||||
for (auto& child : children)
|
||||
child->paint(painter, transform, ignoreSelected);
|
||||
child->paint(painter, transform, force);
|
||||
}
|
||||
|
||||
void LeafLayerWrapper::paint(QPainter* painter, QTransform transform, bool ignoreSelected)
|
||||
void LeafLayerWrapper::paint(QPainter* painter, QTransform transform, bool force)
|
||||
{
|
||||
LayerWrapper::paint(painter, transform, ignoreSelected);
|
||||
if (hidden && !force)
|
||||
return;
|
||||
LayerWrapper::paint(painter, transform, force);
|
||||
transform = property.transform * transform;
|
||||
//qDebug() << transform;
|
||||
if (wrappedElement != nullptr)
|
||||
|
@ -347,11 +345,12 @@ void FolderLayerWrapper::collectDownReachable(std::set<LayerWrapper*>& reachable
|
|||
|
||||
void LayerWrapper::refreshTreeItem()
|
||||
{
|
||||
|
||||
hidden = qTreeWidgetItem->checkState(0) == Qt::Unchecked;
|
||||
}
|
||||
|
||||
void LeafLayerWrapper::refreshTreeItem()
|
||||
{
|
||||
LayerWrapper::refreshTreeItem();
|
||||
if (typeid(*wrappedElement) == typeid(GroupElement))
|
||||
{
|
||||
this->qTreeWidgetItem->setText(0, "@ " + this->property.name);
|
||||
|
@ -366,6 +365,7 @@ void LeafLayerWrapper::refreshTreeItem()
|
|||
|
||||
void FolderLayerWrapper::refreshTreeItem()
|
||||
{
|
||||
LayerWrapper::refreshTreeItem();
|
||||
for (auto& child : this->children) {
|
||||
child->refreshTreeItem();
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@ class LayerWrapper
|
|||
public:
|
||||
QTreeWidgetItem* qTreeWidgetItem;
|
||||
bool selected;
|
||||
bool hidden;
|
||||
struct SimpleProperty
|
||||
{
|
||||
QString name = "";
|
||||
|
@ -58,7 +59,7 @@ class LayerWrapper
|
|||
FolderLayerWrapper*getParent() const; // invoke by manager, then invoke parent's applyStyles
|
||||
LayerWrapper(QJsonObject json, FolderLayerWrapper*parent, ElementManager* elementManager=nullptr);
|
||||
LayerWrapper() = default;
|
||||
virtual void paint(QPainter* painter, QTransform transform=QTransform(), bool ignoreSelected = false);
|
||||
virtual void paint(QPainter* painter, QTransform transform=QTransform(), bool force = false);
|
||||
// TODO : export Function
|
||||
// virtual LayerWrapper *addChild() = 0; // Leaf Child Only
|
||||
// virtual LayerWrapper *addParent() = 0; // Folder Parent Only
|
||||
|
@ -97,7 +98,7 @@ class FolderLayerWrapper : public LayerWrapper
|
|||
QTreeWidgetItem* getQTreeItem() override;
|
||||
QJsonObject toJson() const override;
|
||||
int getReferencedBy()const;
|
||||
void paint(QPainter* painter, QTransform transform = QTransform(), bool ignoreSelected = false) override;
|
||||
void paint(QPainter* painter, QTransform transform = QTransform(), bool force = false) override;
|
||||
void collectDownReachable(std::set<LayerWrapper*>& reachable) override;
|
||||
void refreshTreeItem() override;
|
||||
size_t referencedCount(bool excludeSelf = false) const override;
|
||||
|
@ -115,7 +116,7 @@ class LeafLayerWrapper : public LayerWrapper
|
|||
void refresh(LayerWrapper* layer = nullptr) override;
|
||||
LeafLayerWrapper(QJsonObject json, ElementManager *elementManager, FolderLayerWrapper*parent);
|
||||
QJsonObject toJson() const override;
|
||||
void paint(QPainter* painter, QTransform transform = QTransform(), bool ignoreSelected = false) override;
|
||||
void paint(QPainter* painter, QTransform transform = QTransform(), bool force = false) override;
|
||||
void collectDownReachable(std::set<LayerWrapper*>& reachable) override;
|
||||
QTreeWidgetItem* getQTreeItem() override;
|
||||
void refreshTreeItem() override;
|
||||
|
|
|
@ -100,19 +100,18 @@ void PreviewWindow::mouseMoveEvent(QMouseEvent* event)
|
|||
auto index = -1;
|
||||
if (typeid(*layer) == typeid(FolderLayerWrapper))
|
||||
index = dynamic_cast<FolderLayerWrapper*>(layer)->getReferencedBy();
|
||||
if (index != -1)
|
||||
emit refreshElementPreviewByIndex(index);
|
||||
layer = layer->getParent();
|
||||
}
|
||||
}
|
||||
// 更新上一次的位置
|
||||
emit triggerCentralRefresh();
|
||||
m_lastPos = event->pos();
|
||||
this->repaint();
|
||||
}
|
||||
|
||||
void PreviewWindow::mouseReleaseEvent(QMouseEvent* event)
|
||||
{
|
||||
emit layerInfoChanged();
|
||||
//emit layerInfoChanged();
|
||||
}
|
||||
|
||||
void PreviewWindow::setBackgroundColor(QColor color)
|
||||
|
|
|
@ -46,4 +46,5 @@ class PreviewWindow : public QOpenGLWidget, protected QOpenGLFunctions
|
|||
void layerInfoChanged();
|
||||
void refreshElementPreview(GraphicElement*);
|
||||
void refreshElementPreviewByIndex(int);
|
||||
void triggerCentralRefresh();
|
||||
};
|
||||
|
|
|
@ -21,12 +21,11 @@ void InfoDisplayWidget::generateLayerForm()
|
|||
{
|
||||
while (this->layout()->count() > 0 && (item = this->layout()->takeAt(0)) != nullptr)
|
||||
{
|
||||
delete item->widget();
|
||||
delete item;
|
||||
item->widget()->deleteLater();
|
||||
delete item;
|
||||
}
|
||||
delete this->layout();
|
||||
}
|
||||
|
||||
QFormLayout *layout = new QFormLayout();
|
||||
layout->setRowWrapPolicy(QFormLayout::WrapAllRows);
|
||||
if (this->displayLayer == nullptr)
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#include <QInputDialog>
|
||||
#include <QMenu>
|
||||
#include "./EditorWidgetComponent/LayerCreateWidget.h"
|
||||
#include <QTimer>
|
||||
|
||||
LayerTreeWidget::LayerTreeWidget(QWidget *parent)
|
||||
{
|
||||
|
@ -26,6 +27,10 @@ LayerTreeWidget::LayerTreeWidget(QWidget *parent)
|
|||
}
|
||||
emit triggerCentralRefresh();
|
||||
});
|
||||
connect(this, &QTreeWidget::itemChanged, this, [=]() {
|
||||
emit triggerCentralRefresh();
|
||||
});
|
||||
|
||||
// connect(this, &QTreeWidget::itemDoubleClicked, this, &LayerTreeWidget::onItemDoubleClicked);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue