]> git.sesse.net Git - vlc/blob - modules/gui/qt4/main_interface.hpp
Qt4 - MainInterface: support for speed gestion.
[vlc] / modules / gui / qt4 / main_interface.hpp
1 /*****************************************************************************
2  * main_interface.hpp : Main Interface
3  ****************************************************************************
4  * Copyright (C) 2006-2007 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
24 #ifndef _MAIN_INTERFACE_H_
25 #define _MAIN_INTERFACE_H_
26
27
28 #include "qt4.hpp"
29 #include "ui/main_interface.h"
30 #include "util/qvlcframe.hpp"
31
32 #include <vlc_aout.h>
33
34 #include <QSystemTrayIcon>
35
36 class QSettings;
37 class QCloseEvent;
38 class QKeyEvent;
39 class QLabel;
40 class QEvent;
41 class InputManager;
42 class InputSlider;
43 class VideoWidget;
44 class BackgroundWidget;
45 class PlaylistWidget;
46 class VolumeClickHandler;
47 class VisualSelector;
48 class ControlsWidget;
49 class QMenu;
50 class QSize;
51
52 class MainInterface : public QVLCMW
53 {
54     Q_OBJECT;
55 public:
56     MainInterface( intf_thread_t *);
57     virtual ~MainInterface();
58     void *requestVideo( vout_thread_t *p_nvout, int *pi_x,
59                         int *pi_y, unsigned int *pi_width,
60                         unsigned int *pi_height );
61     void releaseVideo( void *);
62     int controlVideo( void *p_window, int i_query, va_list args );
63
64     QSystemTrayIcon *getSysTray() { return sysTray; };
65     QMenu *getSysTrayMenu() { return systrayMenu; };
66 protected:
67     void resizeEvent( QResizeEvent * );
68     void dropEvent( QDropEvent *);
69     void dragEnterEvent( QDragEnterEvent * );
70     void dragMoveEvent( QDragMoveEvent * );
71     void dragLeaveEvent( QDragLeaveEvent * );
72     void closeEvent( QCloseEvent *);
73     Ui::MainInterfaceUI ui;
74     friend class VolumeClickHandler;
75 private:
76     QSettings *settings;
77     QSize mainSize, addSize;
78     QSystemTrayIcon *sysTray;
79     QMenu *systrayMenu;
80     QString input_name;
81
82     bool need_components_update;
83     void calculateInterfaceSize();
84     void handleMainUi( QSettings* );
85     void handleSystray();
86     void doComponentsUpdate();
87     void createSystray();
88
89     /* Video */
90     VideoWidget         *videoWidget;
91     virtual void keyPressEvent( QKeyEvent *);
92     virtual void wheelEvent( QWheelEvent * );
93
94     bool embeddedPlaylistWasActive;
95     bool videoIsActive;
96     QSize savedVideoSize;
97
98
99     BackgroundWidget    *bgWidget;
100     VisualSelector      *visualSelector;
101     ControlsWidget      *advControls;
102     PlaylistWidget      *playlistWidget;
103
104     bool                 playlistEmbeddedFlag;
105     bool                 videoEmbeddedFlag;
106     bool                 alwaysVideoFlag;
107     bool                 advControlsEnabled;
108     bool                 visualSelectorEnabled;
109
110     InputManager        *main_input_manager;
111     InputSlider         *slider;
112     input_thread_t      *p_input;    ///< Main input associated to the playlist
113
114     QLabel              *timeLabel;
115     QLabel              *speedLabel;
116     QLabel              *nameLabel;
117
118     void customEvent( QEvent *);
119 public slots:
120     void undockPlaylist();
121     void playlist();
122     void toggleUpdateSystrayMenu();
123 private slots:
124     void setNavigation( int );
125     void setStatus( int );
126     void setName( QString );
127     void setVLCWindowsTitle( QString title = "" );
128     void setDisplay( float, int, int );
129     void updateOnTimer();
130     void play();
131     void stop();
132     void prev();
133     void next();
134     void visual();
135     void advanced();
136     void updateVolume( int sliderVolume );
137     void handleSystrayClick(  QSystemTrayIcon::ActivationReason );
138     void updateSystrayMenu( int );
139     void updateSystrayTooltipName( QString );
140     void updateSystrayTooltipStatus( int );
141 };
142
143
144 class VolumeClickHandler : public QObject
145 {
146 public:
147     VolumeClickHandler( intf_thread_t *_p_intf, MainInterface *_m ) :QObject(_m)
148     {m = _m; p_intf = _p_intf; }
149     virtual ~VolumeClickHandler() {};
150     bool eventFilter( QObject *obj, QEvent *e )
151     {
152         if (e->type() == QEvent::MouseButtonPress )
153         {
154             aout_VolumeMute( p_intf, NULL );
155             return true;
156         }
157         return false;
158     }
159 private:
160     MainInterface *m;
161     intf_thread_t *p_intf;
162 };
163
164 #endif