source: smplayer/trunk/src/mplayerwindow.h@ 142

Last change on this file since 142 was 142, checked in by Silvan Scherrer, 12 years ago

SMPlayer: update trunk to 0.8.5

  • Property svn:eol-style set to LF
File size: 5.4 KB
Line 
1/* smplayer, GUI front-end for mplayer.
2 Copyright (C) 2006-2013 Ricardo Villalba <rvm@users.sourceforge.net>
3
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.
8
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.
13
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
17*/
18
19
20#ifndef MPLAYERWINDOW_H
21#define MPLAYERWINDOW_H
22
23#include <QWidget>
24#include <QSize>
25#include <QPoint>
26
27#include <QResizeEvent>
28#include <QWheelEvent>
29#include <QMouseEvent>
30#include <QKeyEvent>
31#include <QPaintEvent>
32
33#include "config.h"
34
35class QWidget;
36class QLabel;
37class QKeyEvent;
38class QTimer;
39
40#define ZOOM_STEP 0.05
41#define ZOOM_MIN 0.5
42
43#define DELAYED_RESIZE 0
44
45//! Screen is a widget that hides the mouse cursor after some seconds if not moved.
46
47class Screen : public QWidget
48{
49 Q_OBJECT
50
51public:
52 Screen(QWidget* parent = 0, Qt::WindowFlags f = 0);
53 ~Screen();
54
55 void setAutoHideCursor(bool b);
56 bool autoHideCursor() { return autohide_cursor; };
57
58 void setAutoHideInterval(int milliseconds) { autohide_interval = milliseconds; };
59 int autoHideInterval() { return autohide_interval; };
60
61public slots:
62 //! Should be called when a file has started.
63 virtual void playingStarted();
64
65 //! Should be called when a file has stopped.
66 virtual void playingStopped();
67
68protected:
69 virtual void mouseMoveEvent( QMouseEvent * e );
70 virtual void paintEvent ( QPaintEvent * e );
71
72protected slots:
73 virtual void checkMousePos();
74
75private:
76 QTimer * check_mouse_timer;
77 QPoint mouse_last_position;
78 bool autohide_cursor;
79 int autohide_interval;
80};
81
82//! MplayerLayer can be instructed to not delete the background.
83
84class MplayerLayer : public Screen
85{
86 Q_OBJECT
87
88public:
89 MplayerLayer(QWidget* parent = 0, Qt::WindowFlags f = 0);
90 ~MplayerLayer();
91
92#if REPAINT_BACKGROUND_OPTION
93 //! If b is true, the background of the widget will be repainted as usual.
94 /*! Otherwise the background will not repainted when a video is playing. */
95 void setRepaintBackground(bool b);
96
97 //! Return true if repainting the background is allowed.
98 bool repaintBackground() { return repaint_background; };
99#endif
100
101public slots:
102 //! Should be called when a file has started.
103 /*! It's needed to know if the background has to be cleared or not. */
104 virtual void playingStarted();
105 //! Should be called when a file has stopped.
106 virtual void playingStopped();
107
108#if REPAINT_BACKGROUND_OPTION
109protected:
110 virtual void paintEvent ( QPaintEvent * e );
111#endif
112
113private:
114#if REPAINT_BACKGROUND_OPTION
115 bool repaint_background;
116#endif
117 bool playing;
118};
119
120
121class MplayerWindow : public Screen
122{
123 Q_OBJECT
124
125public:
126 MplayerWindow( QWidget* parent = 0, Qt::WindowFlags f = 0);
127 ~MplayerWindow();
128
129 MplayerLayer * videoLayer() { return mplayerlayer; };
130
131 void setResolution( int w, int h);
132 void setAspect( double asp);
133 void setMonitorAspect(double asp);
134 void updateVideoWindow();
135
136#if USE_COLORKEY
137 void setColorKey(QColor c);
138#endif
139
140 void setOffsetX( int );
141 int offsetX();
142
143 void setOffsetY( int );
144 int offsetY();
145
146 void setZoom( double );
147 double zoom();
148
149 void allowVideoMovement(bool b) { allow_video_movement = b; };
150 bool isVideoMovementAllowed() { return allow_video_movement; };
151
152 virtual QSize sizeHint () const;
153 virtual QSize minimumSizeHint() const;
154
155 virtual bool eventFilter( QObject * watched, QEvent * event );
156
157#if LOGO_ANIMATION
158 bool animatedLogo() { return animated_logo; }
159#endif
160
161public slots:
162 void setLogoVisible(bool b);
163 void showLogo() { setLogoVisible(true); };
164 void hideLogo() { setLogoVisible(false); };
165
166#if LOGO_ANIMATION
167 void setAnimatedLogo(bool b) { animated_logo = b; };
168#endif
169
170 void moveLeft();
171 void moveRight();
172 void moveUp();
173 void moveDown();
174 void incZoom();
175 void decZoom();
176
177#if DELAYED_RESIZE
178protected slots:
179 void resizeLater();
180#endif
181
182protected:
183 virtual void retranslateStrings();
184 virtual void changeEvent ( QEvent * event ) ;
185
186 virtual void resizeEvent( QResizeEvent * e);
187 virtual void mouseReleaseEvent( QMouseEvent * e);
188 virtual void mouseDoubleClickEvent( QMouseEvent * e );
189 virtual void wheelEvent( QWheelEvent * e );
190 void moveLayer( int offset_x, int offset_y );
191
192signals:
193 //void rightButtonReleased( QPoint p );
194 void doubleClicked();
195 void leftClicked();
196 void rightClicked();
197 void middleClicked();
198 void xbutton1Clicked(); // first X button
199 void xbutton2Clicked(); // second X button
200 void keyPressed(QKeyEvent * e);
201 void wheelUp();
202 void wheelDown();
203 void mouseMoved(QPoint);
204 void mouseMovedDiff(QPoint);
205
206protected:
207 int video_width, video_height;
208 double aspect;
209 double monitoraspect;
210
211 MplayerLayer * mplayerlayer;
212 QLabel * logo;
213
214 // Zoom and moving
215 int offset_x, offset_y;
216 double zoom_factor;
217
218 // Original pos and dimensions of the mplayerlayer
219 // before zooming or moving
220 int orig_x, orig_y;
221 int orig_width, orig_height;
222
223 bool allow_video_movement;
224 QPoint mouse_press_pos;
225
226#if DELAYED_RESIZE
227 QTimer * resize_timer;
228#endif
229
230#if LOGO_ANIMATION
231 bool animated_logo;
232#endif
233};
234
235
236#endif
237
Note: See TracBrowser for help on using the repository browser.