~siretart/vlc/ubuntu

« back to all changes in this revision

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

  • Committer: Reinhard Tartler
  • Date: 2008-09-26 06:45:40 UTC
  • mto: (21.2.1 vlc-0.9.3)
  • mto: This revision was merged to the branch mainline in revision 23.
  • Revision ID: siretart@tauware.de-20080926064540-0sd8zwmig33ksmy4
Tags: upstream-ubuntu-0.9.3
Import upstream version 0.9.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 * main_interface.cpp : Main interface
3
3
 ****************************************************************************
4
4
 * Copyright (C) 2006-2008 the VideoLAN team
5
 
 * $Id: 77823a7204617ec9f5102cbc9ac1605731906d9f $
 
5
 * $Id: 1065248a37730175d65bd3464d79e8dcf5c78438 $
6
6
 *
7
7
 * Authors: Clément Stenac <zorglub@videolan.org>
8
8
 *          Jean-Baptiste Kempf <jb@videolan.org>
146
146
    /* Connect the input manager to the GUI elements it manages */
147
147
 
148
148
    /* It is also connected to the control->slider, see the ControlsWidget */
149
 
    CONNECT( THEMIM->getIM(), positionUpdated( float, int, int ),
150
 
             this, setDisplayPosition( float, int, int ) );
151
149
    /* Change the SpeedRate in the Status */
152
150
    CONNECT( THEMIM->getIM(), rateChanged( int ), this, setRate( int ) );
153
151
 
215
213
    CONNECT( this, askUpdate(), this, doComponentsUpdate() );
216
214
 
217
215
    /* Size and placement of interface */
 
216
    settings->beginGroup( "MainWindow" );
218
217
    QVLCTools::restoreWidgetPosition( settings, this, QSize(380, 60) );
219
218
 
220
 
 
221
219
    bool b_visible = settings->value( "playlist-visible", 0 ).toInt();
222
220
    settings->endGroup();
223
221
 
