[editor] 将项目设置放到了菜单栏中 | #4
parent
8230a98d58
commit
0d5c513523
|
@ -105,6 +105,10 @@
|
|||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="src\Editor\Properties\ProjectPropertyWidget.cpp" />
|
||||
<ClCompile Include="src\Editor\Properties\ProjectPropertyDialog.cpp" />
|
||||
<ClCompile Include="src\Editor\Properties\CanvasPropertyWidget.cpp" />
|
||||
<ClCompile Include="src\Editor\Properties\PropertyWidget.cpp" />
|
||||
<ClCompile Include="src\Editor\EditorWidgetComponent\LayerContainerListWidget.cpp" />
|
||||
<ClCompile Include="src\Editor\DataManager\ProjectDataManager.cpp" />
|
||||
<ClCompile Include="src\Editor\EditorWidgetComponent\FillStyleWidget.cpp" />
|
||||
|
@ -208,6 +212,10 @@
|
|||
<QtMoc Include="src\Editor\RightBar\EditorSettingWidget.h" />
|
||||
<QtMoc Include="src\Editor\EditorWidgetComponent\FillStyleWidget.h" />
|
||||
<QtMoc Include="src\Editor\EditorWidgetComponent\LayerContainerListWidget.h" />
|
||||
<QtMoc Include="src\Editor\Properties\CanvasPropertyWidget.h" />
|
||||
<QtMoc Include="src\Editor\Properties\ProjectPropertyDialog.h" />
|
||||
<QtMoc Include="src\Editor\Properties\ProjectPropertyWidget.h" />
|
||||
<ClInclude Include="src\Editor\Properties\PropertyWidget.h" />
|
||||
<ClInclude Include="src\Editor\DataManager\ProjectDataManager.h" />
|
||||
<ClInclude Include="src\ColorHelper.hpp" />
|
||||
<ClInclude Include="src\Editor\LayerWrapper.h" />
|
||||
|
|
|
@ -270,6 +270,18 @@
|
|||
<ClCompile Include="src\Editor\EditorWidgetComponent\LayerContainerListWidget.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\Editor\Properties\PropertyWidget.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\Editor\Properties\CanvasPropertyWidget.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\Editor\Properties\ProjectPropertyDialog.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\Editor\Properties\ProjectPropertyWidget.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<QtMoc Include="src\Renderer\RendererGLWidget.h">
|
||||
|
@ -332,6 +344,15 @@
|
|||
<QtMoc Include="src\Editor\ElementManager.h">
|
||||
<Filter>Header Files\Editor\Element</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="src\Editor\Properties\CanvasPropertyWidget.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="src\Editor\Properties\ProjectPropertyDialog.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
<QtMoc Include="src\Editor\Properties\ProjectPropertyWidget.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</QtMoc>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="..\data.json" />
|
||||
|
@ -543,6 +564,9 @@
|
|||
<ClInclude Include="src\FluentMenuButton.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\Editor\Properties\PropertyWidget.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<QtRcc Include="res\MainWindow.qrc">
|
||||
|
|
|
@ -98,7 +98,7 @@
|
|||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="RightBar" native="true">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4" stretch="3,2">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4" stretch="0,3,2">
|
||||
<property name="spacing">
|
||||
<number>20</number>
|
||||
</property>
|
||||
|
@ -115,28 +115,24 @@
|
|||
<number>11</number>
|
||||
</property>
|
||||
<item>
|
||||
<widget class="QTabWidget" name="DisplayTab">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
<widget class="QLabel" name="LayerDisplayLabel">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
<property name="text">
|
||||
<string>图层信息</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignCenter</set>
|
||||
</property>
|
||||
<widget class="InfoDisplayWidget" name="LayerDisplay">
|
||||
<attribute name="title">
|
||||
<string>图层信息</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
<widget class="EditorSettingWidget" name="EditorSetting">
|
||||
<attribute name="title">
|
||||
<string>设置</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="InfoDisplayWidget" name="LayerDisplay" native="true"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="LayerTreeWidget" name="LayerTree">
|
||||
<property name="minimumSize">
|
||||
|
@ -233,12 +229,6 @@
|
|||
<header>ElementPoolWidget.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>EditorSettingWidget</class>
|
||||
<extends>QWidget</extends>
|
||||
<header location="global">EditorSettingWidget.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "EditorWidget.h"
|
||||
#include "EditorWidgetItem.h"
|
||||
#include <QMouseEvent>
|
||||
#include "Properties/ProjectPropertyDialog.h"
|
||||
#include <QInputDialog>
|
||||
#include <QMenu>
|
||||
#include <QFileDialog>
|
||||
|
@ -104,6 +104,21 @@ void EditorWidget::initProjectMenu()
|
|||
projectMenuButton->setDisabled(true);
|
||||
}
|
||||
|
||||
auto* actionSettings = new QAction(QStringLiteral("ÏîÄ¿ÉèÖÃ"), projectMenuButton);
|
||||
projectMenuButton->addMenuAction(actionSettings);
|
||||
auto* actionProjectSettings = new QAction(QStringLiteral("ÏîÄ¿ÉèÖÃ"), projectMenuButton);
|
||||
projectMenuButton->addMenuAction(actionProjectSettings);
|
||||
|
||||
connect(actionProjectSettings, &QAction::triggered, [this]
|
||||
{
|
||||
auto* currentEditorWidgetItem = static_cast<EditorWidgetItem*>(this->tabWidget->currentWidget());
|
||||
const auto dialog = new ProjectPropertyDialog(currentEditorWidgetItem, this);
|
||||
dialog->setWindowTitle(QStringLiteral("ÏîÄ¿ÉèÖÃ"));
|
||||
|
||||
connect(dialog, &ProjectPropertyDialog::projectNameChanged,
|
||||
currentEditorWidgetItem, &EditorWidgetItem::handleProjectNameChange);
|
||||
connect(dialog, &ProjectPropertyDialog::backgroundColorChanged,
|
||||
currentEditorWidgetItem, &EditorWidgetItem::handleBackgroundColorChange);
|
||||
connect(dialog, &ProjectPropertyDialog::canvasSizeChanged,
|
||||
currentEditorWidgetItem, &EditorWidgetItem::handleCanvasSizeChange);
|
||||
dialog->exec();
|
||||
});
|
||||
}
|
||||
|
|
|
@ -15,11 +15,9 @@ EditorWidgetItem::EditorWidgetItem(QString filePath,QWidget *parent) : QWidget(p
|
|||
ui.setupUi(this);
|
||||
previewWindow = ui.Preview;
|
||||
treeWidget = ui.LayerTree;
|
||||
tabWidget = ui.DisplayTab;
|
||||
this->filePath = filePath;
|
||||
elementInfoDisplayWidget = ui.ElementDisplay;
|
||||
layerInfoDisplayWidget = dynamic_cast<InfoDisplayWidget*>(tabWidget->widget(0));
|
||||
editorSettingWidget = dynamic_cast<EditorSettingWidget*>(tabWidget->widget(1));
|
||||
layerInfoDisplayWidget = ui.LayerDisplay;
|
||||
elementInfoDisplayWidget->enableEdit();
|
||||
qDebug() << layerInfoDisplayWidget;
|
||||
qDebug() << elementInfoDisplayWidget;
|
||||
|
@ -33,14 +31,11 @@ EditorWidgetItem::EditorWidgetItem(QString filePath,QWidget *parent) : QWidget(p
|
|||
connect(layerInfoDisplayWidget, &InfoDisplayWidget::triggerCentralRefresh, centralRefresh);
|
||||
connect(elementInfoDisplayWidget, &ElementPoolWidget::triggerCentralRefresh, centralRefresh);
|
||||
connect(treeWidget, &LayerTreeWidget::triggerCentralRefresh, centralRefresh);
|
||||
connect(editorSettingWidget, &EditorSettingWidget::backgroundColorChanged, this, &EditorWidgetItem::handleBackgroundColorChange);
|
||||
connect(editorSettingWidget, &EditorSettingWidget::projectNameChanged, this, &EditorWidgetItem::handleProjectNameChange);
|
||||
connect(previewWindow, &PreviewWindow::refreshElementPreviewByIndex, elementInfoDisplayWidget, &ElementPoolWidget::refreshPictureByIndex);
|
||||
connect(treeWidget, &LayerTreeWidget::displayLayerChange, previewWindow, &PreviewWindow::currentLayerChanged);
|
||||
//connect(treeWidget, &LayerTreeWidget::requireRefreshElementWidget, elementInfoDisplayWidget, &ElementPoolWidget::refresh);
|
||||
// connect(layerInfoDisplayWidget, &InfoDisplayWidget::requireRefreshElementWidget, elementInfoDisplayWidget, &ElementPoolWidget::refresh);
|
||||
connect(treeWidget, &LayerTreeWidget::displayLayerChange, this, &EditorWidgetItem::onLayerChange);
|
||||
connect(editorSettingWidget, &EditorSettingWidget::canvasSizeChanged, previewWindow, &PreviewWindow::resize);
|
||||
// connect(layerInfoDisplayWidget, &InfoDisplayWidget::requireRefreshPreview, this,
|
||||
// &EditorWidgetItem::triggerRefreshPreview);
|
||||
// connect(treeWidget, &LayerTreeWidget::requireRefreshPreview, this,
|
||||
|
@ -111,7 +106,7 @@ void EditorWidgetItem::onLayerChange(LayerWrapper *layer)
|
|||
{
|
||||
displayLayer = layer;
|
||||
// TODO : notify InfoDisplayWidget and update
|
||||
dynamic_cast<InfoDisplayWidget *>(tabWidget->widget(0))->setLayer(layer);
|
||||
ui.LayerDisplay->setLayer(layer);
|
||||
this->update();
|
||||
}
|
||||
|
||||
|
@ -165,13 +160,13 @@ void EditorWidgetItem::saveImpl(QString filePath) const
|
|||
file.close();
|
||||
}
|
||||
|
||||
void EditorWidgetItem::handleBackgroundColorChange(QColor color)
|
||||
void EditorWidgetItem::handleBackgroundColorChange(const QColor& color)
|
||||
{
|
||||
this->backgroundColor = color;
|
||||
previewWindow->setBackgroundColor(color);
|
||||
}
|
||||
|
||||
void EditorWidgetItem::handleProjectNameChange(QString name)
|
||||
void EditorWidgetItem::handleProjectNameChange(const QString& name)
|
||||
{
|
||||
this->projectName = name;
|
||||
auto parent = dynamic_cast<EditorWidget*>(this->parent);
|
||||
|
@ -180,4 +175,14 @@ void EditorWidgetItem::handleProjectNameChange(QString name)
|
|||
{
|
||||
parent->renameTab(this, name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void EditorWidgetItem::handleCanvasSizeChange(const QSize& size)
|
||||
{
|
||||
previewWindow->resize(size);
|
||||
}
|
||||
|
||||
QSize EditorWidgetItem::getCanvasReferSize() const
|
||||
{
|
||||
return previewWindow->referSize;
|
||||
}
|
||||
|
|
|
@ -24,7 +24,6 @@ class EditorWidgetItem : public QWidget
|
|||
// QT GUI PART
|
||||
Ui::EditorWidgetItem ui;
|
||||
LayerTreeWidget *treeWidget;
|
||||
QTabWidget *tabWidget;
|
||||
InfoDisplayWidget* layerInfoDisplayWidget;
|
||||
ElementPoolWidget* elementInfoDisplayWidget;
|
||||
EditorSettingWidget* editorSettingWidget;
|
||||
|
@ -45,8 +44,10 @@ public:
|
|||
void paintEvent(QPaintEvent *event) override;
|
||||
void save() const;
|
||||
void saveAs(QString filePath)const;
|
||||
void handleBackgroundColorChange(QColor color);
|
||||
void handleProjectNameChange(QString name);
|
||||
void handleBackgroundColorChange(const QColor& color);
|
||||
void handleProjectNameChange(const QString& name);
|
||||
void handleCanvasSizeChange(const QSize& size);
|
||||
QSize getCanvasReferSize() const;
|
||||
|
||||
private slots:
|
||||
void onLayerChange(LayerWrapper *layer);
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
#include "CanvasPropertyWidget.h"
|
||||
|
||||
#include <QFormLayout>
|
||||
|
||||
CanvasPropertyWidget::CanvasPropertyWidget(const EditorWidgetItem* editorWidgetItem, QWidget* parent)
|
||||
:PropertyWidget(
|
||||
std::make_unique<CanvasProperties>(editorWidgetItem->backgroundColor, editorWidgetItem->getCanvasReferSize()),
|
||||
parent
|
||||
),
|
||||
backgroundColorPicker(new ColorPicker(clonedModel->backgroundColor, this)),
|
||||
canvasWidth(new QtMaterialTextField(this)),
|
||||
canvasHeight(new QtMaterialTextField(this))
|
||||
{
|
||||
auto* layout = new QFormLayout(this);
|
||||
layout->addRow(QStringLiteral("画布背景颜色"), backgroundColorPicker);
|
||||
layout->addRow(QStringLiteral("画布宽度"), canvasWidth);
|
||||
layout->addRow(QStringLiteral("画布高度"), canvasHeight);
|
||||
|
||||
canvasWidth->setText(QString::number(clonedModel->canvasSize.width()));
|
||||
canvasHeight->setText(QString::number(clonedModel->canvasSize.height()));
|
||||
|
||||
canvasWidth->setValidator(new QIntValidator(1, std::numeric_limits<int>::max()));
|
||||
canvasHeight->setValidator(new QIntValidator(1, std::numeric_limits<int>::max()));
|
||||
|
||||
connect(backgroundColorPicker, &ColorPicker::colorChanged, [this](const QColor& color)
|
||||
{
|
||||
this->clonedModel->backgroundColor = color;
|
||||
});
|
||||
connect(canvasWidth, &QtMaterialTextField::textEdited, [this](const QString& newText)
|
||||
{
|
||||
this->clonedModel->canvasSize.setWidth(newText.toInt());
|
||||
});
|
||||
connect(canvasHeight, &QtMaterialTextField::textEdited, [this](const QString& newText)
|
||||
{
|
||||
this->clonedModel->canvasSize.setHeight(newText.toInt());
|
||||
});
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
#pragma once
|
||||
#include "PropertyWidget.h"
|
||||
#include "EditorWidgetItem.h"
|
||||
#include "EditorWidgetComponent/ColorPicker.h"
|
||||
#include <qtmaterialtextfield.h>
|
||||
|
||||
struct CanvasProperties
|
||||
{
|
||||
QColor backgroundColor;
|
||||
QSize canvasSize;
|
||||
};
|
||||
|
||||
class CanvasPropertyWidget : public PropertyWidget<CanvasProperties>
|
||||
{
|
||||
Q_OBJECT
|
||||
private:
|
||||
ColorPicker* backgroundColorPicker;
|
||||
QtMaterialTextField* canvasWidth;
|
||||
QtMaterialTextField* canvasHeight;
|
||||
|
||||
public:
|
||||
CanvasPropertyWidget(const EditorWidgetItem* editorWidgetItem, QWidget* parent = nullptr);
|
||||
};
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
#include "ProjectPropertyDialog.h"
|
||||
|
||||
#include <QLabel>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
ProjectPropertyDialog::ProjectPropertyDialog(const EditorWidgetItem* editorWidgetItem, QWidget* parent)
|
||||
: QDialog(parent),
|
||||
projectPropertyWidget(new ProjectPropertyWidget(editorWidgetItem, this)),
|
||||
canvasPropertyWidget(new CanvasPropertyWidget(editorWidgetItem, this))
|
||||
{
|
||||
auto* layout = new QVBoxLayout(this);
|
||||
layout->addWidget(new QLabel(QStringLiteral("ÏîÄ¿ÉèÖÃ"), this));
|
||||
layout->addWidget(projectPropertyWidget);
|
||||
|
||||
layout->addWidget(new QLabel(QStringLiteral("»²¼ÉèÖÃ"), this));
|
||||
layout->addWidget(canvasPropertyWidget);
|
||||
|
||||
auto* buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, this);
|
||||
layout->addWidget(buttonBox);
|
||||
|
||||
connect(buttonBox, &QDialogButtonBox::accepted, this, &ProjectPropertyDialog::accept);
|
||||
connect(buttonBox, &QDialogButtonBox::rejected, this, &ProjectPropertyDialog::reject);
|
||||
}
|
||||
|
||||
void ProjectPropertyDialog::accept()
|
||||
{
|
||||
const auto projectProperties = std::move(projectPropertyWidget->clonedModel);
|
||||
if (!projectProperties->projectName.isEmpty())
|
||||
{
|
||||
emit projectNameChanged(projectProperties->projectName);
|
||||
}
|
||||
|
||||
const auto canvasProperties = std::move(canvasPropertyWidget->clonedModel);
|
||||
if (canvasProperties->backgroundColor.isValid())
|
||||
{
|
||||
emit backgroundColorChanged(canvasProperties->backgroundColor);
|
||||
}
|
||||
if (canvasProperties->canvasSize.isValid())
|
||||
{
|
||||
emit canvasSizeChanged(canvasProperties->canvasSize);
|
||||
}
|
||||
QDialog::accept();
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
#pragma once
|
||||
#include <QDialog>
|
||||
|
||||
#include "EditorWidgetItem.h"
|
||||
#include "ProjectPropertyWidget.h"
|
||||
#include "CanvasPropertyWidget.h"
|
||||
|
||||
class ProjectPropertyDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
private:
|
||||
ProjectPropertyWidget* projectPropertyWidget;
|
||||
CanvasPropertyWidget* canvasPropertyWidget;
|
||||
|
||||
public:
|
||||
ProjectPropertyDialog(const EditorWidgetItem* editorWidgetItem, QWidget* parent = nullptr);
|
||||
|
||||
signals:
|
||||
void backgroundColorChanged(const QColor& newBackgroundColor);
|
||||
void canvasSizeChanged(const QSize& newCanvasSize);
|
||||
void projectNameChanged(const QString& newProjectName);
|
||||
|
||||
private slots:
|
||||
void accept() override;
|
||||
};
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
#include "ProjectPropertyWidget.h"
|
||||
#include <QFormLayout>
|
||||
|
||||
ProjectPropertyWidget::ProjectPropertyWidget(const EditorWidgetItem* editorWidgetItem, QWidget* parent)
|
||||
: PropertyWidget(std::make_unique<ProjectProperties>(editorWidgetItem->projectName), parent),
|
||||
projectName(new QtMaterialTextField(this))
|
||||
{
|
||||
auto* layout = new QFormLayout(this);
|
||||
layout->addRow(QStringLiteral("ÏîÄ¿Ãû³Æ"), projectName);
|
||||
|
||||
projectName->setText(editorWidgetItem->projectName);
|
||||
|
||||
connect(projectName, &QtMaterialTextField::textEdited, [this](const QString& newText)
|
||||
{
|
||||
if (!newText.isEmpty())
|
||||
{
|
||||
clonedModel->projectName = newText;
|
||||
}
|
||||
});
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
#pragma once
|
||||
#include "EditorWidgetItem.h"
|
||||
#include "PropertyWidget.h"
|
||||
#include <qtmaterialtextfield.h>
|
||||
|
||||
struct ProjectProperties
|
||||
{
|
||||
QString projectName;
|
||||
};
|
||||
|
||||
class ProjectPropertyWidget : public PropertyWidget<ProjectProperties>
|
||||
{
|
||||
Q_OBJECT
|
||||
private:
|
||||
QtMaterialTextField* projectName;
|
||||
|
||||
public:
|
||||
ProjectPropertyWidget(const EditorWidgetItem* editorWidgetItem, QWidget* parent = nullptr);
|
||||
};
|
||||
|
|
@ -0,0 +1 @@
|
|||
#include "PropertyWidget.h"
|
|
@ -0,0 +1,16 @@
|
|||
#pragma once
|
||||
#include <QWidget>
|
||||
|
||||
/**
|
||||
* \brief 配置组件基类,当确认时会发送一个 save 信号
|
||||
*/
|
||||
template<typename T>
|
||||
class PropertyWidget : public QWidget
|
||||
{
|
||||
public:
|
||||
std::unique_ptr<T> clonedModel;
|
||||
/**
|
||||
* \param clonedModel 原配置模型的克隆对象
|
||||
*/
|
||||
PropertyWidget(std::unique_ptr<T> clonedModel, QWidget* parent = nullptr) : QWidget(parent), clonedModel(std::move(clonedModel)) {}
|
||||
};
|
|
@ -78,6 +78,7 @@ InfoDisplayWidget::InfoDisplayWidget(QWidget* parent) :QWidget(parent)
|
|||
connect(ui.styleList, &LayerContainerListWidget::refreshStylePreview, [this] {
|
||||
emit triggerCentralRefresh();
|
||||
});
|
||||
this->setAutoFillBackground(true);
|
||||
}
|
||||
|
||||
void InfoDisplayWidget::setVisiable(bool visiable)
|
||||
|
|
Loading…
Reference in New Issue