Commit 1ec9641c authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

[Qt] Various cleaning.

parent 28b5e483
......@@ -21,21 +21,18 @@
* 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"
......@@ -53,6 +50,12 @@
#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 ) :
......@@ -60,6 +63,7 @@ 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 *) );
......@@ -101,7 +105,7 @@ void DialogsProvider::quit()
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 )
......@@ -148,7 +152,7 @@ void DialogsProvider::customEvent( QEvent *event )
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;
......@@ -233,20 +237,7 @@ void DialogsProvider::podcastConfigureDialog()
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 )
......@@ -309,7 +300,19 @@ void DialogsProvider::openFileGenericDialog( intf_dialog_args_t *p_arg )
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 );
......@@ -330,8 +333,8 @@ void DialogsProvider::openCaptureDialog()
/* 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()
......@@ -511,7 +514,6 @@ void DialogsProvider::saveAPlaylist()
delete qfd;
}
/****************************************************************************
* Sout emulation
****************************************************************************/
......@@ -536,20 +538,49 @@ void DialogsProvider::streamingDialog( QWidget *parent, QString mrl,
}
}
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 )
......@@ -559,20 +590,37 @@ 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;
......@@ -618,44 +666,3 @@ void DialogsProvider::doInteraction( intf_dialog_args_t *p_arg )
}
}
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 );
}
......@@ -37,9 +37,6 @@
#include "dialogs/interaction.hpp"
#include "dialogs/open.hpp"
#include <QObject>
#include <QApplication>
#define ADD_FILTER_MEDIA( string ) \
string += qtr( "Media Files" ); \
string += " ( "; \
......@@ -125,14 +122,13 @@ private:
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();
......@@ -153,13 +149,13 @@ public slots:
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();
......@@ -167,14 +163,15 @@ public slots:
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();
......@@ -182,6 +179,10 @@ public slots:
void loadSubtitlesFile();
void quit();
private slots:
void menuAction( QObject *);
void menuUpdateAction( QObject * );
void SDMenuAction( QString );
};
#endif
......@@ -66,7 +66,7 @@ InputManager::InputManager( QObject *parent, intf_thread_t *_p_intf) :
QObject( parent ), p_intf( _p_intf )
{
i_old_playing_status = END_S;
old_name = "";
oldName = "";
artUrl = "";
p_input = NULL;
i_rate = 0;
......@@ -95,7 +95,6 @@ void InputManager::setInput( input_thread_t *_p_input )
emit statusChanged( PLAYING_S );
UpdateMeta();
UpdateArt();
UpdateSPU();
UpdateTeletext();
UpdateNavigation();
UpdateVout();
......@@ -120,7 +119,7 @@ void InputManager::delInput()
delCallbacks();
i_old_playing_status = END_S;
i_input_id = 0;
old_name = "";
oldName = "";
artUrl = "";
b_video = false;
timeA = 0;
......@@ -133,7 +132,6 @@ void InputManager::delInput()
emit voutChanged( false );
vlc_object_release( p_input );
p_input = NULL;
UpdateSPU();
UpdateTeletext();
}
}
......@@ -187,21 +185,21 @@ void InputManager::delCallbacks()
/* 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();
......@@ -209,23 +207,23 @@ void InputManager::customEvent( QEvent *event )
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();
......@@ -259,6 +257,8 @@ void InputManager::customEvent( QEvent *event )
case InterfaceVoutUpdate_Type:
UpdateVout();
break;
default:
msg_Warn( p_intf, "This shouldn't happen: %i", i_type );
}
}
......@@ -289,6 +289,7 @@ void InputManager::UpdateNavigation()
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) );
......@@ -365,10 +366,10 @@ void InputManager::UpdateMeta()
free( psz_name );
}
if( old_name != text )
if( oldName != text )
{
emit nameChanged( text );
old_name=text;
oldName=text;
}
}
......@@ -402,7 +403,8 @@ void InputManager::UpdateVout()
{
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 );
......@@ -637,7 +639,6 @@ MainInputManager::MainInputManager( intf_thread_t *_p_intf )
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 );
......@@ -669,7 +670,6 @@ MainInputManager::~MainInputManager()
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 );
}
......@@ -688,7 +688,7 @@ void MainInputManager::customEvent( QEvent *event )
}
/* 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) ) )
......@@ -751,18 +751,6 @@ void MainInputManager::togglePlayPause()
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 */
......@@ -771,11 +759,12 @@ static int InterfaceChanged( vlc_object_t *p_this, const char *psz_var,
{
/* 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;
......
......@@ -56,11 +56,13 @@ enum {
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;
};
......@@ -79,22 +81,24 @@ public:
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();
......@@ -176,19 +180,20 @@ public:
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();
......
......@@ -1085,7 +1085,7 @@ void MainInterface::customEvent( QEvent *event )
}
#endif
/*else */
if ( event->type() == SetVideoOnTopEvent_Type )
if ( event->type() == (int)SetVideoOnTopEvent_Type )
{
SetVideoOnTopQtEvent* p_event = (SetVideoOnTopQtEvent*)event;
if( p_event->OnTop() )
......
......@@ -64,8 +64,8 @@ class VideoWidget;
class QSettings;
#if defined(Q_WS_WIN)
#include <QApplication>
#if defined(Q_WS_WIN)
class WinQtApp : public QApplication
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment