Skip to content

Commit

Permalink
+ fixes #2471: In constraint context menu, 'Change Value' is always g…
Browse files Browse the repository at this point in the history
…reyed out
  • Loading branch information
wwmayer committed Mar 12, 2016
1 parent d0e52d3 commit a17870c
Showing 1 changed file with 29 additions and 25 deletions.
54 changes: 29 additions & 25 deletions src/Mod/Sketcher/Gui/TaskSketcherConstrains.cpp
Expand Up @@ -82,7 +82,7 @@ class ConstraintItem : public QListWidgetItem
sketch(s),
ConstraintNbr(ConstNbr)
{
this->setFlags(this->flags() | Qt::ItemIsEditable);
this->setFlags(this->flags() | Qt::ItemIsEditable);
}
~ConstraintItem()
{
Expand Down Expand Up @@ -365,35 +365,39 @@ void ConstraintView::contextMenuEvent (QContextMenuEvent* event)
QMenu menu;
QListWidgetItem* item = currentItem();
QList<QListWidgetItem *> items = selectedItems();

CONTEXT_ITEM("Sketcher_SelectElementsAssociatedWithConstraints","Select Elements","Sketcher_SelectElementsAssociatedWithConstraints",doSelectConstraints,true)

menu.addSeparator();

if(item) // Non-driving-constraints/measurements
{

bool isQuantity = false;
bool isToggleDriving = false;

// Non-driving-constraints/measurements
if (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 ((it->constraintType() == Sketcher::Distance ||
it->constraintType() == Sketcher::DistanceX ||
it->constraintType() == Sketcher::DistanceY ||
it->constraintType() == Sketcher::Radius ||
it->constraintType() == Sketcher::Angle ||
it->constraintType() == Sketcher::SnellsLaw) && it->isEnforceable()) {
driven->setEnabled(true);
}
else{
driven->setEnabled(false);
it->constraintType() == Sketcher::SnellsLaw)) {

isQuantity = true;
if (it->isEnforceable())
isToggleDriving = true;
}
}

QAction* change = menu.addAction(tr("Change value"), this, SLOT(modifyCurrentItem()));
QVariant v = item ? item->data(Qt::UserRole) : QVariant();
change->setEnabled(v.isValid() && it->isDriving());
// 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()));
change->setEnabled(isQuantity);
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())
#ifndef Q_WS_MAC // on Mac F2 doesn't seem to trigger an edit signal
,QKeySequence(Qt::Key_F2)
Expand Down Expand Up @@ -620,11 +624,11 @@ void TaskSketcherConstrains::on_listWidgetConstraints_itemActivated(QListWidgetI

// if its the right constraint
if (it->constraintType() == Sketcher::Distance ||
it->constraintType() == Sketcher::DistanceX ||
it->constraintType() == Sketcher::DistanceY ||
it->constraintType() == Sketcher::Radius ||
it->constraintType() == Sketcher::Angle ||
it->constraintType() == Sketcher::SnellsLaw) {
it->constraintType() == Sketcher::DistanceX ||
it->constraintType() == Sketcher::DistanceY ||
it->constraintType() == Sketcher::Radius ||
it->constraintType() == Sketcher::Angle ||
it->constraintType() == Sketcher::SnellsLaw) {

EditDatumDialog *editDatumDialog = new EditDatumDialog(this->sketchView, it->ConstraintNbr);
editDatumDialog->exec(false);
Expand Down

0 comments on commit a17870c

Please sign in to comment.