interface_widgets.cpp 19.2 KB
Newer Older
1
/*****************************************************************************
2
 * interface_widgets.cpp : Custom widgets for the main interface
3
 ****************************************************************************
4
 * Copyright ( C ) 2006 the VideoLAN team
5
 * $Id$
6 7
 *
 * Authors: Clément Stenac <zorglub@videolan.org>
8
 *          Jean-Baptiste Kempf <jb@videolan.org>
9 10 11 12
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
13
 * ( at your option ) any later version.
14 15 16 17 18 19 20 21 22 23 24
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
 *****************************************************************************/

25
#include "dialogs_provider.hpp"
26
#include "qt4.hpp"
27
#include "components/interface_widgets.hpp"
28
#include "main_interface.hpp"
29
#include "input_manager.hpp"
30

31
#include "util/input_slider.hpp"
Clément Stenac's avatar
Clément Stenac committed
32
#include <vlc_vout.h>
33

Clément Stenac's avatar
Clément Stenac committed
34 35
#include <QLabel>
#include <QSpacerItem>
Clément Stenac's avatar
Clément Stenac committed
36
#include <QCursor>
Clément Stenac's avatar
Clément Stenac committed
37
#include <QPushButton>
38
#include <QHBoxLayout>
Clément Stenac's avatar
Clément Stenac committed
39
#include <QMenu>
Jean-Baptiste Kempf's avatar
Jean-Baptiste Kempf committed
40 41
#include <QPalette>
#include <QResizeEvent>
42

43
#define ICON_SIZE 300
44

45 46 47 48
/**********************************************************************
 * Video Widget. A simple frame on which video is drawn
 * This class handles resize issues
 **********************************************************************/
49 50 51 52 53
static void *DoRequest( intf_thread_t *, vout_thread_t *, int*,int*,
                        unsigned int *, unsigned int * );
static void DoRelease( intf_thread_t *, void * );
static int DoControl( intf_thread_t *, void *, int, va_list );

54
VideoWidget::VideoWidget( intf_thread_t *_p_i ) : QFrame( NULL ), p_intf( _p_i )
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
{
    vlc_mutex_init( p_intf, &lock );
    p_vout = NULL;

    setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred );
}

VideoWidget::~VideoWidget()
{
    vlc_mutex_lock( &lock );
    if( p_vout )
    {
        if( !p_intf->psz_switch_intf )
        {
            if( vout_Control( p_vout, VOUT_CLOSE ) != VLC_SUCCESS )
                vout_Control( p_vout, VOUT_REPARENT );
        }
        else
        {
            if( vout_Control( p_vout, VOUT_REPARENT ) != VLC_SUCCESS )
                vout_Control( p_vout, VOUT_CLOSE );
        }
    }
    vlc_mutex_unlock( &lock );
    vlc_mutex_destroy( &lock );
}

QSize VideoWidget::sizeHint() const
{
84
    return widgetSize;
85 86
}

87
void *VideoWidget::request( vout_thread_t *p_nvout, int *pi_x, int *pi_y,
88 89 90 91 92 93 94 95
                           unsigned int *pi_width, unsigned int *pi_height )
{
    if( p_vout )
    {
        msg_Dbg( p_intf, "embedded video already in use" );
        return NULL;
    }
    p_vout = p_nvout;
96
    setMinimumSize( 16, 16 );
97
    return ( void* )winId();
98 99
}

100
void VideoWidget::release( void *p_win )
101
{
102
    p_vout = NULL;
103
}
104 105 106 107 108 109 110
/**********************************************************************
 * Background Widget. Show a simple image background. Currently,
 * it's a static cone.
 **********************************************************************/
BackgroundWidget::BackgroundWidget( intf_thread_t *_p_i ) :
                                        QFrame( NULL ), p_intf( _p_i )
{
111

Clément Stenac's avatar
Clément Stenac committed
112
    setAutoFillBackground( true );
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
    plt =  palette();
    plt.setColor( QPalette::Active, QPalette::Window , Qt::black );
    plt.setColor( QPalette::Inactive, QPalette::Window , Qt::black );
    setPalette( plt );

    label = new QLabel( "" );
    label->setMaximumHeight( ICON_SIZE );
    label->setMaximumWidth( ICON_SIZE );
    label->setScaledContents( true );
    label->setPixmap( QPixmap( ":/vlc128.png" ) );
    backgroundLayout = new QHBoxLayout;
    backgroundLayout->addWidget( label );
    setLayout( backgroundLayout );
}

