]> git.sesse.net Git - vlc/blob - modules/gui/qt4/dialogs/playlist.cpp
Qt(Dialog provider): Add support for key accelerators
[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 "components/playlist/playlist.hpp"
30
31 #include "util/qt_dirs.hpp"
32
33 #include <QUrl>
34 #include <QMimeData>
35 #include <QHBoxLayout>
36
37 PlaylistDialog::PlaylistDialog( intf_thread_t *_p_intf )
38                 : QVLCMW( _p_intf )
39 {
40     setWindowTitle( qtr( "Playlist" ) );
41     setWindowRole( "vlc-playlist" );
42     setWindowOpacity( var_InheritFloat( p_intf, "qt-opacity" ) );
43
44     playlistWidget = new PlaylistWidget( p_intf, this );
45     setCentralWidget( playlistWidget );
46
47     readSettings( "playlistdialog", QSize( 600,700 ) );
48 }
49
50 PlaylistWidget *PlaylistDialog::exportPlaylistWidget()
51 {
52     Q_ASSERT( playlistWidget );
53     PlaylistWidget *widget = playlistWidget;
54     layout()->removeWidget( playlistWidget );
55     playlistWidget = NULL;
56     return widget;
57 }
58
59 void PlaylistDialog::importPlaylistWidget( PlaylistWidget *widget )
60 {
61     Q_ASSERT( !playlistWidget );
62     playlistWidget = widget;
63     setCentralWidget( playlistWidget );
64     playlistWidget->show();
65 }
66
67 bool PlaylistDialog::hasPlaylistWidget()
68 {
69     return ( !! playlistWidget );
70 }
71
72 void PlaylistDialog::hideEvent( QHideEvent * event )
73 {
74     QWidget::hideEvent( event );
75     emit visibilityChanged( false );
76 }
77
78 PlaylistDialog::~PlaylistDialog()
79 {
80     writeSettings( "playlistdialog" );
81 }
82
83 void PlaylistDialog::dropEvent( QDropEvent *event )
84 {
85     playlistWidget->dropEvent(event);
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