完成元素池,待测试

TaoZhang-Branch
yang.yongquan 2023-03-07 16:24:38 +08:00
parent 6188d6a413
commit f578fe6184
5 changed files with 95 additions and 20 deletions

View File

@ -104,6 +104,7 @@
</Link> </Link>
</ItemDefinitionGroup> </ItemDefinitionGroup>
<ItemGroup> <ItemGroup>
<ClCompile Include="ElementPoolWidget.cpp" />
<ClCompile Include="src\CaptionButton.cpp" /> <ClCompile Include="src\CaptionButton.cpp" />
<ClCompile Include="src\Editor\EditorWidget.cpp" /> <ClCompile Include="src\Editor\EditorWidget.cpp" />
<ClCompile Include="src\Editor\ElementManager.cpp" /> <ClCompile Include="src\Editor\ElementManager.cpp" />
@ -188,6 +189,7 @@
<QtMoc Include="src\Editor\RightBar\InfoDisplayWidget.h" /> <QtMoc Include="src\Editor\RightBar\InfoDisplayWidget.h" />
<QtMoc Include="src\MainWindow.h" /> <QtMoc Include="src\MainWindow.h" />
<ClInclude Include="src\Editor\ElementManager.h" /> <ClInclude Include="src\Editor\ElementManager.h" />
<QtMoc Include="src\Editor\ElementPoolWidget.h" />
<ClInclude Include="src\Editor\GraphicElement.h" /> <ClInclude Include="src\Editor\GraphicElement.h" />
<ClInclude Include="src\Editor\LayerManager.h" /> <ClInclude Include="src\Editor\LayerManager.h" />
<ClInclude Include="src\Editor\LayerStyle.h" /> <ClInclude Include="src\Editor\LayerStyle.h" />

View File

@ -213,6 +213,9 @@
<ClCompile Include="src\Editor\PixelPath.cpp"> <ClCompile Include="src\Editor\PixelPath.cpp">
<Filter>Source Files\Editor</Filter> <Filter>Source Files\Editor</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="ElementPoolWidget.cpp">
<Filter>Source Files\Editor</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<QtMoc Include="src\Renderer\RendererGLWidget.h"> <QtMoc Include="src\Renderer\RendererGLWidget.h">
@ -248,6 +251,9 @@
<QtMoc Include="src\Editor\RightBar\InfoDisplayWidget.h"> <QtMoc Include="src\Editor\RightBar\InfoDisplayWidget.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</QtMoc> </QtMoc>
<QtMoc Include="src\Editor\ElementPoolWidget.h">
<Filter>Header Files\Editor</Filter>
</QtMoc>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="..\data.json" /> <None Include="..\data.json" />

View File

@ -0,0 +1,38 @@
#include "ElementPoolWidget.h"
ElementPoolWidget::ElementPoolWidget(QWidget* parent)
: QWidget(parent)
{
iconWidth = 30, iconHeight = 40;
pictureList = new QListWidget(this);
pictureList->setIconSize(QSize(iconWidth, iconHeight));
pictureList->setResizeMode(QListView::Adjust);
pictureList->setViewMode(QListView::IconMode);
pictureList->setMovement(QListView::Static);
pictureList->setSpacing(10);
setVisible(true);
connect(pictureList, SIGNAL(vitemClicked(QListWidgetItem*)), this, SLOT(pictureItemClicked(QListWidgetItem*)));
}
void ElementPoolWidget::setElementList(std::vector<GraphicElement*> elements) {
pictureList->clear();
for (int index = 0; index < elements.size(); index++) {
QString strPath = QString("D:\\BigC\\Project\\ArchitectureColoredPainting\\svg\\test.svg");
QPixmap itemPixmap(strPath);
QListWidgetItem* pItem = new QListWidgetItem(
itemPixmap.scaled(QSize(iconWidth, iconHeight)),
elements[index]->name);
pItem->setSizeHint(QSize(iconWidth, iconHeight));
pictureList->insertItem(index, pItem);
}
}
ElementPoolWidget::~ElementPoolWidget() {
}
int ElementPoolWidget::pictureItemClicked(QListWidgetItem* item) {
return pictureList->currentRow();
}

View File

@ -0,0 +1,20 @@
#pragma once
#include <QWidget>
#include <vector>
#include <GraphicElement.h>
#include <QListWidget>
class ElementPoolWidget : public QWidget
{
Q_OBJECT
private:
//std::vector<GraphicElement*> elements;
QListWidget* pictureList;
int iconWidth, iconHeight;
public:
ElementPoolWidget(QWidget* parent = NULL);
void setElementList(std::vector<GraphicElement*> elementList);
~ElementPoolWidget();
public slots:
int pictureItemClicked(QListWidgetItem* item);
};

View File

@ -1,11 +1,12 @@
#include "CppUnitTest.h" #include "CppUnitTest.h"
#include "MainWindow.h" //#include "MainWindow.h"
#include <QGuiApplication> #include <QGuiApplication>
#include <QtWidgets/QApplication> #include <QtWidgets/QApplication>
#include <FramelessHelper/Core/private/framelessconfig_p.h> #include <FramelessHelper/Core/private/framelessconfig_p.h>
#include <util/SvgFileLoader.h> #include <util/SvgFileLoader.h>
#include "Renderer/Painting/CubicBezier.h" #include "Renderer/Painting/CubicBezier.h"
#include <Renderer/Painting/StraightLine.h> #include <Renderer/Painting/StraightLine.h>
#include <ElementPoolWidget.h>
using namespace Microsoft::VisualStudio::CppUnitTestFramework; using namespace Microsoft::VisualStudio::CppUnitTestFramework;
@ -43,24 +44,24 @@ namespace UnitTest
TEST_CLASS(UnitTest) TEST_CLASS(UnitTest)
{ {
public: public:
TEST_METHOD(TestMethod1) //TEST_METHOD(TestMethod1)
{ //{
FRAMELESSHELPER_USE_NAMESPACE // FRAMELESSHELPER_USE_NAMESPACE
FramelessHelper::Core::initialize(); // FramelessHelper::Core::initialize();
//QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling); // //QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough); // QApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
char arg[] = ""; // char arg[] = "";
char* argv[] = { arg }; // char* argv[] = { arg };
int argc = 1; // int argc = 1;
QApplication a(argc, argv); // QApplication a(argc, argv);
FramelessHelper::Core::setApplicationOSThemeAware(); // FramelessHelper::Core::setApplicationOSThemeAware();
FramelessConfig::instance()->set(Global::Option::ForceNonNativeBackgroundBlur); // FramelessConfig::instance()->set(Global::Option::ForceNonNativeBackgroundBlur);
FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow); // FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow);
FramelessConfig::instance()->set(Global::Option::CenterWindowBeforeShow); // FramelessConfig::instance()->set(Global::Option::CenterWindowBeforeShow);
MainWindow w; // MainWindow w;
w.show(); // w.show();
a.exec(); // a.exec();
} //}
}; };
TEST_CLASS(SvgLoaderTest) TEST_CLASS(SvgLoaderTest)
@ -94,5 +95,13 @@ namespace UnitTest
} }
}; };
TEST_CLASS(ElementPoolTest)
{
public:
TEST_METHOD(ElementPool) {
qInstallMessageHandler(messageHandler);
ElementPoolWidget wi;
wi.show();
}
};
} }