X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fgui%2Fqt4%2Fmenus.hpp;h=3ccee3b9481037d85a6731543f1b759dc7b22165;hb=fd7e3ccc211703d018d454625a37a1ca662b7b15;hp=f7c15918fec1860a3d3f6b5bb6436a40a359f06e;hpb=e171f5be3b3eeedba554b44be1c6dbb7ccf1198b;p=vlc diff --git a/modules/gui/qt4/menus.hpp b/modules/gui/qt4/menus.hpp index f7c15918fe..3ccee3b948 100644 --- a/modules/gui/qt4/menus.hpp +++ b/modules/gui/qt4/menus.hpp @@ -19,113 +19,165 @@ * * 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. *****************************************************************************/ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. + *****************************************************************************/ -#ifndef _MENUS_H_ -#define _MENUS_H_ +#ifndef QVLC_MENUS_H_ +#define QVLC_MENUS_H_ #include "qt4.hpp" #include -#include - -/* Folder vs. Directory */ -#ifdef WIN32 -#define I_OPEN_FOLDER "Open &Folder..." -#else -#define I_OPEN_FOLDER "Open D&irectory..." -#endif //WIN32 +#include +#include using namespace std; -class QMenu; class QMenuBar; class QSystemTrayIcon; class MenuItemData : public QObject { - -Q_OBJECT + Q_OBJECT public: - MenuItemData( int i_id, int _i_type, vlc_value_t _val, const char *_var ) + MenuItemData( QObject* parent, vlc_object_t *_p_obj, int _i_type, + vlc_value_t _val, const char *_var ) : QObject( parent ) { - i_object_id = i_id; + p_obj = _p_obj; + if( p_obj ) + vlc_object_hold( p_obj ); 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 ); + free( psz_var ); + if( ( i_val_type & VLC_VAR_TYPE) == VLC_VAR_STRING ) + free( val.psz_string ); + if( p_obj ) + vlc_object_release( p_obj ); } - int i_object_id; - int i_val_type; + + vlc_object_t *p_obj; vlc_value_t val; char *psz_var; + +private: + int i_val_type; }; -class QVLCMenu : public QObject +class VLCMenuBar : public QObject { - Q_OBJECT; + Q_OBJECT + friend class MenuFunc; + public: - static void createMenuBar( MainInterface *mi, intf_thread_t *, - bool, bool ); - - /* Menus */ - static QMenu *FileMenu(); - static QMenu *SDMenu( intf_thread_t * ); - static QMenu *PlaylistMenu( MainInterface *, intf_thread_t *); - static QMenu *ToolsMenu( intf_thread_t *, MainInterface *, bool, bool with = true ); - static QMenu *NavigMenu( intf_thread_t * , QMenu * ); - static QMenu *VideoMenu( intf_thread_t * , QMenu * ); - static QMenu *AudioMenu( intf_thread_t * , QMenu * ); - static QMenu *InterfacesMenu( intf_thread_t *p_intf, QMenu * ); - static QMenu *HelpMenu(); + /* Main bar creation */ + static void createMenuBar( MainInterface *mi, intf_thread_t * ); /* Popups Menus */ - static void AudioPopupMenu( intf_thread_t * ); - static void VideoPopupMenu( intf_thread_t * ); - static void MiscPopupMenu( intf_thread_t * ); static void PopupMenu( intf_thread_t *, bool ); + static void AudioPopupMenu( intf_thread_t *, bool ); + static void VideoPopupMenu( intf_thread_t *, bool ); + static void MiscPopupMenu( intf_thread_t *, bool ); /* Systray */ - static void updateSystrayMenu( MainInterface *,intf_thread_t *, + static void updateSystrayMenu( MainInterface *, intf_thread_t *, bool b_force_visible = false); /* Actions */ - static void DoAction( intf_thread_t *, QObject * ); + static void DoAction( QObject * ); + enum actionflag { + ACTION_NONE = 0x0, + ACTION_ALWAYS_ENABLED = 0x1, + ACTION_MANAGED = 0x2, /* managed using EnableStatic(bool)? */ + ACTION_NO_CLEANUP = 0x4, + ACTION_STATIC = 0x6, /* legacy shortcut */ + ACTION_DELETE_ON_REBUILD = 0x8 + }; + Q_DECLARE_FLAGS(actionflags, actionflag) + private: + /* All main Menus */ + static QMenu *FileMenu( intf_thread_t *, QWidget *, MainInterface * mi = NULL ); + + static QMenu *ToolsMenu( QMenu * ); + static QMenu *ToolsMenu( QWidget *parent ) { return ToolsMenu( new QMenu( parent ) ); } + + static QMenu *ViewMenu( intf_thread_t *, QMenu *, MainInterface * mi = NULL ); + + static QMenu *InterfacesMenu( intf_thread_t *p_intf, QMenu * ); + static void ExtensionsMenu( intf_thread_t *p_intf, QMenu * ); + + static QMenu *NavigMenu( intf_thread_t *, QMenu * ); + static QMenu *NavigMenu( intf_thread_t *p_intf, QWidget *parent ) { + return NavigMenu( p_intf, new QMenu( parent ) ); + } + static QMenu *RebuildNavigMenu( intf_thread_t *, QMenu *, bool b_keep = false ); + + static QMenu *VideoMenu( intf_thread_t *, QMenu *, bool b_subtitle = true ); + static QMenu *VideoMenu( intf_thread_t *p_intf, QWidget *parent ) { + return VideoMenu( p_intf, new QMenu( parent ) ); + } + static QMenu *SubtitleMenu( QMenu *current); + + static QMenu *AudioMenu( intf_thread_t *, QMenu * ); + static QMenu *AudioMenu( intf_thread_t *p_intf, QWidget *parent ) { + return AudioMenu( p_intf, new QMenu( parent ) ); + } + + static QMenu *HelpMenu( QWidget * ); + + /* Popups Menus */ + static void PopupMenuStaticEntries( QMenu *menu ); + static void PopupMenuPlaylistEntries( QMenu *menu, intf_thread_t *p_intf, + input_thread_t *p_input ); + static void PopupMenuPlaylistControlEntries( QMenu *menu, intf_thread_t *p_intf ); + static void PopupMenuControlEntries( QMenu *menu, intf_thread_t *p_intf, bool b = true ); + /* Generic automenu methods */ static QMenu * Populate( intf_thread_t *, QMenu *current, - vector&, vector&, - bool append = false ); + QVector&, QVector& ); - static void CreateAndConnect( QMenu *, const char *, QString, QString, - int, int, vlc_value_t, int, bool c = false ); - static void CreateItem( QMenu *, const char *, vlc_object_t *, bool ); + static void CreateAndConnect( QMenu *, const char *, const QString&, + const QString&, int, vlc_object_t *, + vlc_value_t, int, bool c = false ); + static void UpdateItem( intf_thread_t *, QMenu *, const char *, + vlc_object_t *, bool ); static int CreateChoicesMenu( QMenu *,const char *, vlc_object_t *, bool ); + static void EnableStaticEntries( QMenu *, bool ); + + /* recentMRL menu */ + static QMenu *recentsMenu; + +public slots: + static void updateRecents( intf_thread_t * ); }; +Q_DECLARE_OPERATORS_FOR_FLAGS(VLCMenuBar::actionflags) class MenuFunc : public QObject { -Q_OBJECT + Q_OBJECT public: - MenuFunc( QMenu *_menu, int _id ) { menu = _menu; id = _id; }; + MenuFunc( QMenu *_menu, int _id ) : QObject( (QObject *)_menu ), + menu( _menu ), id( _id ){} + void doFunc( intf_thread_t *p_intf) { switch( id ) { - 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; + case 1: VLCMenuBar::AudioMenu( p_intf, menu ); break; + case 2: VLCMenuBar::VideoMenu( p_intf, menu ); break; + case 3: VLCMenuBar::RebuildNavigMenu( p_intf, menu ); break; + case 4: VLCMenuBar::ViewMenu( p_intf, menu ); break; } - }; - int id; QMenu *menu; + } +private: + QMenu *menu; + int id; }; #endif