[PartDesign] Allow single (viewport) click for mapping feature selection

Parameter 'singleClickFeatureSelect' can be used to enable/disable
This commit is contained in:
0penBrain
2022-01-21 12:29:46 +01:00
committed by wmayer
parent 011d67a34a
commit 015b229162
2 changed files with 15 additions and 1 deletions

View File

@@ -442,7 +442,14 @@ App::DocumentObject* TaskFeaturePick::makeCopy(App::DocumentObject* obj, std::st
return copy;
}
void TaskFeaturePick::onSelectionChanged(const Gui::SelectionChanges& /*msg*/)
bool TaskFeaturePick::isSingleSelectionEnabled() const
{
ParameterGrp::handle hGrp = App::GetApplication().GetUserParameter().GetGroup("BaseApp")->
GetGroup("Preferences")->GetGroup("Selection");
return hGrp->GetBool("singleClickFeatureSelect", true);
}
void TaskFeaturePick::onSelectionChanged(const Gui::SelectionChanges& msg)
{
if (doSelection)
return;
@@ -454,6 +461,12 @@ void TaskFeaturePick::onSelectionChanged(const Gui::SelectionChanges& /*msg*/)
QString t = item->data(Qt::UserRole).toString();
if (t.compare(QString::fromLatin1(obj.FeatName))==0) {
item->setSelected(true);
if (msg.Type == Gui::SelectionChanges::AddSelection) {
if (isSingleSelectionEnabled()) {
QMetaObject::invokeMethod(qobject_cast<Gui::ControlSingleton*>(&Gui::Control()), "accept", Qt::QueuedConnection);
}
}
}
}
}

View File

@@ -66,6 +66,7 @@ public:
std::vector<App::DocumentObject*> getFeatures();
std::vector<App::DocumentObject*> buildFeatures();
void showExternal(bool val);
bool isSingleSelectionEnabled() const;
static App::DocumentObject* makeCopy(App::DocumentObject* obj, std::string sub, bool independent);