Clément Stenac's avatar
Clément Stenac committed
128
BackgroundWidget::~BackgroundWidget()
129
{
130
    backgroundLayout->takeAt( 0 );
131 132 133
    delete backgroundLayout;
}

134 135 136 137 138 139 140 141
void BackgroundWidget::setArt( QString url )
{
    if( url.isNull() )
        label->setPixmap( QPixmap( ":/vlc128.png" ) );
    else
        label->setPixmap( QPixmap( url ) );
}

142 143 144 145 146
QSize BackgroundWidget::sizeHint() const
{
    return widgetSize;
}

147 148 149 150 151 152 153
void BackgroundWidget::resizeEvent( QResizeEvent *e )
{
    if( e->size().height() < ICON_SIZE -1 )
        label->setMaximumWidth( e->size().height() );
    else
        label->setMaximumWidth( ICON_SIZE );
}
154

Clément Stenac's avatar
Clément Stenac committed
155 156 157 158 159 160 161
/**********************************************************************
 * Visualization selector panel
 **********************************************************************/
VisualSelector::VisualSelector( intf_thread_t *_p_i ) :
                                                QFrame( NULL ), p_intf( _p_i )
{
    QHBoxLayout *layout = new QHBoxLayout( this );
162
    layout->setMargin( 0 );
Clément Stenac's avatar
Clément Stenac committed
163
    QPushButton *prevButton = new QPushButton( "Prev" );
164
    QPushButton *nextButton = new QPushButton( "Next" );
Clément Stenac's avatar
Clément Stenac committed
165 166
    layout->addWidget( prevButton );
    layout->addWidget( nextButton );
Clément Stenac's avatar
Clément Stenac committed
167 168

    layout->addItem( new QSpacerItem( 40,20,
169 170
                              QSizePolicy::Expanding, QSizePolicy::Minimum ) );
    layout->addWidget( new QLabel( qtr( "Current visualization:" ) ) );
Clément Stenac's avatar
Clément Stenac committed
171 172 173 174 175 176 177

    current = new QLabel( qtr( "None" ) );
    layout->addWidget( current );

    BUTTONACT( prevButton, prev() );
    BUTTONACT( nextButton, next() );

Clément Stenac's avatar
Clément Stenac committed
178
    setLayout( layout );
179
    setMaximumHeight( 35 );
Clément Stenac's avatar
Clément Stenac committed
180 181 182 183 184 185
}

VisualSelector::~VisualSelector()
{
}

Clément Stenac's avatar
Clément Stenac committed
186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208
void VisualSelector::prev()
{
    char *psz_new = aout_VisualPrev( p_intf );
    if( psz_new )
    {
        current->setText( qfu( psz_new ) );
        free( psz_new );
    }
}

void VisualSelector::next()
{
    char *psz_new = aout_VisualNext( p_intf );
    if( psz_new )
    {
        current->setText( qfu( psz_new ) );
        free( psz_new );
    }
}

/**********************************************************************
 * More controls
 **********************************************************************/
209
AdvControlsWidget::AdvControlsWidget( intf_thread_t *_p_i ) :
Clément Stenac's avatar
Clément Stenac committed
210 211 212 213 214 215
                                           QFrame( NULL ), p_intf( _p_i )
{
    QHBoxLayout *layout = new QHBoxLayout( this );
    layout->setMargin( 0 );

    normalButton = new QPushButton( "N" );
216
    BUTTON_SET_ACT( normalButton, "N", qtr( "Normal rate" ), normal() );
Clément Stenac's avatar
Clément Stenac committed
217 218 219 220 221
    layout->addWidget( normalButton );
    normalButton->setMaximumWidth( 35 );


    layout->addItem( new QSpacerItem( 100,20,
222
                              QSizePolicy::Expanding, QSizePolicy::Minimum ) );
Clément Stenac's avatar
Clément Stenac committed
223 224

    snapshotButton = new QPushButton( "S" );
225
    BUTTON_SET_ACT( snapshotButton, "S", qtr( "Take a snapshot" ), snapshot() );
Clément Stenac's avatar
Clément Stenac committed
226 227 228 229
    layout->addWidget( snapshotButton );
    snapshotButton->setMaximumWidth( 35 );

    fullscreenButton = new QPushButton( "F" );
230
    BUTTON_SET_ACT( fullscreenButton, "F", qtr( "Fullscreen" ), fullscreen() );
Clément Stenac's avatar
Clément Stenac committed
231 232 233 234
    layout->addWidget( fullscreenButton );
    fullscreenButton->setMaximumWidth( 35 );
}

