main_interface.hpp 8.56 KB
Newer Older
zorglub's avatar
zorglub committed
1
2
3
/*****************************************************************************
 * main_interface.hpp : Main Interface
 ****************************************************************************
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
4
 * Copyright (C) 2006-2008 the VideoLAN team
5
 * $Id$
zorglub's avatar
zorglub committed
6
7
 *
 * Authors: Clément Stenac <zorglub@videolan.org>
8
 *          Jean-Baptiste Kempf <jb@videolan.org>
zorglub's avatar
zorglub committed
9
10
11
12
13
14
15
16
17
18
19
20
21
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
22
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23
 *****************************************************************************/
zorglub's avatar
zorglub committed
24

25
26
#ifndef QVLC_MAIN_INTERFACE_H_
#define QVLC_MAIN_INTERFACE_H_
zorglub's avatar
zorglub committed
27

zorglub's avatar
zorglub committed
28
#include "qt4.hpp"
zorglub's avatar
zorglub committed
29

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
30
31
#include "util/qvlcframe.hpp"
#include "components/preferences_widgets.hpp" /* First Start */
32
33
34
#ifdef WIN32
 #include <vlc_windows_interfaces.h>
#endif
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
35

36
#include <QSystemTrayIcon>
37
38

class QSettings;
zorglub's avatar
zorglub committed
39
class QCloseEvent;
40
class QKeyEvent;
41
class QLabel;
42
class QEvent;
43
class InputManager;
44
class VideoWidget;
45
46
class BackgroundWidget;
class PlaylistWidget;
zorglub's avatar
zorglub committed
47
class VisualSelector;
48
class AdvControlsWidget;
zorglub's avatar
zorglub committed
49
class ControlsWidget;
50
class InputControlsWidget;
lukas.durfina's avatar
lukas.durfina committed
51
class FullscreenControllerWidget;
52
class SpeedControlWidget;
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
53
class QVBoxLayout;
54
class QMenu;
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
55
class QSize;
56
class QStackedWidget;
57

58
enum {
59
60
    CONTROLS_VISIBLE  = 0x1,
    CONTROLS_HIDDEN   = 0x2,
61
    CONTROLS_ADVANCED = 0x4,
62
};
63

64

65
66
67
68
69
70
71
typedef enum pl_dock_e {
    PL_UNDOCKED,
    PL_BOTTOM,
    PL_RIGHT,
    PL_LEFT
} pl_dock_e;

