修改了ElementPool的样式

TaoZhang-Branch
yang.yongquan 2023-03-08 19:15:42 +08:00
parent 08e54cfc30
commit 11c9ccc3a9
6 changed files with 42 additions and 28 deletions

View File

@ -120,6 +120,7 @@
<ClCompile Include="src\Editor\ThirdPartyLib\qquick\qquicksvgparser.cpp" /> <ClCompile Include="src\Editor\ThirdPartyLib\qquick\qquicksvgparser.cpp" />
<ClCompile Include="src\Editor\ThirdPartyLib\SvgHelper.cpp" /> <ClCompile Include="src\Editor\ThirdPartyLib\SvgHelper.cpp" />
<ClCompile Include="src\Editor\util\PainterPathUtil.cpp" /> <ClCompile Include="src\Editor\util\PainterPathUtil.cpp" />
<ClCompile Include="src\Editor\util\PaintingUtil.cpp" />
<ClCompile Include="src\Editor\util\SvgFileLoader.cpp" /> <ClCompile Include="src\Editor\util\SvgFileLoader.cpp" />
<ClCompile Include="src\gl.c" /> <ClCompile Include="src\gl.c" />
<ClCompile Include="src\IconWidget.cpp" /> <ClCompile Include="src\IconWidget.cpp" />
@ -202,6 +203,7 @@
<ClInclude Include="src\Editor\ThirdPartyLib\qquick\qtquickglobal_p.h" /> <ClInclude Include="src\Editor\ThirdPartyLib\qquick\qtquickglobal_p.h" />
<ClInclude Include="src\Editor\ThirdPartyLib\SvgHelper.h" /> <ClInclude Include="src\Editor\ThirdPartyLib\SvgHelper.h" />
<ClInclude Include="src\Editor\util\PainterPathUtil.h" /> <ClInclude Include="src\Editor\util\PainterPathUtil.h" />
<ClInclude Include="src\Editor\util\PaintingUtil.h" />
<ClInclude Include="src\Editor\util\SvgFileLoader.h" /> <ClInclude Include="src\Editor\util\SvgFileLoader.h" />
<ClInclude Include="src\Renderer\IblUtils.h" /> <ClInclude Include="src\Renderer\IblUtils.h" />
<ClInclude Include="src\Renderer\Painting\BaseStyle.h" /> <ClInclude Include="src\Renderer\Painting\BaseStyle.h" />

View File

@ -216,6 +216,9 @@
<ClCompile Include="src\Editor\ElementPoolWidget.cpp"> <ClCompile Include="src\Editor\ElementPoolWidget.cpp">
<Filter>Source Files\Editor</Filter> <Filter>Source Files\Editor</Filter>
</ClCompile> </ClCompile>
<ClCompile Include="src\Editor\util\PaintingUtil.cpp">
<Filter>Source Files\Editor\util</Filter>
</ClCompile>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<QtMoc Include="src\Renderer\RendererGLWidget.h"> <QtMoc Include="src\Renderer\RendererGLWidget.h">
@ -453,6 +456,9 @@
<ClInclude Include="resource.h"> <ClInclude Include="resource.h">
<Filter>Header Files</Filter> <Filter>Header Files</Filter>
</ClInclude> </ClInclude>
<ClInclude Include="src\Editor\util\PaintingUtil.h">
<Filter>Header Files\Editor\util</Filter>
</ClInclude>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<QtRcc Include="res\MainWindow.qrc"> <QtRcc Include="res\MainWindow.qrc">

View File