235
AdvControlsWidget::~AdvControlsWidget()
Clément Stenac's avatar
Clément Stenac committed
236 237 238
{
}

239
void AdvControlsWidget::enableInput( bool enable )
Clément Stenac's avatar
Clément Stenac committed
240
{
241
//    slowerButton->setEnabled( enable );
Clément Stenac's avatar
Clément Stenac committed
242
    normalButton->setEnabled( enable );
243
//    fasterButton->setEnabled( enable );
Clément Stenac's avatar
Clément Stenac committed
244
}
245
void AdvControlsWidget::enableVideo( bool enable )
Clément Stenac's avatar
Clément Stenac committed
246 247 248 249 250
{
    snapshotButton->setEnabled( enable );
    fullscreenButton->setEnabled( enable );
}

251
void AdvControlsWidget::normal()
Clément Stenac's avatar
Clément Stenac committed
252 253 254 255
{
    THEMIM->getIM()->normalRate();
}

256
void AdvControlsWidget::snapshot()
Clément Stenac's avatar
Clément Stenac committed
257 258 259
{
}

260 261 262 263 264 265 266 267 268 269 270 271 272
void AdvControlsWidget::fullscreen()
{
}

ControlsWidget::ControlsWidget( intf_thread_t *_p_i ) :
                             QFrame( NULL ), p_intf( _p_i )
{
    //QSize size( 500, 200 );
    //resize( size );
    controlLayout = new QGridLayout( this );

    /** The main Slider **/
    slider = new InputSlider( Qt::Horizontal, NULL );
273
    controlLayout->addWidget( slider, 0, 1, 1, 15 );
274 275 276 277 278 279 280
    /* Update the position when the IM has changed */
    CONNECT( THEMIM->getIM(), positionUpdated( float, int, int ),
             slider, setPosition( float,int, int ) );
    /* And update the IM, when the position has changed */
    CONNECT( slider, sliderDragged( float ),
             THEMIM->getIM(), sliderUpdate( float ) );

281 282
    /** Slower and faster Buttons **/
    slowerButton = new QPushButton( "S" );
283
    BUTTON_SET_ACT( slowerButton, "S", qtr( "Slower" ), slower() );
284 285 286 287
    controlLayout->addWidget( slowerButton, 0, 0 );
    slowerButton->setMaximumSize( QSize( 26, 26 ) );

    fasterButton = new QPushButton( "F" );
288
    BUTTON_SET_ACT( fasterButton, "F", qtr( "Faster" ), faster() );
289 290 291
    controlLayout->addWidget( fasterButton, 0, 16 );
    fasterButton->setMaximumSize( QSize( 26, 26 ) );

292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314
    /** Disc and Menus handling */
    discFrame = new QFrame( this );
    QHBoxLayout *discLayout = new QHBoxLayout( discFrame );

    QPushButton *menuButton = new QPushButton( discFrame );
    discLayout->addWidget( menuButton );

    QPushButton *prevSectionButton = new QPushButton( discFrame );
    discLayout->addWidget( prevSectionButton );

    QPushButton *nextSectionButton = new QPushButton( discFrame );
    discLayout->addWidget( nextSectionButton );

    controlLayout->addWidget( discFrame, 1, 13, 1, 4 );

    BUTTON_SET_IMG( prevSectionButton, "", previous.png, "" );
    BUTTON_SET_IMG( nextSectionButton, "", next.png, "" );
    BUTTON_SET_IMG( menuButton, "", previous.png, "" );

    discFrame->hide();

    /* Change the navigation button display when the IM navigation changes */
    CONNECT( THEMIM->getIM(), navigationChanged( int ),
315
             this, setNavigation( int ) );
316 317 318 319 320 321 322 323 324 325 326 327
    /* Changes the IM navigation when triggered on the nav buttons */
    CONNECT( prevSectionButton, clicked(), THEMIM->getIM(),
             sectionPrev() );
    CONNECT( nextSectionButton, clicked(), THEMIM->getIM(),
             sectionNext() );
    CONNECT( menuButton, clicked(), THEMIM->getIM(),
             sectionMenu() );

    /** Play Buttons **/
    QSizePolicy sizePolicy( QSizePolicy::Maximum, QSizePolicy::Fixed );
    sizePolicy.setHorizontalStretch( 0 );
    sizePolicy.setVerticalStretch( 0 );
328
//  sizePolicy.setHeightForWidth( playButton->sizePolicy().hasHeightForWidth() );
329 330 331 332

    /* Play */
    QPushButton *playButton = new QPushButton;
    playButton->setSizePolicy( sizePolicy );
333 334
    playButton->setMaximumSize( QSize( 26, 26 ) );
    playButton->setIconSize( QSize( 20, 20 ) );
335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368

    controlLayout->addWidget( playButton, 2, 0, 2, 2 );

    /** Prev + Stop + Next Block **/
    QHBoxLayout *controlButLayout = new QHBoxLayout;
    controlButLayout->setSpacing( 0 ); /* Don't remove that, will be useful */

    /* Prev */
    QPushButton *prevButton = new QPushButton;
    prevButton->setSizePolicy( sizePolicy );
    prevButton->setMaximumSize( QSize( 26, 26 ) );
    prevButton->setIconSize( QSize( 20, 20 ) );

    controlButLayout->addWidget( prevButton );

    /* Stop */
    QPushButton *stopButton = new QPushButton;
    stopButton->setSizePolicy( sizePolicy );
    stopButton->setMaximumSize( QSize( 26, 26 ) );
    stopButton->setIconSize( QSize( 20, 20 ) );

    controlButLayout->addWidget( stopButton );

    /* next */
    QPushButton *nextButton = new QPushButton;
    nextButton->setSizePolicy( sizePolicy );
    nextButton->setMaximumSize( QSize( 26, 26 ) );
    nextButton->setIconSize( QSize( 20, 20 ) );

    controlButLayout->addWidget( nextButton );

    /* Add this block to the main layout */
    controlLayout->addLayout( controlButLayout, 3, 3, 1, 3 );

369
    BUTTON_SET_ACT_I( playButton, "", play.png, qtr( "Play" ), play() );
370
    BUTTON_SET_ACT_I( prevButton, "" , previous.png,
371 372 373
                      qtr( "Previous" ), prev() );
    BUTTON_SET_ACT_I( nextButton, "", next.png, qtr( "Next" ), next() );
    BUTTON_SET_ACT_I( stopButton, "", stop.png, qtr( "Stop" ), stop() );
374 375 376 377 378 379

    /*
     * Other first Line buttons
     * Might need to be inside a frame to avoid a few resizing pb
     * FIXME
     */
380 381 382 383 384 385
    /** Fullscreen/Visualisation **/
    fullscreenButton = new QPushButton( "F" );
    BUTTON_SET_ACT( fullscreenButton, "F", qtr( "Fullscreen" ), fullscreen() );
    fullscreenButton->setMaximumSize( QSize( 26, 26 ) );
    controlLayout->addWidget( fullscreenButton, 3, 11 );

386 387
    /** Playlist Button **/
    playlistButton = new QPushButton;
388 389
    playlistButton->setMaximumSize( QSize( 45, 45 ) );
    playlistButton->setIconSize( QSize( 30, 30 ) );
390 391 392 393 394

    controlLayout->addWidget( playlistButton, 3, 10 );

    /** extended Settings **/
    QPushButton *extSettingsButton = new QPushButton( "F" );
395
    BUTTON_SET_ACT( extSettingsButton, "Ex", qtr( "Extended Settings" ),
396 397 398 399 400 401
            extSettings() );
    extSettingsButton->setMaximumSize( QSize( 26, 26 ) );
    controlLayout->addWidget( extSettingsButton, 3, 12 );

    /** Preferences **/
    QPushButton *prefsButton = new QPushButton( "P" );
402
    BUTTON_SET_ACT( prefsButton, "P", qtr( "Preferences / Settings" ), prefs() );
403 404 405 406 407 408 409 410 411
    prefsButton->setMaximumSize( QSize( 26, 26 ) );
    controlLayout->addWidget( prefsButton, 3, 13 );

    /* Volume */
    VolumeClickHandler *h = new VolumeClickHandler( p_intf, this );

    QLabel *volMuteLabel = new QLabel;
    volMuteLabel->setPixmap( QPixmap( ":/pixmaps/volume-low.png" ) );
    volMuteLabel->setToolTip( qtr( "Mute" ) );
412
    volMuteLabel->installEventFilter( h );
413 414 415

    volumeSlider = new QSlider;
    volumeSlider->setSizePolicy( sizePolicy );
416
    volumeSlider->setMaximumSize( QSize( 80, 200 ) );
417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437
    volumeSlider->setOrientation( Qt::Horizontal );

    volumeSlider->setMaximum( 100 );
    volumeSlider->setFocusPolicy( Qt::NoFocus );
    controlLayout->addWidget( volMuteLabel, 3, 14 );
    controlLayout->addWidget( volumeSlider, 3, 15, 1, 2 );

    /* Volume control connection */
    CONNECT( volumeSlider, valueChanged( int ), this, updateVolume( int ) );

}
ControlsWidget::~ControlsWidget()
{
}
void ControlsWidget::stop()
{
    THEMIM->stop();
}

