Skip to content
This repository has been archived by the owner on Feb 12, 2023. It is now read-only.

Commit

Permalink
fix(genericchatform): Fixed position of screenshot button
Browse files Browse the repository at this point in the history
Fix #2427.
  • Loading branch information
Diadlo committed Jul 9, 2016
1 parent 464daeb commit 86e4414
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions src/widget/form/genericchatform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ GenericChatForm::~GenericChatForm()

void GenericChatForm::adjustFileMenuPosition()
{
QPoint pos = fileButton->pos();
QPoint pos = fileButton->mapTo(bodySplitter, QPoint());
QSize size = fileFlyout->size();
fileFlyout->move(pos.x() - size.width(), pos.y());
}
Expand All @@ -244,7 +244,6 @@ void GenericChatForm::hideFileMenu()
{
if(fileFlyout->isShown() || fileFlyout->isBeingShown())
fileFlyout->animateHide();

}

bool GenericChatForm::isEmpty()
Expand Down Expand Up @@ -506,8 +505,8 @@ void GenericChatForm::resizeEvent(QResizeEvent* event)

bool GenericChatForm::eventFilter(QObject* object, QEvent* event)
{
EmoticonsWidget * ev = qobject_cast<EmoticonsWidget *>(object);
if (( ev) && (event->type() == QEvent::KeyPress) )
EmoticonsWidget* ev = qobject_cast<EmoticonsWidget*>(object);
if (ev && event->type() == QEvent::KeyPress)
{
QKeyEvent* key = static_cast<QKeyEvent*>(event);
msgEdit->sendKeyEvent(key);
Expand All @@ -527,15 +526,21 @@ bool GenericChatForm::eventFilter(QObject* object, QEvent* event)
showFileMenu();
break;

case QEvent::Leave: {
QPoint pos = mapFromGlobal(QCursor::pos());
QRect fileRect(fileFlyout->pos(), fileFlyout->size());
fileRect = fileRect.united(QRect(fileButton->pos(), fileButton->size()));
case QEvent::Leave:
{
QPoint flyPos = fileFlyout->mapToGlobal(QPoint());
QSize flySize = fileFlyout->size();

QPoint filePos = fileButton->mapToGlobal(QPoint());
QSize fileSize = fileButton->size();

if (!fileRect.contains(pos))
QRect region = QRect(flyPos, flySize).united(QRect(filePos, fileSize));

if (!region.contains(QCursor::pos()))
hideFileMenu();

} break;
break;
}

case QEvent::MouseButtonPress:
hideFileMenu();
Expand Down

0 comments on commit 86e4414

Please sign in to comment.