From 2fbd657d315856ba289039a08b62b1833d0b2ef5 Mon Sep 17 00:00:00 2001 From: Flavio Tordini Date: Fri, 14 Aug 2009 12:35:05 +0200 Subject: [PATCH] Autohide mouse cursor in the video area --- src/videoareawidget.cpp | 18 ++++++++++++++++++ src/videoareawidget.h | 6 ++++++ 2 files changed, 24 insertions(+) diff --git a/src/videoareawidget.cpp b/src/videoareawidget.cpp index 9300b9e..0169148 100644 --- a/src/videoareawidget.cpp +++ b/src/videoareawidget.cpp @@ -5,6 +5,13 @@ VideoAreaWidget::VideoAreaWidget(QWidget *parent) : QWidget(parent) { stackedLayout = new QStackedLayout(this); setLayout(stackedLayout); setAcceptDrops(true); + + // mouse autohide + setMouseTracking(true); + mouseTimer = new QTimer(this); + mouseTimer->setInterval(5000); + mouseTimer->setSingleShot(true); + connect(mouseTimer, SIGNAL(timeout()), SLOT(hideMouse())); } void VideoAreaWidget::setVideoWidget(QWidget *videoWidget) { @@ -41,6 +48,17 @@ void VideoAreaWidget::mousePressEvent(QMouseEvent *event) { emit rightClicked(); } +void VideoAreaWidget::mouseMoveEvent(QMouseEvent * /* event */) { + // show the normal cursor + unsetCursor(); + // then hide it again after a few seconds + mouseTimer->start(); +} + +void VideoAreaWidget::hideMouse() { + setCursor(QCursor(QBitmap(1,1))); +} + void VideoAreaWidget::dragEnterEvent(QDragEnterEvent *event) { qDebug() << event->mimeData()->formats(); if (event->mimeData()->hasFormat("application/x-minitube-video")) { diff --git a/src/videoareawidget.h b/src/videoareawidget.h index 5795374..44e5477 100644 --- a/src/videoareawidget.h +++ b/src/videoareawidget.h @@ -2,6 +2,7 @@ #define VIDEOAREAWIDGET_H #include +#include #include "video.h" #include "loadingwidget.h" #include "ListModel.h" @@ -30,6 +31,10 @@ protected: void mousePressEvent(QMouseEvent *event); void dragEnterEvent(QDragEnterEvent *event); void dropEvent(QDropEvent *event); + void mouseMoveEvent (QMouseEvent *event); + +private slots: + void hideMouse(); private: QStackedLayout *stackedLayout; @@ -37,6 +42,7 @@ private: LoadingWidget *loadingWidget; ListModel *listModel; + QTimer *mouseTimer; }; #endif // VIDEOAREAWIDGET_H -- 2.39.5