INTF_DIALOG_FILE_GENERIC = 30,
INTF_DIALOG_INTERACTION = 50,
+ INTF_DIALOG_SENDKEY = 51,
INTF_DIALOG_UPDATEVLC = 90,
INTF_DIALOG_VLM,
#include "menus.hpp"
#include "recents.hpp"
#include "util/qt_dirs.hpp"
+#include "util/customwidgets.hpp" /* VLCKeyToString() */
#include "main_interface.hpp"
/* The dialogs */
DialogsProvider* DialogsProvider::instance = NULL;
DialogsProvider::DialogsProvider( intf_thread_t *_p_intf ) :
- QObject( NULL ), p_intf( _p_intf )
+ QObject( NULL ), p_intf( _p_intf ),
+ popupMenu( NULL ),
+ videoPopupMenu( NULL ),
+ audioPopupMenu( NULL ),
+ miscPopupMenu( NULL )
{
b_isDying = false;
delete menusUpdateMapper;
delete SDMapper;
- VLCMenuBar::PopupMenu( p_intf, false );
- VLCMenuBar::AudioPopupMenu( p_intf, false );
- VLCMenuBar::VideoPopupMenu( p_intf, false );
- VLCMenuBar::MiscPopupMenu( p_intf, false );
+ delete popupMenu;
+ delete videoPopupMenu;
+ delete audioPopupMenu;
+ delete miscPopupMenu;
}
void DialogsProvider::quit()
bookmarksDialog(); break;
case INTF_DIALOG_EXTENDED:
extendedDialog(); break;
+ case INTF_DIALOG_SENDKEY:
+ sendKey( de->i_arg ); break;
#ifdef ENABLE_VLM
case INTF_DIALOG_VLM:
vlmDialog(); break;
#endif
case INTF_DIALOG_POPUPMENU:
- VLCMenuBar::PopupMenu( p_intf, (de->i_arg != 0) ); break;
+ {
+ delete popupMenu; popupMenu = NULL;
+ bool show = (de->i_arg != 0);
+ if( show )
+ popupMenu = VLCMenuBar::PopupMenu( p_intf, show );
+ break;
+ }
case INTF_DIALOG_AUDIOPOPUPMENU:
- VLCMenuBar::AudioPopupMenu( p_intf, (de->i_arg != 0) ); break;
+ {
+ delete audioPopupMenu; audioPopupMenu = NULL;
+ bool show = (de->i_arg != 0);
+ if( show )
+ audioPopupMenu = VLCMenuBar::AudioPopupMenu( p_intf, show );
+ break;
+ }
case INTF_DIALOG_VIDEOPOPUPMENU:
- VLCMenuBar::VideoPopupMenu( p_intf, (de->i_arg != 0) ); break;
+ {
+ delete videoPopupMenu; videoPopupMenu = NULL;
+ bool show = (de->i_arg != 0);
+ if( show )
+ videoPopupMenu = VLCMenuBar::VideoPopupMenu( p_intf, show );
+ break;
+ }
case INTF_DIALOG_MISCPOPUPMENU:
- VLCMenuBar::MiscPopupMenu( p_intf, (de->i_arg != 0) ); break;
+ {
+ delete miscPopupMenu; miscPopupMenu = NULL;
+ bool show = (de->i_arg != 0);
+ if( show )
+ miscPopupMenu = VLCMenuBar::MiscPopupMenu( p_intf, show );
+ break;
+ }
case INTF_DIALOG_WIZARD:
case INTF_DIALOG_STREAMWIZARD:
openAndStreamingDialogs(); break;
playlist_ServicesDiscoveryRemove( THEPL, qtu( data ) );
}
+void DialogsProvider::sendKey( int key )
+{
+ // translate from a vlc keycode into a Qt sequence
+ QKeySequence kseq0( VLCKeyToString( key, true ) );
+
+ if( popupMenu == NULL )
+ {
+ // make sure at least a non visible popupmenu is available
+ popupMenu = VLCMenuBar::PopupMenu( p_intf, false );
+ if( unlikely( popupMenu == NULL ) )
+ return;
+ }
+
+ // test against key accelerators from the popupmenu
+ QList<QAction*> actions = popupMenu->findChildren<QAction*>();
+ for( int i = 0; i < actions.size(); i++ )
+ {
+ QAction* action = actions.at(i);
+ QKeySequence kseq = action->shortcut();
+ if( kseq == kseq0 )
+ {
+ action->trigger();
+ return;
+ }
+ }
+
+ // forward key to vlc core when not a key accelerator
+ var_SetInteger( p_intf->p_libvlc, "key-pressed", key );
+}
static DialogsProvider *instance;
intf_thread_t *p_intf;
+
+ QMenu* popupMenu;
+ QMenu* videoPopupMenu;
+ QMenu* audioPopupMenu;
+ QMenu* miscPopupMenu;
+
QWidget* root;
bool b_isDying;
void extendedDialog();
void synchroDialog();
void messagesDialog();
+ void sendKey( int key );
#ifdef ENABLE_VLM
void vlmDialog();
#endif
action->setCheckable( true );
action->setChecked( THEMIM->getPlayExitState() );
- if( mi->getSysTray() )
+ if( mi && mi->getSysTray() )
{
action = menu->addAction( qtr( "Close to systray"), mi,
SLOT( toggleUpdateSystrayMenu() ) );
* Popup menus - Right Click menus *
*****************************************************************************/
#define POPUP_BOILERPLATE \
- static QMenu* menu = NULL; \
- delete menu; menu = NULL; \
- if( !show ) \
- return; \
+ QMenu* menu; \
QVector<vlc_object_t *> objects; \
QVector<const char *> varnames; \
input_thread_t *p_input = THEMIM->getInput();
#define CREATE_POPUP \
menu = new QMenu(); \
Populate( p_intf, menu, varnames, objects ); \
- menu->popup( QCursor::pos() ); \
+ if( show ) \
+ menu->popup( QCursor::pos() ); \
void VLCMenuBar::PopupMenuPlaylistEntries( QMenu *menu,
intf_thread_t *p_intf,
}
/* Video Tracks and Subtitles tracks */
-void VLCMenuBar::VideoPopupMenu( intf_thread_t *p_intf, bool show )
+QMenu* VLCMenuBar::VideoPopupMenu( intf_thread_t *p_intf, bool show )
{
POPUP_BOILERPLATE
if( p_input )
VideoAutoMenuBuilder( THEPL, p_input, objects, varnames );
CREATE_POPUP
+ return menu;
}
/* Audio Tracks */
-void VLCMenuBar::AudioPopupMenu( intf_thread_t *p_intf, bool show )
+QMenu* VLCMenuBar::AudioPopupMenu( intf_thread_t *p_intf, bool show )
{
POPUP_BOILERPLATE
if( p_input )
AudioAutoMenuBuilder( p_input, objects, varnames );
CREATE_POPUP
+ return menu;
}
/* Navigation stuff, and general menus ( open ), used only for skins */
-void VLCMenuBar::MiscPopupMenu( intf_thread_t *p_intf, bool show )
+QMenu* VLCMenuBar::MiscPopupMenu( intf_thread_t *p_intf, bool show )
{
POPUP_BOILERPLATE
menu->addSeparator();
PopupMenuStaticEntries( menu );
- menu->popup( QCursor::pos() );
+ if( show )
+ menu->popup( QCursor::pos() );
+ return menu;
}
/* Main Menu that sticks everything together */
-void VLCMenuBar::PopupMenu( intf_thread_t *p_intf, bool show )
+QMenu* VLCMenuBar::PopupMenu( intf_thread_t *p_intf, bool show )
{
POPUP_BOILERPLATE
/* Static entries for ending, like open */
PopupMenuStaticEntries( menu );
- menu->popup( QCursor::pos() );
+ if( show )
+ menu->popup( QCursor::pos() );
+ return menu;
}
#undef CREATE_POPUP
static void createMenuBar( MainInterface *mi, intf_thread_t * );
/* Popups Menus */
- 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 );
+ static QMenu* PopupMenu( intf_thread_t *, bool );
+ static QMenu* AudioPopupMenu( intf_thread_t *, bool );
+ static QMenu* VideoPopupMenu( intf_thread_t *, bool );
+ static QMenu* MiscPopupMenu( intf_thread_t *, bool );
/* Systray */
static void updateSystrayMenu( MainInterface *, intf_thread_t *,