~ubuntu-branches/debian/experimental/smplayer/experimental

« back to all changes in this revision

Viewing changes to src/corelib/mplayerwindow.h

  • Committer: Bazaar Package Importer
  • Author(s): Maia Kozheva
  • Date: 2009-01-03 17:08:06 UTC
  • mfrom: (1.1.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20090103170806-eodntb2slv6g2pb6
Tags: 0.6.6-0ubuntu1
* The "just before FF" release.
* New upstream release.
* debian/control: Bumped Standards-Version to 3.8.0.
* debian/copyright: Changed (C) to © to fix Lintian warning.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*  smplayer, GUI front-end for mplayer.
2
 
    Copyright (C) 2006-2008 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
 
 
39
 
#define ZOOM_STEP 0.05
40
 
#define ZOOM_MIN 0.5
41
 
 
42
 
 
43
 
//! Screen is a widget that hides the mouse cursor after some seconds if not moved.
44
 
 
45
 
class Screen : public QWidget
46
 
{
47
 
        Q_OBJECT
48
 
 
49
 
public:
50
 
        Screen(QWidget* parent = 0, Qt::WindowFlags f = 0);
51
 
        ~Screen();
52
 
 
53
 
protected:
54
 
        virtual void mouseMoveEvent( QMouseEvent * e );
55
 
        virtual void paintEvent ( QPaintEvent * e );
56
 
 
57
 
protected slots:
58
 
        virtual void checkMousePos();
59
 
 
60
 
private:
61
 
        QPoint cursor_pos, last_cursor_pos;
62
 
};
63
 
 
64
 
//! MplayerLayer can be instructed to not delete the background.
65
 
 
66
 
class MplayerLayer : public Screen
67
 
{
68
 
        Q_OBJECT
69
 
 
70
 
public:
71
 
        MplayerLayer(QWidget* parent = 0, Qt::WindowFlags f = 0);
72
 
        ~MplayerLayer();
73
 
 
74
 
        //! If b is true, the background of the widget will be repainted as usual.
75
 
        /*! Otherwise the background will not repainted when a video is playing. */
76
 
        void allowClearingBackground(bool b);
77
 
 
78
 
        //! Return true if repainting the background is allowed.
79
 
        bool isClearingBackgroundAllowed() { return allow_clearing; };
80
 
 
81
 
public slots:
82
 
        //! Should be called when a file has started. 
83
 
    /*! It's needed to know if the background has to be cleared or not. */
84
 
        void playingStarted();
85
 
        //! Should be called when a file has stopped.
86
 
        void playingStopped();
87
 
 
88
 
protected:
89
 
        virtual void paintEvent ( QPaintEvent * e );
90
 
 
91
 
private:
92
 
        bool allow_clearing;
93
 
        bool playing;
94
 
};
95
 
 
96
 
 
97
 
class MplayerWindow : public Screen
98
 
{
99
 
    Q_OBJECT
100
 
 
101
 
public:
102
 
    MplayerWindow( QWidget* parent = 0, Qt::WindowFlags f = 0);
103
 
    ~MplayerWindow();
104
 
    
105
 
        void showLogo( bool b);
106
 
 
107
 
        MplayerLayer * videoLayer() { return mplayerlayer; };
108
 
 
109
 
        void setResolution( int w, int h);
110
 
        void setAspect( double asp);
111
 
        void setMonitorAspect(double asp);
112
 
        void updateVideoWindow();
113
 
 
114
 
#if USE_COLORKEY
115
 
        void setColorKey(QColor c);
116
 
#endif
117
 
 
118
 
        void setOffsetX( int );
119
 
        int offsetX();
120
 
 
121
 
        void setOffsetY( int );
122
 
        int offsetY();
123
 
 
124
 
        void setZoom( double );
125
 
        double zoom();
126
 
 
127
 
        void allowVideoMovement(bool b) { allow_video_movement = b; };
128
 
        bool isVideoMovementAllowed() { return allow_video_movement; };
129
 
 
130
 
        QPoint mousePosition() { return mouse_position; };
131
 
 
132
 
        virtual QSize sizeHint () const;
133
 
        virtual QSize minimumSizeHint() const;
134
 
 
135
 
        virtual bool eventFilter( QObject * watched, QEvent * event );
136
 
 
137
 
public slots:
138
 
        void moveLeft();
139
 
        void moveRight();
140
 
        void moveUp();
141
 
        void moveDown();
142
 
        void incZoom();
143
 
        void decZoom();
144
 
 
145
 
protected:
146
 
        virtual void retranslateStrings();
147
 
        virtual void changeEvent ( QEvent * event ) ;
148
 
 
149
 
    virtual void resizeEvent( QResizeEvent * e);
150
 
    virtual void mouseReleaseEvent( QMouseEvent * e);
151
 
        virtual void mouseDoubleClickEvent( QMouseEvent * e );
152
 
        virtual void wheelEvent( QWheelEvent * e );
153
 
        void moveLayer( int offset_x, int offset_y );
154
 
 
155
 
signals:
156
 
    //void rightButtonReleased( QPoint p );
157
 
        void doubleClicked();
158
 
        void leftClicked();
159
 
        void rightClicked();
160
 
        void middleClicked();
161
 
        void xbutton1Clicked(); // first X button
162
 
        void xbutton2Clicked(); // second X button
163
 
        void keyPressed(QKeyEvent * e);
164
 
        void wheelUp();
165
 
        void wheelDown();
166
 
        void mouseMoved(QPoint);
167
 
 
168
 
protected:
169
 
    int video_width, video_height;
170
 
    double aspect;
171
 
        double monitoraspect;
172
 
 
173
 
        MplayerLayer * mplayerlayer;
174
 
        QLabel * logo;
175
 
 
176
 
        // Zoom and moving
177
 
        int offset_x, offset_y;
178
 
        double zoom_factor;
179
 
 
180
 
        // Original pos and dimensions of the mplayerlayer
181
 
        // before zooming or moving
182
 
        int orig_x, orig_y;
183
 
        int orig_width, orig_height;
184
 
 
185
 
        bool allow_video_movement;
186
 
 
187
 
        QPoint mouse_position;
188
 
};
189
 
 
190
 
 
191
 
#endif
192