zorglub's avatar
zorglub committed
72
class MainInterface : public QVLCMW
zorglub's avatar
zorglub committed
73
74
{
    Q_OBJECT;
75

76
    friend class PlaylistWidget;
77

zorglub's avatar
zorglub committed
78
79
80
public:
    MainInterface( intf_thread_t *);
    virtual ~MainInterface();
81

82
    /* Video requests from core */
83
84
    WId getVideo( int *pi_x, int *pi_y,
                  unsigned int *pi_width, unsigned int *pi_height );
85
    void releaseVideo( void  );
86
    int controlVideo( int i_query, va_list args );
87

88
    /* Getters */
89
#ifndef HAVE_MAEMO
90
91
    QSystemTrayIcon *getSysTray() { return sysTray; }
    QMenu *getSysTrayMenu() { return systrayMenu; }
92
#endif
93
    int getControlsVisibilityStatus();
94

95
    /* Sizehint() */
96
97
    virtual QSize sizeHint() const;

zorglub's avatar
zorglub committed
98
protected:
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
99
    void dropEventPlay( QDropEvent *, bool);
100
101
102
#ifdef WIN32
    bool winEvent( MSG *, long * );
#endif
103
104
105
106
107
108
109
110
111
    virtual void dropEvent( QDropEvent *);
    virtual void dragEnterEvent( QDragEnterEvent * );
    virtual void dragMoveEvent( QDragMoveEvent * );
    virtual void dragLeaveEvent( QDragLeaveEvent * );
    virtual void closeEvent( QCloseEvent *);
    virtual void customEvent( QEvent *);
    virtual void keyPressEvent( QKeyEvent *);
    virtual void wheelEvent( QWheelEvent * );
    virtual void resizeEvent( QResizeEvent * event );
112

zorglub's avatar
zorglub committed
113
private:
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
114
115
    void createMainWidget( QSettings* );
    void createStatusBar();
116

117
118
    /* Systray */
    void handleSystray();
119
    void createSystray();
120
    void initSystray();
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
121
    bool isDocked() { return ( i_pl_dock != PL_UNDOCKED ); }
122

123
    void showTab( int i_tab );
124
    void restoreStackOldWidget();
125
126
    void showVideo() { showTab( VIDEO_TAB ); }
    void showBg() { showTab( BACKG_TAB ); }
127
    void hideStackWidget() { showTab( HIDDEN_TAB ); }
128

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
129
    QSettings           *settings;
130
#ifndef HAVE_MAEMO
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
131
132
    QSystemTrayIcon     *sysTray;
    QMenu               *systrayMenu;
133
#endif
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
134
    QString              input_name;
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
135
    QVBoxLayout         *mainLayout;
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
136
137
138
    ControlsWidget      *controls;
    InputControlsWidget *inputC;
    FullscreenControllerWidget *fullscreenControls;
139
    QStackedWidget      *stackCentralW;
140
    /* Video */
141
    VideoWidget         *videoWidget;
142

143
    BackgroundWidget    *bgWidget;
zorglub's avatar
zorglub committed
144
    VisualSelector      *visualSelector;
145
146
    PlaylistWidget      *playlistWidget;

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
147
148
149
150
151
    /* Status Bar */
    QLabel              *nameLabel;
    QLabel              *cryptedLabel;

    /* Status and flags */
152
153
154
    enum {
        HIDDEN_TAB = -1,
        BACKG_TAB  =  0,
155
156
        VIDEO_TAB  = 1,
        PLAYL_TAB  = 2,
157
158
159
160
    };
    int                  stackCentralOldState;

//    bool                 videoIsActive;       ///< Having a video now / THEMIM->hasV
161
162
    bool                 videoEmbeddedFlag;   ///< Want an external Video Window
    bool                 playlistVisible;     ///< Is the playlist visible ?
163
    bool                 visualSelectorEnabled;
164
    bool                 notificationEnabled; /// Systray Notifications
165

166
    bool                 b_keep_size;         ///< persistent resizeable window
167
168
    QSize                mainBasedSize;       ///< based Wnd (normal mode only)
    QSize                mainVideoSize;       ///< Wnd with video (all modes)
169
    int                  i_visualmode;        ///< Visual Mode
170
    pl_dock_e            i_pl_dock;
171
    int                  i_bg_height;         ///< Save height of bgWidget
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
172
    bool                 b_hideAfterCreation;
173

174
175
176
#ifdef WIN32
    HIMAGELIST himl;
    LPTASKBARLIST3 p_taskbl;
177
    UINT taskbar_wmsg;
178
    void createTaskBarButtons();
179
#endif
180
    void createPlaylist( bool );
181

zorglub's avatar
zorglub committed
182
183
public slots:
    void undockPlaylist();
184
    void dockPlaylist( pl_dock_e i_pos = PL_BOTTOM );
185
    void toggleMinimalView( bool );
186
    void togglePlaylist();
187
#ifndef HAVE_MAEMO
188
    void toggleUpdateSystrayMenu();
189
#endif
190
    void toggleAdvanced();
191
    void toggleFullScreen();
192
    void toggleFSC();
193
    void popupMenu( const QPoint& );
194
    void changeThumbbarButtons( int );
195
196

    /* Manage the Video Functions from the vout threads */
197
198
    void getVideoSlot( WId *p_id, int *pi_x, int *pi_y,
                       unsigned *pi_width, unsigned *pi_height );
199
    void releaseVideoSlot( void );
200

zorglub's avatar
zorglub committed
201
private slots:
202
    void debug();
203
    void destroyPopupMenu();
204
    void recreateToolbars();
205
    void doComponentsUpdate();
ivoire's avatar
ivoire committed
206
207
    void setName( const QString& );
    void setVLCWindowsTitle( const QString& title = "" );
208
#if 0
209
    void visual();
210
#endif
211
#ifndef HAVE_MAEMO
212
    void handleSystrayClick( QSystemTrayIcon::ActivationReason );
ivoire's avatar
ivoire committed
213
    void updateSystrayTooltipName( const QString& );
214
    void updateSystrayTooltipStatus( int );
215
#endif
216
    void showCryptedLabel( bool );
217
218
219

    void handleKeyPress( QKeyEvent * );

220
signals:
221
    void askGetVideo( WId *p_id, int *pi_x, int *pi_y,
222
                      unsigned *pi_width, unsigned *pi_height );
223
    void askReleaseVideo( );
224
    void askVideoToResize( unsigned int, unsigned int );
225
    void askVideoSetFullScreen( bool );
226
    void askUpdate();
227
    void minimalViewToggled( bool );
228
    void fullscreenInterfaceToggled( bool );
229
    void playPauseSignal();
230
231
232
233
234
235
    void play();
    void pause();
    void stop();
    void volumeUp();
    void volumeDown();
    void mute();
236
237
    void prevSignal();
    void nextSignal();
zorglub's avatar
zorglub committed
238
239
};

