diff --git a/src/widget/form/chatform.cpp b/src/widget/form/chatform.cpp index 0a4975c2d..0fa5637bb 100644 --- a/src/widget/form/chatform.cpp +++ b/src/widget/form/chatform.cpp @@ -48,6 +48,7 @@ #include "src/chatlog/chatlog.h" #include "src/offlinemsgengine.h" #include "src/widget/tool/screenshotgrabber.h" +#include "src/widget/tool/flyoutoverlaywidget.h" ChatForm::ChatForm(Friend* chatFriend) : f(chatFriend) @@ -865,11 +866,18 @@ void ChatForm::loadHistory(QDateTime since, bool processUndelivered) void ChatForm::onScreenshotClicked() { - ScreenshotGrabber *screenshotGrabber = new ScreenshotGrabber (this); - connect(screenshotGrabber, &ScreenshotGrabber::screenshotTaken, this, &ChatForm::onScreenshotTaken); + connect(fileFlyout, &FlyoutOverlayWidget::hidden, this, &ChatForm::doScreenshot); + hideFileMenu(); +} + +void ChatForm::doScreenshot() +{ + disconnect(fileFlyout, &FlyoutOverlayWidget::hidden, this, &ChatForm::doScreenshot); + + ScreenshotGrabber* screenshotGrabber = new ScreenshotGrabber (this); + connect(screenshotGrabber, &ScreenshotGrabber::screenshotTaken, this, &ChatForm::onScreenshotTaken); + screenshotGrabber->showGrabber(); - // Try to not grab the context-menu - QTimer::singleShot(200, screenshotGrabber, &ScreenshotGrabber::showGrabber); } void ChatForm::onScreenshotTaken (const QPixmap &pixmap) { diff --git a/src/widget/form/chatform.h b/src/widget/form/chatform.h index cc3835aa1..b0c0f5e8f 100644 --- a/src/widget/form/chatform.h +++ b/src/widget/form/chatform.h @@ -97,6 +97,7 @@ private slots: void onEnableCallButtons(); void onScreenshotClicked(); void onScreenshotTaken(const QPixmap &pixmap); + void doScreenshot(); protected: // drag & drop diff --git a/src/widget/tool/flyoutoverlaywidget.cpp b/src/widget/tool/flyoutoverlaywidget.cpp index 154bc9699..f5b1b10c5 100644 --- a/src/widget/tool/flyoutoverlaywidget.cpp +++ b/src/widget/tool/flyoutoverlaywidget.cpp @@ -20,6 +20,7 @@ #include #include #include +#include FlyoutOverlayWidget::FlyoutOverlayWidget(QWidget *parent) : QWidget(parent) @@ -97,4 +98,9 @@ void FlyoutOverlayWidget::finishedAnimation() { bool hide = (animation->direction() == QAbstractAnimation::Backward); setAttribute(Qt::WA_TransparentForMouseEvents, hide); + + // Delay it by a few frames to let the system catch up on rendering + if (hide) + QTimer::singleShot(50, this, &FlyoutOverlayWidget::hidden); + } diff --git a/src/widget/tool/flyoutoverlaywidget.h b/src/widget/tool/flyoutoverlaywidget.h index 2c2fa5842..04a51350a 100644 --- a/src/widget/tool/flyoutoverlaywidget.h +++ b/src/widget/tool/flyoutoverlaywidget.h @@ -40,6 +40,10 @@ public: void animateShow(); void animateHide(); +signals: + + void hidden(); + protected: void leaveEvent(QEvent* event);