* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
+
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
-#include <QEvent>
-#include <QApplication>
-#include <QSignalMapper>
-#include <QFileDialog>
-
#include <vlc_common.h>
+#include <vlc_intf_strings.h>
+
#include "qt4.hpp"
#include "dialogs_provider.hpp"
#include "main_interface.hpp"
#include "menus.hpp"
-#include <vlc_intf_strings.h>
#include "input_manager.hpp"
#include "recents.hpp"
#include "dialogs/gototime.hpp"
#include "dialogs/podcast_configuration.hpp"
+#include <QEvent>
+#include <QApplication>
+#include <QSignalMapper>
+#include <QFileDialog>
+
+
DialogsProvider* DialogsProvider::instance = NULL;
DialogsProvider::DialogsProvider( intf_thread_t *_p_intf ) :
{
b_isDying = false;
+ /* Various signal mappers for the menus */
menusMapper = new QSignalMapper();
CONNECT( menusMapper, mapped(QObject *), this, menuAction( QObject *) );
void DialogsProvider::customEvent( QEvent *event )
{
- if( event->type() == DialogEvent_Type )
+ if( event->type() == (int)DialogEvent_Type )
{
DialogEvent *de = static_cast<DialogEvent*>(event);
switch( de->i_dialog )
QVLCMenu::MiscPopupMenu( p_intf ); break;
case INTF_DIALOG_WIZARD:
case INTF_DIALOG_STREAMWIZARD:
- openThenStreamingDialogs(); break;
+ openAndStreamingDialogs(); break;
#ifdef UPDATE_CHECK
case INTF_DIALOG_UPDATEVLC:
updateDialog(); break;
PodcastConfigDialog::getInstance( p_intf )->toggleVisible();
}
-
-/****************************************************************************
- * All the open/add stuff
- * Open Dialog first - Simple Open then
- ****************************************************************************/
-
-void DialogsProvider::openDialog( int i_tab )
-{
- OpenDialog::getInstance( p_intf->p_sys->p_mi , p_intf )->showTab( i_tab );
-}
-void DialogsProvider::openDialog()
-{
- openDialog( OPEN_FILE_TAB );
-}
+/* Generic open file */
void DialogsProvider::openFileGenericDialog( intf_dialog_args_t *p_arg )
{
if( p_arg == NULL )
free( p_arg->psz_extensions );
free( p_arg );
}
+/****************************************************************************
+ * All the open/add stuff
+ * Open Dialog first - Simple Open then
+ ****************************************************************************/
+void DialogsProvider::openDialog( int i_tab )
+{
+ OpenDialog::getInstance( p_intf->p_sys->p_mi , p_intf )->showTab( i_tab );
+}
+void DialogsProvider::openDialog()
+{
+ openDialog( OPEN_FILE_TAB );
+}
void DialogsProvider::openFileDialog()
{
openDialog( OPEN_FILE_TAB );
/* Same as the open one, but force the enqueue */
void DialogsProvider::PLAppendDialog()
{
- OpenDialog::getInstance( p_intf->p_sys->p_mi, p_intf, false, OPEN_AND_ENQUEUE)
- ->showTab( OPEN_FILE_TAB );
+ OpenDialog::getInstance( p_intf->p_sys->p_mi, p_intf, false,
+ OPEN_AND_ENQUEUE )->showTab( OPEN_FILE_TAB );
}
void DialogsProvider::MLAppendDialog()
delete qfd;
}
-
/****************************************************************************
* Sout emulation
****************************************************************************/
}
}
-void DialogsProvider::openThenStreamingDialogs()
+void DialogsProvider::openAndStreamingDialogs()
{
OpenDialog::getInstance( p_intf->p_sys->p_mi, p_intf, false, OPEN_AND_STREAM )
->showTab( OPEN_FILE_TAB );
}
-void DialogsProvider::openThenTranscodingDialogs()
+void DialogsProvider::openAndTranscodingDialogs()
{
OpenDialog::getInstance( p_intf->p_sys->p_mi , p_intf, false, OPEN_AND_SAVE )
->showTab( OPEN_FILE_TAB );
}
+void DialogsProvider::loadSubtitlesFile()
+{
+ input_thread_t *p_input = THEMIM->getInput();
+ if( !p_input ) return;
+
+ input_item_t *p_item = input_GetItem( p_input );
+ if( !p_item ) return;
+
+ char *path = input_item_GetURI( p_item );
+ if( !path ) path = strdup( "" );
+
+ char *sep = strrchr( path, DIR_SEP_CHAR );
+ if( sep ) *sep = '\0';
+
+ QStringList qsl = showSimpleOpen( qtr( "Open subtitles..." ),
+ EXT_FILTER_SUBTITLE,
+ path );
+ free( path );
+ QString qsFile;
+ foreach( qsFile, qsl )
+ {
+ if( !input_AddSubtitles( p_input, qtu( toNativeSeparators( qsFile ) ),
+ true ) )
+ msg_Warn( p_intf, "unable to load subtitles from '%s'",
+ qtu( qsFile ) );
+ }
+}
+
+
/****************************************************************************
- * Menus / Interaction
+ * Menus
****************************************************************************/
void DialogsProvider::menuAction( QObject *data )
void DialogsProvider::menuUpdateAction( QObject *data )
{
- MenuFunc * f = qobject_cast<MenuFunc *>(data);
- f->doFunc( p_intf );
+ MenuFunc *func = qobject_cast<MenuFunc *>(data);
+ assert( func );
+ func->doFunc( p_intf );
}
void DialogsProvider::SDMenuAction( QString data )
{
- char *psz_sd = strdup( qtu( data ) );
+ char *psz_sd = qtu( data );
if( !playlist_IsServicesDiscoveryLoaded( THEPL, psz_sd ) )
playlist_ServicesDiscoveryAdd( THEPL, psz_sd );
else
playlist_ServicesDiscoveryRemove( THEPL, psz_sd );
- free( psz_sd );
}
+/**
+ * Play the MRL contained in the Recently played menu.
+ **/
+void DialogsProvider::playMRL( const QString &mrl )
+{
+ input_item_t *p_input = input_item_New( p_intf,
+ qtu( mrl ), NULL );
+ playlist_AddInput( THEPL, p_input, PLAYLIST_GO,
+ PLAYLIST_END, true, pl_Unlocked );
+ vlc_gc_decref( p_input );
+
+ RecentsMRL::getInstance( p_intf )->addRecent( mrl );
+}
+
+/*************************************
+ * Interactions
+ *************************************/
void DialogsProvider::doInteraction( intf_dialog_args_t *p_arg )
{
InteractionDialog *qdialog;
}
}
-void DialogsProvider::loadSubtitlesFile()
-{
- input_thread_t *p_input = THEMIM->getInput();
- if( !p_input )
- return;
- input_item_t *p_item = input_GetItem( p_input );
- if( !p_item )
- return;
- char *path = input_item_GetURI( p_item );
- if( !path )
- path = strdup( "" );
- char *sep = strrchr( path, DIR_SEP_CHAR );
- if( sep )
- *sep = '\0';
- QStringList qsl = showSimpleOpen( qtr( "Open subtitles..." ),
- EXT_FILTER_SUBTITLE,
- path );
- free( path );
- QString qsFile;
- foreach( qsFile, qsl )
- {
- if( !input_AddSubtitles( p_input, qtu( toNativeSeparators( qsFile ) ),
- true ) )
- msg_Warn( p_intf, "unable to load subtitles from '%s'",
- qtu( qsFile ) );
- }
-}
-
-/**
- * Play the MRL contained in the Recently played menu.
- **/
-void DialogsProvider::playMRL( const QString &mrl )
-{
- input_item_t *p_input = input_item_New( p_intf,
- qtu( mrl ), NULL );
- playlist_AddInput( THEPL, p_input, PLAYLIST_GO,
- PLAYLIST_END, true, pl_Unlocked );
- vlc_gc_decref( p_input );
-
- RecentsMRL::getInstance( p_intf )->addRecent( mrl );
-}
#include "dialogs/interaction.hpp"
#include "dialogs/open.hpp"
-#include <QObject>
-#include <QApplication>
-
#define ADD_FILTER_MEDIA( string ) \
string += qtr( "Media Files" ); \
string += " ( "; \
DialogsProvider( intf_thread_t *);
intf_thread_t *p_intf;
static DialogsProvider *instance;
- void addFromSimple( bool, bool );
bool b_isDying;
+ void openDialog( int );
+ void addFromSimple( bool, bool );
+
public slots:
void doInteraction( intf_dialog_args_t * );
- void menuAction( QObject *);
- void menuUpdateAction( QObject * );
- void SDMenuAction( QString );
void playMRL( const QString & );
void playlistDialog();
void gotoTimeDialog();
void podcastConfigureDialog();
+ void openFileGenericDialog( intf_dialog_args_t * );
+
void simpleOpenDialog();
void simplePLAppendDialog();
void simpleMLAppendDialog();
void openDialog();
- void openDialog( int );
- void openFileGenericDialog( intf_dialog_args_t * );
void openDiscDialog();
void openFileDialog();
void openNetDialog();
void PLAppendDialog();
void MLAppendDialog();
+
void PLOpenDir();
void PLAppendDir();
void MLAppendDir();
void streamingDialog( QWidget *parent, QString mrl = "",
bool b_stream = true );
- void openThenStreamingDialogs();
- void openThenTranscodingDialogs();
+ void openAndStreamingDialogs();
+ void openAndTranscodingDialogs();
void openAPlaylist();
void saveAPlaylist();
void loadSubtitlesFile();
void quit();
+private slots:
+ void menuAction( QObject *);
+ void menuUpdateAction( QObject * );
+ void SDMenuAction( QString );
};
#endif
QObject( parent ), p_intf( _p_intf )
{
i_old_playing_status = END_S;
- old_name = "";
+ oldName = "";
artUrl = "";
p_input = NULL;
i_rate = 0;
emit statusChanged( PLAYING_S );
UpdateMeta();
UpdateArt();
- UpdateSPU();
UpdateTeletext();
UpdateNavigation();
UpdateVout();
delCallbacks();
i_old_playing_status = END_S;
i_input_id = 0;
- old_name = "";
+ oldName = "";
artUrl = "";
b_video = false;
timeA = 0;
emit voutChanged( false );
vlc_object_release( p_input );
p_input = NULL;
- UpdateSPU();
UpdateTeletext();
}
}
/* Convert the event from the callbacks in actions */
void InputManager::customEvent( QEvent *event )
{
- int type = event->type();
+ int i_type = event->type();
IMEvent *ple = static_cast<IMEvent *>(event);
- if ( type != PositionUpdate_Type &&
- type != ItemChanged_Type &&
- type != ItemRateChanged_Type &&
- type != ItemTitleChanged_Type &&
- type != ItemSpuChanged_Type &&
- type != ItemTeletextChanged_Type &&
- type != ItemStateChanged_Type &&
- type != StatisticsUpdate_Type &&
- type != InterfaceVoutUpdate_Type )
+ if ( i_type != PositionUpdate_Type &&
+ i_type != ItemChanged_Type &&
+ i_type != ItemRateChanged_Type &&
+ i_type != ItemTitleChanged_Type &&
+ i_type != ItemSpuChanged_Type &&
+ i_type != ItemTeletextChanged_Type &&
+ i_type != ItemStateChanged_Type &&
+ i_type != StatisticsUpdate_Type &&
+ i_type != InterfaceVoutUpdate_Type )
return;
- if( type == ItemStateChanged_Type )
+ if( i_type == ItemStateChanged_Type )
{
UpdateNavigation();
UpdateTeletext();
if( !hasInput() ) return;
- if( ( type != PositionUpdate_Type &&
- type != ItemRateChanged_Type &&
- type != ItemSpuChanged_Type &&
- type != ItemTeletextChanged_Type &&
- type != ItemStateChanged_Type &&
- type != StatisticsUpdate_Type &&
- type != InterfaceVoutUpdate_Type
+ if( ( i_type != PositionUpdate_Type &&
+ i_type != ItemRateChanged_Type &&
+ i_type != ItemSpuChanged_Type &&
+ i_type != ItemTeletextChanged_Type &&
+ i_type != ItemStateChanged_Type &&
+ i_type != StatisticsUpdate_Type &&
+ i_type != InterfaceVoutUpdate_Type
)
&& ( i_input_id != ple->i_id ) )
return;
- if( type != PositionUpdate_Type &&
- type != StatisticsUpdate_Type )
- msg_Dbg( p_intf, "New Event: type %i", type );
+ if( i_type != PositionUpdate_Type &&
+ i_type != StatisticsUpdate_Type )
+ msg_Dbg( p_intf, "New Event: type %i", i_type );
/* Actions */
- switch( type )
+ switch( i_type )
{
case PositionUpdate_Type:
UpdatePosition();
case InterfaceVoutUpdate_Type:
UpdateVout();
break;
+ default:
+ msg_Warn( p_intf, "This shouldn't happen: %i", i_type );
}
}
if( val.i_int > 0 )
{
emit titleChanged( true );
+ /* p_input != NULL since val.i_int != 0 */
val.i_int = 0;
var_Change( p_input, "chapter", VLC_VAR_CHOICESCOUNT, &val, NULL );
emit chapterChanged( (val.i_int > 0) );
free( psz_name );
}
- if( old_name != text )
+ if( oldName != text )
{
emit nameChanged( text );
- old_name=text;
+ oldName=text;
}
}
{
bool b_old_video = b_video;
- vlc_object_t *p_vout = (vlc_object_t*)vlc_object_find( p_input, VLC_OBJECT_VOUT, FIND_CHILD );
+ vlc_object_t *p_vout = (vlc_object_t*)vlc_object_find( p_input,
+ VLC_OBJECT_VOUT, FIND_CHILD );
b_video = p_vout != NULL;
if( p_vout )
vlc_object_release( p_vout );
p_input = NULL;
im = new InputManager( this, p_intf );
-// var_AddCallback( THEPL, "item-change", PLItemChanged, this );
var_AddCallback( THEPL, "item-change", ItemChanged, im );
var_AddCallback( THEPL, "playlist-current", PLItemChanged, this );
var_AddCallback( THEPL, "activity", PLItemChanged, this );
var_DelCallback( THEPL, "activity", PLItemChanged, this );
var_DelCallback( THEPL, "item-change", ItemChanged, im );
-// var_DelCallback( THEPL, "item-change", PLItemChanged, this );
var_DelCallback( THEPL, "playlist-current", PLItemChanged, this );
}
}
/* Should be PLItemChanged Event */
- if( VLC_OBJECT_INTF == p_intf->i_object_type ) /* FIXME: don't use object type */
+ if( !p_intf->p_sys->b_isDialogProvider )
{
vlc_mutex_lock( &p_intf->change_lock );
if( p_input && ( p_input->b_dead || !vlc_object_alive (p_input) ) )
getIM()->togglePlayPause();
}
-bool MainInputManager::teletextState()
-{
- if( getIM()->hasInput() )
- {
- const int i_teletext_es = var_GetInteger( getInput(), "teletext-es" );
- const int i_spu_es = var_GetInteger( getInput(), "spu-es" );
-
- return i_teletext_es >= 0 && i_teletext_es == i_spu_es;
- }
- return false;
-}
-
/* Static callbacks */
/* IM */
{
/* FIXME remove that static variable */
static int counter = 0;
+
InputManager *im = (InputManager*)param;
counter = ++counter % 4;
- if(!counter)
- return VLC_SUCCESS;
+ if(!counter) return VLC_SUCCESS;
+
IMEvent *event = new IMEvent( PositionUpdate_Type, 0 );
QApplication::postEvent( im, static_cast<QEvent*>(event) );
return VLC_SUCCESS;
class IMEvent : public QEvent
{
-public:
+friend class InputManager;
+ public:
IMEvent( int type, int id ) : QEvent( (QEvent::Type)(type) )
{ i_id = id ; } ;
virtual ~IMEvent() {};
+private:
int i_id;
};
bool hasAudio();
bool hasVideo() { return hasInput() && b_video; }
- QString getName() { return old_name; }
+ QString getName() { return oldName; }
private:
intf_thread_t *p_intf;
input_thread_t *p_input;
int i_input_id;
int i_old_playing_status;
- QString old_name;
+ QString oldName;
QString artUrl;
int i_rate;
bool b_video;
mtime_t timeA, timeB;
void customEvent( QEvent * );
+
void addCallbacks();
void delCallbacks();
+
void UpdateRate();
void UpdateMeta();
void UpdateStatus();
private:
MainInputManager( intf_thread_t * );
+ static MainInputManager *instance;
+
void customEvent( QEvent * );
InputManager *im;
input_thread_t *p_input;
-
intf_thread_t *p_intf;
- static MainInputManager *instance;
+
public slots:
- bool teletextState();
void togglePlayPause();
void stop();
void next();
void prev();
+
signals:
void inputChanged( input_thread_t * );
void volumeChanged();
}
#endif
/*else */
- if ( event->type() == SetVideoOnTopEvent_Type )
+ if ( event->type() == (int)SetVideoOnTopEvent_Type )
{
SetVideoOnTopQtEvent* p_event = (SetVideoOnTopQtEvent*)event;
if( p_event->OnTop() )
class QSettings;
-#if defined(Q_WS_WIN)
#include <QApplication>
+#if defined(Q_WS_WIN)
class WinQtApp : public QApplication
{