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

Last change on this file since 97 was 93, checked in by Silvan Scherrer, 15 years ago

smplayer: 0.6.9

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