summaryrefslogtreecommitdiff
path: root/src/mplayerwindow.cpp
diff options
context:
space:
mode:
authorAlessio Treglia <alessio@debian.org>2013-02-10 10:18:21 +0000
committerAlessio Treglia <alessio@debian.org>2013-02-10 10:18:21 +0000
commit038de1a143b9775f37d4848f52c59af7cee66e36 (patch)
tree8d10a35c194be220b6cb2d1b2982546dbcef9480 /src/mplayerwindow.cpp
parent69d32924ffbfe2bb05d881a23af13b6070b9a9bd (diff)
Imported Upstream version 0.8.3
Diffstat (limited to 'src/mplayerwindow.cpp')
-rw-r--r--src/mplayerwindow.cpp74
1 files changed, 40 insertions, 34 deletions
diff --git a/src/mplayerwindow.cpp b/src/mplayerwindow.cpp
index 16b60cf..d4ef168 100644
--- a/src/mplayerwindow.cpp
+++ b/src/mplayerwindow.cpp
@@ -37,24 +37,20 @@
#include <QTimer>
#endif
+#if LOGO_ANIMATION
+#include <QPropertyAnimation>
+#endif
+
Screen::Screen(QWidget* parent, Qt::WindowFlags f) : QWidget(parent, f )
{
setMouseTracking(TRUE);
setFocusPolicy( Qt::NoFocus );
setMinimumSize( QSize(0,0) );
-#if NEW_MOUSE_CHECK_POS
mouse_last_position = QPoint(0,0);
-#else
- cursor_pos = QPoint(0,0);
- last_cursor_pos = QPoint(0,0);
-#endif
check_mouse_timer = new QTimer(this);
connect( check_mouse_timer, SIGNAL(timeout()), this, SLOT(checkMousePos()) );
-#if !NEW_MOUSE_CHECK_POS
- check_mouse_timer->start(2000);
-#endif
// Change attributes
setAttribute(Qt::WA_NoSystemBackground);
@@ -64,10 +60,8 @@ Screen::Screen(QWidget* parent, Qt::WindowFlags f) : QWidget(parent, f )
setAttribute(Qt::WA_PaintUnclipped);
//setAttribute(Qt::WA_PaintOutsidePaintEvent);
-#if NEW_MOUSE_CHECK_POS
setAutoHideInterval(1000);
setAutoHideCursor(false);
-#endif
}
Screen::~Screen() {
@@ -80,7 +74,6 @@ void Screen::paintEvent( QPaintEvent * e ) {
//painter.fillRect( e->rect(), QColor(255,0,0) );
}
-#if NEW_MOUSE_CHECK_POS
void Screen::setAutoHideCursor(bool b) {
qDebug("Screen::setAutoHideCursor: %d", b);
@@ -112,45 +105,22 @@ void Screen::checkMousePos() {
}
mouse_last_position = pos;
}
-#else
-void Screen::checkMousePos() {
- //qDebug("Screen::checkMousePos");
-
- if ( cursor_pos == last_cursor_pos ) {
- //qDebug(" same pos");
- if (cursor().shape() != Qt::BlankCursor) {
- //qDebug(" hiding mouse cursor");
- setCursor(QCursor(Qt::BlankCursor));
- }
- } else {
- last_cursor_pos = cursor_pos;
- }
-}
void Screen::mouseMoveEvent( QMouseEvent * e ) {
- //qDebug("Screen::mouseMoveEvent");
- //qDebug(" pos: x: %d y: %d", e->pos().x(), e->pos().y() );
- cursor_pos = e->pos();
-
if (cursor().shape() != Qt::ArrowCursor) {
//qDebug(" showing mouse cursor" );
setCursor(QCursor(Qt::ArrowCursor));
}
}
-#endif
void Screen::playingStarted() {
-#if NEW_MOUSE_CHECK_POS
qDebug("Screen::playingStarted");
setAutoHideCursor(true);
-#endif
}
void Screen::playingStopped() {
-#if NEW_MOUSE_CHECK_POS
qDebug("Screen::playingStopped");
setAutoHideCursor(false);
-#endif
}
/* ---------------------------------------------------------------------- */
@@ -262,7 +232,32 @@ void MplayerWindow::retranslateStrings() {
}
void MplayerWindow::setLogoVisible( bool b) {
+#if !LOGO_ANIMATION
logo->setVisible(b);
+#else
+ if (!animated_logo) {
+ logo->setVisible(b);
+ } else {
+ if (b) {
+ logo->show();
+ QPropertyAnimation * animation = new QPropertyAnimation(logo, "pos");
+ animation->setDuration(200);
+ animation->setEasingCurve(QEasingCurve::OutBounce);
+ animation->setStartValue(QPoint(logo->x(), 0 - logo->y()));
+ animation->setEndValue(logo->pos());
+ animation->start();
+ } else {
+ QPropertyAnimation * animation = new QPropertyAnimation(logo, "pos");
+ animation->setDuration(200);
+ animation->setEasingCurve(QEasingCurve::OutBounce);
+ animation->setEndValue(QPoint(width(), logo->y()));
+ animation->setStartValue(logo->pos());
+ animation->start();
+ connect(animation, SIGNAL(finished()), logo, SLOT(hide()));
+ //logo->hide();
+ }
+ }
+#endif
}
/*
@@ -438,9 +433,20 @@ bool MplayerWindow::eventFilter( QObject * /*watched*/, QEvent * event ) {
if (event->type() == QEvent::MouseMove) {
emit mouseMoved(mouse_event->pos());
+
+ if ( mouse_event->buttons().testFlag(Qt::LeftButton)) {
+ emit mouseMovedDiff( mouse_event->globalPos() - mouse_press_pos);
+ mouse_press_pos = mouse_event->globalPos();
+ /* qDebug("MplayerWindow::eventFilter: mouse_press_pos: x: %d y: %d", mouse_press_pos.x(), mouse_press_pos.y()); */
+ }
}
}
+ if (event->type() == QEvent::MouseButtonPress) {
+ QMouseEvent *mouse_event = static_cast<QMouseEvent *>(event);
+ mouse_press_pos = mouse_event->globalPos();
+ }
+
return false;
}