Part: [skip ci] make sure to open a transaction when starting edit mode of primitives via context-menu
This commit is contained in:
@@ -31,9 +31,11 @@
|
||||
#include <Base/Console.h>
|
||||
#include <Base/Exception.h>
|
||||
#include <App/Document.h>
|
||||
#include <Gui/ActionFunction.h>
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/Control.h>
|
||||
#include <Gui/Document.h>
|
||||
|
||||
#include <Mod/Part/App/PartFeature.h>
|
||||
#include <Mod/Part/App/PrimitiveFeature.h>
|
||||
@@ -57,10 +59,9 @@ ViewProviderPart::~ViewProviderPart()
|
||||
|
||||
bool ViewProviderPart::doubleClicked(void)
|
||||
{
|
||||
std::string Msg("Edit ");
|
||||
Msg += this->pcObject->Label.getValue();
|
||||
try {
|
||||
Gui::Command::openCommand(Msg.c_str());
|
||||
QString text = QObject::tr("Edit %1").arg(QString::fromUtf8(getObject()->Label.getValue()));
|
||||
Gui::Command::openCommand(text.toUtf8());
|
||||
FCMD_SET_EDIT(pcObject);
|
||||
return true;
|
||||
}
|
||||
@@ -113,12 +114,25 @@ ViewProviderPrimitive::~ViewProviderPrimitive()
|
||||
|
||||
void ViewProviderPrimitive::setupContextMenu(QMenu* menu, QObject* receiver, const char* member)
|
||||
{
|
||||
QAction* act;
|
||||
act = menu->addAction(QObject::tr("Edit %1").arg(QString::fromUtf8(getObject()->Label.getValue())), receiver, member);
|
||||
Gui::ActionFunction* func = new Gui::ActionFunction(menu);
|
||||
QAction* act = menu->addAction(QObject::tr("Edit %1").arg(QString::fromUtf8(getObject()->Label.getValue())));
|
||||
act->setData(QVariant((int)ViewProvider::Default));
|
||||
func->trigger(act, boost::bind(&ViewProviderPrimitive::startDefaultEditMode, this));
|
||||
|
||||
ViewProviderPart::setupContextMenu(menu, receiver, member);
|
||||
}
|
||||
|
||||
void ViewProviderPrimitive::startDefaultEditMode()
|
||||
{
|
||||
QString text = QObject::tr("Edit %1").arg(QString::fromUtf8(getObject()->Label.getValue()));
|
||||
Gui::Command::openCommand(text.toUtf8());
|
||||
|
||||
Gui::Document* document = this->getDocument();
|
||||
if (document) {
|
||||
document->setEdit(this, ViewProvider::Default);
|
||||
}
|
||||
}
|
||||
|
||||
bool ViewProviderPrimitive::setEdit(int ModNum)
|
||||
{
|
||||
if (ModNum == ViewProvider::Default) {
|
||||
|
||||
@@ -76,6 +76,9 @@ public:
|
||||
protected:
|
||||
bool setEdit(int ModNum);
|
||||
void unsetEdit(int ModNum);
|
||||
|
||||
private:
|
||||
void startDefaultEditMode();
|
||||
};
|
||||
|
||||
} // namespace PartGui
|
||||
|
||||
Reference in New Issue
Block a user