Adds an option to qt4 intf to set opacity for main interface, playlist, and extended...
[vlc.git] / 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
24 #include "dialogs/playlist.hpp"
25
26 #include "qt4.hpp"
27 #include "main_interface.hpp"
28 #include "util/qvlcframe.hpp"
29 #include "components/interface_widgets.hpp"
30 #include "dialogs_provider.hpp"
31 #include "menus.hpp"
32
33 #include <QUrl>
34 #include <QHBoxLayout>
35 #include <QSignalMapper>
36 #include <QMenu>
37 #include <QAction>
38 #include <QMenuBar>
39
40 PlaylistDialog *PlaylistDialog::instance = NULL;
41
42 PlaylistDialog::PlaylistDialog( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
43 {
44     QWidget *main = new QWidget( this );
45     setCentralWidget( main );
46     setWindowTitle( qtr( "Playlist" ) );
47     setWindowOpacity( config_GetFloat( p_intf, "qt-opacity" ) );
48
49     createPlMenuBar( menuBar(), p_intf );
50
51     QHBoxLayout *l = new QHBoxLayout( centralWidget() );
52     PlaylistWidget *plw = new PlaylistWidget( p_intf );
53     l->addWidget( plw );
54
55     readSettings( "playlist", QSize( 600,700 ) );
56 }
57
58 PlaylistDialog::~PlaylistDialog()
59 {
60     writeSettings( "playlist" );
61 }
62
63 void PlaylistDialog::createPlMenuBar( QMenuBar *bar, intf_thread_t *p_intf )
64 {
65     QMenu *manageMenu = new QMenu();
66     manageMenu->setTitle( qtr("Manage") );
67     manageMenu->addAction( qtr("Open playlist file"), THEDP,
68             SLOT( openPlaylist() ), qtr( "Ctrl+X") );
69     manageMenu->addSeparator();
70     manageMenu->addAction( qtr("Dock playlist"), this, SLOT( dock() ),
71             qtr( "Ctrl+U" ) );
72     bar->addMenu( manageMenu );
73     bar->addMenu( QVLCMenu::SDMenu( p_intf ) );
74 }
75
76 void PlaylistDialog::dock()
77 {
78     hide();
79     QEvent *event = new QEvent( (QEvent::Type)(PLDockEvent_Type) );
80     QApplication::postEvent( p_intf->p_sys->p_mi, event );
81 }
82
83
84 void PlaylistDialog::dropEvent(QDropEvent *event)
85 {
86      const QMimeData *mimeData = event->mimeData();
87      foreach( QUrl url, mimeData->urls() ) {
88         QString s = url.toString();
89         if( s.length() > 0 ) {
90             playlist_Add( THEPL, qtu(s), NULL,
91                           PLAYLIST_APPEND, PLAYLIST_END, VLC_TRUE, VLC_FALSE );
92         }
93      }
94      event->acceptProposedAction();
95 }
96 void PlaylistDialog::dragEnterEvent(QDragEnterEvent *event)
97 {
98      event->acceptProposedAction();
99 }
100 void PlaylistDialog::dragMoveEvent(QDragMoveEvent *event)
101 {
102      event->acceptProposedAction();
103 }
104 void PlaylistDialog::dragLeaveEvent(QDragLeaveEvent *event)
105 {
106      event->accept();
107 }
108
109