Gui: Add cancel button to transform task UI dialog

Fixes #7517
This commit is contained in:
didendron
2023-09-03 16:13:39 +02:00
committed by wmayer
parent 1cdc73ff92
commit ce2c0ed322
4 changed files with 33 additions and 11 deletions

View File

@@ -67,6 +67,16 @@ TaskCSysDragger::~TaskCSysDragger()
Gui::Application::Instance->commandManager().getCommandByName("Std_PerspectiveCamera")->setEnabled(true);
}
void TaskCSysDragger::dragStartCallback(void *, SoDragger *)
{
// This is called when a manipulator is about to manipulating
if(firstDrag)
{
Gui::Application::Instance->activeDocument()->openCommand(QT_TRANSLATE_NOOP("Command", "Transform"));
firstDrag=false;
}
}
void TaskCSysDragger::setupGui()
{
auto incrementsBox = new Gui::TaskView::TaskBox(
@@ -117,6 +127,7 @@ void TaskCSysDragger::onRIncrementSlot(double freshValue)
void TaskCSysDragger::open()
{
dragger->addStartCallback(dragStartCallback, this);
//we can't have user switching camera types while dragger is shown.
Gui::Application::Instance->commandManager().getCommandByName("Std_OrthographicCamera")->setEnabled(false);
Gui::Application::Instance->commandManager().getCommandByName("Std_PerspectiveCamera")->setEnabled(false);
@@ -141,6 +152,7 @@ bool TaskCSysDragger::accept()
if (dObject) {
Gui::Document* document = Gui::Application::Instance->getDocument(dObject->getDocument());
assert(document);
firstDrag = true;
document->commitCommand();
document->resetEdit();
document->getDocument()->recompute();
@@ -148,4 +160,18 @@ bool TaskCSysDragger::accept()
return Gui::TaskView::TaskDialog::accept();
}
bool TaskCSysDragger::reject()
{
App::DocumentObject* dObject = vpObject.getObject();
if (dObject) {
Gui::Document* document = Gui::Application::Instance->getDocument(dObject->getDocument());
assert(document);
firstDrag = true;
document->abortCommand();
document->resetEdit();
document->getDocument()->recompute();
}
return Gui::TaskView::TaskDialog::reject();
}
#include "moc_TaskCSysDragger.cpp"