From 7e0abc7cde4a9c02fabc27cc2b6506bd41f0588d Mon Sep 17 00:00:00 2001 From: Arno Date: Sat, 23 Oct 2010 15:09:49 +0200 Subject: Fix hover issues Hopefully this commit fixes all issues with hovering over items. First, only use QCursor::pos() to determine the position of the hover window and fix position calculation accordingly. For that SmGlobals now return a QSize of the actual cursor size. Introduced a hoverOffeset to HoverWindow defaulting to SmGlobals::cursorSize() + 30 to prevent a HoverLeave event on showing the HoverWindow. Also fixed Qt::WindowFlags of HoverWindow. We don't want the HoverWindow to show in the taskbar or get sent to background when clicking on an item. --- hoverwindow.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'hoverwindow.h') diff --git a/hoverwindow.h b/hoverwindow.h index 49aec40..ee061dd 100644 --- a/hoverwindow.h +++ b/hoverwindow.h @@ -13,19 +13,27 @@ #include class QLabel; +class QHBoxLayout; class HoverWindow : public QWidget { Q_OBJECT + Q_PROPERTY(QPoint HoverOffset READ hoverOffset WRITE setHoverOffset); public: - explicit HoverWindow(QWidget *parent = 0, Qt::WindowFlags f = Qt::FramelessWindowHint); + explicit HoverWindow(QWidget *parent = 0, Qt::WindowFlags f = Qt::Tool | Qt::FramelessWindowHint); void setContent(const QString &parent, const QStringList &children); void setPixmap(const QPixmap &pm); void setData(const QList &data); int pixmapHeight() const; - void setPos(const QPoint &cursorPos); + void setPos(); + QPoint hoverOffset() const { return mHoverOffset; } + void setHoverOffset(const QPoint &point) { mHoverOffset = point; } private: QLabel *mLabel; + QPoint mHoverOffset; + QHBoxLayout *mMainLayout; + bool mAlignCenter; + int mDesktopHeight; }; #endif // HOVERWINDOW_H -- cgit v1.2.3-70-g09d2