main_interface.hpp 5.38 KB
Newer Older
Clément Stenac's avatar
Clément Stenac committed
1 2 3
/*****************************************************************************
 * main_interface.hpp : Main Interface
 ****************************************************************************
4
 * Copyright (C) 2006-2007 the VideoLAN team
5
 * $Id$
Clément Stenac's avatar
Clément Stenac committed
6 7
 *
 * Authors: Clément Stenac <zorglub@videolan.org>
8
 *          Jean-Baptiste Kempf <jb@videolan.org>
Clément Stenac's avatar
Clément Stenac 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
 *****************************************************************************/
Clément Stenac's avatar
Clément Stenac committed
24 25 26 27

#ifndef _MAIN_INTERFACE_H_
#define _MAIN_INTERFACE_H_

Clément Stenac's avatar
Clément Stenac committed
28
#include "qt4.hpp"
Clément Stenac's avatar
Clément Stenac committed
29
#include "util/qvlcframe.hpp"
30
#include "components/preferences_widgets.hpp"
Clément Stenac's avatar
Clément Stenac committed
31

Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
32 33
#include <vlc_aout.h>

34
#include <QSystemTrayIcon>
35 36

class QSettings;
Clément Stenac's avatar
Clément Stenac committed
37
class QCloseEvent;
38
class QKeyEvent;
39
class QLabel;
40
class QEvent;
41
class InputManager;
42
class VideoWidget;
43 44
class BackgroundWidget;
class PlaylistWidget;
Clément Stenac's avatar
Clément Stenac committed
45
class VisualSelector;
46
class AdvControlsWidget;
Clément Stenac's avatar
Clément Stenac committed
47
class ControlsWidget;
48
class SpeedControlWidget;
49
class QMenu;
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
50
class QSize;
51
class QDockWidet;
52
class QProgressBar;
53 54 55 56 57 58

enum{
    CONTROLS_HIDDEN = 0x0,
    CONTROLS_VISIBLE = 0x1,
    CONTROLS_ADVANCED = 0x2
};
59

60
class MainInterface : public QVLCMW
Clément Stenac's avatar
Clément Stenac committed
61 62
{
    Q_OBJECT;
63 64 65 66

    friend class VolumeClickHandler;
    friend class InteractionDialog;

Clément Stenac's avatar
Clément Stenac committed
67 68 69
public:
    MainInterface( intf_thread_t *);
    virtual ~MainInterface();
70

71
    /* Video requests from core */
72 73 74
    void *requestVideo( vout_thread_t *p_nvout, int *pi_x,
                        int *pi_y, unsigned int *pi_width,
                        unsigned int *pi_height );
75
    void releaseVideo( void * );
76
    int controlVideo( void *p_window, int i_query, va_list args );
77
    void requestLayoutUpdate();
78

79
    /* Getters */
80 81
    QSystemTrayIcon *getSysTray() { return sysTray; };
    QMenu *getSysTrayMenu() { return systrayMenu; };
82
    int getControlsVisibilityStatus();
83

84 85
    bool b_toUpdate;
#if 0    /* Sizehint() */
86
    QSize sizeHint() const;
87
#endif
Clément Stenac's avatar
Clément Stenac committed
88
protected:
89
//    void resizeEvent( QResizeEvent * );
90 91 92 93
    void dropEvent( QDropEvent *);
    void dragEnterEvent( QDragEnterEvent * );
    void dragMoveEvent( QDragMoveEvent * );
    void dragLeaveEvent( QDragLeaveEvent * );
Clément Stenac's avatar
Clément Stenac committed
94
    void closeEvent( QCloseEvent *);
95

Clément Stenac's avatar
Clément Stenac committed
96
private:
97 98 99 100 101 102
    QSettings           *settings;
    QSystemTrayIcon     *sysTray;
    QMenu               *systrayMenu;
    QString              input_name;
    QVBoxLayout         *mainLayout;
    ControlsWidget      *controls;
103
    QMenu               *speedControlMenu;
104
    SpeedControlWidget  *speedControl;
105
    QProgressBar        *pgBar;
106

107
    void handleMainUi( QSettings* );
108
    void askForPrivacy();
109
    int  privacyDialog( QList<ConfigControl *> controls );
110

111 112
    /* Systray */
    void handleSystray();
113
    void createSystray();
114

115 116 117
    void createStatusBar();
    void initSystray();

118
    /* Video */
119
    VideoWidget         *videoWidget;
120
    //    QSize                savedVideoSize;
121

122
    BackgroundWidget    *bgWidget;
Clément Stenac's avatar
Clément Stenac committed
123
    VisualSelector      *visualSelector;
124
    PlaylistWidget      *playlistWidget;
125
    QDockWidget         *dockPL;
126

127 128 129
    bool                 videoIsActive; ///< Having a video now / THEMIM->hasV
    bool                 videoEmbeddedFlag; ///< Want an external Video Window
    bool                 playlistVisible; ///< Is the playlist visible ?
130
    bool                 visualSelectorEnabled;
131 132
    bool                 notificationEnabled; /// Systray Notifications
    bool                 b_remainingTime; /* showing elapsed or remaining time */
133
    int                  i_visualmode; ///< Visual Mode
134 135 136

    input_thread_t      *p_input;    ///< Main input associated to the playlist

137
    /* Status Bar */
138
    QLabel              *timeLabel;
139
    QLabel              *speedLabel;
140
    QLabel              *nameLabel;
141

142 143 144
    virtual void customEvent( QEvent *);
    virtual void keyPressEvent( QKeyEvent *);
    virtual void wheelEvent( QWheelEvent * );
145

146 147
public slots:
    void undockPlaylist();
148
    void toggleMinimalView();
149
    void togglePlaylist();
150
    void toggleUpdateSystrayMenu();
151
    void toggleAdvanced();
152
    void toggleFullScreen();
153 154 155 156

    /* Manage the Video Functions from the vout threads */
    void releaseVideoSlot( void * );

Clément Stenac's avatar
Clément Stenac committed
157
private slots:
158
    void debug();
159
    void updateOnTimer();
160
    void doComponentsUpdate();
161
    void setStatus( int );
162
    void setRate( int );
Clément Stenac's avatar
Clément Stenac committed
163
    void setName( QString );
164
    void setVLCWindowsTitle( QString title = "" );
165
    void setDisplayPosition( float, int, int );
166
    void toggleTimeDisplay();
167
#if 0
168
    void visual();
169 170
#endif
    void handleSystrayClick( QSystemTrayIcon::ActivationReason );
171 172
    void updateSystrayTooltipName( QString );
    void updateSystrayTooltipStatus( int );
173
    void showSpeedMenu( QPoint );
174
signals:
175
    void askReleaseVideo( void * );
176
    void askVideoToResize( unsigned int, unsigned int );
177 178
    void askVideoToToggle();
    void askBgWidgetToToggle();
179
    void askUpdate();
Clément Stenac's avatar
Clément Stenac committed
180 181
};

Clément Stenac's avatar
Clément Stenac committed
182
#endif