diff --git a/src/Gui/NotificationArea.cpp b/src/Gui/NotificationArea.cpp index 8e81a502cc..6e4d6fd8c8 100644 --- a/src/Gui/NotificationArea.cpp +++ b/src/Gui/NotificationArea.cpp @@ -991,17 +991,13 @@ void NotificationArea::showInNotificationArea() msgw += QString::fromLatin1("
"); - // Calculate the main window QRect in global screen coordinates. - auto mainwindow = getMainWindow(); - auto mainwindowrect = mainwindow->rect(); - auto globalmainwindowrect = - QRect(mainwindow->mapToGlobal(mainwindowrect.topLeft()), mainwindowrect.size()); - NotificationBox::showText(this->mapToGlobal(QPoint()), msgw, + getMainWindow(), pImp->notificationExpirationTime, pImp->minimumOnScreenTime, - globalmainwindowrect, + NotificationBox::OnlyIfReferenceActive | + NotificationBox::RestrictAreaToReference, pImp->notificationWidth); } } diff --git a/src/Gui/NotificationBox.cpp b/src/Gui/NotificationBox.cpp index 3699a37593..ff07a9646a 100644 --- a/src/Gui/NotificationBox.cpp +++ b/src/Gui/NotificationBox.cpp @@ -309,9 +309,28 @@ bool NotificationLabel::notificationLabelChanged(const QString& text) /***************************** NotificationBox **********************************/ -void NotificationBox::showText(const QPoint& pos, const QString& text, int displayTime, - unsigned int minShowTime, const QRect &restrictionarea, int width) +void NotificationBox::showText(const QPoint& pos, const QString& text, QWidget * referenceWidget, int displayTime, + unsigned int minShowTime, Options options, + int width) { + QRect restrictionarea = {}; + + if(referenceWidget) { + if(options & Options::OnlyIfReferenceActive) { + if (!referenceWidget->isActiveWindow()) { + return; + } + } + + if(options & Options::RestrictAreaToReference) { + // Calculate the main window QRect in global screen coordinates. + auto mainwindowrect = referenceWidget->rect(); + + restrictionarea = + QRect(referenceWidget->mapToGlobal(mainwindowrect.topLeft()), mainwindowrect.size()); + } + } + // a label does already exist if (NotificationLabel::instance && NotificationLabel::instance->isVisible()) { if (text.isEmpty()) {// empty text means hide current label diff --git a/src/Gui/NotificationBox.h b/src/Gui/NotificationBox.h index 4ddcd93083..dca3cd9bf6 100644 --- a/src/Gui/NotificationBox.h +++ b/src/Gui/NotificationBox.h @@ -23,6 +23,7 @@ #ifndef GUI_NOTIFICATIONBOX_H #define GUI_NOTIFICATIONBOX_H +#include