~ubuntu-branches/ubuntu/wily/smplayer/wily

« back to all changes in this revision

Viewing changes to src/mplayerwindow.h

  • Committer: Bazaar Package Importer
  • Author(s): Maia Kozheva
  • Date: 2009-03-31 23:05:43 UTC
  • mfrom: (1.2.2 upstream)
  • mto: This revision was merged to the branch mainline in revision 14.
  • Revision ID: james.westby@ubuntu.com-20090331230543-0h2hfwpwlu9opbv2
* New upstream release. (Closes: #523791)
  - Reworked subtitle font preferences. (Closes: #503295)
  - No longer installs qt_fr.qm. (Closes: #486314)
* debian/control:
  - Bumped Standards-Version to 3.8.1.
  - Changed maintainer name (still the same person and GPG key).
  - Changed section to video.
  - Build-depend on zlib1g-dev for findsubtitles.
  - Require Qt >= 4.3 per readme.
  - Added ${misc:Depends}.
  - Make smplayer-translations depend on smplayer and smplayer recommend
    smplayer-translations, not the other way round. (Closes: #489375)
* debian/copyright:
  - Significantly expanded per-file with new upstream authors.
* debian/rules:
  - Make make use correct uic in install.
  - Clean svn_revision.
  - Removed get-orig-source - not needed with uscan --repack.
* debian/patches/01_gl_translation.patch:
  - Added patch to fix lrelease error on smplayer_gl.ts.
* Added debian/README.source for simple-patchsys.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*  smplayer, GUI front-end for mplayer.
 
2
    Copyright (C) 2006-2009 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
 
 
35
class QWidget;
 
36
class QLabel;
 
37
class QKeyEvent;
 
38
class 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
 
 
48
class Screen : public QWidget
 
49
{
 
50
        Q_OBJECT
 
51
 
 
52
public:
 
53
        Screen(QWidget* parent = 0, Qt::WindowFlags f = 0);
 
54
        ~Screen();
 
55
 
 
56
protected:
 
57
#if !NEW_MOUSE_CHECK_POS
 
58
        virtual void mouseMoveEvent( QMouseEvent * e );
 
59
#endif
 
60
        virtual void paintEvent ( QPaintEvent * e );
 
61
 
 
62
protected slots:
 
63
        virtual void checkMousePos();
 
64
 
 
65
private:
 
66
#if NEW_MOUSE_CHECK_POS
 
67
        QPoint mouse_last_position;
 
68
#else
 
69
        QPoint cursor_pos, last_cursor_pos;
 
70
#endif
 
71
};
 
72
 
 
73
//! MplayerLayer can be instructed to not delete the background.
 
74
 
 
75
class MplayerLayer : public Screen
 
76
{
 
77
        Q_OBJECT
 
78
 
 
79
public:
 
80
        MplayerLayer(QWidget* parent = 0, Qt::WindowFlags f = 0);
 
81
        ~MplayerLayer();
 
82
 
 
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);
 
87
 
 
88
        //! Return true if repainting the background is allowed.
 
89
        bool repaintBackground() { return repaint_background; };
 
90
#endif
 
91
 
 
92
public slots:
 
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();
 
98
 
 
99
#if REPAINT_BACKGROUND_OPTION
 
100
protected:
 
101
        virtual void paintEvent ( QPaintEvent * e );
 
102
#endif
 
103
 
 
104
private:
 
105
#if REPAINT_BACKGROUND_OPTION
 
106
        bool repaint_background;
 
107
#endif
 
108
        bool playing;
 
109
};
 
110
 
 
111
 
 
112
class MplayerWindow : public Screen
 
113
{
 
114
    Q_OBJECT
 
115
 
 
116
public:
 
117
    MplayerWindow( QWidget* parent = 0, Qt::WindowFlags f = 0);
 
118
    ~MplayerWindow();
 
119
    
 
120
        void showLogo( bool b);
 
121
 
 
122
        MplayerLayer * videoLayer() { return mplayerlayer; };
 
123
 
 
124
        void setResolution( int w, int h);
 
125
        void setAspect( double asp);
 
126
        void setMonitorAspect(double asp);
 
127
        void updateVideoWindow();
 
128
 
 
129
#if USE_COLORKEY
 
130
        void setColorKey(QColor c);
 
131
#endif
 
132
 
 
133
        void setOffsetX( int );
 
134
        int offsetX();
 
135
 
 
136
        void setOffsetY( int );
 
137
        int offsetY();
 
138
 
 
139
        void setZoom( double );
 
140
        double zoom();
 
141
 
 
142
        void allowVideoMovement(bool b) { allow_video_movement = b; };
 
143
        bool isVideoMovementAllowed() { return allow_video_movement; };
 
144
 
 
145
        virtual QSize sizeHint () const;
 
146
        virtual QSize minimumSizeHint() const;
 
147
 
 
148
        virtual bool eventFilter( QObject * watched, QEvent * event );
 
149
 
 
150
public slots:
 
151
        void moveLeft();
 
152
        void moveRight();
 
153
        void moveUp();
 
154
        void moveDown();
 
155
        void incZoom();
 
156
        void decZoom();
 
157
 
 
158
#if DELAYED_RESIZE
 
159
protected slots:
 
160
        void resizeLater();
 
161
#endif
 
162
 
 
163
protected:
 
164
        virtual void retranslateStrings();
 
165
        virtual void changeEvent ( QEvent * event ) ;
 
166
 
 
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 );
 
172
 
 
173
signals:
 
174
    //void rightButtonReleased( QPoint p );
 
175
        void doubleClicked();
 
176
        void leftClicked();
 
177
        void rightClicked();
 
178
        void middleClicked();
 
179
        void xbutton1Clicked(); // first X button
 
180
        void xbutton2Clicked(); // second X button
 
181
        void keyPressed(QKeyEvent * e);
 
182
        void wheelUp();
 
183
        void wheelDown();
 
184
        void mouseMoved(QPoint);
 
185
 
 
186
protected:
 
187
    int video_width, video_height;
 
188
    double aspect;
 
189
        double monitoraspect;
 
190
 
 
191
        MplayerLayer * mplayerlayer;
 
192
        QLabel * logo;
 
193
 
 
194
        // Zoom and moving
 
195
        int offset_x, offset_y;
 
196
        double zoom_factor;
 
197
 
 
198
        // Original pos and dimensions of the mplayerlayer
 
199
        // before zooming or moving
 
200
        int orig_x, orig_y;
 
201
        int orig_width, orig_height;
 
202
 
 
203
        bool allow_video_movement;
 
204
 
 
205
#if DELAYED_RESIZE
 
206
        QTimer * resize_timer;
 
207
#endif
 
208
};
 
209
 
 
210
 
 
211
#endif
 
212