249
247
{
250
248
    msg_Dbg( p_intf, "Destroying the main interface" );
251
249
 
 
250
    if( videoIsActive ) videoWidget->hide();
 
251
 
252
252
    /* Saving volume */
253
253
    if( config_GetInt( p_intf, "qt-autosave-volume" ) )
254
254
    {
271
271
    settings->setValue( "adv-controls",
272
272
                        getControlsVisibilityStatus() & CONTROLS_ADVANCED );
273
273
 
274
 
    if( !videoIsActive )
275
 
    {
276
 
        QVLCTools::saveWidgetPosition(settings, this);
277
 
    }
278
 
    else
279
 
    {
280
 
        msg_Dbg( p_intf, "Not saving because video is in use." );
281
 
    }
282
 
 
283
274
    if( bgWidget )
284
275
        settings->setValue( "backgroundSize", bgWidget->size() );
285
276
 
 
277
    QVLCTools::saveWidgetPosition(settings, this);
286
278
    settings->endGroup();
287
279
 
288
280
    var_DelCallback( p_intf->p_libvlc, "intf-show", IntfShowCB, p_intf );
306
298
     *  Status Bar  *
307
299
     ****************/
308
300
    /* Widgets Creation*/
309
 
    b_remainingTime = false;
310
 
    timeLabel = new TimeLabel;
311
 
    timeLabel->setText( " --:--/--:-- " );
312
 
    timeLabel->setAlignment( Qt::AlignRight | Qt::AlignVCenter );
313
 
    timeLabel->setToolTip( qtr( "Toggle between elapsed and remaining time" ) );
 
301
    timeLabel = new TimeLabel( p_intf );
314
302
    nameLabel = new QLabel;
315
303
    nameLabel->setTextInteractionFlags( Qt::TextSelectableByMouse
316
304
                                      | Qt::TextSelectableByKeyboard );
333
321
       - double clicking opens the goto time dialog
334
322
       - right-clicking and clicking just toggle between remaining and
335
323
         elapsed time.*/
336
 
    CONNECT( timeLabel, timeLabelClicked(), this, toggleTimeDisplay() );
337
324
    CONNECT( timeLabel, timeLabelDoubleClicked(), THEDP, gotoTimeDialog() );
338
 
    CONNECT( timeLabel, timeLabelDoubleClicked(), this, toggleTimeDisplay() );
339
325
 
340
326
    /* Speed Label behaviour:
341
327
       - right click gives the vertical speed slider */
401
387
    CONNECT( controls, advancedControlsToggled( bool ),
402
388
             this, doComponentsUpdate() );
403
389
 
404
 
#ifdef WIN32
405
 
    if ( depth() > 8 )
406
 
#endif
407
 
    /* Create the FULLSCREEN CONTROLS Widget */
408
 
    if( config_GetInt( p_intf, "qt-fs-controller" ) )
409
 
    {
410
 
        fullscreenControls = new FullscreenControllerWidget( p_intf, this,
411
 
                settings->value( "adv-controls", false ).toBool(),
412
 
                b_shiny );
413
 
        CONNECT( fullscreenControls, advancedControlsToggled( bool ),
414
 
                this, doComponentsUpdate() );
415
 
    }
416
 
 
417
390
    /* Add the controls Widget to the main Widget */
418
391
    mainLayout->insertWidget( 0, controls, 0, Qt::AlignBottom );
419
392
 
456
429
 
457
430
    /* Finish the sizing */
458
431
    main->updateGeometry();
 
432
 
 
433
    getSettings()->endGroup();
 
434
#ifdef WIN32
 
435
    if ( depth() > 8 )
 
436
#endif
 
437
    /* Create the FULLSCREEN CONTROLS Widget */
 
438
    if( config_GetInt( p_intf, "qt-fs-controller" ) )
 
439
    {
 
440
        fullscreenControls = new FullscreenControllerWidget( p_intf, this,
 
441
                settings->value( "adv-controls", false ).toBool(),
 
442
                b_shiny );
 
443
        CONNECT( fullscreenControls, advancedControlsToggled( bool ),
 
444
                this, doComponentsUpdate() );
 
445
    }
459
446
}
460
447
 
461
448
inline void MainInterface::askForPrivacy()
755
742
 
756
743
        if( i_pl_dock == PL_UNDOCKED )
757
744
        {
758
 
            playlistWidget->setWindowFlags( Qt::Window );
 
745
            playlistWidget->setParent( this, Qt::Window );
759
746
 
 
747
            /* This will restore the geometry but will not work for position,
 
748
               because of parenting */
760
749
            QVLCTools::restoreWidgetPosition( p_intf, "Playlist",
761
750
                    playlistWidget, QSize( 600, 300 ) );
 
751
            /* Move it correctly then */
 
752
            playlistWidget->move(
 
753
                    getSettings()->value( "Playlist/GlobalPos" ).toPoint() );
762
754
        }
763
755
        else
764
756
        {
869
861
/************************************************************************
870
862
 * Other stuff
871
863
 ************************************************************************/
872
 
void MainInterface::setDisplayPosition( float pos, int time, int length )
873
 
{
874
 
    char psz_length[MSTRTIME_MAX_SIZE], psz_time[MSTRTIME_MAX_SIZE];
875
 
    secstotimestr( psz_length, length );
876
 
    secstotimestr( psz_time, ( b_remainingTime && length ) ? length - time
877
 
                                                           : time );
878
 
 
879
 
    QString timestr;
880
 
    timestr.sprintf( "%s/%s", psz_time,
881
 
                            ( !length && time ) ? "--:--" : psz_length );
882
 
 
883
 
    /* Add a minus to remaining time*/
884
 
    if( b_remainingTime && length ) timeLabel->setText( " -"+timestr+" " );
885
 
    else timeLabel->setText( " "+timestr+" " );
886
 
}
887
 
 
888
 
void MainInterface::toggleTimeDisplay()
889
 
{
890
 
    b_remainingTime = !b_remainingTime;
891
 
}
892
 
 
893
864
void MainInterface::setName( QString name )
894
865
{
895
866
    input_name = name; /* store it for the QSystray use */
1083
1054
 ************************************************************************/
1084
1055
void MainInterface::dropEvent(QDropEvent *event)
1085
1056
{
 
1057
    dropEventPlay( event, true );
 
1058
}
 
1059
 
 
1060
void MainInterface::dropEventPlay( QDropEvent *event, bool b_play )
 
1061
{
1086
1062
     const QMimeData *mimeData = event->mimeData();
1087
1063
 
1088
1064
     /* D&D of a subtitles file, add it on the fly */
1100
1076
            }
1101
1077
        }
1102
1078
     }
1103
 
     bool first = true;
 
1079
     bool first = b_play;
1104
1080
     foreach( QUrl url, mimeData->urls() )
1105
1081
     {
1106
1082
        QString s = toNativeSeparators( url.toLocalFile() );
1107
1083
 
1108
1084
        if( s.length() > 0 ) {
1109
1085
            playlist_Add( THEPL, qtu(s), NULL,
1110
 
                          PLAYLIST_APPEND | (first ? PLAYLIST_GO:0),
 
1086
                          PLAYLIST_APPEND | (first ? PLAYLIST_GO: 0),
1111
1087
                          PLAYLIST_END, true, false );
1112
1088
            first = false;
1113
1089
        }