Skip to content

Commit

Permalink
Added a 'show' option to the Selection View's context menu
Browse files Browse the repository at this point in the history
  • Loading branch information
yorikvanhavre committed May 9, 2017
1 parent 4174aac commit 84a9f74
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/Gui/SelectionView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,22 @@ void SelectionView::toPython(void)
}
}

void SelectionView::showPart(void)
{
QListWidgetItem *item = selectionView->currentItem();
if (!item)
return;
QStringList elements = item->text().split(QString::fromLatin1("."));
if (elements.length() > 2) {
elements[2] = elements[2].split(QString::fromLatin1(" "))[0];
if ( elements[2].contains(QString::fromLatin1("Face")) || elements[2].contains(QString::fromLatin1("Edge")) ) {
Gui::Command::addModule(Gui::Command::Gui,"Part");
QString cmd = QString::fromLatin1("Part.show(App.getDocument(\"%1\").getObject(\"%2\").Shape.%3)").arg(elements[0]).arg(elements[1]).arg(elements[2]);
Gui::Command::runCommand(Gui::Command::Gui,cmd.toLatin1());
}
}
}

void SelectionView::onItemContextMenu(const QPoint& point)
{
QListWidgetItem *item = selectionView->itemAt(point);
Expand All @@ -283,6 +299,15 @@ void SelectionView::onItemContextMenu(const QPoint& point)
QAction *toPythonAction = menu.addAction(tr("To python console"),this,SLOT(toPython()));
toPythonAction->setIcon(QIcon::fromTheme(QString::fromLatin1("applications-python")));
toPythonAction->setToolTip(tr("Reveals this object and its subelements in the python console."));
QStringList elements = item->text().split(QString::fromLatin1("."));
if (elements.length() > 2) {
if ( elements[2].contains(QString::fromLatin1("Face")) || elements[2].contains(QString::fromLatin1("Edge")) ) {
// subshape-specific entries
QAction *showPart = menu.addAction(tr("Duplicate subshape"),this,SLOT(showPart()));
showPart->setIcon(QIcon(QString::fromLatin1(":/icons/ClassBrowser/member.svg")));
showPart->setToolTip(tr("Creates a standalone copy of this subshape in the document"));
}
}
menu.exec(selectionView->mapToGlobal(point));
}

Expand Down
1 change: 1 addition & 0 deletions src/Gui/SelectionView.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public Q_SLOTS:
void treeSelect(void);
void toPython(void);
void touch(void);
void showPart(void);

};

Expand Down

0 comments on commit 84a9f74

Please sign in to comment.