实现另存为和打开的路径选取
parent
33475f6f57
commit
1031ba5808
|
@ -15,7 +15,23 @@
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||||
<item>
|
<item>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout" stretch="1,1,20">
|
<layout class="QVBoxLayout" name="verticalLayout" stretch="1,1,1,20">
|
||||||
|
<property name="topMargin">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_2">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QWidget" name="widget" native="true">
|
<widget class="QWidget" name="widget" native="true">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||||
|
@ -40,6 +56,25 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="openButton">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>80</width>
|
||||||
|
<height>0</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>80</width>
|
||||||
|
<height>16777215</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>打开</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="saveButton">
|
<widget class="QPushButton" name="saveButton">
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
#include <QInputDialog>
|
#include <QInputDialog>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
|
#include <QFileDialog>
|
||||||
|
|
||||||
EditorWidget::EditorWidget(QWidget* parent) : QWidget(parent)
|
EditorWidget::EditorWidget(QWidget* parent) : QWidget(parent)
|
||||||
{
|
{
|
||||||
|
@ -11,6 +12,7 @@ EditorWidget::EditorWidget(QWidget* parent) : QWidget(parent)
|
||||||
this->closeButton = ui.closeButton;
|
this->closeButton = ui.closeButton;
|
||||||
this->saveButton = ui.saveButton;
|
this->saveButton = ui.saveButton;
|
||||||
this->saveAsButton = ui.saveAsButton;
|
this->saveAsButton = ui.saveAsButton;
|
||||||
|
this->openButton = ui.openButton;
|
||||||
this->tabWidget = ui.tabWidget;
|
this->tabWidget = ui.tabWidget;
|
||||||
while (this->tabWidget->count() > 0)
|
while (this->tabWidget->count() > 0)
|
||||||
{
|
{
|
||||||
|
@ -20,6 +22,10 @@ EditorWidget::EditorWidget(QWidget* parent) : QWidget(parent)
|
||||||
static int count = 0;
|
static int count = 0;
|
||||||
this->tabWidget->addTab(new EditorWidgetItem("../data.json",this), "untitled" + QString::number(count++));
|
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]() {
|
connect(this->closeButton, &QPushButton::clicked, this, [this]() {
|
||||||
this->tabWidget->removeTab(this->tabWidget->currentIndex());
|
this->tabWidget->removeTab(this->tabWidget->currentIndex());
|
||||||
});
|
});
|
||||||
|
@ -27,14 +33,15 @@ EditorWidget::EditorWidget(QWidget* parent) : QWidget(parent)
|
||||||
EditorWidgetItem* item = dynamic_cast<EditorWidgetItem*>(this->tabWidget->currentWidget());
|
EditorWidgetItem* item = dynamic_cast<EditorWidgetItem*>(this->tabWidget->currentWidget());
|
||||||
if (item != nullptr)
|
if (item != nullptr)
|
||||||
{
|
{
|
||||||
item->saveAs("../data.back.json");
|
//item->save();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
connect(this->saveAsButton, &QPushButton::clicked, this, [this]() {
|
connect(this->saveAsButton, &QPushButton::clicked, this, [this]() {
|
||||||
EditorWidgetItem* item = dynamic_cast<EditorWidgetItem*>(this->tabWidget->currentWidget());
|
EditorWidgetItem* item = dynamic_cast<EditorWidgetItem*>(this->tabWidget->currentWidget());
|
||||||
if (item != nullptr)
|
if (item != nullptr)
|
||||||
{
|
{
|
||||||
item->saveAs("../data.back.json");
|
QString fileName = QFileDialog::getSaveFileName(this->saveAsButton, QString::fromLocal8Bit("Áí´æΪ"), "", QString::fromLocal8Bit("JSONÎļþ(*.json)"));
|
||||||
|
item->saveAs(fileName);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ private:
|
||||||
QPushButton* closeButton;
|
QPushButton* closeButton;
|
||||||
QPushButton* saveButton;
|
QPushButton* saveButton;
|
||||||
QPushButton* saveAsButton;
|
QPushButton* saveAsButton;
|
||||||
|
QPushButton* openButton;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
EditorWidget(QWidget* parent = nullptr);
|
EditorWidget(QWidget* parent = nullptr);
|
||||||
|
|
|
@ -150,6 +150,6 @@ void InfoDisplayWidget::triggerSelfRefresh()
|
||||||
{
|
{
|
||||||
if (this->displayLayer != nullptr)
|
if (this->displayLayer != nullptr)
|
||||||
this->generateLayerForm();
|
this->generateLayerForm();
|
||||||
else
|
if (this->displayElement != nullptr)
|
||||||
this->generateElementForm();
|
this->generateElementForm();
|
||||||
}
|
}
|
|
@ -37,10 +37,14 @@ void LayerTreeWidget::popMenu(const QPoint &pos)
|
||||||
this->selectedItem = item;
|
this->selectedItem = item;
|
||||||
// TODO
|
// TODO
|
||||||
menu.addAction(QString::fromLocal8Bit("创建子节点"), this, &LayerTreeWidget::onRenameEvent);
|
menu.addAction(QString::fromLocal8Bit("创建子节点"), this, &LayerTreeWidget::onRenameEvent);
|
||||||
|
//if (item != root->getQTreeItem())
|
||||||
|
//{
|
||||||
menu.addAction(QString::fromLocal8Bit("重命名"), this, &LayerTreeWidget::onRenameEvent);
|
menu.addAction(QString::fromLocal8Bit("重命名"), this, &LayerTreeWidget::onRenameEvent);
|
||||||
// menu.addAction("Copy", this, &LayerTreeWidget::onRenameEvent);
|
// menu.addAction("Copy", this, &LayerTreeWidget::onRenameEvent);
|
||||||
if (item != nullptr && item->childCount() > 0)
|
if (item != nullptr && item->childCount() > 0)
|
||||||
menu.addAction(QString::fromLocal8Bit("删除(保留子节点)"), this, [this]() {
|
menu.addAction(QString::fromLocal8Bit("删除(保留子节点)"), this, [this]() {
|
||||||
|
if (this->selectedItem == nullptr)
|
||||||
|
return;
|
||||||
auto layer = this->selectedItem->data(0, Qt::UserRole).value<LayerWrapper*>();
|
auto layer = this->selectedItem->data(0, Qt::UserRole).value<LayerWrapper*>();
|
||||||
layer->delSelf();
|
layer->delSelf();
|
||||||
layer->getParent()->removeChild(layer);
|
layer->getParent()->removeChild(layer);
|
||||||
|
@ -56,6 +60,7 @@ void LayerTreeWidget::popMenu(const QPoint &pos)
|
||||||
this->refresh();
|
this->refresh();
|
||||||
emit requireRefreshPreview();
|
emit requireRefreshPreview();
|
||||||
});
|
});
|
||||||
|
//}
|
||||||
menu.exec(mapToGlobal(pos));
|
menu.exec(mapToGlobal(pos));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,18 +1,10 @@
|
||||||
{
|
{
|
||||||
"elements": [
|
"elements": [
|
||||||
{
|
{
|
||||||
"name": "ababa",
|
"name": ""
|
||||||
"type": "svg-file",
|
|
||||||
"data": {
|
|
||||||
"include": "./svg/2.svg"
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "ababa-group",
|
"name": ""
|
||||||
"type": "group",
|
|
||||||
"data": {
|
|
||||||
"reference-layer": "0.0"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"height": 1080,
|
"height": 1080,
|
||||||
|
|
Loading…
Reference in New Issue