240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
#ifdef WIN32
#define WM_APPCOMMAND 0x0319

#define APPCOMMAND_VOLUME_MUTE            8
#define APPCOMMAND_VOLUME_DOWN            9
#define APPCOMMAND_VOLUME_UP              10
#define APPCOMMAND_MEDIA_NEXTTRACK        11
#define APPCOMMAND_MEDIA_PREVIOUSTRACK    12
#define APPCOMMAND_MEDIA_STOP             13
#define APPCOMMAND_MEDIA_PLAY_PAUSE       14
#define APPCOMMAND_LAUNCH_MEDIA_SELECT    16
#define APPCOMMAND_BASS_DOWN              19
#define APPCOMMAND_BASS_BOOST             20
#define APPCOMMAND_BASS_UP                21
#define APPCOMMAND_TREBLE_DOWN            22
#define APPCOMMAND_TREBLE_UP              23
#define APPCOMMAND_MICROPHONE_VOLUME_MUTE 24
#define APPCOMMAND_MICROPHONE_VOLUME_DOWN 25
#define APPCOMMAND_MICROPHONE_VOLUME_UP   26
#define APPCOMMAND_DICTATE_OR_COMMAND_CONTROL_TOGGLE    43
#define APPCOMMAND_MIC_ON_OFF_TOGGLE      44
#define APPCOMMAND_MEDIA_PLAY             46
#define APPCOMMAND_MEDIA_PAUSE            47
#define APPCOMMAND_MEDIA_RECORD           48
#define APPCOMMAND_MEDIA_FAST_FORWARD     49
#define APPCOMMAND_MEDIA_REWIND           50
#define APPCOMMAND_MEDIA_CHANNEL_UP       51
#define APPCOMMAND_MEDIA_CHANNEL_DOWN     52

#define FAPPCOMMAND_MOUSE 0x8000
#define FAPPCOMMAND_KEY   0
#define FAPPCOMMAND_OEM   0x1000
#define FAPPCOMMAND_MASK  0xF000

#define GET_APPCOMMAND_LPARAM(lParam) ((short)(HIWORD(lParam) & ~FAPPCOMMAND_MASK))
#define GET_DEVICE_LPARAM(lParam)     ((WORD)(HIWORD(lParam) & FAPPCOMMAND_MASK))
#define GET_MOUSEORKEY_LPARAM         GET_DEVICE_LPARAM
#define GET_FLAGS_LPARAM(lParam)      (LOWORD(lParam))
#define GET_KEYSTATE_LPARAM(lParam)   GET_FLAGS_LPARAM(lParam)
#endif
zorglub's avatar
zorglub committed
280
#endif