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

@@ -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]);