]> git.sesse.net Git - vlc/blob - modules/gui/qt4/main_interface.hpp
Qt4 - MI: Install an event filter to make click on timeLabel automatically switch...
[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  *          Jean-Baptiste Kempf <jb@videolan.org>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23  *****************************************************************************/
24
25 #ifndef _MAIN_INTERFACE_H_
26 #define _MAIN_INTERFACE_H_
27
28 #include "qt4.hpp"
29 #include "util/qvlcframe.hpp"
30
31 #include <vlc_aout.h>
32
33 #include <QSystemTrayIcon>
34
35 class QSettings;
36 class QCloseEvent;
37 class QKeyEvent;
38 class QLabel;
39 class QEvent;
40 class InputManager;
41 class VideoWidget;
42 class BackgroundWidget;
43 class PlaylistWidget;
44 class VisualSelector;
45 class AdvControlsWidget;
46 class ControlsWidget;
47 class QMenu;
48 class QSize;
49
50 class MainInterface : public QVLCMW
51 {
52     Q_OBJECT;
53 public:
54     MainInterface( intf_thread_t *);
55     virtual ~MainInterface();
56
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     bool isAdvancedVisible();
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  
74     bool eventFilter(QObject *obj, QEvent *event);
75
76     friend class VolumeClickHandler;
77 private:
78     QSettings           *settings;
79     QSize                mainSize, addSize;
80     QSystemTrayIcon     *sysTray;
81     QMenu               *systrayMenu;
82     QString              input_name;
83     QVBoxLayout         *mainLayout;
84     ControlsWidget      *controls;
85
86     bool                 need_components_update;
87
88     void calculateInterfaceSize();
89     void handleMainUi( QSettings* );
90     void handleSystray();
91     void doComponentsUpdate();
92     void createSystray();
93
94     /* Video */
95     VideoWidget         *videoWidget;
96     virtual void keyPressEvent( QKeyEvent *);
97     virtual void wheelEvent( QWheelEvent * );
98
99     bool                 embeddedPlaylistWasActive;
100     bool                 videoIsActive;
101     QSize                savedVideoSize;
102
103     BackgroundWidget    *bgWidget;
104     VisualSelector      *visualSelector;
105     PlaylistWidget      *playlistWidget;
106
107     bool                 playlistEmbeddedFlag;
108     bool                 videoEmbeddedFlag;
109     bool                 alwaysVideoFlag;
110     bool                 visualSelectorEnabled;
111     bool                 notificationEnabled;
112
113     InputManager        *main_input_manager;
114     input_thread_t      *p_input;    ///< Main input associated to the playlist
115
116     QLabel              *timeLabel;
117     QLabel              *speedLabel;
118     QLabel              *nameLabel;
119     
120     bool                 b_remainingTime;
121
122     void customEvent( QEvent *);
123 public slots:
124     void undockPlaylist();
125     void toggleMenus();
126     void togglePlaylist();
127     void toggleUpdateSystrayMenu();
128     void toggleAdvanced();
129 private slots:
130     void updateOnTimer();
131     void setStatus( int );
132     void setName( QString );
133     void setVLCWindowsTitle( QString title = "" );
134     void setDisplay( float, int, int );
135     void toggleTimeDisplay();
136     void setElapsedTime();
137     void setRemainTime();
138 #if 0
139     void visual();
140 #endif
141     void handleSystrayClick( QSystemTrayIcon::ActivationReason );
142     void updateSystrayMenu( int );
143     void updateSystrayTooltipName( QString );
144     void updateSystrayTooltipStatus( int );
145     void showSpeedMenu( QPoint );
146     void showTimeMenu( QPoint );
147 };
148
149 #endif