Changeset 277e9ab5a2a4df835797c6df5b7741f25b9721ad

Show
Ignore:
Timestamp:
09/10/06 21:00:21 (2 years ago)
Author:
Clément Stenac <zorglub@videolan.org>
git-committer:
Clément Stenac <zorglub@videolan.org> 1157914821 +0000
git-parent:

[75b1aa19f528bb6f847c09963485d1e0356e1af5]

git-author:
Clément Stenac <zorglub@videolan.org> 1157914821 +0000
Message:

Fix SD support

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/gui/qt4/dialogs/playlist.cpp

    rf10eac9 r277e9ab  
    2828#include "components/playlist/selector.hpp" 
    2929#include <QHBoxLayout> 
    30 #include "menus.hpp" 
     30#include <QSignalMapper> 
     31#include <QMenu> 
     32#include <QAction> 
     33#include <QMenuBar> 
     34#include "dialogs_provider.hpp" 
    3135 
    3236PlaylistDialog *PlaylistDialog::instance = NULL; 
     
    3741    setCentralWidget( main ); 
    3842    setWindowTitle( qtr( "Playlist" ) ); 
    39     QVLCMenu::createPlMenuBar( menuBar(), p_intf ); 
     43 
     44    SDMapper = new QSignalMapper(); 
     45    connect( SDMapper, SIGNAL( mapped (QString)), this, 
     46             SLOT( SDMenuAction( QString ) ) ); 
     47    createPlMenuBar( menuBar(), p_intf ); 
    4048 
    4149    selector = new PLSelector( centralWidget(), p_intf, THEPL ); 
     
    6169    writeSettings( "playlist" ); 
    6270} 
     71 
     72void PlaylistDialog::createPlMenuBar( QMenuBar *bar, intf_thread_t *p_intf ) 
     73{ 
     74    QMenu *manageMenu = new QMenu(); 
     75    manageMenu->setTitle( qtr("Add") ); 
     76 
     77    QMenu *subPlaylist = new QMenu(); 
     78    subPlaylist->setTitle( qtr("Add to current playlist") ); 
     79    subPlaylist->addAction( "&File...", THEDP, 
     80                           SLOT( simplePLAppendDialog() ) ); 
     81    subPlaylist->addAction( "&Advanced add...", THEDP, 
     82                           SLOT( PLAppendDialog() ) ); 
     83    manageMenu->addMenu( subPlaylist ); 
     84    manageMenu->addSeparator(); 
     85 
     86    QMenu *subML = new QMenu(); 
     87    subML->setTitle( qtr("Add to Media library") ); 
     88    subML->addAction( "&File...", THEDP, 
     89                           SLOT( simpleMLAppendDialog() ) ); 
     90    subML->addAction( "Directory", THEDP, SLOT( openMLDirectory() )); 
     91    subML->addAction( "&Advanced add...", THEDP, 
     92                           SLOT( MLAppendDialog() ) ); 
     93    manageMenu->addMenu( subML ); 
     94    manageMenu->addAction( "Open playlist file", THEDP, SLOT( openPlaylist() )); 
     95 
     96    bar->addMenu( manageMenu ); 
     97    bar->addMenu( SDMenu() ); 
     98} 
     99 
     100QMenu *PlaylistDialog::SDMenu() 
     101{ 
     102    QMenu *menu = new QMenu(); 
     103    menu->setTitle( qtr( "Additional sources" ) ); 
     104    vlc_list_t *p_list = vlc_list_find( p_intf, VLC_OBJECT_MODULE, 
     105                                        FIND_ANYWHERE ); 
     106    int i_num = 0; 
     107    for( int i_index = 0 ; i_index < p_list->i_count; i_index++ ) 
     108    { 
     109        module_t * p_parser = (module_t *)p_list->p_values[i_index].p_object ; 
     110        if( !strcmp( p_parser->psz_capability, "services_discovery" ) ) 
     111            i_num++; 
     112    } 
     113    for( int i_index = 0 ; i_index < p_list->i_count; i_index++ ) 
     114    { 
     115        module_t * p_parser = (module_t *)p_list->p_values[i_index].p_object; 
     116        if( !strcmp( p_parser->psz_capability, "services_discovery" ) ) 
     117        { 
     118            QAction *a = new QAction( qfu( p_parser->psz_longname ), menu ); 
     119            a->setCheckable( true ); 
     120            /* hack to handle submodules properly */ 
     121            int i = -1; 
     122            while( p_parser->pp_shortcuts[++i] != NULL ); 
     123            i--; 
     124            if( playlist_IsServicesDiscoveryLoaded( THEPL, 
     125                 i>=0?p_parser->pp_shortcuts[i] : p_parser->psz_object_name ) ) 
     126            { 
     127                a->setChecked( true ); 
     128            } 
     129            connect( a , SIGNAL( triggered() ), SDMapper, SLOT( map() ) ); 
     130            SDMapper->setMapping( a, i>=0? p_parser->pp_shortcuts[i] : 
     131                                            p_parser->psz_object_name ); 
     132            menu->addAction( a ); 
     133        } 
     134    } 
     135    vlc_list_release( p_list ); 
     136    return menu; 
     137} 
     138 
     139void PlaylistDialog::SDMenuAction( QString data ) 
     140{ 
     141    char *psz_sd = data.toUtf8().data(); 
     142    if( !playlist_IsServicesDiscoveryLoaded( THEPL, psz_sd ) ) 
     143        playlist_ServicesDiscoveryAdd( THEPL, psz_sd ); 
     144    else 
     145        playlist_ServicesDiscoveryRemove( THEPL, psz_sd ); 
     146} 
  • modules/gui/qt4/dialogs/playlist.hpp

    ra20ffdd r277e9ab  
    2727#include "util/qvlcframe.hpp" 
    2828 
     29class QSignalMapper; 
    2930class PLSelector; 
    3031class PLPanel; 
     
    4142    virtual ~PlaylistDialog(); 
    4243private: 
     44 
     45    void createPlMenuBar( QMenuBar *bar, intf_thread_t *p_intf ); 
     46    QMenu * SDMenu(); 
    4347    PlaylistDialog( intf_thread_t * ); 
    4448    static PlaylistDialog *instance; 
    4549 
     50    QSignalMapper *SDMapper; 
    4651    PLSelector *selector; 
    4752    PLPanel *rightPanel; 
     53private slots: 
     54    void SDMenuAction( QString ); 
    4855}; 
    4956 
  • modules/gui/qt4/dialogs_provider.cpp

    rf787ec7 r277e9ab  
    3838                                      QObject( NULL ), p_intf( _p_intf ) 
    3939{ 
    40 //    idle_timer = new QTimer( this ); 
    41 //    idle_timer->start( 0 ); 
    42  
    4340    fixed_timer = new QTimer( this ); 
    4441    fixed_timer->start( 150 /* milliseconds */ ); 
     
    5350} 
    5451 
    55 DialogsProvider::~DialogsProvider() 
    56 { 
    57 } 
    5852void DialogsProvider::customEvent( QEvent *event ) 
    5953{ 
  • modules/gui/qt4/dialogs_provider.hpp

    rf787ec7 r277e9ab  
    5151        return instance; 
    5252    } 
    53     virtual ~DialogsProvider(); 
    54     QTimer *idle_timer; 
     53    virtual ~DialogsProvider() {}; 
    5554    QTimer *fixed_timer; 
    5655protected: 
  • modules/gui/qt4/menus.cpp

    r72e190b r277e9ab  
    3939 
    4040static QActionGroup *currentGroup; 
    41 static char ** pp_sds; 
    4241 
    4342// Add static entries to menus 
     
    129128    //    BAR_ADD( HelpMenu(), qtr("Help" ) ); 
    130129} 
    131  
    132 void QVLCMenu::createPlMenuBar( QMenuBar *bar, intf_thread_t *p_intf ) 
    133 { 
    134     QMenu *manageMenu = new QMenu(); 
    135     manageMenu->setTitle( qtr("Operations") ); 
    136  
    137     QMenu *subPlaylist = new QMenu(); 
    138     subPlaylist->setTitle( qtr("Add to current playlist") ); 
    139     subPlaylist->addAction( "&File...", THEDP, 
    140                            SLOT( simplePLAppendDialog() ) ); 
    141     subPlaylist->addAction( "&Advanced add...", THEDP, 
    142                            SLOT( PLAppendDialog() ) ); 
    143     manageMenu->addMenu( subPlaylist ); 
    144     manageMenu->addSeparator(); 
    145  
    146     QMenu *subML = new QMenu(); 
    147     subML->setTitle( qtr("Add to Media library") ); 
    148     subML->addAction( "&File...", THEDP, 
    149                            SLOT( simpleMLAppendDialog() ) ); 
    150     subML->addAction( "Directory", THEDP, SLOT( openMLDirectory() )); 
    151     subML->addAction( "&Advanced add...", THEDP, 
    152                            SLOT( MLAppendDialog() ) ); 
    153     manageMenu->addMenu( subML ); 
    154     manageMenu->addAction( "Open playlist file", THEDP, SLOT( openPlaylist() )); 
    155     manageMenu->addSeparator(); 
    156  
    157 //    manageMenu->addMenu( SDMenu( p_intf ) ); 
    158  
    159     bar->addMenu( manageMenu ); 
    160 } 
    161  
    162 QMenu *QVLCMenu::SDMenu( intf_thread_t *p_intf ) 
    163 { 
    164     QMenu *menu = new QMenu(); 
    165     menu->setTitle( qtr( "Services Discovery" ) ); 
    166     playlist_t *p_playlist = (playlist_t *)vlc_object_find( p_intf, 
    167                                             VLC_OBJECT_PLAYLIST, 
    168                                             FIND_ANYWHERE ); 
    169     assert( p_playlist ); 
    170     vlc_list_t *p_list = vlc_list_find( p_intf, VLC_OBJECT_MODULE, 
    171                                         FIND_ANYWHERE ); 
    172     int i_num = 0; 
    173     for( int i_index = 0 ; i_index < p_list->i_count; i_index++ ) 
    174     { 
    175         module_t * p_parser = (module_t *)p_list->p_values[i_index].p_object ; 
    176         if( !strcmp( p_parser->psz_capability, "services_discovery" ) ) 
    177             i_num++; 
    178     } 
    179     if( i_num )  pp_sds = (char **)calloc( i_num, sizeof(void *) ); 
    180     for( int i_index = 0 ; i_index < p_list->i_count; i_index++ ) 
    181     { 
    182         module_t * p_parser = (module_t *)p_list->p_values[i_index].p_object; 
    183         if( !strcmp( p_parser->psz_capability, "services_discovery" ) ) 
    184         { 
    185             QAction *a = menu->addAction( 
    186                             qfu( p_parser->psz_longname ? 
    187                                    p_parser->psz_longname : 
    188                                    ( p_parser->psz_shortname ? 
    189                                        p_parser->psz_shortname : 
    190                                        p_parser->psz_object_name ) ) ); 
    191             a->setCheckable( true ); 
    192             /* hack to handle submodules properly */ 
    193             int i = -1; 
    194             while( p_parser->pp_shortcuts[++i] != NULL ); 
    195             i--; 
    196             if( playlist_IsServicesDiscoveryLoaded( p_playlist, 
    197                  i>=0?p_parser->pp_shortcuts[i] : p_parser->psz_object_name ) ) 
    198             { 
    199                 a->setChecked( true ); 
    200             } 
    201             pp_sds[i_num++] = i>=0? p_parser->pp_shortcuts[i] : 
    202                                     p_parser->psz_object_name; 
    203         } 
    204     } 
    205     vlc_list_release( p_list ); 
    206     vlc_object_release( p_playlist ); 
    207     return menu; 
    208 } 
    209  
    210130QMenu *QVLCMenu::FileMenu() 
    211131{