[editor] 将项目设置放到了菜单栏中 | #4
parent
8230a98d58
commit
0d5c513523
|
@ -105,6 +105,10 @@
|
||||||
</Link>
|
</Link>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemGroup>
|
<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\EditorWidgetComponent\LayerContainerListWidget.cpp" />
|
||||||
<ClCompile Include="src\Editor\DataManager\ProjectDataManager.cpp" />
|
<ClCompile Include="src\Editor\DataManager\ProjectDataManager.cpp" />
|
||||||
<ClCompile Include="src\Editor\EditorWidgetComponent\FillStyleWidget.cpp" />
|
<ClCompile Include="src\Editor\EditorWidgetComponent\FillStyleWidget.cpp" />
|
||||||
|
@ -208,6 +212,10 @@
|
||||||
<QtMoc Include="src\Editor\RightBar\EditorSettingWidget.h" />
|
<QtMoc Include="src\Editor\RightBar\EditorSettingWidget.h" />
|
||||||
<QtMoc Include="src\Editor\EditorWidgetComponent\FillStyleWidget.h" />
|
<QtMoc Include="src\Editor\EditorWidgetComponent\FillStyleWidget.h" />
|
||||||
<QtMoc Include="src\Editor\EditorWidgetComponent\LayerContainerListWidget.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\Editor\DataManager\ProjectDataManager.h" />
|
||||||
<ClInclude Include="src\ColorHelper.hpp" />
|
<ClInclude Include="src\ColorHelper.hpp" />
|
||||||
<ClInclude Include="src\Editor\LayerWrapper.h" />
|
<ClInclude Include="src\Editor\LayerWrapper.h" />
|
||||||
|
|
|
@ -270,6 +270,18 @@
|
||||||
<ClCompile Include="src\Editor\EditorWidgetComponent\LayerContainerListWidget.cpp">
|
<ClCompile Include="src\Editor\EditorWidgetComponent\LayerContainerListWidget.cpp">
|
||||||
<Filter>Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</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>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<QtMoc Include="src\Renderer\RendererGLWidget.h">
|
<QtMoc Include="src\Renderer\RendererGLWidget.h">
|
||||||
|
@ -332,6 +344,15 @@
|
||||||
<QtMoc Include="src\Editor\ElementManager.h">
|
<QtMoc Include="src\Editor\ElementManager.h">
|
||||||
<Filter>Header Files\Editor\Element</Filter>
|
<Filter>Header Files\Editor\Element</Filter>
|
||||||
</QtMoc>
|
</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>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<None Include="..\data.json" />
|
<None Include="..\data.json" />
|
||||||
|
@ -543,6 +564,9 @@
|
||||||
<ClInclude Include="src\FluentMenuButton.h">
|
<ClInclude Include="src\FluentMenuButton.h">
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="src\Editor\Properties\PropertyWidget.h">
|
||||||
|
<Filter>Header Files</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<QtRcc Include="res\MainWindow.qrc">
|
<QtRcc Include="res\MainWindow.qrc">
|
||||||
|
|
|
@ -98,7 +98,7 @@
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QWidget" name="RightBar" native="true">
|
<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">
|
<property name="spacing">
|
||||||
<number>20</number>
|
<number>20</number>
|
||||||
</property>
|
</property>
|
||||||
|
@ -115,28 +115,24 @@
|
||||||
<number>11</number>
|
<number>11</number>
|
||||||
</property>
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QTabWidget" name="DisplayTab">
|
<widget class="QLabel" name="LayerDisplayLabel">
|
||||||
<property name="minimumSize">
|
<property name="sizePolicy">
|
||||||
<size>
|
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||||
<width>0</width>
|
<horstretch>0</horstretch>
|
||||||
<height>0</height>
|
<verstretch>0</verstretch>
|
||||||
</size>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
<property name="currentIndex">
|
<property name="text">
|
||||||
<number>0</number>
|
<string>图层信息</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignCenter</set>
|
||||||
</property>
|
</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>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="InfoDisplayWidget" name="LayerDisplay" native="true"/>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="LayerTreeWidget" name="LayerTree">
|
<widget class="LayerTreeWidget" name="LayerTree">
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
|
@ -233,12 +229,6 @@
|
||||||
<header>ElementPoolWidget.h</header>
|
<header>ElementPoolWidget.h</header>
|
||||||
<container>1</container>
|
<container>1</container>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
<customwidget>
|
|
||||||
<class>EditorSettingWidget</class>
|
|
||||||
<extends>QWidget</extends>
|
|
||||||
<header location="global">EditorSettingWidget.h</header>
|
|
||||||
<container>1</container>
|
|
||||||
</customwidget>
|
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources/>
|
<resources/>
|
||||||
<connections/>
|
<connections/>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include "EditorWidget.h"
|
#include "EditorWidget.h"
|
||||||
#include "EditorWidgetItem.h"
|
#include "EditorWidgetItem.h"
|
||||||
#include <QMouseEvent>
|
#include "Properties/ProjectPropertyDialog.h"
|
||||||
#include <QInputDialog>
|
#include <QInputDialog>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QFileDialog>
|
#include <QFileDialog>
|
||||||
|
@ -104,6 +104,21 @@ void EditorWidget::initProjectMenu()
|
||||||
projectMenuButton->setDisabled(true);
|
projectMenuButton->setDisabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto* actionSettings = new QAction(QStringLiteral("ÏîÄ¿ÉèÖÃ"), projectMenuButton);
|
auto* actionProjectSettings = new QAction(QStringLiteral("ÏîÄ¿ÉèÖÃ"), projectMenuButton);
|
||||||
projectMenuButton->addMenuAction(actionSettings);
|
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);
|
ui.setupUi(this);
|
||||||
previewWindow = ui.Preview;
|
previewWindow = ui.Preview;
|
||||||
treeWidget = ui.LayerTree;
|
treeWidget = ui.LayerTree;
|
||||||
tabWidget = ui.DisplayTab;
|
|
||||||
this->filePath = filePath;
|
this->filePath = filePath;
|
||||||
elementInfoDisplayWidget = ui.ElementDisplay;
|
elementInfoDisplayWidget = ui.ElementDisplay;
|
||||||
layerInfoDisplayWidget = dynamic_cast<InfoDisplayWidget*>(tabWidget->widget(0));
|
layerInfoDisplayWidget = ui.LayerDisplay;
|
||||||
editorSettingWidget = dynamic_cast<EditorSettingWidget*>(tabWidget->widget(1));
|
|
||||||
elementInfoDisplayWidget->enableEdit();
|
elementInfoDisplayWidget->enableEdit();
|
||||||
qDebug() << layerInfoDisplayWidget;
|
qDebug() << layerInfoDisplayWidget;
|
||||||
qDebug() << elementInfoDisplayWidget;
|
qDebug() << elementInfoDisplayWidget;
|
||||||
|
@ -33,14 +31,11 @@ EditorWidgetItem::EditorWidgetItem(QString filePath,QWidget *parent) : QWidget(p
|
||||||
connect(layerInfoDisplayWidget, &InfoDisplayWidget::triggerCentralRefresh, centralRefresh);
|
connect(layerInfoDisplayWidget, &InfoDisplayWidget::triggerCentralRefresh, centralRefresh);
|
||||||
connect(elementInfoDisplayWidget, &ElementPoolWidget::triggerCentralRefresh, centralRefresh);
|
connect(elementInfoDisplayWidget, &ElementPoolWidget::triggerCentralRefresh, centralRefresh);
|
||||||
connect(treeWidget, &LayerTreeWidget::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(previewWindow, &PreviewWindow::refreshElementPreviewByIndex, elementInfoDisplayWidget, &ElementPoolWidget::refreshPictureByIndex);
|
||||||
connect(treeWidget, &LayerTreeWidget::displayLayerChange, previewWindow, &PreviewWindow::currentLayerChanged);
|
connect(treeWidget, &LayerTreeWidget::displayLayerChange, previewWindow, &PreviewWindow::currentLayerChanged);
|
||||||
//connect(treeWidget, &LayerTreeWidget::requireRefreshElementWidget, elementInfoDisplayWidget, &ElementPoolWidget::refresh);
|
//connect(treeWidget, &LayerTreeWidget::requireRefreshElementWidget, elementInfoDisplayWidget, &ElementPoolWidget::refresh);
|
||||||
// connect(layerInfoDisplayWidget, &InfoDisplayWidget::requireRefreshElementWidget, elementInfoDisplayWidget, &ElementPoolWidget::refresh);
|
// connect(layerInfoDisplayWidget, &InfoDisplayWidget::requireRefreshElementWidget, elementInfoDisplayWidget, &ElementPoolWidget::refresh);
|
||||||
connect(treeWidget, &LayerTreeWidget::displayLayerChange, this, &EditorWidgetItem::onLayerChange);
|
connect(treeWidget, &LayerTreeWidget::displayLayerChange, this, &EditorWidgetItem::onLayerChange);
|
||||||
connect(editorSettingWidget, &EditorSettingWidget::canvasSizeChanged, previewWindow, &PreviewWindow::resize);
|
|
||||||
// connect(layerInfoDisplayWidget, &InfoDisplayWidget::requireRefreshPreview, this,
|
// connect(layerInfoDisplayWidget, &InfoDisplayWidget::requireRefreshPreview, this,
|
||||||
// &EditorWidgetItem::triggerRefreshPreview);
|
// &EditorWidgetItem::triggerRefreshPreview);
|
||||||
// connect(treeWidget, &LayerTreeWidget::requireRefreshPreview, this,
|
// connect(treeWidget, &LayerTreeWidget::requireRefreshPreview, this,
|
||||||
|
@ -111,7 +106,7 @@ void EditorWidgetItem::onLayerChange(LayerWrapper *layer)
|
||||||
{
|
{
|
||||||
displayLayer = layer;
|
displayLayer = layer;
|
||||||
// TODO : notify InfoDisplayWidget and update
|
// TODO : notify InfoDisplayWidget and update
|
||||||
dynamic_cast<InfoDisplayWidget *>(tabWidget->widget(0))->setLayer(layer);
|
ui.LayerDisplay->setLayer(layer);
|
||||||
this->update();
|
this->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,13 +160,13 @@ void EditorWidgetItem::saveImpl(QString filePath) const
|
||||||
file.close();
|
file.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorWidgetItem::handleBackgroundColorChange(QColor color)
|
void EditorWidgetItem::handleBackgroundColorChange(const QColor& color)
|
||||||
{
|
{
|
||||||
this->backgroundColor = color;
|
this->backgroundColor = color;
|
||||||
previewWindow->setBackgroundColor(color);
|
previewWindow->setBackgroundColor(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorWidgetItem::handleProjectNameChange(QString name)
|
void EditorWidgetItem::handleProjectNameChange(const QString& name)
|
||||||
{
|
{
|
||||||
this->projectName = name;
|
this->projectName = name;
|
||||||
auto parent = dynamic_cast<EditorWidget*>(this->parent);
|
auto parent = dynamic_cast<EditorWidget*>(this->parent);
|
||||||
|
@ -180,4 +175,14 @@ void EditorWidgetItem::handleProjectNameChange(QString name)
|
||||||
{
|
{
|
||||||
parent->renameTab(this, 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
|
// QT GUI PART
|
||||||
Ui::EditorWidgetItem ui;
|
Ui::EditorWidgetItem ui;
|
||||||
LayerTreeWidget *treeWidget;
|
LayerTreeWidget *treeWidget;
|
||||||
QTabWidget *tabWidget;
|
|
||||||
InfoDisplayWidget* layerInfoDisplayWidget;
|
InfoDisplayWidget* layerInfoDisplayWidget;
|
||||||
ElementPoolWidget* elementInfoDisplayWidget;
|
ElementPoolWidget* elementInfoDisplayWidget;
|
||||||
EditorSettingWidget* editorSettingWidget;
|
EditorSettingWidget* editorSettingWidget;
|
||||||
|
@ -45,8 +44,10 @@ public:
|
||||||
void paintEvent(QPaintEvent *event) override;
|
void paintEvent(QPaintEvent *event) override;
|
||||||
void save() const;
|
void save() const;
|
||||||
void saveAs(QString filePath)const;
|
void saveAs(QString filePath)const;
|
||||||
void handleBackgroundColorChange(QColor color);
|
void handleBackgroundColorChange(const QColor& color);
|
||||||
void handleProjectNameChange(QString name);
|
void handleProjectNameChange(const QString& name);
|
||||||
|
void handleCanvasSizeChange(const QSize& size);
|
||||||
|
QSize getCanvasReferSize() const;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void onLayerChange(LayerWrapper *layer);
|
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] {
|
connect(ui.styleList, &LayerContainerListWidget::refreshStylePreview, [this] {
|
||||||
emit triggerCentralRefresh();
|
emit triggerCentralRefresh();
|
||||||
});
|
});
|
||||||
|
this->setAutoFillBackground(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void InfoDisplayWidget::setVisiable(bool visiable)
|
void InfoDisplayWidget::setVisiable(bool visiable)
|
||||||
|
|
Loading…
Reference in New Issue