diff options
-rw-r--r-- | filestreewidget.cpp | 9 | ||||
-rw-r--r-- | hoverwindow.cpp | 16 | ||||
-rw-r--r-- | hoverwindow.h | 1 | ||||
-rw-r--r-- | seriestreewidget.cpp | 6 |
4 files changed, 9 insertions, 23 deletions
diff --git a/filestreewidget.cpp b/filestreewidget.cpp index 1181c21..43611f9 100644 --- a/filestreewidget.cpp +++ b/filestreewidget.cpp @@ -327,7 +327,10 @@ bool FilesTreeView::event(QEvent *e){ mCurHover = curIdx; QPixmap pm = QPixmap(curIdx.data(FilesTreeModel::FullPathRole).toString()); mHoverWin->setPixmap(pm); - mHoverWin->setPos(where); + if(mHoverWin->pixmapHeight()){ + where = QPoint(where.x(), where.y() - mHoverWin->pixmapHeight() / 2); + } + mHoverWin->move(where); mHoverWin->setVisible(true); return true; } @@ -339,11 +342,11 @@ bool FilesTreeView::event(QEvent *e){ mCurHover = curIdx; mHoverWin->setPixmap(QPixmap(curIdx.data(FilesTreeModel::FullPathRole).toString())); mHoverWin->setVisible(false); - mHoverWin->setPos(where); + mHoverWin->move(where); mHoverWin->setVisible(true); return true; }else{ - mHoverWin->setPos(where); + mHoverWin->move(where); return true; } } diff --git a/hoverwindow.cpp b/hoverwindow.cpp index 100f278..8c5f227 100644 --- a/hoverwindow.cpp +++ b/hoverwindow.cpp @@ -7,8 +7,6 @@ #include <QHBoxLayout> #include <QLabel> -#include <QApplication> -#include <QDesktopWidget> #include "hoverwindow.h" @@ -53,17 +51,3 @@ 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); -} diff --git a/hoverwindow.h b/hoverwindow.h index 4223f9a..6991d0b 100644 --- a/hoverwindow.h +++ b/hoverwindow.h @@ -19,7 +19,6 @@ class HoverWindow : public QWidget { void setContent(const QString &parent, const QStringList &children); void setPixmap(const QPixmap &pm); int pixmapHeight() const; - void setPos(const QPoint &cursorPos); private: QLabel *mLabel; diff --git a/seriestreewidget.cpp b/seriestreewidget.cpp index c9abafd..77784b8 100644 --- a/seriestreewidget.cpp +++ b/seriestreewidget.cpp @@ -358,7 +358,7 @@ bool SeriesTreeView::event(QEvent *e){ if(e->type() == QEvent::HoverEnter){ mCurHover = curIdx; mHoverWin->setContent(curIdx.data(Qt::DisplayRole).toString(), children(curIdx)); - mHoverWin->setPos(where); + mHoverWin->move(where); mHoverWin->setVisible(true); return true; } @@ -367,11 +367,11 @@ bool SeriesTreeView::event(QEvent *e){ mCurHover = curIdx; mHoverWin->setContent(curIdx.data(Qt::DisplayRole).toString(), children(curIdx)); mHoverWin->setVisible(false); - mHoverWin->setPos(where); + mHoverWin->move(where); mHoverWin->setVisible(true); return true; }else{ - mHoverWin->setPos(where); + mHoverWin->move(where); return true; } } |