@ -3,24 +3,27 @@
ElementPoolWidget::ElementPoolWidget(QWidget* parent) ElementPoolWidget::ElementPoolWidget(QWidget* parent)
: QWidget(parent) : QWidget(parent)
{ {
parentSize = QSize(270, 210);
elementManager = nullptr; elementManager = nullptr;
iconWidth = 80, iconHeight = 60; iconWidth = 100, iconHeight = 75;
pictureList = new QListWidget(this); pictureList = new QListWidget();
pictureList->setIconSize(QSize(iconWidth, iconHeight)); pictureList->setIconSize(QSize(iconWidth, iconHeight));
pictureList->setResizeMode(QListView::Adjust); pictureList->setWindowFlags(Qt::FramelessWindowHint);
pictureList->setViewMode(QListView::IconMode); pictureList->setResizeMode(QListWidget::Adjust);
pictureList->setMovement(QListView::Static); pictureList->setViewMode(QListWidget::IconMode);
pictureList->setSpacing(5); pictureList->setMovement(QListWidget::Static);
pictureList->setStyleSheet("QListWidget::Item:hover{background-color:rgba(47,46,46,0);border-radius:5px; }"
"QListWidget::item:selected{background-color:rgba(47,46,46,0);color:rgb(61,61,61);border:1px solid #000;border-radius:2px; }"
"QScrollBar:vertical{width:6px}");
pictureList->setFocusPolicy(Qt::NoFocus);
pictureList->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); pictureList->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
//pictureList->setFixedSize(600, 800); pictureList->setWrapping(true);
pictureList->setSpacing(5);
pictureList->setStyleSheet("QListWidget::Item:hover{background-color: #f5f5f5;border-radius:5px; }"
"QListWidget::item:selected{background-color:rgba(234,234,234,1);color:rgb(61,61,61);border:1px solid #778899;border-radius:2px; }"
"QScrollBar:vertical{width:6px}"
"QListWidget{outline:none;border:0px}");
pictureList->setFocusPolicy(Qt::NoFocus);
setVisible(true); QLayout* layout = new QHBoxLayout();
layout->addWidget(pictureList);
setLayout(layout);
//pictureList->setFixedSize(600, 800);
connect(pictureList, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(pictureItemClicked(QListWidgetItem*))); connect(pictureList, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(pictureItemClicked(QListWidgetItem*)));
} }
@ -32,7 +35,7 @@ void ElementPoolWidget::setElementList(std::vector<GraphicElement*> elements) {
// //
//QString strPath = QString("C:\\Users\\86177\\Pictures\\Screenshots\\test.png"); //QString strPath = QString("C:\\Users\\86177\\Pictures\\Screenshots\\test.png");
//QPixmap itemPixmap(strPath); //QPixmap itemPixmap(strPath);
//QPixmap itemPixmap(QSize(200,200)); //QPixmap itemPixmap(QSize(200, 200));
//itemPixmap.fill(Qt::red); //itemPixmap.fill(Qt::red);
QPixmap itemPixmap = elements[index]->getPaintObject().getDetail(); QPixmap itemPixmap = elements[index]->getPaintObject().getDetail();
qDebug() << this->parentWidget()->size(); qDebug() << this->parentWidget()->size();
@ -45,19 +48,13 @@ void ElementPoolWidget::setElementList(std::vector<GraphicElement*> elements) {
//p->show(); //p->show();
QListWidgetItem* pItem = new QListWidgetItem( QListWidgetItem* pItem = new QListWidgetItem(
itemPixmap.scaled(QSize(iconWidth-15, iconHeight-15)), itemPixmap.scaled(QSize(iconWidth - 15, iconHeight - 15)),
elements[index]->name); elements[index]->name);
pItem->setSizeHint(QSize(iconWidth, iconHeight)); pItem->setSizeHint(QSize(iconWidth, iconHeight));
pictureList->insertItem(index, pItem); pictureList->insertItem(index, pItem);
} }
} }
void ElementPoolWidget::setParentSize(QSize pSize) {
parentSize = pSize;
iconWidth = (parentSize.width() - 30) / 3;
iconHeight = (parentSize.width() - 30) / 4;
}
ElementPoolWidget::~ElementPoolWidget() { ElementPoolWidget::~ElementPoolWidget() {
} }

View File

@ -4,6 +4,7 @@
#include <GraphicElement.h> #include <GraphicElement.h>
#include <QListWidget> #include <QListWidget>
#include <ElementManager.h> #include <ElementManager.h>
#include <QLayout>
class ElementPoolWidget : public QWidget class ElementPoolWidget : public QWidget
{ {
@ -12,14 +13,12 @@ private:
std::vector<GraphicElement*> elements; std::vector<GraphicElement*> elements;
QListWidget* pictureList; QListWidget* pictureList;
int iconWidth, iconHeight; int iconWidth, iconHeight;
QSize parentSize;
ElementManager* elementManager; ElementManager* elementManager;
public: public:
ElementPoolWidget(QWidget* parent = nullptr); ElementPoolWidget(QWidget* parent = nullptr);
void setElementList(std::vector<GraphicElement*> elementList); void setElementList(std::vector<GraphicElement*> elementList);
void setElementManager(ElementManager* element); void setElementManager(ElementManager* element);
void setParentSize(QSize pSize);
~ElementPoolWidget(); ~ElementPoolWidget();
signals: signals:

View File

@ -0,0 +1,2 @@
#include "PaintingUtil.h"

View File

@ -0,0 +1,8 @@
#pragma once
#include "../../Renderer/Painting/Painting.h"
class PaintingUtil
{
public:
//static Renderer::Painting transfromToPainting();
};