Merge pull request #20160 from karliss/popup-parent

Add missing parent for messagbox and other popups.
This commit is contained in:
Chris Hennes
2025-03-17 00:16:49 -05:00
committed by GitHub
22 changed files with 33 additions and 24 deletions

View File

@@ -343,7 +343,7 @@ void StdCmdRestartInSafeMode::activated(int iMsg)
{
Q_UNUSED(iMsg);
QMessageBox restartBox;
QMessageBox restartBox(Gui::getMainWindow());
restartBox.setIcon(QMessageBox::Warning);
restartBox.setWindowTitle(QObject::tr("Restart in safe mode"));
restartBox.setText(QObject::tr("Are you sure you want to restart FreeCAD and enter safe mode?"));

View File

@@ -565,7 +565,7 @@ void DlgMacroExecuteImp::onToolbarButtonClicked()
.GetParameterGroupByPath("User parameter:BaseApp/Preferences/Macro")
->GetBool("ShowWalkthroughMessage", true);
if (showAgain) {
QMessageBox msgBox;
QMessageBox msgBox(this);
QAbstractButton* doNotShowAgainButton =
msgBox.addButton(tr("Do not show again"), QMessageBox::YesRole);
msgBox.setText(tr("Guided Walkthrough"));

View File

@@ -759,7 +759,7 @@ void DlgPreferencesImp::applyChanges()
void DlgPreferencesImp::restartIfRequired()
{
if (restartRequired) {
QMessageBox restartBox;
QMessageBox restartBox(parentWidget()); // current window likely already closed, cant parent to it
restartBox.setIcon(QMessageBox::Warning);
restartBox.setWindowTitle(tr("Restart required"));

View File

@@ -708,7 +708,7 @@ void Placement::onSelectedVertexClicked()
if (!success) {
Base::Console().Warning("Placement selection error. Select either 1 or 2 points.\n");
QMessageBox msgBox;
QMessageBox msgBox(this);
msgBox.setText(tr("Please select 1, 2, or 3 points before clicking this button. A point may be on a vertex, \
face, or edge. If on a face or edge the point used will be the point at the mouse position along \
face or edge. If 1 point is selected it will be used as the center of rotation. If 2 points are \

View File

@@ -30,6 +30,7 @@
#include <App/Document.h>
#include <Gui/Application.h>
#include <Gui/Document.h>
#include <Gui/MainWindow.h>
#include <Gui/View3DInventor.h>
#include <Gui/ViewProviderDocumentObject.h>
@@ -96,7 +97,7 @@ const std::vector<QWidget*> &TaskDialog::getDialogContent() const
bool TaskDialog::canClose() const
{
QMessageBox msgBox;
QMessageBox msgBox(Gui::getMainWindow());
msgBox.setText(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

@@ -55,6 +55,7 @@
#include <Gui/CommandT.h>
#include <Gui/Control.h>
#include <Gui/MDIView.h>
#include <Gui/MainWindow.h>
#include <Gui/SoFCCSysDragger.h>
#include <Gui/View3DInventor.h>
#include <Gui/View3DInventorViewer.h>
@@ -191,7 +192,7 @@ bool ViewProviderAssembly::canDragObjectToTarget(App::DocumentObject* obj,
if (obj == obj1 || obj == obj2 || obj == part1 || obj == part2 || obj == obj3) {
if (!prompted) {
prompted = true;
QMessageBox msgBox;
QMessageBox msgBox(Gui::getMainWindow());
msgBox.setText(tr("The object is associated to one or more joints."));
msgBox.setInformativeText(
tr("Do you want to move the object and delete associated joints?"));

View File

@@ -333,7 +333,7 @@ bool ViewProviderFemPostFunction::setEdit(int ModNum)
postDlg = nullptr; // another pad left open its task panel
}
if (dlg && !postDlg) {
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

@@ -964,7 +964,7 @@ bool ViewProviderFemPostObject::setEdit(int ModNum)
postDlg = nullptr; // another pad left open its task panel
}
if (dlg && !postDlg) {
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

@@ -890,7 +890,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);
@@ -912,7 +912,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);
@@ -1010,7 +1010,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);

View File

@@ -112,7 +112,7 @@ void CmdPointsImport::activated(int iMsg)
auto center = bbox.GetCenter();
if (!bbox.IsInBox(Base::Vector3d(0, 0, 0))) {
QMessageBox msgBox;
QMessageBox msgBox(Gui::getMainWindow());
msgBox.setIcon(QMessageBox::Question);
msgBox.setWindowTitle(QObject::tr("Points not at Origin"));
msgBox.setText(QObject::tr(

View File

@@ -2980,7 +2980,7 @@ bool ViewProviderSketch::setEdit(int ModNum)
if (sketchDlg && sketchDlg->getSketchView() != this)
sketchDlg = nullptr;// another sketch left open its task panel
if (dlg && !sketchDlg) {
QMessageBox msgBox;
QMessageBox msgBox(Gui::getMainWindow());
msgBox.setText(tr("A dialog is already open in the task panel"));
msgBox.setInformativeText(tr("Do you want to close this dialog?"));
msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No);

View File

@@ -424,7 +424,7 @@ void CmdTechDrawView::activated(int iMsg)
bool dontShowAgain = hGrp->GetBool("DontShowInsertFileMessage", false);
if (!dontShowAgain) {
auto msgText = QObject::tr("If you want to insert a view from existing objects, please select them before invoking this tool. Without a selection, a file browser will open, to insert a SVG or image file.");
QMessageBox msgBox;
QMessageBox msgBox(Gui::getMainWindow());
msgBox.setText(msgText);
auto dontShowMsg = QObject::tr("Do not show this message again");
QCheckBox dontShowCheckBox(dontShowMsg, &msgBox);

View File

@@ -113,7 +113,7 @@ void execInsertPrefixChar(Gui::Command* cmd, std::string prefixFormat, const QAc
std::string prefixText(prefixFormat);
if (prefixFormat.find("%s") != std::string::npos) {
DlgTemplateField ui;
DlgTemplateField ui(Gui::getMainWindow());
const int MAX_PREFIX_LENGTH = 31;
if (action) {

View File

@@ -30,6 +30,7 @@
#endif // #ifndef _PreCmp_
#include <Base/Console.h>
#include <Gui/MainWindow.h>
#include <Mod/TechDraw/App/DrawTemplate.h>
#include <Mod/TechDraw/App/DrawSVGTemplate.h>
@@ -73,7 +74,7 @@ void TemplateTextField::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
if ( tmplte && m_rect->rect().contains(event->pos()) ) {
event->accept();
DlgTemplateField ui;
DlgTemplateField ui(Gui::getMainWindow());
ui.setFieldName(fieldNameStr);
ui.setFieldContent(tmplte->EditableTexts[fieldNameStr]);