diff options
author | Arno <am@disconnect.de> | 2010-10-17 11:09:56 +0200 |
---|---|---|
committer | Arno <am@disconnect.de> | 2010-10-17 11:09:56 +0200 |
commit | fe9e348cc2ec4990b0c81179b0507f4a1df54c95 (patch) | |
tree | d1b793941906c9a681ce39562df69ec84aa064df /hoverwindow.cpp | |
parent | 20df1c43f5b7425810b5d16e3658f0772aae9b6c (diff) | |
download | SheMov-fe9e348cc2ec4990b0c81179b0507f4a1df54c95.tar.gz SheMov-fe9e348cc2ec4990b0c81179b0507f4a1df54c95.tar.bz2 SheMov-fe9e348cc2ec4990b0c81179b0507f4a1df54c95.zip |
Revert "Revert "Let HoverWindow always stay on screen""
This reverts commit 20df1c43f5b7425810b5d16e3658f0772aae9b6c.
revert the revert... I actually wanted to check out something...
Diffstat (limited to 'hoverwindow.cpp')
-rw-r--r-- | hoverwindow.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/hoverwindow.cpp b/hoverwindow.cpp index 8c5f227..100f278 100644 --- a/hoverwindow.cpp +++ b/hoverwindow.cpp @@ -7,6 +7,8 @@ #include <QHBoxLayout> #include <QLabel> +#include <QApplication> +#include <QDesktopWidget> #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); +} |