Prepare for implementation of component property widget
parent
c3f70e982c
commit
8474d80c4d
|
@ -106,6 +106,8 @@ HEADERS += sources/component_preview_grid_widget.h
|
||||||
SOURCES += sources/component_preview_grid_widget.cc
|
SOURCES += sources/component_preview_grid_widget.cc
|
||||||
HEADERS += sources/component_preview_images_decorator.h
|
HEADERS += sources/component_preview_images_decorator.h
|
||||||
SOURCES += sources/component_preview_images_decorator.cc
|
SOURCES += sources/component_preview_images_decorator.cc
|
||||||
|
HEADERS += sources/component_property_widget.h
|
||||||
|
SOURCES += sources/component_property_widget.cc
|
||||||
HEADERS += sources/cut_face_preview.h
|
HEADERS += sources/cut_face_preview.h
|
||||||
SOURCES += sources/cut_face_preview.cc
|
SOURCES += sources/cut_face_preview.cc
|
||||||
HEADERS += sources/dds_file.h
|
HEADERS += sources/dds_file.h
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
#include "component_property_widget.h"
|
||||||
|
|
||||||
|
ComponentPropertyWidget::ComponentPropertyWidget(Document *document, QWidget *parent):
|
||||||
|
QWidget(parent),
|
||||||
|
m_document(document)
|
||||||
|
{
|
||||||
|
setFixedSize(300, 200);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ComponentPropertyWidget::setComponentIds(const std::vector<dust3d::Uuid> &componentIds)
|
||||||
|
{
|
||||||
|
if (m_componentIds == componentIds)
|
||||||
|
return;
|
||||||
|
m_componentIds = componentIds;
|
||||||
|
if (m_componentIds.empty()) {
|
||||||
|
//hide();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// TODO:
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
#ifndef DUST3D_APPLICATION_COMPONENT_PROPERTY_WIDGET_H_
|
||||||
|
#define DUST3D_APPLICATION_COMPONENT_PROPERTY_WIDGET_H_
|
||||||
|
|
||||||
|
#include <dust3d/base/uuid.h>
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
|
class Document;
|
||||||
|
|
||||||
|
class ComponentPropertyWidget: public QWidget
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
ComponentPropertyWidget(Document *document, QWidget *parent=nullptr);
|
||||||
|
public slots:
|
||||||
|
void setComponentIds(const std::vector<dust3d::Uuid> &componentIds);
|
||||||
|
private:
|
||||||
|
Document *m_document = nullptr;
|
||||||
|
std::vector<dust3d::Uuid> m_componentIds;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
|
@ -1,6 +1,9 @@
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
#include <QWidgetAction>
|
||||||
|
#include <QMenu>
|
||||||
#include "part_manage_widget.h"
|
#include "part_manage_widget.h"
|
||||||
#include "component_preview_grid_widget.h"
|
#include "component_preview_grid_widget.h"
|
||||||
|
#include "component_property_widget.h"
|
||||||
#include "component_list_model.h"
|
#include "component_list_model.h"
|
||||||
#include "theme.h"
|
#include "theme.h"
|
||||||
#include "document.h"
|
#include "document.h"
|
||||||
|
@ -15,21 +18,22 @@ PartManageWidget::PartManageWidget(Document *document, QWidget *parent):
|
||||||
|
|
||||||
setStyleSheet("QPushButton:disabled {border: 0; color: " + Theme::gray.name() + "}");
|
setStyleSheet("QPushButton:disabled {border: 0; color: " + Theme::gray.name() + "}");
|
||||||
|
|
||||||
auto createButton = [](QChar icon) {
|
auto createButton = [](QChar icon, const QString &title) {
|
||||||
QPushButton *button = new QPushButton(icon);
|
QPushButton *button = new QPushButton(icon);
|
||||||
button->setFixedSize(Theme::toolIconSize, Theme::toolIconSize);
|
button->setFixedSize(Theme::toolIconSize, Theme::toolIconSize);
|
||||||
|
button->setToolTip(title);
|
||||||
return button;
|
return button;
|
||||||
};
|
};
|
||||||
|
|
||||||
m_levelUpButton = createButton(QChar(fa::levelup));
|
m_levelUpButton = createButton(QChar(fa::levelup), tr("Go level up"));
|
||||||
m_selectButton = createButton(QChar(fa::checksquareo));
|
m_selectButton = createButton(QChar(fa::objectgroup), tr("Select them on canvas"));
|
||||||
m_lockButton = createButton(QChar(fa::lock));
|
m_lockButton = createButton(QChar(fa::lock), tr("Lock them on canvas"));
|
||||||
m_unlockButton = createButton(QChar(fa::unlock));
|
m_unlockButton = createButton(QChar(fa::unlock), tr("Unlock them on canvas"));
|
||||||
m_showButton = createButton(QChar(fa::eye));
|
m_showButton = createButton(QChar(fa::eye), tr("Show them on canvas"));
|
||||||
m_hideButton = createButton(QChar(fa::eyeslash));
|
m_hideButton = createButton(QChar(fa::eyeslash), tr("Hide them on canvas"));
|
||||||
m_unlinkButton = createButton(QChar(fa::unlink));
|
m_unlinkButton = createButton(QChar(fa::unlink), tr("Exclude them from result generation"));
|
||||||
m_linkButton = createButton(QChar(fa::link));
|
m_linkButton = createButton(QChar(fa::link), tr("Include them in result generation"));
|
||||||
m_removeButton = createButton(QChar(fa::trash));
|
m_propertyButton = createButton(QChar(fa::sliders), tr("Configure properties"));
|
||||||
|
|
||||||
toolsLayout->addWidget(m_levelUpButton);
|
toolsLayout->addWidget(m_levelUpButton);
|
||||||
toolsLayout->addWidget(m_selectButton);
|
toolsLayout->addWidget(m_selectButton);
|
||||||
|
@ -39,7 +43,7 @@ PartManageWidget::PartManageWidget(Document *document, QWidget *parent):
|
||||||
toolsLayout->addWidget(m_unlockButton);
|
toolsLayout->addWidget(m_unlockButton);
|
||||||
toolsLayout->addWidget(m_unlinkButton);
|
toolsLayout->addWidget(m_unlinkButton);
|
||||||
toolsLayout->addWidget(m_linkButton);
|
toolsLayout->addWidget(m_linkButton);
|
||||||
toolsLayout->addWidget(m_removeButton);
|
toolsLayout->addWidget(m_propertyButton);
|
||||||
toolsLayout->addStretch();
|
toolsLayout->addStretch();
|
||||||
|
|
||||||
m_componentPreviewGridWidget = new ComponentPreviewGridWidget(document);
|
m_componentPreviewGridWidget = new ComponentPreviewGridWidget(document);
|
||||||
|
@ -49,6 +53,8 @@ PartManageWidget::PartManageWidget(Document *document, QWidget *parent):
|
||||||
connect(m_componentPreviewGridWidget, &ComponentPreviewGridWidget::unselectAllOnCanvas, this, &PartManageWidget::unselectAllOnCanvas);
|
connect(m_componentPreviewGridWidget, &ComponentPreviewGridWidget::unselectAllOnCanvas, this, &PartManageWidget::unselectAllOnCanvas);
|
||||||
connect(m_componentPreviewGridWidget, &ComponentPreviewGridWidget::selectPartOnCanvas, this, &PartManageWidget::selectPartOnCanvas);
|
connect(m_componentPreviewGridWidget, &ComponentPreviewGridWidget::selectPartOnCanvas, this, &PartManageWidget::selectPartOnCanvas);
|
||||||
|
|
||||||
|
//connect(m_componentPreviewGridWidget->selectionModel(), &QItemSelectionModel::selectionChanged, this, &PartManageWidget::showSelectedComponentProperties);
|
||||||
|
|
||||||
connect(m_levelUpButton, &QPushButton::clicked, [this]() {
|
connect(m_levelUpButton, &QPushButton::clicked, [this]() {
|
||||||
const auto &parent = m_document->findComponentParent(this->m_componentPreviewGridWidget->componentListModel()->listingComponentId());
|
const auto &parent = m_document->findComponentParent(this->m_componentPreviewGridWidget->componentListModel()->listingComponentId());
|
||||||
if (nullptr == parent)
|
if (nullptr == parent)
|
||||||
|
@ -89,12 +95,6 @@ PartManageWidget::PartManageWidget(Document *document, QWidget *parent):
|
||||||
this->m_document->saveSnapshot();
|
this->m_document->saveSnapshot();
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(m_removeButton, &QPushButton::clicked, [this]() {
|
|
||||||
for (const auto &componentId: this->m_componentPreviewGridWidget->getSelectedComponentIds())
|
|
||||||
this->m_document->removeComponent(componentId);
|
|
||||||
this->m_document->saveSnapshot();
|
|
||||||
});
|
|
||||||
|
|
||||||
connect(m_selectButton, &QPushButton::clicked, [this]() {
|
connect(m_selectButton, &QPushButton::clicked, [this]() {
|
||||||
for (const auto &componentId: this->m_componentPreviewGridWidget->getSelectedComponentIds()) {
|
for (const auto &componentId: this->m_componentPreviewGridWidget->getSelectedComponentIds()) {
|
||||||
std::vector<dust3d::Uuid> partIds;
|
std::vector<dust3d::Uuid> partIds;
|
||||||
|
@ -104,6 +104,8 @@ PartManageWidget::PartManageWidget(Document *document, QWidget *parent):
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
connect(m_propertyButton, &QPushButton::clicked, this, &PartManageWidget::showSelectedComponentProperties);
|
||||||
|
|
||||||
connect(m_document, &Document::partLockStateChanged, this, &PartManageWidget::updateToolButtons);
|
connect(m_document, &Document::partLockStateChanged, this, &PartManageWidget::updateToolButtons);
|
||||||
connect(m_document, &Document::partVisibleStateChanged, this, &PartManageWidget::updateToolButtons);
|
connect(m_document, &Document::partVisibleStateChanged, this, &PartManageWidget::updateToolButtons);
|
||||||
connect(m_document, &Document::partDisableStateChanged, this, &PartManageWidget::updateToolButtons);
|
connect(m_document, &Document::partDisableStateChanged, this, &PartManageWidget::updateToolButtons);
|
||||||
|
@ -119,6 +121,29 @@ PartManageWidget::PartManageWidget(Document *document, QWidget *parent):
|
||||||
updateLevelUpButton();
|
updateLevelUpButton();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PartManageWidget::showSelectedComponentProperties()
|
||||||
|
{
|
||||||
|
auto componentIds = m_componentPreviewGridWidget->getSelectedComponentIds();
|
||||||
|
if (componentIds.empty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
auto *propertyWidget = new ComponentPropertyWidget(m_document);
|
||||||
|
propertyWidget->setComponentIds(componentIds);
|
||||||
|
|
||||||
|
auto menu = std::make_unique<QMenu>(this);
|
||||||
|
QWidgetAction *widgetAction = new QWidgetAction(menu.get());
|
||||||
|
widgetAction->setDefaultWidget(propertyWidget);
|
||||||
|
menu->addAction(widgetAction);
|
||||||
|
|
||||||
|
auto x = mapToGlobal(QPoint(0, 0)).x();
|
||||||
|
if (x <= 0)
|
||||||
|
x = QCursor::pos().x();
|
||||||
|
menu->exec(QPoint(
|
||||||
|
x - propertyWidget->width(),
|
||||||
|
QCursor::pos().y()
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
void PartManageWidget::selectComponentByPartId(const dust3d::Uuid &partId)
|
void PartManageWidget::selectComponentByPartId(const dust3d::Uuid &partId)
|
||||||
{
|
{
|
||||||
const auto &part = m_document->findPart(partId);
|
const auto &part = m_document->findPart(partId);
|
||||||
|
@ -160,9 +185,9 @@ void PartManageWidget::updateToolButtons()
|
||||||
bool enableUnlockButton = false;
|
bool enableUnlockButton = false;
|
||||||
bool enableUnlinkButton = false;
|
bool enableUnlinkButton = false;
|
||||||
bool enableLinkButton = false;
|
bool enableLinkButton = false;
|
||||||
bool enableRemoveButton = false;
|
bool enablePropertyButton = false;
|
||||||
for (const auto &component: selectedComponents) {
|
for (const auto &component: selectedComponents) {
|
||||||
enableRemoveButton = true;
|
enablePropertyButton = true;
|
||||||
enableSelectButton = true;
|
enableSelectButton = true;
|
||||||
if (component->linkToPartId.isNull()) {
|
if (component->linkToPartId.isNull()) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -191,5 +216,5 @@ void PartManageWidget::updateToolButtons()
|
||||||
m_unlockButton->setEnabled(enableUnlockButton);
|
m_unlockButton->setEnabled(enableUnlockButton);
|
||||||
m_unlinkButton->setEnabled(enableUnlinkButton);
|
m_unlinkButton->setEnabled(enableUnlinkButton);
|
||||||
m_linkButton->setEnabled(enableLinkButton);
|
m_linkButton->setEnabled(enableLinkButton);
|
||||||
m_removeButton->setEnabled(enableRemoveButton);
|
m_propertyButton->setEnabled(enablePropertyButton);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
class Document;
|
class Document;
|
||||||
class ComponentPreviewGridWidget;
|
class ComponentPreviewGridWidget;
|
||||||
|
class ComponentPropertyWidget;
|
||||||
class QPushButton;
|
class QPushButton;
|
||||||
|
|
||||||
class PartManageWidget: public QWidget
|
class PartManageWidget: public QWidget
|
||||||
|
@ -16,6 +17,7 @@ signals:
|
||||||
void selectPartOnCanvas(const dust3d::Uuid &partId);
|
void selectPartOnCanvas(const dust3d::Uuid &partId);
|
||||||
public slots:
|
public slots:
|
||||||
void selectComponentByPartId(const dust3d::Uuid &partId);
|
void selectComponentByPartId(const dust3d::Uuid &partId);
|
||||||
|
void showSelectedComponentProperties();
|
||||||
public:
|
public:
|
||||||
PartManageWidget(Document *document, QWidget *parent=nullptr);
|
PartManageWidget(Document *document, QWidget *parent=nullptr);
|
||||||
private:
|
private:
|
||||||
|
@ -29,7 +31,7 @@ private:
|
||||||
QPushButton *m_hideButton = nullptr;
|
QPushButton *m_hideButton = nullptr;
|
||||||
QPushButton *m_unlinkButton = nullptr;
|
QPushButton *m_unlinkButton = nullptr;
|
||||||
QPushButton *m_linkButton = nullptr;
|
QPushButton *m_linkButton = nullptr;
|
||||||
QPushButton *m_removeButton = nullptr;
|
QPushButton *m_propertyButton = nullptr;
|
||||||
void updateToolButtons();
|
void updateToolButtons();
|
||||||
void updateLevelUpButton();
|
void updateLevelUpButton();
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue