~ubuntu-branches/ubuntu/natty/vlc/natty

« back to all changes in this revision

Viewing changes to modules/gui/qt4/dialogs_provider.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Benjamin Drung
  • Date: 2010-06-25 01:09:16 UTC
  • mfrom: (1.1.30 upstream)
  • Revision ID: james.westby@ubuntu.com-20100625010916-asxhep2mutg6g6pd
Tags: 1.1.0-1ubuntu1
* Merge from Debian unstable, remaining changes:
  - build and install the libx264 plugin
  - add Xb-Npp header to vlc package
  - Add apport hook to include more vlc dependencies in bug reports
* Drop xulrunner patches.
* Drop 502_xulrunner_191.diff.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 * dialogs_provider.cpp : Dialog Provider
3
3
 *****************************************************************************
4
4
 * Copyright (C) 2006-2009 the VideoLAN team
5
 
 * $Id: 89cd76ca1e523e0a931057ffebebf0f8e5160d65 $
 
5
 * $Id: 13dbbfa86a924d4c4f736f2700162957174b6372 $
6
6
 *
7
7
 * Authors: Clément Stenac <zorglub@videolan.org>
8
8
 *          Jean-Baptiste Kempf <jb@videolan.org>
53
53
#include "dialogs/toolbar.hpp"
54
54
#include "dialogs/plugins.hpp"
55
55
#include "dialogs/external.hpp"
 
56
#include "dialogs/epg.hpp"
 
57
#include "dialogs/errors.hpp"
56
58
 
57
59
#include <QEvent>
58
60
#include <QApplication>
59
61
#include <QSignalMapper>
60
62
#include <QFileDialog>
61
63
 
 
64
#define I_OP_DIR_WINTITLE I_DIR_OR_FOLDER( N_("Open Directory"), \
 
65
                                           N_("Open Folder") )
62
66
 
63
67
DialogsProvider* DialogsProvider::instance = NULL;
64
68
 
78
82
    SDMapper = new QSignalMapper();
79
83
    CONNECT( SDMapper, mapped (QString), this, SDMenuAction( QString ) );
80
84
 
81
 
    DialogHandler *dialogHandler = new DialogHandler (p_intf, this );
 
85
    new DialogHandler (p_intf, this );
82
86
}
83
87
 
84
88
DialogsProvider::~DialogsProvider()
92
96
#ifdef UPDATE_CHECK
93
97
    UpdateDialog::killInstance();
94
98
#endif
 
99
    PluginDialog::killInstance();
95
100
 
96
101
    delete menusMapper;
97
102
    delete menusUpdateMapper;
98
103
    delete SDMapper;
 
104
 
 
105
    QVLCMenu::PopupMenu( p_intf, false );
 
106
    QVLCMenu::AudioPopupMenu( p_intf, false );
 
107
    QVLCMenu::VideoPopupMenu( p_intf, false );
 
108
    QVLCMenu::MiscPopupMenu( p_intf, false );
99
109
}
100
110
 
101
111
void DialogsProvider::quit()
144
154
        case INTF_DIALOG_POPUPMENU:
145
155
           QVLCMenu::PopupMenu( p_intf, (de->i_arg != 0) ); break;
146
156
        case INTF_DIALOG_AUDIOPOPUPMENU:
147
 
           QVLCMenu::AudioPopupMenu( p_intf ); break;
 
157
           QVLCMenu::AudioPopupMenu( p_intf, (de->i_arg != 0) ); break;
148
158
        case INTF_DIALOG_VIDEOPOPUPMENU:
149
 
           QVLCMenu::VideoPopupMenu( p_intf ); break;
 
159
           QVLCMenu::VideoPopupMenu( p_intf, (de->i_arg != 0) ); break;
150
160
        case INTF_DIALOG_MISCPOPUPMENU:
151
 
           QVLCMenu::MiscPopupMenu( p_intf ); break;
 
161
           QVLCMenu::MiscPopupMenu( p_intf, (de->i_arg != 0) ); break;
152
162
        case INTF_DIALOG_WIZARD:
153
163
        case INTF_DIALOG_STREAMWIZARD:
154
164
            openAndStreamingDialogs(); break;
262
272
    PluginDialog::getInstance( p_intf )->toggleVisible();
263
273
}
264
274
 
 
275
void DialogsProvider::epgDialog()
 
276
{
 
277
    EpgDialog::getInstance( p_intf )->toggleVisible();
 
278
}
 
279
 
265
280
/* Generic open file */
266
281
void DialogsProvider::openFileGenericDialog( intf_dialog_args_t *p_arg )
267
282
{
281
296
        else
282
297
            extensions.replace( i, 1, "(" );
283
298
    }
284
 
    extensions.replace(QString(";*"), QString(" *"));
 
299
    extensions.replace( ";*", " *" );
285
300
    extensions.append( ")" );
286
301
 
287
302
    /* Save */
308
323
        i = 0;
309
324
        foreach( const QString &file, files )
310
325
            p_arg->psz_results[i++] = strdup( qtu( toNativeSepNoSlash( file ) ) );
311
 
        p_intf->p_sys->filepath = qfu( p_arg->psz_results[i] );
 
326
        if(i == 0)
 
327
            p_intf->p_sys->filepath = QString::fromAscii("");
 
328
        else
 
329
            p_intf->p_sys->filepath = qfu( p_arg->psz_results[i-1] );
312
330
    }
313
331
 
314
332
    /* Callback */
357
375
}
358
376
 
359
377
/* Same as the open one, but force the enqueue */
360
 
void DialogsProvider::PLAppendDialog()
 
378
void DialogsProvider::PLAppendDialog( int tab )
361
379
{
362
380
    OpenDialog::getInstance( p_intf->p_sys->p_mi, p_intf, false,
363
 
                             OPEN_AND_ENQUEUE )->showTab( OPEN_FILE_TAB );
 
381
                             OPEN_AND_ENQUEUE )->showTab( tab );
364
382
}
365
383
 
366
 
void DialogsProvider::MLAppendDialog()
 
384
void DialogsProvider::MLAppendDialog( int tab )
367
385
{
368
386
    OpenDialog::getInstance( p_intf->p_sys->p_mi, p_intf, false,
369
387
                            OPEN_AND_ENQUEUE, false, false )
370
 
                                    ->showTab( OPEN_FILE_TAB );
 
388
                                    ->showTab( tab );
371
389
}
372
390
 
373
391
/**
374
392
 * Simple open
375
393
 ***/
376
 
QStringList DialogsProvider::showSimpleOpen( QString help,
 
394
QStringList DialogsProvider::showSimpleOpen( const QString& help,
377
395
                                             int filters,
378
 
                                             QString path )
 
396
                                             const QString& path )
