menus.hpp 3.92 KB
Newer Older
1 2 3
/*****************************************************************************
 * menus.hpp : Menus handling
 ****************************************************************************
4 5
 * Copyright (C) 2006 the VideoLAN team
 * $Id$
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
 *
 * Authors: Clément Stenac <zorglub@videolan.org>
 *
 * 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
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/

#ifndef _MENUS_H_
#define _MENUS_H_

#include "qt4.hpp"
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
27

28 29 30 31 32 33
#include <QObject>
#include <vector>

using namespace std;

class QMenu;
34
class QMenuBar;
35
class QSystemTrayIcon;
36 37 38

class MenuItemData : public QObject
{
39 40 41

Q_OBJECT

42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
public:
    MenuItemData( int i_id, int _i_type, vlc_value_t _val, const char *_var )
    {
        i_object_id = i_id;
        i_val_type = _i_type;
        val = _val;
        psz_var = strdup( _var );
    }
    virtual ~MenuItemData()
    {
        if( psz_var ) free( psz_var );
        if( ((i_val_type & VLC_VAR_TYPE) == VLC_VAR_STRING)
            && val.psz_string ) free( val.psz_string );
    }
    int i_object_id;
    int i_val_type;
    vlc_value_t val;
    char *psz_var;
};

class QVLCMenu : public QObject
{
    Q_OBJECT;
public:
66 67
    static void createMenuBar( MainInterface *mi, intf_thread_t *,
                               bool, bool, bool );
68

69
    /* Menus */
70
    static QMenu *FileMenu();
Clément Stenac's avatar
Qt4:  
Clément Stenac committed
71
    static QMenu *SDMenu( intf_thread_t * );
72
    static QMenu *PlaylistMenu( MainInterface *, intf_thread_t *);
73
    static QMenu *ToolsMenu( intf_thread_t *, MainInterface *, bool, bool,
Clément Stenac's avatar
Clément Stenac committed
74
                             bool with = true );
75 76 77
    static QMenu *NavigMenu( intf_thread_t * , QMenu * );
    static QMenu *VideoMenu( intf_thread_t * , QMenu * );
    static QMenu *AudioMenu( intf_thread_t * , QMenu * );
78
    static QMenu *InterfacesMenu( intf_thread_t *p_intf, QMenu * );
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
79
    static QMenu *HelpMenu();
80

81
    /* Popups Menus */
82 83 84
    static void AudioPopupMenu( intf_thread_t * );
    static void VideoPopupMenu( intf_thread_t * );
    static void MiscPopupMenu( intf_thread_t * );
Damien Fouilleul's avatar
Damien Fouilleul committed
85
    static void PopupMenu( intf_thread_t *, bool );
86

87
    /* Systray */
88 89
    static void updateSystrayMenu( MainInterface *,intf_thread_t  *,
                                   bool b_force_visible = false);
90 91

    /* Actions */
92 93
    static void DoAction( intf_thread_t *, QObject * );
private:
94 95
    /* Generic automenu methods */
    static QMenu * Populate( intf_thread_t *, QMenu *current,
96 97
                             vector<const char*>&, vector<int>&,
                             bool append = false );
98 99 100

    static void CreateAndConnect( QMenu *, const char *, QString, QString,
                                  int, int, vlc_value_t, int, bool c = false );
101 102 103 104 105 106
    static void CreateItem( QMenu *, const char *, vlc_object_t *, bool );
    static int CreateChoicesMenu( QMenu *,const char *, vlc_object_t *, bool );
};

class MenuFunc : public QObject
{
107 108
Q_OBJECT

109 110 111 112 113 114
public:
    MenuFunc( QMenu *_menu, int _id ) { menu = _menu; id = _id; };
    void doFunc( intf_thread_t *p_intf)
    {
        switch( id )
        {
Clément Stenac's avatar
Clément Stenac committed
115 116 117 118
        case 1: QVLCMenu::VideoMenu( p_intf, menu ); break;
        case 2: QVLCMenu::AudioMenu( p_intf, menu ); break;
        case 3: QVLCMenu::NavigMenu( p_intf, menu ); break;
        case 4: QVLCMenu::InterfacesMenu( p_intf, menu ); break;
119 120 121
        }
    };
    int id; QMenu *menu;
122 123 124
};

#endif