添加了ElementPoolWidget
parent
edb7e37b91
commit
368eaa6c89
|
@ -53,14 +53,14 @@
|
|||
<item>
|
||||
<widget class="QTabWidget" name="DisplayTab">
|
||||
<property name="currentIndex">
|
||||
<number>0</number>
|
||||
<number>1</number>
|
||||
</property>
|
||||
<widget class="InfoDisplayWidget" name="LayerDisplay">
|
||||
<attribute name="title">
|
||||
<string>Layer</string>
|
||||
</attribute>
|
||||
</widget>
|
||||
<widget class="QWidget" name="ElementDisplay">
|
||||
<widget class="ElementPoolWidget" name="ElementDisplay">
|
||||
<attribute name="title">
|
||||
<string>Element</string>
|
||||
</attribute>
|
||||
|
@ -107,6 +107,12 @@
|
|||
<header location="global">InfoDisplayWidget.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>ElementPoolWidget</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>ElementPoolWidget.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
|
|
|
@ -11,7 +11,9 @@ EditorWidgetItem::EditorWidgetItem(QString filePath,QWidget *parent) : QWidget(p
|
|||
tabWidget = ui.DisplayTab;
|
||||
this->filePath = filePath;
|
||||
layerInfoDisplayWidget = dynamic_cast<InfoDisplayWidget *>(tabWidget->widget(0));
|
||||
elementInfoDisplayWidget = dynamic_cast<InfoDisplayWidget *>(tabWidget->widget(1));
|
||||
elementInfoDisplayWidget = dynamic_cast<ElementPoolWidget *>(tabWidget->widget(1));
|
||||
qDebug() << layerInfoDisplayWidget;
|
||||
qDebug() << elementInfoDisplayWidget;
|
||||
connect(treeWidget, &LayerTreeWidget::displayLayerChange, this, &EditorWidgetItem::onLayerChange);
|
||||
connect(layerInfoDisplayWidget, &InfoDisplayWidget::requireRefreshPreview, this,
|
||||
&EditorWidgetItem::triggerRefreshPreview);
|
||||
|
@ -33,8 +35,11 @@ EditorWidgetItem::EditorWidgetItem(QString filePath,QWidget *parent) : QWidget(p
|
|||
QJsonObject source = jsonDoc.object();
|
||||
elementManager = new ElementManager(source,previewWindow->getRenderer());
|
||||
layerManager = new LayerManager(source, elementManager);
|
||||
elementInfoDisplayWidget->setElementManager(elementManager);
|
||||
qDebug() << layerManager->toJson();
|
||||
previewWindow->initialize(layerManager,QSize(jsonDoc.object().value("width").toDouble(),jsonDoc.object().value("height").toDouble()));
|
||||
|
||||
|
||||
if (layerManager->getRoot() != nullptr)
|
||||
{
|
||||
treeWidget->root = layerManager->getRoot();
|
||||
|
@ -49,6 +54,7 @@ EditorWidgetItem::~EditorWidgetItem()
|
|||
|
||||
void EditorWidgetItem::paintEvent(QPaintEvent *event)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void EditorWidgetItem::onLayerChange(LayerWrapper *layer)
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "ElementManager.h"
|
||||
#include "ElementPoolWidget.h"
|
||||
#include "InfoDisplayWidget.h"
|
||||
#include "LayerManager.h"
|
||||
#include "LayerTreeWidget.h"
|
||||
|
@ -23,7 +24,8 @@ class EditorWidgetItem : public QWidget
|
|||
Ui::EditorWidgetItem ui;
|
||||
LayerTreeWidget *treeWidget;
|
||||
QTabWidget *tabWidget;
|
||||
InfoDisplayWidget *layerInfoDisplayWidget, *elementInfoDisplayWidget;
|
||||
InfoDisplayWidget* layerInfoDisplayWidget;
|
||||
ElementPoolWidget* elementInfoDisplayWidget;
|
||||
// QT DATA PART
|
||||
LayerWrapper *displayLayer;
|
||||
GraphicElement *displayElement;
|
||||
|
|
|
@ -11,7 +11,7 @@ class Renderer::ElementRenderer;
|
|||
|
||||
class ElementManager
|
||||
{
|
||||
private:
|
||||
public:
|
||||
vector<GraphicElement *> elements;
|
||||
|
||||
public:
|
||||
|
|
|
@ -19,11 +19,23 @@ ElementPoolWidget::ElementPoolWidget(QWidget* parent)
|
|||
|
||||
void ElementPoolWidget::setElementList(std::vector<GraphicElement*> elements) {
|
||||
pictureList->clear();
|
||||
this->elements = elements;
|
||||
for (int index = 0; index < elements.size(); index++) {
|
||||
//
|
||||
//QString strPath = QString("C:\\Users\\86177\\Pictures\\Screenshots\\test.png");
|
||||
//QPixmap itemPixmap(strPath);
|
||||
QPixmap itemPixmap = elements[index]->getPaintObject().getPixmap();
|
||||
QPixmap itemPixmap(QSize(200,200));
|
||||
itemPixmap.fill(Qt::red);
|
||||
//QPixmap itemPixmap = elements[index]->getPaintObject().getDetail();
|
||||
qDebug() << this->parentWidget()->size();
|
||||
//auto p = new QWidget();
|
||||
//auto lb = new QLabel(p);
|
||||
//lb->setPixmap(itemPixmap);
|
||||
//lb->setFixedSize(1920, 1080);
|
||||
//p->setFixedSize(1920, 1080);
|
||||
//lb->show();
|
||||
//p->show();
|
||||
|
||||
QListWidgetItem* pItem = new QListWidgetItem(
|
||||
itemPixmap.scaled(QSize(iconWidth-20, iconHeight-20)),
|
||||
elements[index]->name);
|
||||
|
@ -38,5 +50,12 @@ ElementPoolWidget::~ElementPoolWidget() {
|
|||
|
||||
int ElementPoolWidget::pictureItemClicked(QListWidgetItem* item) {
|
||||
//qDebug() << pictureList->currentRow();
|
||||
emit elementSelected(this->elements[pictureList->currentRow()]);
|
||||
return pictureList->currentRow();
|
||||
}
|
||||
|
||||
void ElementPoolWidget::setElementManager(ElementManager* element)
|
||||
{
|
||||
this->elementManager = element;
|
||||
this->setElementList(this->elementManager->elements);
|
||||
}
|
|
@ -3,17 +3,26 @@
|
|||
#include <vector>
|
||||
#include <GraphicElement.h>
|
||||
#include <QListWidget>
|
||||
#include <ElementManager.h>
|
||||
|
||||
class ElementPoolWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
private:
|
||||
//std::vector<GraphicElement*> elements;
|
||||
std::vector<GraphicElement*> elements;
|
||||
QListWidget* pictureList;
|
||||
int iconWidth, iconHeight;
|
||||
ElementManager* elementManager;
|
||||
|
||||
public:
|
||||
ElementPoolWidget(QWidget* parent = NULL);
|
||||
ElementPoolWidget(QWidget* parent = nullptr);
|
||||
void setElementList(std::vector<GraphicElement*> elementList);
|
||||
void setElementManager(ElementManager* element);
|
||||
~ElementPoolWidget();
|
||||
|
||||
signals:
|
||||
void elementSelected(GraphicElement* element);
|
||||
|
||||
public slots:
|
||||
int pictureItemClicked(QListWidgetItem* item);
|
||||
};
|
||||
|
|
|
@ -84,4 +84,15 @@ QPixmap PixelPath::resizedPixel(QSize size)const
|
|||
painter.setRenderHint(QPainter::HighQualityAntialiasing);
|
||||
painter.drawPixmap(0, 0, pixmap.scaled(size, Qt::IgnoreAspectRatio, Qt::SmoothTransformation));
|
||||
return result;
|
||||
}
|
||||
|
||||
QPixmap PixelPath::getDetail()const
|
||||
{
|
||||
QPixmap result;
|
||||
auto rect = boundingRect.toRect();
|
||||
rect.setHeight(rect.height() + 20);
|
||||
rect.setWidth(rect.width() + 20);
|
||||
qDebug() << rect;
|
||||
result = pixmap.copy(rect);
|
||||
return result;
|
||||
}
|
|
@ -23,4 +23,5 @@ public:
|
|||
void clear();
|
||||
PixelPath trans(QTransform& mat)const;
|
||||
QPixmap resizedPixel(QSize size)const;
|
||||
QPixmap getDetail()const;
|
||||
};
|
|
@ -11,11 +11,7 @@ void InfoDisplayWidget::setLayer(LayerWrapper *layer)
|
|||
this->displayLayer = layer;
|
||||
generateLayerForm();
|
||||
}
|
||||
void InfoDisplayWidget::setElement(GraphicElement *element)
|
||||
{
|
||||
this->displayElement = element;
|
||||
generateElementForm();
|
||||
}
|
||||
|
||||
void InfoDisplayWidget::generateLayerForm()
|
||||
{
|
||||
QLayoutItem *item;
|
||||
|
@ -144,12 +140,13 @@ void InfoDisplayWidget::generateLayerForm()
|
|||
|
||||
void InfoDisplayWidget::generateElementForm()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void InfoDisplayWidget::triggerSelfRefresh()
|
||||
{
|
||||
if (this->displayLayer != nullptr)
|
||||
this->generateLayerForm();
|
||||
if (this->displayElement != nullptr)
|
||||
else
|
||||
this->generateElementForm();
|
||||
}
|
|
@ -4,17 +4,17 @@
|
|||
#include <QFormLayout>
|
||||
#include <QLabel>
|
||||
#include <QWidget>
|
||||
#include "ElementPoolWidget.h"
|
||||
|
||||
class InfoDisplayWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
private:
|
||||
LayerWrapper *displayLayer;
|
||||
GraphicElement *displayElement;
|
||||
|
||||
|
||||
public:
|
||||
void setLayer(LayerWrapper *layer);
|
||||
void setElement(GraphicElement *element);
|
||||
void generateLayerForm();
|
||||
void generateElementForm();
|
||||
|
||||
|
|
Loading…
Reference in New Issue