From 5cc9bae455b0158a95f42a123cd5be4776dee2bb Mon Sep 17 00:00:00 2001 From: wmayer Date: Thu, 27 Oct 2022 19:30:24 +0200 Subject: [PATCH] Gui: bind spin boxes of Placement dialog when opening it via menu --- src/Gui/CommandDoc.cpp | 13 ++++++++++++- src/Gui/Placement.cpp | 16 +++++++++++++--- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/Gui/CommandDoc.cpp b/src/Gui/CommandDoc.cpp index 4839ad7650..6cc82096ad 100644 --- a/src/Gui/CommandDoc.cpp +++ b/src/Gui/CommandDoc.cpp @@ -1498,8 +1498,19 @@ void StdCmdPlacement::activated(int iMsg) auto plm = new Gui::Dialog::TaskPlacement(); if (!sel.empty()) { App::Property* prop = sel.front()->getPropertyByName("Placement"); - if (prop && prop->getTypeId() == App::PropertyPlacement::getClassTypeId()) + if (prop && prop->getTypeId() == App::PropertyPlacement::getClassTypeId()) { plm->setPlacement(static_cast(prop)->getValue()); + + std::vector selection; + selection.reserve(sel.size()); + std::transform(sel.cbegin(), sel.cend(), std::back_inserter(selection), [](App::DocumentObject* obj) { + return Gui::SelectionObject(obj); + }); + + plm->setPropertyName(QLatin1String("Placement")); + plm->setSelection(selection); + plm->bindObject(); + } } Gui::Control().showDialog(plm); } diff --git a/src/Gui/Placement.cpp b/src/Gui/Placement.cpp index 70cf317d9c..4ea3cfc2b1 100644 --- a/src/Gui/Placement.cpp +++ b/src/Gui/Placement.cpp @@ -156,8 +156,13 @@ void Placement::setupSignalMapper() signalMapper->setMapping(it, id++); } +#if QT_VERSION < QT_VERSION_CHECK(5,15,0) connect(signalMapper, qOverload(&QSignalMapper::mapped), this, &Placement::onPlacementChanged); +#else + connect(signalMapper, &QSignalMapper::mappedInt, + this, &Placement::onPlacementChanged); +#endif } void Placement::setupDocument() @@ -229,7 +234,8 @@ void Placement::revertTransformation() { for (const auto & it : documents) { Gui::Document* document = Application::Instance->getDocument(it.c_str()); - if (!document) continue; + if (!document) + continue; if (!changeProperty) { std::vector obj = document->getDocument()-> @@ -245,7 +251,9 @@ void Placement::revertTransformation() auto property = static_cast(jt->second); Base::Placement cur = property->getValue(); Gui::ViewProvider* vp = document->getViewProvider(it); - if (vp) vp->setTransformation(cur.toMatrix()); + if (vp) { + vp->setTransformation(cur.toMatrix()); + } } } } @@ -282,7 +290,9 @@ void Placement::applyPlacement(const Base::Placement& p, bool incremental) if (!changeProperty) { Gui::ViewProvider* vp = document->getViewProvider(it); - if (vp) vp->setTransformation(cur.toMatrix()); + if (vp) { + vp->setTransformation(cur.toMatrix()); + } } else { property->setValue(cur);