Core: Enable TaskDialogs to associate view (#17373)
* Core: Add possibility for task dialogs to associate a view and be able to close when associated view is closed. * TaskImage: Use task dialog view association. * Sketcher: Use task dialog view association. Preventing crash (https://github.com/FreeCAD/FreeCAD/issues/16702) * EditableDatumLabel: Use QPointer to prevent crash
This commit is contained in:
@@ -27,6 +27,13 @@
|
||||
# include <QMessageBox>
|
||||
#endif
|
||||
|
||||
#include <App/Document.h>
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/Document.h>
|
||||
#include <Gui/View3DInventor.h>
|
||||
#include <Gui/ViewProviderDocumentObject.h>
|
||||
|
||||
|
||||
#include "TaskDialog.h"
|
||||
#include "TaskView.h"
|
||||
|
||||
@@ -42,6 +49,8 @@ TaskDialog::TaskDialog()
|
||||
: QObject(nullptr), pos(North)
|
||||
, escapeButton(true)
|
||||
, autoCloseTransaction(false)
|
||||
, autoCloseDeletedDocument(false)
|
||||
, autoCloseClosedView(false)
|
||||
{
|
||||
|
||||
}
|
||||
@@ -96,6 +105,25 @@ bool TaskDialog::canClose() const
|
||||
return (ret == QMessageBox::Yes);
|
||||
}
|
||||
|
||||
void TaskDialog::associateToObject3dView(App::DocumentObject* obj)
|
||||
{
|
||||
if (!obj) {
|
||||
return;
|
||||
}
|
||||
|
||||
Gui::Document* guiDoc = Gui::Application::Instance->getDocument(obj->getDocument());
|
||||
auto* vp = Gui::Application::Instance->getViewProvider(obj);
|
||||
auto* vpdo = static_cast<Gui::ViewProviderDocumentObject*>(vp);
|
||||
auto* view = guiDoc->openEditingView3D(vpdo);
|
||||
|
||||
if (!view) {
|
||||
return;
|
||||
}
|
||||
|
||||
setAssociatedView(view);
|
||||
setAutoCloseOnClosedView(true);
|
||||
}
|
||||
|
||||
//==== calls from the TaskView ===============================================================
|
||||
|
||||
void TaskDialog::open()
|
||||
@@ -118,6 +146,11 @@ void TaskDialog::autoClosedOnDeletedDocument()
|
||||
|
||||
}
|
||||
|
||||
void TaskDialog::autoClosedOnClosedView()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void TaskDialog::clicked(int)
|
||||
{
|
||||
|
||||
|
||||
Reference in New Issue
Block a user