+ fixes #0002471: In constraint context menu, 'Change Value' is always greyed out
This commit is contained in:
parent
d0e52d3578
commit
a17870c93c
|
@ -366,34 +366,38 @@ void ConstraintView::contextMenuEvent (QContextMenuEvent* event)
|
||||||
QListWidgetItem* item = currentItem();
|
QListWidgetItem* item = currentItem();
|
||||||
QList<QListWidgetItem *> items = selectedItems();
|
QList<QListWidgetItem *> items = selectedItems();
|
||||||
|
|
||||||
CONTEXT_ITEM("Sketcher_SelectElementsAssociatedWithConstraints","Select Elements","Sketcher_SelectElementsAssociatedWithConstraints",doSelectConstraints,true)
|
bool isQuantity = false;
|
||||||
|
bool isToggleDriving = false;
|
||||||
|
|
||||||
menu.addSeparator();
|
// Non-driving-constraints/measurements
|
||||||
|
if (item) {
|
||||||
if(item) // Non-driving-constraints/measurements
|
|
||||||
{
|
|
||||||
ConstraintItem *it = dynamic_cast<ConstraintItem*>(item);
|
ConstraintItem *it = dynamic_cast<ConstraintItem*>(item);
|
||||||
|
|
||||||
QAction* driven = menu.addAction(tr("Toggle to/from reference"), this, SLOT(updateDrivingStatus()));
|
|
||||||
// if its the right constraint
|
// if its the right constraint
|
||||||
if ((it->constraintType() == Sketcher::Distance ||
|
if ((it->constraintType() == Sketcher::Distance ||
|
||||||
it->constraintType() == Sketcher::DistanceX ||
|
it->constraintType() == Sketcher::DistanceX ||
|
||||||
it->constraintType() == Sketcher::DistanceY ||
|
it->constraintType() == Sketcher::DistanceY ||
|
||||||
it->constraintType() == Sketcher::Radius ||
|
it->constraintType() == Sketcher::Radius ||
|
||||||
it->constraintType() == Sketcher::Angle ||
|
it->constraintType() == Sketcher::Angle ||
|
||||||
it->constraintType() == Sketcher::SnellsLaw) && it->isEnforceable()) {
|
it->constraintType() == Sketcher::SnellsLaw)) {
|
||||||
driven->setEnabled(true);
|
|
||||||
|
isQuantity = true;
|
||||||
|
if (it->isEnforceable())
|
||||||
|
isToggleDriving = true;
|
||||||
}
|
}
|
||||||
else{
|
|
||||||
driven->setEnabled(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This does the same as a double-click and thus it should be the first action and with bold text
|
||||||
QAction* change = menu.addAction(tr("Change value"), this, SLOT(modifyCurrentItem()));
|
QAction* change = menu.addAction(tr("Change value"), this, SLOT(modifyCurrentItem()));
|
||||||
QVariant v = item ? item->data(Qt::UserRole) : QVariant();
|
change->setEnabled(isQuantity);
|
||||||
change->setEnabled(v.isValid() && it->isDriving());
|
menu.setDefaultAction(change);
|
||||||
|
|
||||||
|
QAction* driven = menu.addAction(tr("Toggle to/from reference"), this, SLOT(updateDrivingStatus()));
|
||||||
|
driven->setEnabled(isToggleDriving);
|
||||||
|
|
||||||
|
menu.addSeparator();
|
||||||
|
CONTEXT_ITEM("Sketcher_SelectElementsAssociatedWithConstraints","Select Elements","Sketcher_SelectElementsAssociatedWithConstraints",doSelectConstraints,true)
|
||||||
|
|
||||||
}
|
|
||||||
QAction* rename = menu.addAction(tr("Rename"), this, SLOT(renameCurrentItem())
|
QAction* rename = menu.addAction(tr("Rename"), this, SLOT(renameCurrentItem())
|
||||||
#ifndef Q_WS_MAC // on Mac F2 doesn't seem to trigger an edit signal
|
#ifndef Q_WS_MAC // on Mac F2 doesn't seem to trigger an edit signal
|
||||||
,QKeySequence(Qt::Key_F2)
|
,QKeySequence(Qt::Key_F2)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user