From 1031ba580855827a76a4fea5971aef07f27a19c9 Mon Sep 17 00:00:00 2001 From: karlis <2995621482@qq.com> Date: Tue, 7 Mar 2023 19:13:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E5=8F=A6=E5=AD=98=E4=B8=BA?= =?UTF-8?q?=E5=92=8C=E6=89=93=E5=BC=80=E7=9A=84=E8=B7=AF=E5=BE=84=E9=80=89?= =?UTF-8?q?=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ArchitectureColoredPainting/EditorWidget.ui | 37 +++++- .../src/Editor/EditorWidget.cpp | 11 +- .../src/Editor/EditorWidget.h | 1 + .../src/Editor/RightBar/InfoDisplayWidget.cpp | 2 +- .../src/Editor/RightBar/LayerTreeWidget.cpp | 25 ++-- data - 副本.json | 111 ++++++++++++++++++ data.back.json | 20 +--- 7 files changed, 179 insertions(+), 28 deletions(-) create mode 100644 data - 副本.json diff --git a/ArchitectureColoredPainting/EditorWidget.ui b/ArchitectureColoredPainting/EditorWidget.ui index 0ae06e0..3e07151 100644 --- a/ArchitectureColoredPainting/EditorWidget.ui +++ b/ArchitectureColoredPainting/EditorWidget.ui @@ -15,7 +15,23 @@ - + + + 0 + + + + + Qt::Horizontal + + + + 40 + 20 + + + + @@ -40,6 +56,25 @@ + + + + + 80 + 0 + + + + + 80 + 16777215 + + + + 打开 + + + diff --git a/ArchitectureColoredPainting/src/Editor/EditorWidget.cpp b/ArchitectureColoredPainting/src/Editor/EditorWidget.cpp index 1c3a43b..2c990de 100644 --- a/ArchitectureColoredPainting/src/Editor/EditorWidget.cpp +++ b/ArchitectureColoredPainting/src/Editor/EditorWidget.cpp @@ -3,6 +3,7 @@ #include #include #include +#include EditorWidget::EditorWidget(QWidget* parent) : QWidget(parent) { @@ -11,6 +12,7 @@ EditorWidget::EditorWidget(QWidget* parent) : QWidget(parent) this->closeButton = ui.closeButton; this->saveButton = ui.saveButton; this->saveAsButton = ui.saveAsButton; + this->openButton = ui.openButton; this->tabWidget = ui.tabWidget; while (this->tabWidget->count() > 0) { @@ -20,6 +22,10 @@ EditorWidget::EditorWidget(QWidget* parent) : QWidget(parent) static int count = 0; this->tabWidget->addTab(new EditorWidgetItem("../data.json",this), "untitled" + QString::number(count++)); }); + connect(this->openButton, &QPushButton::clicked, this, [this]() { + QString fileName = QFileDialog::getOpenFileName(this->saveAsButton, QString::fromLocal8Bit("´ò¿ª"), "", QString::fromLocal8Bit("JSONÎļþ(*.json)")); + this->tabWidget->addTab(new EditorWidgetItem(fileName, this), fileName); + }); connect(this->closeButton, &QPushButton::clicked, this, [this]() { this->tabWidget->removeTab(this->tabWidget->currentIndex()); }); @@ -27,14 +33,15 @@ EditorWidget::EditorWidget(QWidget* parent) : QWidget(parent) EditorWidgetItem* item = dynamic_cast(this->tabWidget->currentWidget()); if (item != nullptr) { - item->saveAs("../data.back.json"); + //item->save(); } }); connect(this->saveAsButton, &QPushButton::clicked, this, [this]() { EditorWidgetItem* item = dynamic_cast(this->tabWidget->currentWidget()); if (item != nullptr) { - item->saveAs("../data.back.json"); + QString fileName = QFileDialog::getSaveFileName(this->saveAsButton, QString::fromLocal8Bit("Áí´æΪ"), "", QString::fromLocal8Bit("JSONÎļþ(*.json)")); + item->saveAs(fileName); } }); } diff --git a/ArchitectureColoredPainting/src/Editor/EditorWidget.h b/ArchitectureColoredPainting/src/Editor/EditorWidget.h index 6024513..b0cfe2f 100644 --- a/ArchitectureColoredPainting/src/Editor/EditorWidget.h +++ b/ArchitectureColoredPainting/src/Editor/EditorWidget.h @@ -13,6 +13,7 @@ private: QPushButton* closeButton; QPushButton* saveButton; QPushButton* saveAsButton; + QPushButton* openButton; public: EditorWidget(QWidget* parent = nullptr); diff --git a/ArchitectureColoredPainting/src/Editor/RightBar/InfoDisplayWidget.cpp b/ArchitectureColoredPainting/src/Editor/RightBar/InfoDisplayWidget.cpp index d069285..74720dc 100644 --- a/ArchitectureColoredPainting/src/Editor/RightBar/InfoDisplayWidget.cpp +++ b/ArchitectureColoredPainting/src/Editor/RightBar/InfoDisplayWidget.cpp @@ -150,6 +150,6 @@ void InfoDisplayWidget::triggerSelfRefresh() { if (this->displayLayer != nullptr) this->generateLayerForm(); - else + if (this->displayElement != nullptr) this->generateElementForm(); } \ No newline at end of file diff --git a/ArchitectureColoredPainting/src/Editor/RightBar/LayerTreeWidget.cpp b/ArchitectureColoredPainting/src/Editor/RightBar/LayerTreeWidget.cpp index 7ee7083..9424203 100644 --- a/ArchitectureColoredPainting/src/Editor/RightBar/LayerTreeWidget.cpp +++ b/ArchitectureColoredPainting/src/Editor/RightBar/LayerTreeWidget.cpp @@ -37,25 +37,30 @@ void LayerTreeWidget::popMenu(const QPoint &pos) this->selectedItem = item; // TODO menu.addAction(QString::fromLocal8Bit("´´½¨×Ó½Úµã"), this, &LayerTreeWidget::onRenameEvent); - menu.addAction(QString::fromLocal8Bit("ÖØÃüÃû"), this, &LayerTreeWidget::onRenameEvent); - // menu.addAction("Copy", this, &LayerTreeWidget::onRenameEvent); - if (item != nullptr && item->childCount() > 0) - menu.addAction(QString::fromLocal8Bit("ɾ³ý£¨±£Áô×ӽڵ㣩"), this, [this]() { - auto layer = this->selectedItem->data(0, Qt::UserRole).value(); + //if (item != root->getQTreeItem()) + //{ + menu.addAction(QString::fromLocal8Bit("ÖØÃüÃû"), this, &LayerTreeWidget::onRenameEvent); + // menu.addAction("Copy", this, &LayerTreeWidget::onRenameEvent); + if (item != nullptr && item->childCount() > 0) + menu.addAction(QString::fromLocal8Bit("ɾ³ý£¨±£Áô×ӽڵ㣩"), this, [this]() { + if (this->selectedItem == nullptr) + return; + auto layer = this->selectedItem->data(0, Qt::UserRole).value(); layer->delSelf(); layer->getParent()->removeChild(layer); this->refresh(); emit requireRefreshPreview(); - }); - menu.addAction(QString::fromLocal8Bit("ɾ³ý"), this, [this]() { + }); + menu.addAction(QString::fromLocal8Bit("ɾ³ý"), this, [this]() { if (this->selectedItem == nullptr) - return; + return; auto layer = this->selectedItem->data(0, Qt::UserRole).value(); layer->del(); - layer->getParent()->removeChild(layer); + layer->getParent()->removeChild(layer); this->refresh(); emit requireRefreshPreview(); - }); + }); + //} menu.exec(mapToGlobal(pos)); } diff --git a/data - 副本.json b/data - 副本.json new file mode 100644 index 0000000..150cb6c --- /dev/null +++ b/data - 副本.json @@ -0,0 +1,111 @@ +{ + "height": 1080, + "width": 1080, + "elements": [ + { + "name": "ababa", + "type": "svg-file", + "data": { + "include": "./svg/2.svg" + } + }, + { + "name": "ababa-group", + "type": "group", + "data": { + "reference-layer": "0.0" + } + } + ], + "root-layer": { + "name": "root", + "transform": { + "offset": { + "x": 0, + "y": 0 + }, + "scale": { + "x": 1.0, + "y": 1.0 + }, + "rotation": 0.0 + }, + "effects": [], + "is-folder": true, + "referenced-by": null, + "children": [ + + { + "name": "GroupFolderExample", + "transform": { + "offset": { + "x": 50, + "y": 50 + }, + "scale": { + "x": 1.0, + "y": 1.0 + }, + "rotation": 0.0 + }, + "effects": [], + "is-folder": true, + "referenced-by": 1, + "children": [ + { + "name": "Leaf1", + "transform": { + "offset": { + "x": 0, + "y": 0 + }, + "scale": { + "x": 1.0, + "y": 1.0 + }, + "rotation": 0.0 + }, + "effects": [], + "is-folder": false, + "element": 0 + }, + { + "name": "Leaf2", + "transform": { + "offset": { + "x": 150, + "y": 0 + }, + "scale": { + "x": 1.5, + "y": 1.5 + }, + "rotation": 0.0 + }, + "effects": [], + "is-folder": false, + "element": 0 + } + ] + }, + + { + "name": "ReferencingGroupLayer", + "transform": { + "offset": { + "x": 100, + "y": 0 + }, + "scale": { + "x": 1, + "y": 1 + }, + "rotation": 45 + }, + "effects": [], + "is-folder": false, + "element": 1 + } + ] + } +} \ No newline at end of file diff --git a/data.back.json b/data.back.json index f58455c..bf590e5 100644 --- a/data.back.json +++ b/data.back.json @@ -1,19 +1,11 @@ { "elements": [ - { - "name": "ababa", - "type": "svg-file", - "data": { - "include": "./svg/2.svg" - } - }, - { - "name": "ababa-group", - "type": "group", - "data": { - "reference-layer": "0.0" - } - } + { + "name": "" + }, + { + "name": "" + } ], "height": 1080, "root-layer": {