From a3a556cc8af3433de1f8d5e22a4ba62cc029f145 Mon Sep 17 00:00:00 2001 From: Arno Date: Sun, 17 Oct 2010 08:14:47 +0200 Subject: Let HoverWindow always stay on screen Fixed HoverWindow so it always stays completely on screeen. --- 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