#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 * ) );
void DialogsProvider::addFromSimple( bool pl, bool go)
{
QStringList files = DialogsProvider::showSimpleOpen();
- int mode = go ? PLAYLIST_GO : PLAYLIST_PREPARSE;
+ bool first = go;
files.sort();
foreach( const QString &file, files )
{
QString url = toURI( toNativeSeparators( file ) );
- playlist_Add( THEPL, qtu( url ), NULL, PLAYLIST_APPEND | mode,
- PLAYLIST_END, pl, pl_Unlocked );
- RecentsMRL::getInstance( p_intf )->addRecent( url );
- mode = PLAYLIST_PREPARSE;
+ Open::openMRL( p_intf, url, first, pl);
+ first = false;
}
}
url = qfu(uri);
free( uri );
}
- playlist_Add( THEPL, qtu(url), NULL,
- !oud.shouldEnqueue() ? ( PLAYLIST_APPEND | PLAYLIST_GO )
- : ( PLAYLIST_APPEND | PLAYLIST_PREPARSE ),
- PLAYLIST_END, true, pl_Unlocked );
- RecentsMRL::getInstance( p_intf )->addRecent( url );
+
+ Open::openMRL( p_intf, qtu(url), !oud.shouldEnqueue() );
}
/* Directory */
**/
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;
-
- RecentsMRL::getInstance( p_intf )->addRecent( qfu(uri) );
-
- input_item_t *p_input = input_item_New( uri, NULL );
- free( uri );
- if( unlikely( p_input == NULL ) )
- return;
-
- /* FIXME: playlist_AddInput() can fail */
- playlist_AddInput( THEPL, p_input,
- go ? ( PLAYLIST_APPEND | PLAYLIST_GO ) : PLAYLIST_APPEND,
- PLAYLIST_END, pl, pl_Unlocked );
- vlc_gc_decref( p_input );
+ QString uri = DialogsProvider::getDirectoryDialog( p_intf );
+ if( !uri.isEmpty() )
+ Open::openMRL( p_intf, uri, go, pl );
}
-QString DialogsProvider::getDirectoryDialog()
+QString DialogsProvider::getDirectoryDialog( intf_thread_t *p_intf )
{
- QString dir = QFileDialog::getExistingDirectory( NULL, qtr( I_OP_DIR_WINTITLE ), p_intf->p_sys->filepath );
+ QString dir = QFileDialog::getExistingDirectory( NULL,
+ qtr( I_OP_DIR_WINTITLE ), p_intf->p_sys->filepath );
if( dir.isEmpty() ) return QString();
}
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 );
{
options += soutoption.split( " :");
- /* Create Input */
- input_item_t *p_input;
- p_input = input_item_New( qtu( mrl ), _("Streaming") );
-
- /* Add normal Options */
- for( int j = 0; j < options.count(); j++ )
- {
- QString qs = colon_unescape( options[j] );
- if( !qs.isEmpty() )
- {
- input_item_AddOption( p_input, qtu( qs ),
- VLC_INPUT_OPTION_TRUSTED );
- msg_Dbg( p_intf, "Adding option: %s", qtu( qs ) );
- }
- }
-
- /* Switch between enqueuing and starting the item */
- /* FIXME: playlist_AddInput() can fail */
- playlist_AddInput( THEPL, p_input,
- PLAYLIST_APPEND | PLAYLIST_GO, PLAYLIST_END, true, pl_Unlocked );
- vlc_gc_decref( p_input );
-
- RecentsMRL::getInstance( p_intf )->addRecent( mrl );
+ Open::openMRLwithOptions( p_intf, mrl, &options, true, true, _("Streaming") );
}
}
playlist_ServicesDiscoveryRemove( THEPL, qtu( data ) );
}
-/**
- * Play the MRL contained in the Recently played menu.
- **/
-void DialogsProvider::playMRL( const QString &mrl )
-{
- playlist_Add( THEPL, qtu(mrl), NULL,
- PLAYLIST_APPEND | PLAYLIST_GO , PLAYLIST_END, true, pl_Unlocked );
- RecentsMRL::getInstance( p_intf )->addRecent( mrl );
+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 );
}