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

Last change on this file since 165 was 165, checked in by Silvan Scherrer, 11 years ago

SMPlayer: update trunk to latest 0.8.7

  • Property svn:eol-style set to LF
File size: 5.6 KB
Line 
1/* smplayer, GUI front-end for mplayer.
2 Copyright (C) 2006-2014 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
68signals:
69 void mouseMoved(QPoint);
70
71protected:
72 virtual void mouseMoveEvent( QMouseEvent * e );
73
74protected slots:
75 virtual void checkMousePos();
76
77private:
78 QTimer * check_mouse_timer;
79 QPoint mouse_last_position;
80 bool autohide_cursor;
81 int autohide_interval;
82};
83
84//! MplayerLayer can be instructed to not delete the background.
85
86class MplayerLayer : public Screen
87{
88 Q_OBJECT
89
90public:
91 MplayerLayer(QWidget* parent = 0, Qt::WindowFlags f = 0);
92 ~MplayerLayer();
93
94#if REPAINT_BACKGROUND_OPTION
95 //! If b is true, the background of the widget will be repainted as usual.
96 /*! Otherwise the background will not repainted when a video is playing. */
97 void setRepaintBackground(bool b);
98
99 //! Return true if repainting the background is allowed.
100 bool repaintBackground() { return repaint_background; };
101#endif
102
103public slots:
104 //! Should be called when a file has started.
105 /*! It's needed to know if the background has to be cleared or not. */
106 virtual void playingStarted();
107 //! Should be called when a file has stopped.
108 virtual void playingStopped();
109
110#if REPAINT_BACKGROUND_OPTION
111protected:
112 virtual void paintEvent ( QPaintEvent * e );
113#endif
114
115private:
116#if REPAINT_BACKGROUND_OPTION
117 bool repaint_background;
118#endif
119 bool playing;
120};
121
122
123class MplayerWindow : public Screen
124{
125 Q_OBJECT
126
127public:
128 MplayerWindow(QWidget* parent = 0, Qt::WindowFlags f = 0);
129 ~MplayerWindow();
130
131 MplayerLayer * videoLayer() { return mplayerlayer; };
132
133 void setResolution( int w, int h);
134 void setAspect( double asp);
135 void setMonitorAspect(double asp);
136 void updateVideoWindow();
137
138#if USE_COLORKEY
139 void setColorKey(QColor c);
140#endif
141
142 void setOffsetX( int );
143 int offsetX();
144
145 void setOffsetY( int );
146 int offsetY();
147
148 void setZoom( double );
149 double zoom();
150
151 void allowVideoMovement(bool b) { allow_video_movement = b; };
152 bool isVideoMovementAllowed() { return allow_video_movement; };
153
154 void delayLeftClick(bool b) { delay_left_click = b; };
155 bool isLeftClickDelayed() { return delay_left_click; };
156
157 virtual QSize sizeHint () const;
158 virtual QSize minimumSizeHint() const;
159
160 virtual bool eventFilter(QObject *, QEvent *);
161
162#if LOGO_ANIMATION
163 bool animatedLogo() { return animated_logo; }
164#endif
165
166public slots:
167 void setLogoVisible(bool b);
168 void showLogo() { setLogoVisible(true); };
169 void hideLogo() { setLogoVisible(false); };
170
171#if LOGO_ANIMATION
172 void setAnimatedLogo(bool b) { animated_logo = b; };
173#endif
174
175 void moveLeft();
176 void moveRight();
177 void moveUp();
178 void moveDown();
179 void incZoom();
180 void decZoom();
181
182 void activateMouseDragTracking(bool active) { mouse_drag_tracking = active; }
183
184#if DELAYED_RESIZE
185protected slots:
186 void resizeLater();
187#endif
188
189protected:
190 virtual void retranslateStrings();
191 virtual void changeEvent ( QEvent * event ) ;
192
193 virtual void resizeEvent( QResizeEvent * e);
194 virtual void mouseReleaseEvent( QMouseEvent * e);
195 virtual void mouseDoubleClickEvent( QMouseEvent * e );
196 virtual void wheelEvent( QWheelEvent * e );
197 void moveLayer( int offset_x, int offset_y );
198
199signals:
200 //void rightButtonReleased( QPoint p );
201 void doubleClicked();
202 void leftClicked();
203 void rightClicked();
204 void middleClicked();
205 void xbutton1Clicked(); // first X button
206 void xbutton2Clicked(); // second X button
207 void keyPressed(QKeyEvent * e);
208 void wheelUp();
209 void wheelDown();
210 void mouseMovedDiff(QPoint);
211
212protected:
213 int video_width, video_height;
214 double aspect;
215 double monitoraspect;
216
217 MplayerLayer * mplayerlayer;
218 QLabel * logo;
219
220 // Zoom and moving
221 int offset_x, offset_y;
222 double zoom_factor;
223
224 // Original pos and dimensions of the mplayerlayer
225 // before zooming or moving
226 int orig_x, orig_y;
227 int orig_width, orig_height;
228
229 bool allow_video_movement;
230
231#if DELAYED_RESIZE
232 QTimer * resize_timer;
233#endif
234
235 // Delay left click event
236 bool delay_left_click;
237 QTimer * left_click_timer;
238 bool double_clicked;
239
240#if LOGO_ANIMATION
241 bool animated_logo;
242#endif
243
244private:
245 bool mouse_drag_tracking;
246 bool isMoving;
247 QPoint startDrag;
248};
249
250#endif
251
Note: See TracBrowser for help on using the repository browser.