diff --git a/src/Mod/PartDesign/Gui/TaskChamferParameters.cpp b/src/Mod/PartDesign/Gui/TaskChamferParameters.cpp index 527a2aa0e8..893ec7713c 100644 --- a/src/Mod/PartDesign/Gui/TaskChamferParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskChamferParameters.cpp @@ -101,7 +101,7 @@ TaskChamferParameters::TaskChamferParameters(ViewProviderDressUp *DressUpView, Q connect(action, SIGNAL(triggered()), this, SLOT(onRefDeleted())); ui->listWidgetReferences->setContextMenuPolicy(Qt::ActionsContextMenu); - connect(ui->listWidgetReferences, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), + connect(ui->listWidgetReferences, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(setSelection(QListWidgetItem*))); connect(ui->listWidgetReferences, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(doubleClicked(QListWidgetItem*))); diff --git a/src/Mod/PartDesign/Gui/TaskDraftParameters.cpp b/src/Mod/PartDesign/Gui/TaskDraftParameters.cpp index e0110ffab8..7e1d0dd51f 100644 --- a/src/Mod/PartDesign/Gui/TaskDraftParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskDraftParameters.cpp @@ -115,7 +115,7 @@ TaskDraftParameters::TaskDraftParameters(ViewProviderDressUp *DressUpView, QWidg connect(action, SIGNAL(triggered()), this, SLOT(onRefDeleted())); ui->listWidgetReferences->setContextMenuPolicy(Qt::ActionsContextMenu); - connect(ui->listWidgetReferences, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), + connect(ui->listWidgetReferences, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(setSelection(QListWidgetItem*))); connect(ui->listWidgetReferences, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(doubleClicked(QListWidgetItem*))); diff --git a/src/Mod/PartDesign/Gui/TaskDressUpParameters.cpp b/src/Mod/PartDesign/Gui/TaskDressUpParameters.cpp index 171897ca2a..08689c6dae 100644 --- a/src/Mod/PartDesign/Gui/TaskDressUpParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskDressUpParameters.cpp @@ -156,10 +156,11 @@ void TaskDressUpParameters::onButtonRefRemove(const bool checked) } void TaskDressUpParameters::doubleClicked(QListWidgetItem* item) { - // executed when the user selected a new item in the list + // executed when the user double-clicks on any item in the list // shows the fillets as they are -> useful to switch out of selection mode Q_UNUSED(item) + wasDoubleClicked = true; // assure we are not in selection mode exitSelectionMode(); @@ -170,29 +171,42 @@ void TaskDressUpParameters::doubleClicked(QListWidgetItem* item) { // remove any highlights andd selections DressUpView->highlightReferences(false); Gui::Selection().clearSelection(); + + // enable next possible single-click event after double-click time passed + QTimer::singleShot(QApplication::doubleClickInterval(), this, SLOT(itemClickedTimeout())); } void TaskDressUpParameters::setSelection(QListWidgetItem* current) { - // executed when the user selected a new item in the list + // executed when the user selected an item in the list (but double-clicked it) // highlights the currently selected item - // name of the item - std::string subName = current->text().toStdString(); - // get the document name - std::string docName = DressUpView->getObject()->getDocument()->getName(); - // get the name of the body we are in - Part::BodyBase* body = PartDesign::Body::findBodyOf(DressUpView->getObject()); - std::string objName = body->getNameInDocument(); + if (!wasDoubleClicked) { + // we treat it as single-click event once the QApplication double-click time is passed + QTimer::singleShot(QApplication::doubleClickInterval(), this, SLOT(itemClickedTimeout())); - // hide fillet to see the original edge - // (a fillet creates new edges so that the original one is not available) - hideObject(); - // highlight all objects in the list - DressUpView->highlightReferences(true); - // clear existing selections - Gui::Selection().clearSelection(); - // highligh the selected item - Gui::Selection().addSelection(docName.c_str(), objName.c_str(), subName.c_str(), 0, 0, 0); + // name of the item + std::string subName = current->text().toStdString(); + // get the document name + std::string docName = DressUpView->getObject()->getDocument()->getName(); + // get the name of the body we are in + Part::BodyBase* body = PartDesign::Body::findBodyOf(DressUpView->getObject()); + std::string objName = body->getNameInDocument(); + + // hide fillet to see the original edge + // (a fillet creates new edges so that the original one is not available) + hideObject(); + // highlight all objects in the list + DressUpView->highlightReferences(true); + // clear existing selections + Gui::Selection().clearSelection(); + // highligh the selected item + Gui::Selection().addSelection(docName.c_str(), objName.c_str(), subName.c_str(), 0, 0, 0); + } +} + +void TaskDressUpParameters::itemClickedTimeout() { + // executed after double-click time passed + wasDoubleClicked = false; } const std::vector TaskDressUpParameters::getReferences() const diff --git a/src/Mod/PartDesign/Gui/TaskDressUpParameters.h b/src/Mod/PartDesign/Gui/TaskDressUpParameters.h index cc231d607b..0f8696218b 100644 --- a/src/Mod/PartDesign/Gui/TaskDressUpParameters.h +++ b/src/Mod/PartDesign/Gui/TaskDressUpParameters.h @@ -63,11 +63,13 @@ protected Q_SLOTS: void onButtonRefRemove(const bool checked); void doubleClicked(QListWidgetItem* item); void setSelection(QListWidgetItem* current); + void itemClickedTimeout(); virtual void onRefDeleted(void) = 0; protected: void exitSelectionMode(); bool referenceSelected(const Gui::SelectionChanges& msg); + bool wasDoubleClicked = false; protected: enum selectionModes { none, refAdd, refRemove, plane, line }; diff --git a/src/Mod/PartDesign/Gui/TaskFilletParameters.cpp b/src/Mod/PartDesign/Gui/TaskFilletParameters.cpp index 0879d64780..c145223b53 100644 --- a/src/Mod/PartDesign/Gui/TaskFilletParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskFilletParameters.cpp @@ -102,7 +102,7 @@ TaskFilletParameters::TaskFilletParameters(ViewProviderDressUp *DressUpView, QWi connect(deleteAction, SIGNAL(triggered()), this, SLOT(onRefDeleted())); ui->listWidgetReferences->setContextMenuPolicy(Qt::ActionsContextMenu); - connect(ui->listWidgetReferences, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), + connect(ui->listWidgetReferences, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(setSelection(QListWidgetItem*))); connect(ui->listWidgetReferences, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(doubleClicked(QListWidgetItem*))); diff --git a/src/Mod/PartDesign/Gui/TaskThicknessParameters.cpp b/src/Mod/PartDesign/Gui/TaskThicknessParameters.cpp index d7b0cdc72f..e1edc2ed89 100644 --- a/src/Mod/PartDesign/Gui/TaskThicknessParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskThicknessParameters.cpp @@ -117,7 +117,7 @@ TaskThicknessParameters::TaskThicknessParameters(ViewProviderDressUp *DressUpVie connect(action, SIGNAL(triggered()), this, SLOT(onRefDeleted())); ui->listWidgetReferences->setContextMenuPolicy(Qt::ActionsContextMenu); - connect(ui->listWidgetReferences, SIGNAL(currentItemChanged(QListWidgetItem*, QListWidgetItem*)), + connect(ui->listWidgetReferences, SIGNAL(itemClicked(QListWidgetItem*)), this, SLOT(setSelection(QListWidgetItem*))); connect(ui->listWidgetReferences, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(doubleClicked(QListWidgetItem*)));