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