From fe9e348cc2ec4990b0c81179b0507f4a1df54c95 Mon Sep 17 00:00:00 2001 From: Arno Date: Sun, 17 Oct 2010 11:09:56 +0200 Subject: Revert "Revert "Let HoverWindow always stay on screen"" This reverts commit 20df1c43f5b7425810b5d16e3658f0772aae9b6c. revert the revert... I actually wanted to check out something... --- hoverwindow.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'hoverwindow.cpp') diff --git a/hoverwindow.cpp b/hoverwindow.cpp index 8c5f227..100f278 100644 --- a/hoverwindow.cpp +++ b/hoverwindow.cpp @@ -7,6 +7,8 @@ #include #include +#include +#include #include "hoverwindow.h" @@ -51,3 +53,17 @@ int HoverWindow::pixmapHeight() const{ const QPixmap *pm = mLabel->pixmap(); return pm ? pm->height() : 0; } + +void HoverWindow::setPos(const QPoint &cursorPos){ + if(cursorPos.y() - height() / 2 < 0){ + move(QPoint(cursorPos.x(), 0)); + return; + } + QDesktopWidget *desktop = qApp->desktop(); + int desktopHeight = desktop->availableGeometry().height(); + if(cursorPos.y() + height() / 2 > desktopHeight){ + move(QPoint(cursorPos.x(), desktopHeight - height())); + return; + } + move(cursorPos); +} -- cgit v1.2.3-70-g09d2