1
/* smplayer, GUI front-end for mplayer.
2
Copyright (C) 2006-2009 Ricardo Villalba <rvm@escomposlinux.org>
4
This program is free software; you can redistribute it and/or modify
5
it under the terms of the GNU General Public License as published by
6
the Free Software Foundation; either version 2 of the License, or
7
(at your option) any later version.
9
This program is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
GNU General Public License for more details.
14
You should have received a copy of the GNU General Public License
15
along with this program; if not, write to the Free Software
16
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20
#ifndef MPLAYERWINDOW_H
21
#define MPLAYERWINDOW_H
27
#include <QResizeEvent>
28
#include <QWheelEvent>
29
#include <QMouseEvent>
31
#include <QPaintEvent>
40
#define ZOOM_STEP 0.05
43
#define DELAYED_RESIZE 0
44
#define NEW_MOUSE_CHECK_POS 1
46
//! Screen is a widget that hides the mouse cursor after some seconds if not moved.
48
class Screen : public QWidget
53
Screen(QWidget* parent = 0, Qt::WindowFlags f = 0);
57
#if !NEW_MOUSE_CHECK_POS
58
virtual void mouseMoveEvent( QMouseEvent * e );
60
virtual void paintEvent ( QPaintEvent * e );
63
virtual void checkMousePos();
66
#if NEW_MOUSE_CHECK_POS
67
QPoint mouse_last_position;
69
QPoint cursor_pos, last_cursor_pos;
73
//! MplayerLayer can be instructed to not delete the background.
75
class MplayerLayer : public Screen
80
MplayerLayer(QWidget* parent = 0, Qt::WindowFlags f = 0);
83
#if REPAINT_BACKGROUND_OPTION
84
//! If b is true, the background of the widget will be repainted as usual.
85
/*! Otherwise the background will not repainted when a video is playing. */
86
void setRepaintBackground(bool b);
88
//! Return true if repainting the background is allowed.
89
bool repaintBackground() { return repaint_background; };
93
//! Should be called when a file has started.
94
/*! It's needed to know if the background has to be cleared or not. */
95
void playingStarted();
96
//! Should be called when a file has stopped.
97
void playingStopped();
99
#if REPAINT_BACKGROUND_OPTION
101
virtual void paintEvent ( QPaintEvent * e );
105
#if REPAINT_BACKGROUND_OPTION
106
bool repaint_background;
112
class MplayerWindow : public Screen
117
MplayerWindow( QWidget* parent = 0, Qt::WindowFlags f = 0);
120
void showLogo( bool b);
122
MplayerLayer * videoLayer() { return mplayerlayer; };
124
void setResolution( int w, int h);
125
void setAspect( double asp);
126
void setMonitorAspect(double asp);
127
void updateVideoWindow();
130
void setColorKey(QColor c);
133
void setOffsetX( int );
136
void setOffsetY( int );
139
void setZoom( double );
142
void allowVideoMovement(bool b) { allow_video_movement = b; };
143
bool isVideoMovementAllowed() { return allow_video_movement; };
145
virtual QSize sizeHint () const;
146
virtual QSize minimumSizeHint() const;
148
virtual bool eventFilter( QObject * watched, QEvent * event );
164
virtual void retranslateStrings();
165
virtual void changeEvent ( QEvent * event ) ;
167
virtual void resizeEvent( QResizeEvent * e);
168
virtual void mouseReleaseEvent( QMouseEvent * e);
169
virtual void mouseDoubleClickEvent( QMouseEvent * e );
170
virtual void wheelEvent( QWheelEvent * e );
171
void moveLayer( int offset_x, int offset_y );
174
//void rightButtonReleased( QPoint p );
175
void doubleClicked();
178
void middleClicked();
179
void xbutton1Clicked(); // first X button
180
void xbutton2Clicked(); // second X button
181
void keyPressed(QKeyEvent * e);
184
void mouseMoved(QPoint);
187
int video_width, video_height;
189
double monitoraspect;
191
MplayerLayer * mplayerlayer;
195
int offset_x, offset_y;
198
// Original pos and dimensions of the mplayerlayer
199
// before zooming or moving
201
int orig_width, orig_height;
203
bool allow_video_movement;
206
QTimer * resize_timer;