From f14c3992974d364b9c03a5e6ee1df00144ac2d97 Mon Sep 17 00:00:00 2001 From: Stefan Merettig Date: Sat, 4 Apr 2015 23:22:03 +0200 Subject: [PATCH] Screen grabber: Fix flying-flyout bug when resizing window while open --- qtox.pro | 2 +- src/widget/form/chatform.h | 1 - src/widget/form/genericchatform.cpp | 17 ++++++++++++++--- src/widget/form/genericchatform.h | 2 ++ 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/qtox.pro b/qtox.pro index d15539a9d..22e46a67d 100644 --- a/qtox.pro +++ b/qtox.pro @@ -432,7 +432,7 @@ SOURCES += \ src/core/corefile.cpp \ src/core/corestructs.cpp \ src/profilelocker.cpp \ - src/avatarbroadcaster.cpp + src/avatarbroadcaster.cpp \ src/widget/tool/screenshotgrabber.cpp \ src/widget/tool/screengrabberchooserrectitem.cpp \ src/widget/tool/screengrabberoverlayitem.cpp \ diff --git a/src/widget/form/chatform.h b/src/widget/form/chatform.h index b0c0f5e8f..28a703b2d 100644 --- a/src/widget/form/chatform.h +++ b/src/widget/form/chatform.h @@ -79,7 +79,6 @@ public slots: void onVolMuteToggle(); void onAvatarChange(uint32_t FriendId, const QPixmap& pic); void onAvatarRemoved(uint32_t FriendId); - void onAttachContext(const QPoint &pos); private slots: void onSendTriggered(); diff --git a/src/widget/form/genericchatform.cpp b/src/widget/form/genericchatform.cpp index bba23332f..98138ed0f 100644 --- a/src/widget/form/genericchatform.cpp +++ b/src/widget/form/genericchatform.cpp @@ -192,12 +192,17 @@ GenericChatForm::GenericChatForm(QWidget *parent) fileFlyout->installEventFilter(this); } +void GenericChatForm::adjustFileMenuPosition() +{ + QPoint pos = fileButton->pos(); + QSize size = fileFlyout->size(); + fileFlyout->move(pos.x() - size.width(), pos.y()); +} + void GenericChatForm::showFileMenu() { if (!fileFlyout->isShown() && !fileFlyout->isBeingShown()) { - QPoint pos = fileButton->pos(); - QSize size = fileFlyout->size(); - fileFlyout->move(pos.x() - size.width(), pos.y()); + adjustFileMenuPosition(); } fileFlyout->animateShow(); @@ -416,6 +421,12 @@ void GenericChatForm::hideEvent(QHideEvent* event) QWidget::hideEvent(event); } +void GenericChatForm::resizeEvent(QResizeEvent* event) +{ + adjustFileMenuPosition(); + QWidget::resizeEvent(event); +} + bool GenericChatForm::eventFilter(QObject* object, QEvent* event) { if (object != this->fileButton && object != this->fileFlyout) diff --git a/src/widget/form/genericchatform.h b/src/widget/form/genericchatform.h index 831aee68d..65f20a8a5 100644 --- a/src/widget/form/genericchatform.h +++ b/src/widget/form/genericchatform.h @@ -85,6 +85,8 @@ protected: QString resolveToxID(const ToxID &id); void insertChatMessage(ChatMessage::Ptr msg); void hideEvent(QHideEvent* event); + void resizeEvent(QResizeEvent* event); + void adjustFileMenuPosition(); ToxID previousId; QDateTime prevMsgDateTime;