]> git.sesse.net Git - vlc/blob - modules/gui/qt4/dialogs/playlist.cpp
Merge branch 'master' of git@git.videolan.org:vlc
[vlc] / modules / gui / qt4 / dialogs / playlist.cpp
1 /*****************************************************************************
2  * playlist.cpp : Playlist dialog
3  ****************************************************************************
4  * Copyright (C) 2006 the VideoLAN team
5  * $Id$
6  *
7  * Authors: ClĂ©ment Stenac <zorglub@videolan.org>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22  ******************************************************************************/
23 #ifdef HAVE_CONFIG_H
24 # include "config.h"
25 #endif
26
27 #include "dialogs/playlist.hpp"
28
29 #include "main_interface.hpp"
30 #include "components/playlist/playlist.hpp"
31 #include "dialogs_provider.hpp"
32 #include "menus.hpp"
33
34 #include <QUrl>
35 #include <QHBoxLayout>
36 #include <QSignalMapper>
37 #include <QMenu>
38 #include <QAction>
39 #include <QMenuBar>
40
41 PlaylistDialog *PlaylistDialog::instance = NULL;
42
43 PlaylistDialog::PlaylistDialog( intf_thread_t *_p_intf )
44                 : QVLCMW( _p_intf )
45 {
46     QWidget *main = new QWidget( this );
47     setCentralWidget( main );
48     setWindowTitle( qtr( "Playlist" ) );
49     setWindowOpacity( config_GetFloat( p_intf, "qt-opacity" ) );
50
51     QHBoxLayout *l = new QHBoxLayout( centralWidget() );
52
53     settings = new QSettings( "vlc", "vlc-qt-interface" );
54     settings->beginGroup("playlistdialog");
55
56     playlistWidget = new PlaylistWidget( p_intf, settings, this );
57     l->addWidget( playlistWidget );
58
59     readSettings( settings, QSize( 600,700 ) );
60
61     settings->endGroup();
62 }
63
64 PlaylistDialog::~PlaylistDialog()
65 {
66     settings->beginGroup("playlistdialog");
67
68     writeSettings(settings);
69     playlistWidget->savingSettings(settings);
70
71     settings->endGroup();
72     delete settings;
73 }
74
75 void PlaylistDialog::dropEvent( QDropEvent *event )
76 {
77      const QMimeData *mimeData = event->mimeData();
78      foreach( QUrl url, mimeData->urls() ) {
79         QString s = url.toString();
80         if( s.length() > 0 ) {
81             playlist_Add( THEPL, qtu(s), NULL,
82                           PLAYLIST_APPEND, PLAYLIST_END, true, false );
83         }
84      }
85      event->acceptProposedAction();
86 }
87 void PlaylistDialog::dragEnterEvent( QDragEnterEvent *event )
88 {
89      event->acceptProposedAction();
90 }
91 void PlaylistDialog::dragMoveEvent( QDragMoveEvent *event )
92 {
93      event->acceptProposedAction();
94 }
95 void PlaylistDialog::dragLeaveEvent( QDragLeaveEvent *event )
96 {
97      event->accept();
98 }
99