mirror of
https://github.com/qTox/qTox.git
synced 2024-03-22 14:00:36 +08:00
Screen grabber: Wait for the flyout to collapse before grabbing
After clicking the "Screenshot" button in the file flyout, the flyout now collapses and then triggers the screenshot functionality. This adds a delay of ca. 1/3 seconds between the click and the action.
This commit is contained in:
parent
04dc650596
commit
7ab64d5628
|
@ -48,6 +48,7 @@
|
||||||
#include "src/chatlog/chatlog.h"
|
#include "src/chatlog/chatlog.h"
|
||||||
#include "src/offlinemsgengine.h"
|
#include "src/offlinemsgengine.h"
|
||||||
#include "src/widget/tool/screenshotgrabber.h"
|
#include "src/widget/tool/screenshotgrabber.h"
|
||||||
|
#include "src/widget/tool/flyoutoverlaywidget.h"
|
||||||
|
|
||||||
ChatForm::ChatForm(Friend* chatFriend)
|
ChatForm::ChatForm(Friend* chatFriend)
|
||||||
: f(chatFriend)
|
: f(chatFriend)
|
||||||
|
@ -865,11 +866,18 @@ void ChatForm::loadHistory(QDateTime since, bool processUndelivered)
|
||||||
|
|
||||||
void ChatForm::onScreenshotClicked()
|
void ChatForm::onScreenshotClicked()
|
||||||
{
|
{
|
||||||
ScreenshotGrabber *screenshotGrabber = new ScreenshotGrabber (this);
|
connect(fileFlyout, &FlyoutOverlayWidget::hidden, this, &ChatForm::doScreenshot);
|
||||||
connect(screenshotGrabber, &ScreenshotGrabber::screenshotTaken, this, &ChatForm::onScreenshotTaken);
|
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) {
|
void ChatForm::onScreenshotTaken (const QPixmap &pixmap) {
|
||||||
|
|
|
@ -97,6 +97,7 @@ private slots:
|
||||||
void onEnableCallButtons();
|
void onEnableCallButtons();
|
||||||
void onScreenshotClicked();
|
void onScreenshotClicked();
|
||||||
void onScreenshotTaken(const QPixmap &pixmap);
|
void onScreenshotTaken(const QPixmap &pixmap);
|
||||||
|
void doScreenshot();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// drag & drop
|
// drag & drop
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QBitmap>
|
#include <QBitmap>
|
||||||
|
#include <QTimer>
|
||||||
|
|
||||||
FlyoutOverlayWidget::FlyoutOverlayWidget(QWidget *parent)
|
FlyoutOverlayWidget::FlyoutOverlayWidget(QWidget *parent)
|
||||||
: QWidget(parent)
|
: QWidget(parent)
|
||||||
|
@ -97,4 +98,9 @@ void FlyoutOverlayWidget::finishedAnimation()
|
||||||
{
|
{
|
||||||
bool hide = (animation->direction() == QAbstractAnimation::Backward);
|
bool hide = (animation->direction() == QAbstractAnimation::Backward);
|
||||||
setAttribute(Qt::WA_TransparentForMouseEvents, hide);
|
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);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,10 @@ public:
|
||||||
void animateShow();
|
void animateShow();
|
||||||
void animateHide();
|
void animateHide();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
void hidden();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void leaveEvent(QEvent* event);
|
void leaveEvent(QEvent* event);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user