]> git.sesse.net Git - vlc/blob - modules/gui/qt4/main_interface.hpp
Qt4 - MouseWheel support - patch by Sergey Volk.
[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 "qt4.hpp"
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 class QEvent;
38 class InputManager;
39 class InputSlider;
40 class VideoWidget;
41 class BackgroundWidget;
42 class PlaylistWidget;
43 class VolumeClickHandler;
44 class VisualSelector;
45 class ControlsWidget;
46
47 class MainInterface : public QVLCMW
48 {
49     Q_OBJECT;
50 public:
51     MainInterface( intf_thread_t *);
52     virtual ~MainInterface();
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 dropEvent( QDropEvent *);
61     void dragEnterEvent( QDragEnterEvent * );
62     void dragMoveEvent( QDragMoveEvent * );
63     void dragLeaveEvent( QDragLeaveEvent * );
64     void closeEvent( QCloseEvent *);
65     Ui::MainInterfaceUI ui;
66     friend class VolumeClickHandler;
67 private:
68     QSettings *settings;
69     QSize mainSize, addSize;
70
71     bool need_components_update;
72     void calculateInterfaceSize();
73     void handleMainUi( QSettings* );
74     void doComponentsUpdate();
75
76     /* Video */
77     VideoWidget         *videoWidget;
78     virtual void keyPressEvent( QKeyEvent *);
79     virtual void wheelEvent( QWheelEvent * );
80
81     bool embeddedPlaylistWasActive;
82     bool videoIsActive;
83     QSize savedVideoSize;
84
85
86     BackgroundWidget    *bgWidget;
87     VisualSelector      *visualSelector;
88     ControlsWidget      *advControls;
89     PlaylistWidget      *playlistWidget;
90
91     bool                 playlistEmbeddedFlag;
92     bool                 videoEmbeddedFlag;
93     bool                 alwaysVideoFlag;
94     bool                 advControlsEnabled;
95     bool                 visualSelectorEnabled;
96
97     InputManager        *main_input_manager;
98     InputSlider         *slider;
99     input_thread_t      *p_input;    ///< Main input associated to the playlist
100
101     QLabel              *timeLabel;
102     QLabel              *nameLabel;
103
104     void customEvent( QEvent *);
105 public slots:
106     void undockPlaylist();
107 private slots:
108     void setNavigation( int );
109     void setStatus( int );
110     void setName( QString );
111     void setDisplay( float, int, int );
112     void updateOnTimer();
113     void play();
114     void stop();
115     void prev();
116     void next();
117     void playlist();
118     void visual();
119     void advanced();
120     void updateVolume( int sliderVolume );
121 };
122
123
124 class VolumeClickHandler : public QObject
125 {
126 public:
127     VolumeClickHandler( intf_thread_t *_p_intf, MainInterface *_m ) :QObject(_m)
128     {m = _m; p_intf = _p_intf; }
129     virtual ~VolumeClickHandler() {};
130     bool eventFilter( QObject *obj, QEvent *e )
131     {
132         if (e->type() == QEvent::MouseButtonPress )
133         {
134             aout_VolumeMute( p_intf, NULL );
135             return true;
136         }
137         return false;
138     }
139 private:
140     MainInterface *m;
141     intf_thread_t *p_intf;
142 };
143
144 #endif