]> git.sesse.net Git - vlc/blob - modules/gui/qt4/main_interface.hpp
Give control back to the main interface for handling interaction with video.
[vlc] / modules / gui / qt4 / main_interface.hpp
1 /*****************************************************************************
2  * main_interface.hpp : Main Interface
3  ****************************************************************************
4  * Copyright (C) 2006 the VideoLAN team
5  * $Id$
6  *
7  * Authors: ClĂ©ment Stenac <zorglub@videolan.org>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/
22
23 #ifndef _MAIN_INTERFACE_H_
24 #define _MAIN_INTERFACE_H_
25
26 #include <vlc/intf.h>
27 #include <vlc/aout.h>
28 #include "ui/main_interface.h"
29 #include "util/qvlcframe.hpp"
30
31 #include <QSize>
32
33 class QSettings;
34 class QCloseEvent;
35 class QKeyEvent;
36 class QLabel;
37
38 class InputManager;
39 class InputSlider;
40 class VideoWidget;
41 class BackgroundWidget;
42 class PlaylistWidget;
43 class VolumeClickHandler;
44
45 class MainInterface : public QVLCMW
46 {
47     Q_OBJECT;
48 public:
49     MainInterface( intf_thread_t *);
50     virtual ~MainInterface();
51
52
53     void *requestVideo( vout_thread_t *p_nvout, int *pi_x,
54                         int *pi_y, unsigned int *pi_width,
55                         unsigned int *pi_height );
56     void releaseVideo( void *);
57     int controlVideo( void *p_window, int i_query, va_list args );
58 protected:
59     void resizeEvent( QResizeEvent * );
60     void closeEvent( QCloseEvent *);
61     Ui::MainInterfaceUI ui;
62     friend class VolumeClickHandler;
63 private:
64     QSettings *settings;
65     QSize mainSize, addSize;
66
67     bool need_components_update;
68     void calculateInterfaceSize();
69     void handleMainUi( QSettings* );
70     void doComponentsUpdate();
71
72     /* Video */
73     VideoWidget         *videoWidget;
74     virtual void keyPressEvent( QKeyEvent *);
75
76     BackgroundWidget    *bgWidget;
77     PlaylistWidget      *playlistWidget;
78
79     bool                 playlistEmbeddedFlag;
80     bool                 videoEmbeddedFlag;
81
82     InputManager        *main_input_manager;
83     InputSlider         *slider;
84     input_thread_t      *p_input;    ///< Main input associated to the playlist
85
86     QLabel              *timeLabel;
87     QLabel              *nameLabel;
88 private slots:
89     void setStatus( int );
90     void setName( QString );
91     void setDisplay( float, int, int );
92     void updateOnTimer();
93     void play();
94     void stop();
95     void prev();
96     void next();
97     void playlist();
98     void updateVolume( int sliderVolume );
99 };
100
101
102 class VolumeClickHandler : public QObject
103 {
104 public:
105     VolumeClickHandler( MainInterface *_m ) :QObject(_m) {m = _m; }
106     virtual ~VolumeClickHandler() {};
107     bool eventFilter( QObject *obj, QEvent *e )
108     {
109         if (e->type() == QEvent::MouseButtonPress )
110         {
111             if( obj->objectName() == "volLowLabel" )
112             {
113                 m->ui.volumeSlider->setValue( 0 );
114             }
115             else
116                 m->ui.volumeSlider->setValue( 100 );
117             return true;
118         }
119         return false;
120     }
121 private:
122     MainInterface *m;
123 };
124
125 #endif