Merge pull request #10529 from wwmayer/cancel-button-feature

Gui: Add cancel button to transform task UI dialog
This commit is contained in:
sliptonic
2023-09-11 10:55:00 -05:00
committed by GitHub
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"

View File

@@ -20,12 +20,14 @@
* *
***************************************************************************/
#ifndef TASKCSYSDRAGGER_H
#define TASKCSYSDRAGGER_H
#include "TaskView/TaskDialog.h"
#include <App/DocumentObserver.h>
class SoDragger;
namespace Gui
{
@@ -40,13 +42,16 @@ namespace Gui
TaskCSysDragger(ViewProviderDocumentObject *vpObjectIn, SoFCCSysDragger *draggerIn);
~TaskCSysDragger() override;
QDialogButtonBox::StandardButtons getStandardButtons() const override
{ return QDialogButtonBox::Ok;}
{ return QDialogButtonBox::Ok | QDialogButtonBox::Cancel;}
void open() override;
bool accept() override;
bool reject() override;
private Q_SLOTS:
void onTIncrementSlot(double freshValue);
void onRIncrementSlot(double freshValue);
private:
static inline bool firstDrag = true;
static void dragStartCallback(void * data, SoDragger * d);
void setupGui();
App::DocumentObjectT vpObject;
SoFCCSysDragger *dragger;

View File

@@ -146,7 +146,6 @@ bool ViewProviderDragger::setEdit(int ModNum)
pcTransform->translation.connectFrom(&csysDragger->translation);
pcTransform->rotation.connectFrom(&csysDragger->rotation);
csysDragger->addStartCallback(dragStartCallback, this);
csysDragger->addFinishCallback(dragFinishCallback, this);
// dragger node is added to viewer's editing root in setEditViewer
@@ -212,12 +211,6 @@ void ViewProviderDragger::unsetEditViewer(Gui::View3DInventorViewer* viewer)
}
}
void ViewProviderDragger::dragStartCallback(void *, SoDragger *)
{
// This is called when a manipulator is about to manipulating
Gui::Application::Instance->activeDocument()->openCommand(QT_TRANSLATE_NOOP("Command", "Transform"));
}
void ViewProviderDragger::dragFinishCallback(void *data, SoDragger *d)
{
// This is called when a manipulator has done manipulating
@@ -226,7 +219,7 @@ void ViewProviderDragger::dragFinishCallback(void *data, SoDragger *d)
auto dragger = static_cast<SoFCCSysDragger *>(d);
updatePlacementFromDragger(sudoThis, dragger);
Gui::Application::Instance->activeDocument()->commitCommand();
//Gui::Application::Instance->activeDocument()->commitCommand();
}
void ViewProviderDragger::updatePlacementFromDragger(ViewProviderDragger* sudoThis, SoFCCSysDragger* draggerIn)

View File

@@ -72,9 +72,7 @@ protected:
SoFCCSysDragger *csysDragger = nullptr;
private:
static void dragStartCallback(void * data, SoDragger * d);
static void dragFinishCallback(void * data, SoDragger * d);
static void updatePlacementFromDragger(ViewProviderDragger *sudoThis, SoFCCSysDragger *draggerIn);
bool checkLink();