void ControlsWidget::play()
{
438
    if( playlist_IsEmpty( THEPL ) )
439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459
    {
        /* The playlist is empty, open a file requester */
        THEDP->openFileDialog();
        setStatus( 0 );
        return;
    }
    THEMIM->togglePlayPause();
}

void ControlsWidget::prev()
{
    THEMIM->prev();
}

void ControlsWidget::next()
{
    THEMIM->next();
}

void ControlsWidget::setNavigation( int navigation )
{
460 461 462 463 464
#define HELP_MENU N_( "Menu" )
#define HELP_PCH N_( "Previous chapter" )
#define HELP_NCH N_( "Next chapter" )
#define HELP_PTR N_( "Previous track" )
#define HELP_NTR N_( "Next track" )
465 466 467 468 469 470 471

    // 1 = chapter, 2 = title, 0 = no
    if( navigation == 0 )
    {
        discFrame->hide();
    } else if( navigation == 1 ) {
        prevSectionButton->show();
472
        prevSectionButton->setToolTip( qfu( HELP_PCH ) );
473
        nextSectionButton->show();
474
        nextSectionButton->setToolTip( qfu( HELP_NCH ) );
475 476 477 478
        menuButton->show();
        discFrame->show();
    } else {
        prevSectionButton->show();
479
        prevSectionButton->setToolTip( qfu( HELP_PCH ) );
480
        nextSectionButton->show();
481
        nextSectionButton->setToolTip( qfu( HELP_NCH ) );
482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501
        menuButton->hide();
        discFrame->show();
    }
}