379
397
{
380
398
    QString fileTypes = "";
381
399
    if( filters & EXT_FILTER_MEDIA ) {
394
412
        ADD_FILTER_SUBTITLE( fileTypes );
395
413
    }
396
414
    ADD_FILTER_ALL( fileTypes );
397
 
    fileTypes.replace(QString(";*"), QString(" *"));
 
415
    fileTypes.replace( ";*", " *");
398
416
 
399
417
    QStringList files = QFileDialog::getOpenFileNames( NULL,
400
418
        help.isEmpty() ? qtr(I_OP_SEL_FILES ) : help,
418
436
    files.sort();
419
437
    foreach( const QString &file, files )
420
438
    {
421
 
        playlist_Add( THEPL, qtu( toNativeSeparators( file ) ), NULL,
422
 
                      go ? ( PLAYLIST_APPEND | ( i ? 0 : PLAYLIST_GO ) |
423
 
                                               ( i ? PLAYLIST_PREPARSE : 0 ) )
 
439
        char* psz_uri = make_URI( qtu( toNativeSeparators(file) ) );
 
440
        playlist_Add( THEPL, psz_uri, NULL,
 
441
                      go ? ( PLAYLIST_APPEND | ( i ? PLAYLIST_PREPARSE : PLAYLIST_GO ) )
424
442
                         : ( PLAYLIST_APPEND | PLAYLIST_PREPARSE ),
425
 
                      PLAYLIST_END,
426
 
                      pl ? true : false, false );
 
443
                      PLAYLIST_END, pl, pl_Unlocked );
 
444
        free( psz_uri );
427
445
        RecentsMRL::getInstance( p_intf )->addRecent(
428
446
                toNativeSeparators( file ) );
429
447
        i++;
452
470
 **/
453
471
void DialogsProvider::openUrlDialog()
454
472
{
455
 
    OpenUrlDialog *oud = OpenUrlDialog::getInstance( p_intf->p_sys->p_mi,
456
 
                                                     p_intf );
 
473
    OpenUrlDialog *oud = new OpenUrlDialog( p_intf );
457
474
    if( oud->exec() == QDialog::Accepted )
458
475
    {
459
476
        QString url = oud->url();
467
484
            RecentsMRL::getInstance( p_intf )->addRecent( url );
468
485
        }
469
486
    }
 
487
    delete oud;
470
488
}
471
489
 
472
490
/* Directory */
477
495
 **/
478
496
static void openDirectory( intf_thread_t *p_intf, bool pl, bool go )
479
497
{
480
 
    QString dir = QFileDialog::getExistingDirectory( NULL, qtr("Open Directory"), p_intf->p_sys->filepath );
 
498
    QString dir = QFileDialog::getExistingDirectory( NULL, qtr( I_OP_DIR_WINTITLE ), p_intf->p_sys->filepath );
481
499
 
482
500
    if (!dir.isEmpty() )
483
501
    {
492
510
                       PLAYLIST_END, pl, pl_Unlocked );
493
511
        RecentsMRL::getInstance( p_intf )->addRecent( mrl );
494
512
        if( !go )
495
 
            input_Read( THEPL, p_input, true );
 
513
            input_Read( THEPL, p_input );
496
514
        vlc_gc_decref( p_input );
497
515
    }
498
516
}
533
551
        char module[12];
534
552
    } types[] = {
535
553
        { N_("XSPF playlist (*.xspf)"), "export-xspf", },
 
554
        { N_("M3U8 playlist (*.m3u)"), "export-m3u8", },
536
555
        { N_("M3U playlist (*.m3u)"), "export-m3u", },
537
556
        { N_("HTML playlist (*.html)"), "export-html", },
538
557
    };
555
574
        if( selected == qfu( vlc_gettext( types[i].filter ) ) )
556
575
        {
557
576
            playlist_Export( THEPL, qtu( toNativeSeparators( file ) ),
558
 
                             THEPL->p_local_category, types[i].module );
 
577
                             THEPL->p_playing, types[i].module );
559
578
            break;
560
579
        }
561
580
}
565
584
 ****************************************************************************/
566
585
 
567
586
void DialogsProvider::streamingDialog( QWidget *parent,
568
 
                                       QString mrl,
 
587
                                       const QString& mrl,
569
588
                                       bool b_transcode_only,
570
589
                                       QStringList options )
571
590
{
685
704
    func->doFunc( p_intf );
686
705
}
687
706
 
688
 
void DialogsProvider::SDMenuAction( QString data )
 
707
void DialogsProvider::SDMenuAction( const QString& data )
689
708
{
690
709
    char *psz_sd = strdup( qtu( data ) );
691
710
    if( !playlist_IsServicesDiscoveryLoaded( THEPL, psz_sd ) )
700
719
 **/
701
720
void DialogsProvider::playMRL( const QString &mrl )
702
721
{
703
 
    playlist_Add( THEPL, qtu( mrl ) , NULL,
 
722
    char* psz_uri = make_URI( qtu(mrl) );
 
723
    playlist_Add( THEPL, psz_uri, NULL,
704
724
           PLAYLIST_APPEND | PLAYLIST_GO , PLAYLIST_END, true, false );
 
725
    free( psz_uri );
705
726
 
706
727
    RecentsMRL::getInstance( p_intf )->addRecent( mrl );
707
728
}