#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;
EpgDialog::getInstance( p_intf )->toggleVisible();
}
+void DialogsProvider::setPopupMenu()
+{
+ delete popupMenu;
+ popupMenu = VLCMenuBar::PopupMenu( p_intf, true );
+}
+
+void DialogsProvider::destroyPopupMenu()
+{
+ delete popupMenu;
+ popupMenu = NULL;
+}
+
/* Generic open file */
void DialogsProvider::openFileGenericDialog( intf_dialog_args_t *p_arg )
{
/* Save */
if( p_arg->b_save )
{
- QString file = QFileDialog::getSaveFileName( NULL, p_arg->psz_title,
+ QString file = QFileDialog::getSaveFileName( NULL,
+ qfu( p_arg->psz_title ),
p_intf->p_sys->filepath, extensions );
if( !file.isEmpty() )
{
else /* non-save mode */
{
QStringList files = QFileDialog::getOpenFileNames( NULL,
- p_arg->psz_title, p_intf->p_sys->filepath,
+ qfu( p_arg->psz_title ), p_intf->p_sys->filepath,
extensions );
p_arg->i_results = files.count();
p_arg->psz_results = (char **)malloc( p_arg->i_results * sizeof( char * ) );
**/
static void openDirectory( intf_thread_t *p_intf, bool pl, bool go )
{
- QString dir = QFileDialog::getExistingDirectory( NULL, qtr( I_OP_DIR_WINTITLE ), p_intf->p_sys->filepath );
-
- if( dir.isEmpty() )
- return;
-
- p_intf->p_sys->filepath = dir;
-
- const char *scheme = "directory";
- if( dir.endsWith( DIR_SEP "VIDEO_TS", Qt::CaseInsensitive ) )
- scheme = "dvd";
- else if( dir.endsWith( DIR_SEP "BDMV", Qt::CaseInsensitive ) )
- {
- scheme = "bluray";
- dir.remove( "BDMV" );
- }
-
- char *uri = vlc_path2uri( qtu( toNativeSeparators( dir ) ), scheme );
- if( unlikely(uri == NULL) )
- return;
-
- Open::openMRL( p_intf, uri, go, pl );
+ QString uri = DialogsProvider::getDirectoryDialog( p_intf );
+ if( !uri.isEmpty() )
+ Open::openMRL( p_intf, uri, go, pl );
}
QString DialogsProvider::getDirectoryDialog( intf_thread_t *p_intf )
}
char *uri = vlc_path2uri( qtu( toNativeSeparators( dir ) ), scheme );
- if( unlikely(uri == NULL) ) return QString();
+ if( unlikely(uri == NULL) )
+ return QString();
+
dir = qfu( uri );
free( uri );
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 );
+}