修正图元更改后列表不正确的问题
parent
f175e50b7b
commit
578fd5da8e
|
@ -85,6 +85,7 @@ EditorWidgetItem::EditorWidgetItem(QString filePath,QWidget *parent) : QWidget(p
|
|||
this->projectName = source.value("project-name").toString();
|
||||
qDebug() << this->backgroundColor;
|
||||
qDebug() << this->projectName;
|
||||
elementInfoDisplayWidget->refresh();
|
||||
QTimer::singleShot(300, this, [this, centralRefresh]() {
|
||||
handleBackgroundColorChange(this->backgroundColor);
|
||||
handleProjectNameChange(this->projectName);
|
||||
|
|
|
@ -10,7 +10,7 @@ ElementPoolWidget::ElementPoolWidget(QWidget* parent)
|
|||
: QWidget(parent)
|
||||
{
|
||||
elementManager = nullptr;
|
||||
iconWidth = 120, iconHeight = 90;
|
||||
iconWidth = 120, iconHeight = 120;
|
||||
pictureList = new QListWidget(this);
|
||||
pictureList->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
pictureList->setIconSize(QSize(iconWidth, iconHeight));
|
||||
|
@ -41,7 +41,7 @@ void ElementPoolWidget::setElementList(std::vector<GraphicElement*> elements) {
|
|||
for (int index = 0; index < elements.size(); index++) {
|
||||
QListWidgetItem* pItem = new QListWidgetItem(elements[index]->name);
|
||||
QPainter* painter = new QPainter();
|
||||
QImage* image = new QImage(QSize(iconWidth - 12, iconHeight - 12), QImage::Format_ARGB32);
|
||||
QImage* image = new QImage(QSize(iconWidth - 25, iconHeight - 25), QImage::Format_ARGB32);
|
||||
image->fill(Qt::transparent);
|
||||
pItem->setIcon(QIcon(QPixmap::fromImage(*image)));
|
||||
pItem->setSizeHint(QSize(iconWidth, iconHeight));
|
||||
|
@ -84,6 +84,9 @@ void ElementPoolWidget::refresh() {
|
|||
refreshWait = false;
|
||||
if (elementManager != nullptr)
|
||||
{
|
||||
elements = elementManager->elements;
|
||||
for (int i = elements.size(); i < pictureList->count(); i++)
|
||||
pictureList->takeItem(i);
|
||||
for (int i = 0; i < elements.size(); i++)
|
||||
{
|
||||
QListWidgetItem* pItem = pictureList->item(i);
|
||||
|
@ -93,7 +96,7 @@ void ElementPoolWidget::refresh() {
|
|||
pictureList->insertItem(i, pItem);
|
||||
}
|
||||
QPainter* painter = new QPainter();
|
||||
QImage* image = new QImage(QSize(iconWidth - 12, iconHeight - 12), QImage::Format_ARGB32);
|
||||
QImage* image = new QImage(QSize(iconWidth - 25, iconHeight - 25), QImage::Format_ARGB32);
|
||||
image->fill(Qt::transparent);
|
||||
painter->begin(image);
|
||||
elements[i]->paintPreview(painter);
|
||||
|
@ -101,6 +104,7 @@ void ElementPoolWidget::refresh() {
|
|||
pItem->setIcon(QIcon(QPixmap::fromImage(*image)));
|
||||
pItem->setData(Qt::UserRole, QVariant::fromValue(image));
|
||||
pItem->setSizeHint(QSize(iconWidth, iconHeight));
|
||||
pItem->setText(elements[i]->name);
|
||||
pictureList->insertItem(i, pItem);
|
||||
}
|
||||
}
|
||||
|
@ -154,11 +158,12 @@ void ElementPoolWidget::popMenu(const QPoint& pos)
|
|||
if (bOk && !sName.isEmpty())
|
||||
{
|
||||
currentElement->name = sName;
|
||||
emit triggerCentralRefresh();
|
||||
this->refresh();
|
||||
}
|
||||
});
|
||||
menu->addAction(QString::fromLocal8Bit("ɾ³ý"), this, [this, currentElement]() {
|
||||
menu->addAction(QString::fromLocal8Bit("ɾ³ý"), this, [this, currentElement, currentIndex]() {
|
||||
this->elementManager->removeElement(currentElement);
|
||||
this->refresh();
|
||||
});
|
||||
menu->actions().last()->setDisabled(currentElement->referencedCount > 0);
|
||||
}
|
||||
|
@ -175,6 +180,7 @@ void ElementPoolWidget::popMenu(const QPoint& pos)
|
|||
QString fileName = fileInfo.fileName();
|
||||
qDebug() << fileName << " " << filePath;
|
||||
this->elementManager->createSimpleElement(fileName, filePath);
|
||||
this->refresh();
|
||||
emit triggerCentralRefresh();
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue