From 11c9ccc3a96089db29490573e6e724bda2282c7c Mon Sep 17 00:00:00 2001
From: "yang.yongquan" <3395816735@qq.com>
Date: Wed, 8 Mar 2023 19:15:42 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86ElementPool=E7=9A=84?=
=?UTF-8?q?=E6=A0=B7=E5=BC=8F?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../ArchitectureColoredPainting.vcxproj | 2 +
...rchitectureColoredPainting.vcxproj.filters | 6 +++
.../src/Editor/ElementPoolWidget.cpp | 43 +++++++++----------
.../src/Editor/ElementPoolWidget.h | 9 ++--
.../src/Editor/util/PaintingUtil.cpp | 2 +
.../src/Editor/util/PaintingUtil.h | 8 ++++
6 files changed, 42 insertions(+), 28 deletions(-)
create mode 100644 ArchitectureColoredPainting/src/Editor/util/PaintingUtil.cpp
create mode 100644 ArchitectureColoredPainting/src/Editor/util/PaintingUtil.h
diff --git a/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj b/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj
index 5a1f7bd..a60f373 100644
--- a/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj
+++ b/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj
@@ -120,6 +120,7 @@
+
@@ -202,6 +203,7 @@
+
diff --git a/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj.filters b/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj.filters
index a80ee13..df8eb42 100644
--- a/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj.filters
+++ b/ArchitectureColoredPainting/ArchitectureColoredPainting.vcxproj.filters
@@ -216,6 +216,9 @@
Source Files\Editor
+
+ Source Files\Editor\util
+
@@ -453,6 +456,9 @@
Header Files
+
+ Header Files\Editor\util
+
diff --git a/ArchitectureColoredPainting/src/Editor/ElementPoolWidget.cpp b/ArchitectureColoredPainting/src/Editor/ElementPoolWidget.cpp
index f3875a5..5a07153 100644
--- a/ArchitectureColoredPainting/src/Editor/ElementPoolWidget.cpp
+++ b/ArchitectureColoredPainting/src/Editor/ElementPoolWidget.cpp
@@ -3,25 +3,28 @@
ElementPoolWidget::ElementPoolWidget(QWidget* parent)
: QWidget(parent)
{
- parentSize = QSize(270, 210);
elementManager = nullptr;
- iconWidth = 80, iconHeight = 60;
- pictureList = new QListWidget(this);
+ iconWidth = 100, iconHeight = 75;
+ pictureList = new QListWidget();
pictureList->setIconSize(QSize(iconWidth, iconHeight));
- pictureList->setResizeMode(QListView::Adjust);
- pictureList->setViewMode(QListView::IconMode);
- pictureList->setMovement(QListView::Static);
- pictureList->setSpacing(5);
- 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->setWindowFlags(Qt::FramelessWindowHint);
+ pictureList->setResizeMode(QListWidget::Adjust);
+ pictureList->setViewMode(QListWidget::IconMode);
+ pictureList->setMovement(QListWidget::Static);
pictureList->setVerticalScrollMode(QAbstractItemView::ScrollPerPixel);
+ 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);
+
+ QLayout* layout = new QHBoxLayout();
+ layout->addWidget(pictureList);
+ setLayout(layout);
//pictureList->setFixedSize(600, 800);
- setVisible(true);
-
connect(pictureList, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(pictureItemClicked(QListWidgetItem*)));
}
@@ -32,7 +35,7 @@ void ElementPoolWidget::setElementList(std::vector elements) {
//
//QString strPath = QString("C:\\Users\\86177\\Pictures\\Screenshots\\test.png");
//QPixmap itemPixmap(strPath);
- //QPixmap itemPixmap(QSize(200,200));
+ //QPixmap itemPixmap(QSize(200, 200));
//itemPixmap.fill(Qt::red);
QPixmap itemPixmap = elements[index]->getPaintObject().getDetail();
qDebug() << this->parentWidget()->size();
@@ -43,21 +46,15 @@ void ElementPoolWidget::setElementList(std::vector elements) {
//p->setFixedSize(1920, 1080);
//lb->show();
//p->show();
-
+
QListWidgetItem* pItem = new QListWidgetItem(
- itemPixmap.scaled(QSize(iconWidth-15, iconHeight-15)),
+ itemPixmap.scaled(QSize(iconWidth - 15, iconHeight - 15)),
elements[index]->name);
pItem->setSizeHint(QSize(iconWidth, iconHeight));
pictureList->insertItem(index, pItem);
}
}
-void ElementPoolWidget::setParentSize(QSize pSize) {
- parentSize = pSize;
- iconWidth = (parentSize.width() - 30) / 3;
- iconHeight = (parentSize.width() - 30) / 4;
-}
-
ElementPoolWidget::~ElementPoolWidget() {
}
diff --git a/ArchitectureColoredPainting/src/Editor/ElementPoolWidget.h b/ArchitectureColoredPainting/src/Editor/ElementPoolWidget.h
index abd09a2..19f0961 100644
--- a/ArchitectureColoredPainting/src/Editor/ElementPoolWidget.h
+++ b/ArchitectureColoredPainting/src/Editor/ElementPoolWidget.h
@@ -4,6 +4,7 @@
#include
#include
#include
+#include
class ElementPoolWidget : public QWidget
{
@@ -12,19 +13,17 @@ private:
std::vector elements;
QListWidget* pictureList;
int iconWidth, iconHeight;
- QSize parentSize;
ElementManager* elementManager;
-
+
public:
ElementPoolWidget(QWidget* parent = nullptr);
void setElementList(std::vector elementList);
void setElementManager(ElementManager* element);
- void setParentSize(QSize pSize);
~ElementPoolWidget();
-
+
signals:
void elementSelected(GraphicElement* element);
-
+
public slots:
int pictureItemClicked(QListWidgetItem* item);
void refresh();
diff --git a/ArchitectureColoredPainting/src/Editor/util/PaintingUtil.cpp b/ArchitectureColoredPainting/src/Editor/util/PaintingUtil.cpp
new file mode 100644
index 0000000..7064a16
--- /dev/null
+++ b/ArchitectureColoredPainting/src/Editor/util/PaintingUtil.cpp
@@ -0,0 +1,2 @@
+#include "PaintingUtil.h"
+
diff --git a/ArchitectureColoredPainting/src/Editor/util/PaintingUtil.h b/ArchitectureColoredPainting/src/Editor/util/PaintingUtil.h
new file mode 100644
index 0000000..83dbac3
--- /dev/null
+++ b/ArchitectureColoredPainting/src/Editor/util/PaintingUtil.h
@@ -0,0 +1,8 @@
+#pragma once
+#include "../../Renderer/Painting/Painting.h"
+class PaintingUtil
+{
+public:
+ //static Renderer::Painting transfromToPainting();
+};
+