Add missing parent for messagebox and other popups

Unparented popups can easily get lost in backround, but they still block top level event loop when run with ::exec() thus preventing interactions with main window.  This mainly happens on wayland. Setting the parent ensures they are always kept on top and reasonably positioned.
This commit is contained in:
Karliss
2025-03-13 12:00:17 +02:00
committed by Chris Hennes
parent 223f12caf7
commit 42790475d6
22 changed files with 33 additions and 24 deletions

View File

@@ -892,7 +892,7 @@ void prepareProfileBased(PartDesign::Body *pcActiveBody, Gui::Command* cmd, cons
(which.compare("Pocket") == 0)) {
if (!pcActiveBody->isSolid()) {
QMessageBox msgBox;
QMessageBox msgBox(Gui::getMainWindow());
msgBox.setText(QObject::tr("Cannot use this command as there is no solid to subtract from."));
msgBox.setInformativeText(QObject::tr("Ensure that the body contains a feature before attempting a subtractive command."));
msgBox.setStandardButtons(QMessageBox::Ok);
@@ -914,7 +914,7 @@ void prepareProfileBased(PartDesign::Body *pcActiveBody, Gui::Command* cmd, cons
}
}
if (!onlyAllowed) {
QMessageBox msgBox;
QMessageBox msgBox(Gui::getMainWindow());
msgBox.setText(QObject::tr("Cannot use selected object. Selected object must belong to the active body"));
msgBox.setInformativeText(QObject::tr("Consider using a ShapeBinder or a BaseFeature to reference external geometry in a body."));
msgBox.setStandardButtons(QMessageBox::Ok);
@@ -1012,7 +1012,7 @@ void prepareProfileBased(PartDesign::Body *pcActiveBody, Gui::Command* cmd, cons
Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog();
PartDesignGui::TaskDlgFeaturePick *pickDlg = qobject_cast<PartDesignGui::TaskDlgFeaturePick *>(dlg);
if (dlg && !pickDlg) {
QMessageBox msgBox;
QMessageBox msgBox(Gui::getMainWindow());
msgBox.setText(QObject::tr("A dialog is already open in the task panel"));
msgBox.setInformativeText(QObject::tr("Do you want to close this dialog?"));
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);

View File

@@ -651,7 +651,7 @@ private:
Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog();
PartDesignGui::TaskDlgFeaturePick *pickDlg = qobject_cast<PartDesignGui::TaskDlgFeaturePick *>(dlg);
if (dlg && !pickDlg) {
QMessageBox msgBox;
QMessageBox msgBox(Gui::getMainWindow());
msgBox.setText(QObject::tr("A dialog is already open in the task panel"));
msgBox.setInformativeText(QObject::tr("Do you want to close this dialog?"));
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);

View File

@@ -97,7 +97,7 @@ bool TaskDlgDatumParameters::accept() {
//see if we are able to assign a mode
if (parameter->getActiveMapMode() == mmDeactivated) {
QMessageBox msg;
QMessageBox msg(Gui::getMainWindow());
msg.setWindowTitle(tr("Incompatible reference set"));
msg.setText(tr("There is no attachment mode that fits the current set"
" of references. If you choose to continue, the feature will remain where"

View File

@@ -37,6 +37,7 @@
#include <Gui/Command.h>
#include <Gui/Control.h>
#include <Gui/Document.h>
#include <Gui/MainWindow.h>
#include <Mod/PartDesign/App/Body.h>
#include <Mod/PartDesign/App/Feature.h>
@@ -101,7 +102,7 @@ bool ViewProvider::setEdit(int ModNum)
featureDlg = nullptr; // another feature left open its task panel
}
if (dlg && !featureDlg) {
QMessageBox msgBox;
QMessageBox msgBox(Gui::getMainWindow());
msgBox.setText(QObject::tr("A dialog is already open in the task panel"));
msgBox.setInformativeText(QObject::tr("Do you want to close this dialog?"));
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);

View File

@@ -36,6 +36,7 @@
#include <Gui/Control.h>
#include <Gui/Command.h>
#include <Gui/Document.h>
#include <Gui/MainWindow.h>
using namespace PartDesignGui;
@@ -74,7 +75,7 @@ bool ViewProviderBoolean::setEdit(int ModNum)
if (booleanDlg && booleanDlg->getBooleanView() != this)
booleanDlg = nullptr; // another pad left open its task panel
if (dlg && !booleanDlg) {
QMessageBox msgBox;
QMessageBox msgBox(Gui::getMainWindow());
msgBox.setText(QObject::tr("A dialog is already open in the task panel"));
msgBox.setInformativeText(QObject::tr("Do you want to close this dialog?"));
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);

View File

@@ -45,6 +45,7 @@
#include <Gui/Application.h>
#include <Gui/Command.h>
#include <Gui/Control.h>
#include <Gui/MainWindow.h>
#include <Gui/View3DInventor.h>
#include <Gui/View3DInventorViewer.h>
#include <Gui/ViewProviderCoordinateSystem.h>
@@ -245,7 +246,7 @@ bool ViewProviderDatum::setEdit(int ModNum)
if (datumDlg && datumDlg->getViewProvider() != this)
datumDlg = nullptr; // another datum feature left open its task panel
if (dlg && !datumDlg) {
QMessageBox msgBox;
QMessageBox msgBox(Gui::getMainWindow());
msgBox.setText(QObject::tr("A dialog is already open in the task panel"));
msgBox.setInformativeText(QObject::tr("Do you want to close this dialog?"));
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);

View File

@@ -31,6 +31,7 @@
#include <Gui/Application.h>
#include <Gui/Control.h>
#include <Gui/Command.h>
#include <Gui/MainWindow.h>
#include <Mod/PartDesign/App/FeatureHole.h>
#include <Mod/Sketcher/App/SketchObject.h>
@@ -73,7 +74,7 @@ bool ViewProviderHole::setEdit(int ModNum)
if (holeDlg && holeDlg->getViewObject() != this)
holeDlg = nullptr; // another hole left open its task panel
if (dlg && !holeDlg) {
QMessageBox msgBox;
QMessageBox msgBox(Gui::getMainWindow());
msgBox.setText(QObject::tr("A dialog is already open in the task panel"));
msgBox.setInformativeText(QObject::tr("Do you want to close this dialog?"));
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);

View File

@@ -30,6 +30,7 @@
#include <Gui/BitmapFactory.h>
#include <Gui/Command.h>
#include <Gui/Control.h>
#include <Gui/MainWindow.h>
#include <Gui/TaskView/TaskDialog.h>
#include <Mod/PartDesign/App/FeaturePrimitive.h>
@@ -64,7 +65,7 @@ bool ViewProviderPrimitive::setEdit(int ModNum)
Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog();
TaskPrimitiveParameters *primitiveDlg = qobject_cast<TaskPrimitiveParameters *>(dlg);
if (dlg && !primitiveDlg) {
QMessageBox msgBox;
QMessageBox msgBox(Gui::getMainWindow());
msgBox.setText(QObject::tr("A dialog is already open in the task panel"));
msgBox.setInformativeText(QObject::tr("Do you want to close this dialog?"));
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);

View File

@@ -38,6 +38,7 @@
#include <Gui/Command.h>
#include <Gui/Control.h>
#include <Gui/Document.h>
#include <Gui/MainWindow.h>
#include <Gui/ViewParams.h>
#include <Mod/PartDesign/App/ShapeBinder.h>
@@ -91,7 +92,7 @@ bool ViewProviderShapeBinder::setEdit(int ModNum) {
Gui::TaskView::TaskDialog* dlg = Gui::Control().activeDialog();
TaskDlgShapeBinder* sbDlg = qobject_cast<TaskDlgShapeBinder*>(dlg);
if (dlg && !sbDlg) {
QMessageBox msgBox;
QMessageBox msgBox(Gui::getMainWindow());
msgBox.setText(QObject::tr("A dialog is already open in the task panel"));
msgBox.setInformativeText(QObject::tr("Do you want to close this dialog?"));
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);