static bool b_my_volume;
void ControlsWidget::updateVolume( int sliderVolume )
{
    if( !b_my_volume )
    {
        int i_res = sliderVolume * AOUT_VOLUME_MAX /
                            ( 2*volumeSlider->maximum() );
        aout_VolumeSet( p_intf, i_res );
    }
}

void ControlsWidget::updateOnTimer()
{
    audio_volume_t i_volume;
    aout_VolumeGet( p_intf, &i_volume );
502
    i_volume = ( i_volume *  200 )/ AOUT_VOLUME_MAX ;
503 504 505 506 507 508 509 510 511
    int i_gauge = volumeSlider->value();
    b_my_volume = false;
    if( i_volume - i_gauge > 1 || i_gauge - i_volume > 1 )
    {
        b_my_volume = true;
        volumeSlider->setValue( i_volume );
        b_my_volume = false;
    }
}
512 513

/* FIXME */
514 515 516
void ControlsWidget::setStatus( int status )
{
    if( status == 1 ) // Playing
517 518 519 520
    {
        msg_Dbg( p_intf, "I was here %i", status );
        // playButton->setIcon( QIcon( ":/pixmaps/pause.png" ) );
    }
521
    else
522 523 524 525
    {
        msg_Dbg( p_intf, "I was here %i", status );
        // playButton->setIcon( QIcon( ":/pixmaps/play.png" ) );
    }
526
}
527

528 529 530 531
/*
 * This functions toggle the fullscreen mode
 * If there is no video, it should first activate Visualisations... TODO
 */
