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": {