实现另存为和打开的路径选取
parent
33475f6f57
commit
1031ba5808
|
@ -15,7 +15,23 @@
|
|||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<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>
|
||||
<widget class="QWidget" name="widget" native="true">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||
|
@ -40,6 +56,25 @@
|
|||
</property>
|
||||
</widget>
|
||||
</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>
|
||||
<widget class="QPushButton" name="saveButton">
|
||||
<property name="minimumSize">
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#include <QMouseEvent>
|
||||
#include <QInputDialog>
|
||||
#include <QMenu>
|
||||
#include <QFileDialog>
|
||||
|
||||
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<EditorWidgetItem*>(this->tabWidget->currentWidget());
|
||||
if (item != nullptr)
|
||||
{
|
||||
item->saveAs("../data.back.json");
|
||||
//item->save();
|
||||
}
|
||||
});
|
||||
connect(this->saveAsButton, &QPushButton::clicked, this, [this]() {
|
||||
EditorWidgetItem* item = dynamic_cast<EditorWidgetItem*>(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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ private:
|
|||
QPushButton* closeButton;
|
||||
QPushButton* saveButton;
|
||||
QPushButton* saveAsButton;
|
||||
QPushButton* openButton;
|
||||
|
||||
public:
|
||||
EditorWidget(QWidget* parent = nullptr);
|
||||
|
|
|
@ -150,6 +150,6 @@ void InfoDisplayWidget::triggerSelfRefresh()
|
|||
{
|
||||
if (this->displayLayer != nullptr)
|
||||
this->generateLayerForm();
|
||||
else
|
||||
if (this->displayElement != nullptr)
|
||||
this->generateElementForm();
|
||||
}
|
|
@ -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<LayerWrapper*>();
|
||||
//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<LayerWrapper*>();
|
||||
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<LayerWrapper*>();
|
||||
layer->del();
|
||||
layer->getParent()->removeChild(layer);
|
||||
layer->getParent()->removeChild(layer);
|
||||
this->refresh();
|
||||
emit requireRefreshPreview();
|
||||
});
|
||||
});
|
||||
//}
|
||||
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,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": {
|
||||
|
|
Loading…
Reference in New Issue