diff options
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); +} |