playlist.cpp 2.49 KB
Newer Older
zorglub's avatar
zorglub committed
1 2 3
/*****************************************************************************
 * playlist.cpp : Playlist dialog
 ****************************************************************************
4 5
 * Copyright (C) 2006 the VideoLAN team
 * $Id$
zorglub's avatar
zorglub committed
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
 *
 * Authors: Clément Stenac <zorglub@videolan.org>
 *
 * 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
 * (at your option) any later version.
 *
 * 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
zorglub's avatar
zorglub committed
21 22
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
 ******************************************************************************/
zorglub's avatar
zorglub committed
23 24

#include "dialogs/playlist.hpp"
25

zorglub's avatar
zorglub committed
26
#include "qt4.hpp"
27 28
#include "main_interface.hpp"
#include "util/qvlcframe.hpp"
zorglub's avatar
zorglub committed
29
#include "components/interface_widgets.hpp"
30
#include "dialogs_provider.hpp"
zorglub's avatar
zorglub committed
31
#include "menus.hpp"
32

33
#include <QHBoxLayout>
zorglub's avatar
zorglub committed
34 35 36 37
#include <QSignalMapper>
#include <QMenu>
#include <QAction>
#include <QMenuBar>
zorglub's avatar
zorglub committed
38 39 40

PlaylistDialog *PlaylistDialog::instance = NULL;

zorglub's avatar
zorglub committed
41
PlaylistDialog::PlaylistDialog( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
zorglub's avatar
zorglub committed
42
{
zorglub's avatar
zorglub committed
43 44
    QWidget *main = new QWidget( this );
    setCentralWidget( main );
zorglub's avatar
zorglub committed
45
    setWindowTitle( qtr( "Playlist" ) );
zorglub's avatar
zorglub committed
46

zorglub's avatar
zorglub committed
47
    createPlMenuBar( menuBar(), p_intf );
48

zorglub's avatar
zorglub committed
49 50 51
    QHBoxLayout *l = new QHBoxLayout( centralWidget() );
    PlaylistWidget *plw = new PlaylistWidget( p_intf );
    l->addWidget( plw );
zorglub's avatar
zorglub committed
52

zorglub's avatar
zorglub committed
53
    readSettings( "playlist", QSize( 600,700 ) );
zorglub's avatar
zorglub committed
54 55 56 57
}

PlaylistDialog::~PlaylistDialog()
{
zorglub's avatar
zorglub committed
58
    writeSettings( "playlist" );
zorglub's avatar
zorglub committed
59
}
zorglub's avatar
zorglub committed
60 61 62 63

void PlaylistDialog::createPlMenuBar( QMenuBar *bar, intf_thread_t *p_intf )
{
    QMenu *manageMenu = new QMenu();
zorglub's avatar
zorglub committed
64
    manageMenu->setTitle( qtr("Manage") );
zorglub's avatar
zorglub committed
65
    manageMenu->addAction( "Open playlist file", THEDP, SLOT( openPlaylist() ));
zorglub's avatar
zorglub committed
66
    manageMenu->addSeparator();
67
    manageMenu->addAction( "Dock playlist", this, SLOT( dock() ) );
zorglub's avatar
zorglub committed
68
    bar->addMenu( manageMenu );
zorglub's avatar
zorglub committed
69
    bar->addMenu( QVLCMenu::SDMenu( p_intf ) );
zorglub's avatar
zorglub committed
70 71
}

72 73 74 75 76 77
void PlaylistDialog::dock()
{
    hide();
    QEvent *event = new QEvent( (QEvent::Type)(PLDockEvent_Type) );
    QApplication::postEvent( p_intf->p_sys->p_mi, event );
}