Clément Stenac's avatar
Clément Stenac committed
532 533
void ControlsWidget::fullscreen()
{
534
    msg_Dbg( p_intf, "Not implemented yet" );
535 536 537 538 539 540 541 542 543
}

void ControlsWidget::extSettings()
{
    THEDP->extendedDialog();
}
void ControlsWidget::prefs()
{
    THEDP->prefsDialog();
Clément Stenac's avatar
Clément Stenac committed
544 545
}

546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562
void ControlsWidget::slower()
{
    THEMIM->getIM()->slower();
}

void ControlsWidget::faster()
{
    THEMIM->getIM()->faster();
}

void ControlsWidget::enableInput( bool enable )
{
    slowerButton->setEnabled( enable );
    slider->setEnabled( enable );
    fasterButton->setEnabled( enable );
}

563 564 565 566 567 568 569
void ControlsWidget::enableVideo( bool enable )
{
    // TODO Later make the fullscreenButton toggle Visualisation and so on.
    fullscreenButton->setEnabled( enable );
}


570 571 572 573 574 575
/**********************************************************************
 * Playlist Widget. The embedded playlist
 **********************************************************************/
#include "components/playlist/panels.hpp"
#include "components/playlist/selector.hpp"

576
PlaylistWidget::PlaylistWidget( intf_thread_t *_p_intf ) :
577
                                p_intf ( _p_intf )
578
{
579 580 581
    /* Left Part and design */
    QWidget *leftW = new QWidget( this );
    QVBoxLayout *left = new QVBoxLayout( leftW );
Clément Stenac's avatar
Clément Stenac committed
582

583
    /* Source Selector */
584
    selector = new PLSelector( this, p_intf, THEPL );
Clément Stenac's avatar
Clément Stenac committed
585 586
    left->addWidget( selector );

587
    /* Art label */
588
    art = new QLabel( "" );
589 590
    art->setMinimumHeight( 128 );
    art->setMinimumWidth( 128 );
Clément Stenac's avatar
Clément Stenac committed
591 592 593
    art->setMaximumHeight( 128 );
    art->setMaximumWidth( 128 );
    art->setScaledContents( true );
594
    art->setPixmap( QPixmap( ":/noart.png" ) );
Clément Stenac's avatar
Clément Stenac committed
595
    left->addWidget( art );
596

597
    /* Initialisation of the playlist */
598 599 600
    playlist_item_t *p_root = playlist_GetPreferredNode( THEPL,
                                                THEPL->p_local_category );

601
    rightPanel = qobject_cast<PLPanel *>( new StandardPLPanel( this,
602 603
                              p_intf, THEPL, p_root ) );

604
    /* Connects */
605
    CONNECT( selector, activated( int ), rightPanel, setRoot( int ) );
606

607
    CONNECT( qobject_cast<StandardPLPanel *>( rightPanel )->model,
Clément Stenac's avatar
Clément Stenac committed
608 609
             artSet( QString ) , this, setArt( QString ) );
    /* Forward removal requests from the selector to the main panel */
610
    CONNECT( qobject_cast<PLSelector *>( selector )->model,
Clément Stenac's avatar
Clément Stenac committed
611
             shouldRemove( int ),
612
             qobject_cast<StandardPLPanel *>( rightPanel ), removeItem( int ) );
613

614
    connect( selector, SIGNAL( activated( int ) ),
615 616
             this, SIGNAL( rootChanged( int ) ) );
    emit rootChanged( p_root->i_id );
617

618 619 620 621
    /* Add the two sides of the QSplitter */
    addWidget( leftW );
    addWidget( rightPanel );

622 623 624 625 626 627
    leftW->setMaximumWidth( 250 );
    setCollapsible( 1, false );

    QList<int> sizeList;
    sizeList << 180 << 520 ;
    setSizes( sizeList );
628 629
}

630 631
void PlaylistWidget::setArt( QString url )
{
632 633 634
    if( url.isNull() )
        art->setPixmap( QPixmap( ":/noart.png" ) );
    else if( prevArt != url )
Clément Stenac's avatar
Clément Stenac committed
635
        art->setPixmap( QPixmap( url ) );
636
    prevArt = url;
637
    emit artSet( url );
638 639
}

640 641 642 643 644 645 646 647 648
PlaylistWidget::~PlaylistWidget()
{
}

QSize PlaylistWidget::sizeHint() const
{
    return widgetSize;
}