1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

fix position of tooltip in screen grabber

The tooltip is shown centred at top of the screen which currently contains the mouse cursor.
This commit is contained in:
Nils Fenner 2015-10-03 10:03:14 +02:00
parent 9cafb31eca
commit 84a8e2789b
No known key found for this signature in database
GPG Key ID: 9591A163FF9BE04C

View File

@ -181,14 +181,20 @@ void ScreenshotGrabber::chooseHelperTooltipText(QRect rect)
useRegionSelectedTooltip();
}
/**
* @internal
*
* Align the tooltip centred at top of screen with the mouse cursor.
*/
void ScreenshotGrabber::adjustTooltipPosition()
{
QRectF size = this->helperToolbox->childrenBoundingRect();
QRect screenRect = QApplication::desktop()->screen()->rect();
// Align the toolbox center-top.
helperToolbox->setX(screenRect.x() + (screenRect.width() - size.width() + size.x()) / 2);
helperToolbox->setY(screenRect.y());
QRect recGL = QGuiApplication::primaryScreen()->virtualGeometry();
QRect rec = qApp->desktop()->screenGeometry(QCursor::pos());
const QRectF ttRect = this->helperToolbox->childrenBoundingRect();
int x = abs(recGL.x()) + rec.x() + ((rec.width() - ttRect.width()) / 2);
int y = abs(recGL.y()) + rec.y();
helperToolbox->setX(x);
helperToolbox->setY(y);
}
void ScreenshotGrabber::reject()