forked from qt-creator/qt-creator
QmlDesigner: Refactor 3D view background and grid color implementation
The new implementation doesn't require these colors to be stored in external dependencies anymore, as auxiliary properties are used for them instead. Fixes: QDS-10496 Change-Id: Ie71408617259d1af73a45f327d4bdfa4f2fa3a2b Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
This commit is contained in:
@@ -38,9 +38,7 @@ public:
|
||||
const QString &language,
|
||||
QSize captureImageMinimumSize,
|
||||
QSize captureImageMaximumSize,
|
||||
qint32 stateInstanceId,
|
||||
const QList<QColor> &edit3dBackgroundColor,
|
||||
const QColor &edit3dGridColor)
|
||||
qint32 stateInstanceId)
|
||||
: instances(instanceContainer)
|
||||
, reparentInstances(reparentContainer)
|
||||
, ids(idVector)
|
||||
@@ -56,8 +54,6 @@ public:
|
||||
, captureImageMinimumSize(captureImageMinimumSize)
|
||||
, captureImageMaximumSize(captureImageMaximumSize)
|
||||
, stateInstanceId{stateInstanceId}
|
||||
, edit3dBackgroundColor{edit3dBackgroundColor}
|
||||
, edit3dGridColor{edit3dGridColor}
|
||||
{}
|
||||
|
||||
friend QDataStream &operator<<(QDataStream &out, const CreateSceneCommand &command)
|
||||
@@ -77,8 +73,6 @@ public:
|
||||
out << command.stateInstanceId;
|
||||
out << command.captureImageMinimumSize;
|
||||
out << command.captureImageMaximumSize;
|
||||
out << command.edit3dBackgroundColor;
|
||||
out << command.edit3dGridColor;
|
||||
|
||||
return out;
|
||||
}
|
||||
@@ -100,8 +94,6 @@ public:
|
||||
in >> command.stateInstanceId;
|
||||
in >> command.captureImageMinimumSize;
|
||||
in >> command.captureImageMaximumSize;
|
||||
in >> command.edit3dBackgroundColor;
|
||||
in >> command.edit3dGridColor;
|
||||
|
||||
return in;
|
||||
}
|
||||
@@ -122,8 +114,6 @@ public:
|
||||
QSize captureImageMinimumSize;
|
||||
QSize captureImageMaximumSize;
|
||||
qint32 stateInstanceId = 0;
|
||||
QList<QColor> edit3dBackgroundColor;
|
||||
QColor edit3dGridColor;
|
||||
};
|
||||
|
||||
QDebug operator<<(QDebug debug, const CreateSceneCommand &command);
|
||||
|
@@ -44,9 +44,6 @@ enum class View3DActionType {
|
||||
ParticlesPlay,
|
||||
ParticlesRestart,
|
||||
ParticlesSeek,
|
||||
SelectBackgroundColor,
|
||||
SelectGridColor,
|
||||
ResetBackgroundColor,
|
||||
SyncBackgroundColor,
|
||||
GetNodeAtPos,
|
||||
SetBakeLightsView3D
|
||||
|
@@ -13,13 +13,13 @@ using namespace QmlDesigner;
|
||||
void BackgroundColorSelection::showBackgroundColorSelectionWidget(QWidget *parent,
|
||||
const QByteArray &key,
|
||||
AbstractView *view,
|
||||
View3DActionType actionType,
|
||||
const AuxiliaryDataKeyView &auxProp,
|
||||
const std::function<void()> &colorSelected)
|
||||
{
|
||||
if (m_dialog)
|
||||
return;
|
||||
|
||||
m_dialog = BackgroundColorSelection::createColorDialog(parent, key, view, actionType, colorSelected);
|
||||
m_dialog = BackgroundColorSelection::createColorDialog(parent, key, view, auxProp, colorSelected);
|
||||
QTC_ASSERT(m_dialog, return);
|
||||
|
||||
QObject::connect(m_dialog, &QWidget::destroyed, m_dialog, [&]() {
|
||||
@@ -30,7 +30,7 @@ void BackgroundColorSelection::showBackgroundColorSelectionWidget(QWidget *paren
|
||||
QColorDialog *BackgroundColorSelection::createColorDialog(QWidget *parent,
|
||||
const QByteArray &key,
|
||||
AbstractView *view,
|
||||
View3DActionType actionType,
|
||||
const AuxiliaryDataKeyView &auxProp,
|
||||
const std::function<void()> &colorSelected)
|
||||
{
|
||||
auto dialog = new QColorDialog(parent);
|
||||
@@ -43,8 +43,8 @@ QColorDialog *BackgroundColorSelection::createColorDialog(QWidget *parent,
|
||||
dialog->show();
|
||||
|
||||
QObject::connect(dialog, &QColorDialog::currentColorChanged, dialog,
|
||||
[actionType, view](const QColor &color) {
|
||||
Edit3DViewConfig::setColors(view, actionType, {color});
|
||||
[auxProp, view](const QColor &color) {
|
||||
Edit3DViewConfig::setColors(view, auxProp, {color});
|
||||
});
|
||||
|
||||
QObject::connect(dialog, &QColorDialog::colorSelected, dialog,
|
||||
@@ -57,8 +57,8 @@ QColorDialog *BackgroundColorSelection::createColorDialog(QWidget *parent,
|
||||
|
||||
if (Edit3DViewConfig::colorsValid(oldColorConfig)) {
|
||||
QObject::connect(dialog, &QColorDialog::rejected, dialog,
|
||||
[actionType, oldColorConfig, view]() {
|
||||
Edit3DViewConfig::setColors(view, actionType, oldColorConfig);
|
||||
[auxProp, oldColorConfig, view]() {
|
||||
Edit3DViewConfig::setColors(view, auxProp, oldColorConfig);
|
||||
});
|
||||
}
|
||||
|
||||
|
@@ -3,7 +3,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <nodeinstanceglobal.h>
|
||||
#include <auxiliarydata.h>
|
||||
|
||||
#include <QByteArray>
|
||||
#include <QObject>
|
||||
@@ -13,6 +13,11 @@ QT_FORWARD_DECLARE_CLASS(QColorDialog)
|
||||
namespace QmlDesigner {
|
||||
class AbstractView;
|
||||
|
||||
inline constexpr AuxiliaryDataKeyView edit3dGridColorProperty{AuxiliaryDataType::NodeInstanceAuxiliary,
|
||||
"edit3dGridColor"};
|
||||
inline constexpr AuxiliaryDataKeyView edit3dBgColorProperty{AuxiliaryDataType::NodeInstanceAuxiliary,
|
||||
"edit3dBgColor"};
|
||||
|
||||
class BackgroundColorSelection : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -25,14 +30,14 @@ public:
|
||||
static void showBackgroundColorSelectionWidget(QWidget *parent,
|
||||
const QByteArray &key,
|
||||
AbstractView *view,
|
||||
View3DActionType actionType,
|
||||
const AuxiliaryDataKeyView &auxProp,
|
||||
const std::function<void()> &colorSelected = {});
|
||||
|
||||
private:
|
||||
static QColorDialog *createColorDialog(QWidget *parent,
|
||||
const QByteArray &key,
|
||||
AbstractView *view,
|
||||
View3DActionType actionType,
|
||||
const AuxiliaryDataKeyView &auxProp,
|
||||
const std::function<void ()> &colorSelected);
|
||||
|
||||
inline static QColorDialog *m_dialog = nullptr;
|
||||
|
@@ -25,10 +25,8 @@ Edit3DActionTemplate::Edit3DActionTemplate(const QString &description,
|
||||
|
||||
void Edit3DActionTemplate::actionTriggered(bool b)
|
||||
{
|
||||
if (m_type != View3DActionType::Empty && m_type != View3DActionType::SelectBackgroundColor
|
||||
&& m_type != View3DActionType::SelectGridColor) {
|
||||
if (m_type != View3DActionType::Empty)
|
||||
m_view->emitView3DAction(m_type, b);
|
||||
}
|
||||
|
||||
if (m_action)
|
||||
m_action(m_selectionContext);
|
||||
|
@@ -119,6 +119,7 @@ void Edit3DView::updateActiveScene3D(const QVariantMap &sceneState)
|
||||
const QString cameraFrustumKey = QStringLiteral("showCameraFrustum");
|
||||
const QString particleEmitterKey = QStringLiteral("showParticleEmitter");
|
||||
const QString particlesPlayKey = QStringLiteral("particlePlay");
|
||||
const QString syncBgColorKey = QStringLiteral("syncBackgroundColor");
|
||||
|
||||
if (sceneState.contains(sceneKey)) {
|
||||
qint32 newActiveScene = sceneState[sceneKey].value<qint32>();
|
||||
@@ -189,6 +190,11 @@ void Edit3DView::updateActiveScene3D(const QVariantMap &sceneState)
|
||||
else
|
||||
m_particlesPlayAction->action()->setChecked(true);
|
||||
|
||||
if (sceneState.contains(syncBgColorKey))
|
||||
m_syncBackgroundColorAction->action()->setChecked(sceneState[syncBgColorKey].toBool());
|
||||
else
|
||||
m_syncBackgroundColorAction->action()->setChecked(true);
|
||||
|
||||
// Selection context change updates visible and enabled states
|
||||
SelectionContext selectionContext(this);
|
||||
selectionContext.setUpdateMode(SelectionContext::UpdateMode::Fast);
|
||||
@@ -202,6 +208,13 @@ void Edit3DView::modelAttached(Model *model)
|
||||
|
||||
syncSnapAuxPropsToSettings();
|
||||
|
||||
rootModelNode().setAuxiliaryData(edit3dGridColorProperty,
|
||||
QVariant::fromValue(Edit3DViewConfig::loadColor(
|
||||
DesignerSettingsKey::EDIT3DVIEW_GRID_COLOR)));
|
||||
rootModelNode().setAuxiliaryData(edit3dBgColorProperty,
|
||||
QVariant::fromValue(Edit3DViewConfig::loadColor(
|
||||
DesignerSettingsKey::EDIT3DVIEW_BACKGROUND_COLOR)));
|
||||
|
||||
checkImports();
|
||||
auto cachedImage = m_canvasCache.take(model);
|
||||
if (cachedImage) {
|
||||
@@ -423,10 +436,10 @@ void Edit3DView::createSelectBackgroundColorAction(QAction *syncBackgroundColorA
|
||||
edit3DWidget(),
|
||||
DesignerSettingsKey::EDIT3DVIEW_BACKGROUND_COLOR,
|
||||
this,
|
||||
View3DActionType::SelectBackgroundColor,
|
||||
edit3dBgColorProperty,
|
||||
[this, syncBackgroundColorAction]() {
|
||||
if (syncBackgroundColorAction->isChecked()) {
|
||||
Edit3DViewConfig::set(this, View3DActionType::SyncBackgroundColor, false);
|
||||
emitView3DAction(View3DActionType::SyncBackgroundColor, false);
|
||||
syncBackgroundColorAction->setChecked(false);
|
||||
}
|
||||
});
|
||||
@@ -434,7 +447,7 @@ void Edit3DView::createSelectBackgroundColorAction(QAction *syncBackgroundColorA
|
||||
|
||||
m_selectBackgroundColorAction = std::make_unique<Edit3DAction>(
|
||||
Constants::EDIT3D_EDIT_SELECT_BACKGROUND_COLOR,
|
||||
View3DActionType::SelectBackgroundColor,
|
||||
View3DActionType::Empty,
|
||||
description,
|
||||
QKeySequence(),
|
||||
false,
|
||||
@@ -456,12 +469,12 @@ void Edit3DView::createGridColorSelectionAction()
|
||||
edit3DWidget(),
|
||||
DesignerSettingsKey::EDIT3DVIEW_GRID_COLOR,
|
||||
this,
|
||||
View3DActionType::SelectGridColor);
|
||||
edit3dGridColorProperty);
|
||||
};
|
||||
|
||||
m_selectGridColorAction = std::make_unique<Edit3DAction>(
|
||||
Constants::EDIT3D_EDIT_SELECT_GRID_COLOR,
|
||||
View3DActionType::SelectGridColor,
|
||||
View3DActionType::Empty,
|
||||
description,
|
||||
QKeySequence(),
|
||||
false,
|
||||
@@ -481,22 +494,22 @@ void Edit3DView::createResetColorAction(QAction *syncBackgroundColorAction)
|
||||
|
||||
auto operation = [this, syncBackgroundColorAction](const SelectionContext &) {
|
||||
QList<QColor> bgColors = {QRgb(0x222222), QRgb(0x999999)};
|
||||
Edit3DViewConfig::setColors(this, View3DActionType::SelectBackgroundColor, bgColors);
|
||||
Edit3DViewConfig::setColors(this, edit3dBgColorProperty, bgColors);
|
||||
Edit3DViewConfig::saveColors(DesignerSettingsKey::EDIT3DVIEW_BACKGROUND_COLOR, bgColors);
|
||||
|
||||
QColor gridColor{0xaaaaaa};
|
||||
Edit3DViewConfig::setColors(this, View3DActionType::SelectGridColor, {gridColor});
|
||||
Edit3DViewConfig::setColors(this, edit3dGridColorProperty, {gridColor});
|
||||
Edit3DViewConfig::saveColors(DesignerSettingsKey::EDIT3DVIEW_GRID_COLOR, {gridColor});
|
||||
|
||||
if (syncBackgroundColorAction->isChecked()) {
|
||||
Edit3DViewConfig::set(this, View3DActionType::SyncBackgroundColor, false);
|
||||
emitView3DAction(View3DActionType::SyncBackgroundColor, false);
|
||||
syncBackgroundColorAction->setChecked(false);
|
||||
}
|
||||
};
|
||||
|
||||
m_resetColorAction = std::make_unique<Edit3DAction>(
|
||||
QmlDesigner::Constants::EDIT3D_EDIT_RESET_BACKGROUND_COLOR,
|
||||
View3DActionType::ResetBackgroundColor,
|
||||
View3DActionType::Empty,
|
||||
description,
|
||||
QKeySequence(),
|
||||
false,
|
||||
|
@@ -3,7 +3,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <nodeinstanceview.h>
|
||||
#include <auxiliarydata.h>
|
||||
#include <qmldesignerplugin.h>
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
@@ -38,20 +38,20 @@ public:
|
||||
QmlDesignerPlugin::settings().insert(key, value);
|
||||
}
|
||||
|
||||
static void setColors(AbstractView *view, View3DActionType type, const QList<QColor> &colorConfig)
|
||||
static void setColors(AbstractView *view, const AuxiliaryDataKeyView &auxProp, const QList<QColor> &colorConfig)
|
||||
{
|
||||
QVariant param;
|
||||
if (type == View3DActionType::SelectGridColor)
|
||||
if (auxProp.name == "edit3dGridColor")
|
||||
param = colorConfig.isEmpty() ? QColor() : colorConfig[0];
|
||||
else
|
||||
param = QVariant::fromValue(colorConfig);
|
||||
setVariant(view, type, param);
|
||||
setVariant(view, auxProp, param);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
static void set(AbstractView *view, View3DActionType type, const T &value)
|
||||
static void set(AbstractView *view, const AuxiliaryDataKeyView &auxProp, const T &value)
|
||||
{
|
||||
setVariant(view, type, QVariant::fromValue(value));
|
||||
setVariant(view, auxProp, QVariant::fromValue(value));
|
||||
}
|
||||
|
||||
static void saveColors(const QByteArray &key, const QList<QColor> &colorConfig)
|
||||
@@ -66,11 +66,10 @@ public:
|
||||
static bool colorsValid(const QList<QColor> &colorConfig) { return !colorConfig.isEmpty(); }
|
||||
|
||||
private:
|
||||
static void setVariant(AbstractView *view, View3DActionType type, const QVariant &value)
|
||||
static void setVariant(AbstractView *view, const AuxiliaryDataKeyView &auxProp, const QVariant &value)
|
||||
{
|
||||
view->emitView3DAction(type, value);
|
||||
view->rootModelNode().setAuxiliaryData(auxProp, value);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
} // namespace QmlDesigner
|
||||
|
@@ -29,8 +29,6 @@ public:
|
||||
virtual QString defaultPuppetToplevelBuildDirectory() const = 0;
|
||||
virtual QUrl projectUrl() const = 0;
|
||||
virtual QString currentProjectDirPath() const = 0;
|
||||
virtual QList<QColor> designerSettingsEdit3DViewBackgroundColor() const = 0;
|
||||
virtual QColor designerSettingsEdit3DViewGridColor() const = 0;
|
||||
virtual QUrl currentResourcePath() const = 0;
|
||||
virtual void parseItemLibraryDescriptions() = 0;
|
||||
virtual const DesignerSettings &designerSettings() const = 0;
|
||||
|
@@ -1182,9 +1182,6 @@ CreateSceneCommand NodeInstanceView::createCreateSceneCommand()
|
||||
if (stateNode.isValid() && stateNode.metaInfo().isQtQuickState())
|
||||
stateInstanceId = stateNode.internalId();
|
||||
|
||||
QColor gridColor = m_externalDependencies.designerSettingsEdit3DViewGridColor();
|
||||
QList<QColor> backgroundColor = m_externalDependencies.designerSettingsEdit3DViewBackgroundColor();
|
||||
|
||||
return CreateSceneCommand(instanceContainerList,
|
||||
reparentContainerList,
|
||||
idContainerList,
|
||||
@@ -1199,9 +1196,7 @@ CreateSceneCommand NodeInstanceView::createCreateSceneCommand()
|
||||
lastUsedLanguage,
|
||||
m_captureImageMinimumSize,
|
||||
m_captureImageMaximumSize,
|
||||
stateInstanceId,
|
||||
backgroundColor,
|
||||
gridColor);
|
||||
stateInstanceId);
|
||||
}
|
||||
|
||||
ClearSceneCommand NodeInstanceView::createClearSceneCommand() const
|
||||
|
@@ -62,20 +62,6 @@ QString ExternalDependencies::currentProjectDirPath() const
|
||||
return QmlDesignerPlugin::instance()->documentManager().currentProjectDirPath().toString();
|
||||
}
|
||||
|
||||
QList<QColor> ExternalDependencies::designerSettingsEdit3DViewBackgroundColor() const
|
||||
{
|
||||
return Edit3DViewConfig::loadColor(DesignerSettingsKey::EDIT3DVIEW_BACKGROUND_COLOR);
|
||||
}
|
||||
|
||||
QColor ExternalDependencies::designerSettingsEdit3DViewGridColor() const
|
||||
{
|
||||
QList<QColor> gridColorList = Edit3DViewConfig::loadColor(DesignerSettingsKey::EDIT3DVIEW_GRID_COLOR);
|
||||
if (!gridColorList.isEmpty())
|
||||
return gridColorList.front();
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
QUrl ExternalDependencies::currentResourcePath() const
|
||||
{
|
||||
return QUrl::fromLocalFile(
|
||||
|
@@ -22,8 +22,6 @@ public:
|
||||
QString defaultPuppetToplevelBuildDirectory() const override;
|
||||
QUrl projectUrl() const override;
|
||||
QString currentProjectDirPath() const override;
|
||||
QList<QColor> designerSettingsEdit3DViewBackgroundColor() const override;
|
||||
QColor designerSettingsEdit3DViewGridColor() const override;
|
||||
QUrl currentResourcePath() const override;
|
||||
void parseItemLibraryDescriptions() override;
|
||||
const DesignerSettings &designerSettings() const override;
|
||||
|
@@ -136,6 +136,11 @@ Item {
|
||||
}
|
||||
}
|
||||
|
||||
if (syncBackgroundColor)
|
||||
updateBackgroundColors([_generalHelper.sceneEnvironmentColor(sceneId)]);
|
||||
else
|
||||
updateBackgroundColors(_generalHelper.bgColor);
|
||||
|
||||
notifyActiveSceneChange();
|
||||
}
|
||||
}
|
||||
@@ -191,21 +196,14 @@ Item {
|
||||
cameraControl.alignView(cameraNodes);
|
||||
}
|
||||
|
||||
function updateViewStates(viewStates)
|
||||
{
|
||||
if ("selectBackgroundColor" in viewStates) {
|
||||
var colors = viewStates.selectBackgroundColor
|
||||
if (colors.length === 1) {
|
||||
backgroundGradientColorStart = colors[0];
|
||||
backgroundGradientColorEnd = colors[0];
|
||||
} else {
|
||||
backgroundGradientColorStart = colors[0];
|
||||
backgroundGradientColorEnd = colors[1];
|
||||
}
|
||||
function updateBackgroundColors(colors) {
|
||||
if (colors.length === 1) {
|
||||
backgroundGradientColorStart = colors[0];
|
||||
backgroundGradientColorEnd = colors[0];
|
||||
} else {
|
||||
backgroundGradientColorStart = colors[0];
|
||||
backgroundGradientColorEnd = colors[1];
|
||||
}
|
||||
|
||||
if ("selectGridColor" in viewStates)
|
||||
viewRoot.gridColor = viewStates.selectGridColor
|
||||
}
|
||||
|
||||
// If resetToDefault is true, tool states not specifically set to anything will be reset to
|
||||
@@ -224,13 +222,13 @@ Item {
|
||||
|
||||
if ("syncBackgroundColor" in toolStates) {
|
||||
syncBackgroundColor = toolStates.syncBackgroundColor;
|
||||
if (syncBackgroundColor) {
|
||||
var color = [];
|
||||
color[0] = _generalHelper.sceneEnvironmentColor(sceneId);
|
||||
updateViewStates({"selectBackgroundColor": color});
|
||||
}
|
||||
if (syncBackgroundColor)
|
||||
updateBackgroundColors([_generalHelper.sceneEnvironmentColor(sceneId)]);
|
||||
else
|
||||
updateBackgroundColors(_generalHelper.bgColor);
|
||||
} else if (resetToDefault) {
|
||||
syncBackgroundColor = false;
|
||||
updateBackgroundColors(_generalHelper.bgColor);
|
||||
}
|
||||
|
||||
if ("showSelectionBox" in toolStates)
|
||||
|
@@ -568,6 +568,11 @@ QColor GeneralHelper::sceneEnvironmentColor(const QString &sceneId) const
|
||||
return m_sceneEnvironmentColor[sceneId];
|
||||
}
|
||||
|
||||
void GeneralHelper::clearSceneEnvironmentColors()
|
||||
{
|
||||
m_sceneEnvironmentColor.clear();
|
||||
}
|
||||
|
||||
void GeneralHelper::initToolStates(const QString &sceneId, const QVariantMap &toolStates)
|
||||
{
|
||||
m_toolStates[sceneId] = toolStates;
|
||||
@@ -977,6 +982,14 @@ QVector3D GeneralHelper::adjustScaleForSnap(const QVector3D &newScale)
|
||||
return adjScale;
|
||||
}
|
||||
|
||||
void GeneralHelper::setBgColor(const QVariant &colors)
|
||||
{
|
||||
if (m_bgColor != colors) {
|
||||
m_bgColor = colors;
|
||||
emit bgColorChanged();
|
||||
}
|
||||
}
|
||||
|
||||
void GeneralHelper::handlePendingToolStateUpdate()
|
||||
{
|
||||
m_toolStateUpdateTimer.stop();
|
||||
|
@@ -32,6 +32,7 @@ class GeneralHelper : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(bool isMacOS READ isMacOS CONSTANT)
|
||||
Q_PROPERTY(QVariant bgColor READ bgColor NOTIFY bgColorChanged FINAL)
|
||||
|
||||
public:
|
||||
GeneralHelper();
|
||||
@@ -94,6 +95,7 @@ public:
|
||||
|
||||
void setSceneEnvironmentColor(const QString &sceneId, const QColor &color);
|
||||
Q_INVOKABLE QColor sceneEnvironmentColor(const QString &sceneId) const;
|
||||
void clearSceneEnvironmentColors();
|
||||
|
||||
bool isMacOS() const;
|
||||
|
||||
@@ -118,13 +120,16 @@ public:
|
||||
void setSnapRotationInterval(double interval) { m_snapRotationInterval = interval; }
|
||||
void setSnapScaleInterval(double interval) { m_snapScaleInterval = interval / 100.; }
|
||||
|
||||
void setBgColor(const QVariant &colors);
|
||||
QVariant bgColor() const { return m_bgColor; }
|
||||
|
||||
signals:
|
||||
void overlayUpdateNeeded();
|
||||
void toolStateChanged(const QString &sceneId, const QString &tool, const QVariant &toolState);
|
||||
void hiddenStateChanged(QQuick3DNode *node);
|
||||
void lockedStateChanged(QQuick3DNode *node);
|
||||
void rotationBlocksChanged();
|
||||
|
||||
void bgColorChanged();
|
||||
private:
|
||||
void handlePendingToolStateUpdate();
|
||||
QVector3D pivotScenePosition(QQuick3DNode *node) const;
|
||||
@@ -159,6 +164,8 @@ private:
|
||||
double m_snapPositionInterval = 50.;
|
||||
double m_snapRotationInterval = 5.;
|
||||
double m_snapScaleInterval = .1;
|
||||
|
||||
QVariant m_bgColor;
|
||||
};
|
||||
|
||||
}
|
||||
|
@@ -393,6 +393,25 @@ void Qt5InformationNodeInstanceServer::updateSnapSettings(const QVector<Property
|
||||
#endif
|
||||
}
|
||||
|
||||
void Qt5InformationNodeInstanceServer::updateColorSettings(const QVector<PropertyValueContainer> &valueChanges)
|
||||
{
|
||||
#ifdef QUICK3D_MODULE
|
||||
if (m_editView3DData.rootItem) {
|
||||
for (const auto &container : valueChanges) {
|
||||
if (container.name() == "edit3dGridColor") {
|
||||
QQmlProperty gridProp(m_editView3DData.rootItem, "gridColor", context());
|
||||
gridProp.write(container.value());
|
||||
} else if (container.name() == "edit3dBgColor") {
|
||||
QMetaObject::invokeMethod(m_editView3DData.rootItem, "updateBackgroundColors",
|
||||
Q_ARG(QVariant, container.value()));
|
||||
if (auto helper = qobject_cast<QmlDesigner::Internal::GeneralHelper *>(m_3dHelper))
|
||||
helper->setBgColor(container.value());
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void Qt5InformationNodeInstanceServer::removeRotationBlocks(
|
||||
[[maybe_unused]] const QVector<qint32> &instanceIds)
|
||||
{
|
||||
@@ -943,20 +962,8 @@ void Qt5InformationNodeInstanceServer::updateActiveSceneToEditView3D([[maybe_unu
|
||||
|
||||
updateView3DRect(m_active3DView);
|
||||
|
||||
auto helper = qobject_cast<QmlDesigner::Internal::GeneralHelper *>(m_3dHelper);
|
||||
if (helper) {
|
||||
if (auto helper = qobject_cast<QmlDesigner::Internal::GeneralHelper *>(m_3dHelper))
|
||||
helper->storeToolState(helper->globalStateId(), helper->lastSceneIdKey(), QVariant(sceneId), 0);
|
||||
QVariantMap toolStates = helper->getToolStates(sceneId);
|
||||
if (toolStates.contains("syncBackgroundColor")) {
|
||||
bool sync = toolStates["syncBackgroundColor"].toBool();
|
||||
if (sync) {
|
||||
QList<QColor> colors{helper->sceneEnvironmentColor(sceneId)};
|
||||
View3DActionCommand cmd(View3DActionType::SelectBackgroundColor,
|
||||
QVariant::fromValue(colors));
|
||||
view3DAction(cmd);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1036,6 +1043,9 @@ void Qt5InformationNodeInstanceServer::resolveSceneRoots()
|
||||
}
|
||||
++it;
|
||||
}
|
||||
|
||||
updateSceneEnvColorsToHelper();
|
||||
|
||||
if (updateActiveScene) {
|
||||
m_active3DView = findView3DForSceneRoot(m_active3DScene);
|
||||
updateActiveSceneToEditView3D();
|
||||
@@ -1975,18 +1985,7 @@ void Qt5InformationNodeInstanceServer::setup3DEditView(
|
||||
|
||||
m_editView3DSetupDone = true;
|
||||
|
||||
auto activeView = qobject_cast<QQuick3DViewport *>(m_active3DView);
|
||||
if (activeView) {
|
||||
QQuick3DSceneEnvironment *activeEnv = activeView->environment();
|
||||
QColor clearColor = activeEnv->clearColor();
|
||||
|
||||
if (clearColor.isValid() && helper) {
|
||||
ServerNodeInstance activeSceneInstance = active3DSceneInstance();
|
||||
const QString sceneId = activeSceneInstance.id();
|
||||
|
||||
helper->setSceneEnvironmentColor(sceneId, clearColor);
|
||||
}
|
||||
}
|
||||
updateSceneEnvColorsToHelper();
|
||||
|
||||
if (toolStates.contains({})) {
|
||||
// Update tool state to an existing no-scene state before updating the active scene to
|
||||
@@ -2000,19 +1999,6 @@ void Qt5InformationNodeInstanceServer::setup3DEditView(
|
||||
|
||||
createCameraAndLightGizmos(instanceList);
|
||||
|
||||
if (!command.edit3dBackgroundColor.isEmpty()) {
|
||||
View3DActionCommand backgroundColorCommand(View3DActionType::SelectBackgroundColor,
|
||||
QVariant::fromValue(
|
||||
command.edit3dBackgroundColor));
|
||||
view3DAction(backgroundColorCommand);
|
||||
}
|
||||
|
||||
if (command.edit3dGridColor.isValid()) {
|
||||
View3DActionCommand backgroundColorCommand(View3DActionType::SelectGridColor,
|
||||
QVariant::fromValue(command.edit3dGridColor));
|
||||
view3DAction(backgroundColorCommand);
|
||||
}
|
||||
|
||||
// Queue two renders to make sure icon gizmos update properly
|
||||
render3DEditView(2);
|
||||
#endif
|
||||
@@ -2140,6 +2126,7 @@ void Qt5InformationNodeInstanceServer::createScene(const CreateSceneCommand &com
|
||||
updateRotationBlocks(command.auxiliaryChanges);
|
||||
updateMaterialPreviewData(command.auxiliaryChanges);
|
||||
updateSnapSettings(command.auxiliaryChanges);
|
||||
updateColorSettings(command.auxiliaryChanges);
|
||||
}
|
||||
|
||||
QObject::connect(&m_renderModelNodeImageViewTimer, &QTimer::timeout,
|
||||
@@ -2346,11 +2333,10 @@ void Qt5InformationNodeInstanceServer::setSceneEnvironmentColor(const PropertyVa
|
||||
|
||||
if (toolStates.contains("syncBackgroundColor")) {
|
||||
bool sync = toolStates["syncBackgroundColor"].toBool();
|
||||
QList<QColor> colors{color};
|
||||
if (sync) {
|
||||
View3DActionCommand cmd(View3DActionType::SelectBackgroundColor,
|
||||
QVariant::fromValue(colors));
|
||||
view3DAction(cmd);
|
||||
QList<QColor> colors{color};
|
||||
QMetaObject::invokeMethod(m_editView3DData.rootItem, "updateBackgroundColors",
|
||||
Q_ARG(QVariant, QVariant::fromValue(colors)));
|
||||
}
|
||||
}
|
||||
#else
|
||||
@@ -2396,6 +2382,42 @@ QVariantList Qt5InformationNodeInstanceServer::alignCameraList() const
|
||||
return cameras;
|
||||
}
|
||||
|
||||
void Qt5InformationNodeInstanceServer::updateSceneEnvColorsToHelper()
|
||||
{
|
||||
#ifdef QUICK3D_MODULE
|
||||
// Update stored scene environment colors for all scenes
|
||||
auto helper = qobject_cast<QmlDesigner::Internal::GeneralHelper *>(m_3dHelper);
|
||||
if (!helper)
|
||||
return;
|
||||
|
||||
helper->clearSceneEnvironmentColors();
|
||||
|
||||
const auto sceneRoots = m_3DSceneMap.uniqueKeys();
|
||||
for (QObject *sceneRoot : sceneRoots) {
|
||||
auto view3D = qobject_cast<QQuick3DViewport *>(findView3DForSceneRoot(sceneRoot));
|
||||
if (!view3D)
|
||||
continue;
|
||||
|
||||
QQuick3DSceneEnvironment *env = view3D->environment();
|
||||
if (!env)
|
||||
continue;
|
||||
|
||||
QColor clearColor = env->clearColor();
|
||||
if (clearColor.isValid() && helper) {
|
||||
ServerNodeInstance sceneInstance;
|
||||
if (hasInstanceForObject(sceneRoot))
|
||||
sceneInstance = instanceForObject(sceneRoot);
|
||||
else if (hasInstanceForObject(view3D))
|
||||
sceneInstance = instanceForObject(view3D);
|
||||
|
||||
const QString sceneId = sceneInstance.id();
|
||||
|
||||
helper->setSceneEnvironmentColor(sceneId, clearColor);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void Qt5InformationNodeInstanceServer::changePropertyValues(const ChangeValuesCommand &command)
|
||||
{
|
||||
bool hasDynamicProperties = false;
|
||||
@@ -2510,13 +2532,6 @@ void Qt5InformationNodeInstanceServer::view3DAction(const View3DActionCommand &c
|
||||
case View3DActionType::SyncBackgroundColor:
|
||||
updatedToolState.insert("syncBackgroundColor", command.isEnabled());
|
||||
break;
|
||||
case View3DActionType::SelectBackgroundColor:
|
||||
updatedViewState.insert("selectBackgroundColor", command.value());
|
||||
break;
|
||||
case View3DActionType::SelectGridColor: {
|
||||
updatedViewState.insert("selectGridColor", command.value());
|
||||
break;
|
||||
}
|
||||
#ifdef QUICK3D_PARTICLES_MODULE
|
||||
case View3DActionType::ShowParticleEmitter:
|
||||
updatedToolState.insert("showParticleEmitter", command.isEnabled());
|
||||
@@ -2581,6 +2596,7 @@ void Qt5InformationNodeInstanceServer::changeAuxiliaryValues(const ChangeAuxilia
|
||||
updateRotationBlocks(command.auxiliaryChanges);
|
||||
updateMaterialPreviewData(command.auxiliaryChanges);
|
||||
updateSnapSettings(command.auxiliaryChanges);
|
||||
updateColorSettings(command.auxiliaryChanges);
|
||||
Qt5NodeInstanceServer::changeAuxiliaryValues(command);
|
||||
render3DEditView();
|
||||
}
|
||||
|
@@ -126,6 +126,7 @@ private:
|
||||
void updateMaterialPreviewData(const QVector<PropertyValueContainer> &valueChanges);
|
||||
void updateRotationBlocks(const QVector<PropertyValueContainer> &valueChanges);
|
||||
void updateSnapSettings(const QVector<PropertyValueContainer> &valueChanges);
|
||||
void updateColorSettings(const QVector<PropertyValueContainer> &valueChanges);
|
||||
void removeRotationBlocks(const QVector<qint32> &instanceIds);
|
||||
void getNodeAtPos(const QPointF &pos);
|
||||
|
||||
@@ -137,6 +138,7 @@ private:
|
||||
#endif
|
||||
void setSceneEnvironmentColor(const PropertyValueContainer &container);
|
||||
QVariantList alignCameraList() const;
|
||||
void updateSceneEnvColorsToHelper();
|
||||
|
||||
RenderViewData m_editView3DData;
|
||||
RenderViewData m_modelNode3DImageViewData;
|
||||
|
@@ -146,8 +146,6 @@ public:
|
||||
QString defaultPuppetToplevelBuildDirectory() const override { return {}; }
|
||||
QString qmlPuppetFallbackDirectory() const override { return {}; }
|
||||
QUrl projectUrl() const override { return {}; }
|
||||
QList<QColor> designerSettingsEdit3DViewBackgroundColor() const override { return {}; }
|
||||
QColor designerSettingsEdit3DViewGridColor() const override { return {}; }
|
||||
void parseItemLibraryDescriptions() override {}
|
||||
const QmlDesigner::DesignerSettings &designerSettings() const override { return settings; }
|
||||
void undoOnCurrentDesignDocument() override {}
|
||||
|
@@ -16,8 +16,6 @@ public:
|
||||
MOCK_METHOD(QString, defaultPuppetToplevelBuildDirectory, (), (const, override));
|
||||
MOCK_METHOD(QUrl, projectUrl, (), (const, override));
|
||||
MOCK_METHOD(QString, currentProjectDirPath, (), (const, override));
|
||||
MOCK_METHOD(QList<QColor>, designerSettingsEdit3DViewBackgroundColor, (), (const, override));
|
||||
MOCK_METHOD(QColor, designerSettingsEdit3DViewGridColor, (), (const, override));
|
||||
MOCK_METHOD(QUrl, currentResourcePath, (), (const, override));
|
||||
MOCK_METHOD(void, parseItemLibraryDescriptions, (), (override));
|
||||
MOCK_METHOD(const QmlDesigner::DesignerSettings &, designerSettings, (), (const, override));
|
||||
|
Reference in New Issue
Block a user