]> git.sesse.net Git - vlc/blob - modules/gui/qt4/components/interface_widgets.cpp
Remove useless code
[vlc] / modules / gui / qt4 / components / interface_widgets.cpp
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  *
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_provider.hpp"
25 #include "qt4.hpp"
26 #include "components/interface_widgets.hpp"
27 #include "main_interface.hpp"
28 #include "input_manager.hpp"
29
30 #include "pixmaps/art.xpm"
31 #include <vlc/vout.h>
32
33 #include <QCursor>
34 #include <QPushButton>
35 #include <QHBoxLayout>
36 #include <QMenu>
37
38 #define ICON_SIZE 128
39
40 /**********************************************************************
41  * Video Widget. A simple frame on which video is drawn
42  * This class handles resize issues
43  **********************************************************************/
44 static void *DoRequest( intf_thread_t *, vout_thread_t *, int*,int*,
45                         unsigned int *, unsigned int * );
46 static void DoRelease( intf_thread_t *, void * );
47 static int DoControl( intf_thread_t *, void *, int, va_list );
48
49 VideoWidget::VideoWidget( intf_thread_t *_p_i ) : QFrame( NULL ), p_intf( _p_i )
50 {
51     vlc_mutex_init( p_intf, &lock );
52     p_vout = NULL;
53
54     setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred );
55 }
56
57 VideoWidget::~VideoWidget()
58 {
59     vlc_mutex_lock( &lock );
60     if( p_vout )
61     {
62         if( !p_intf->psz_switch_intf )
63         {
64             if( vout_Control( p_vout, VOUT_CLOSE ) != VLC_SUCCESS )
65                 vout_Control( p_vout, VOUT_REPARENT );
66         }
67         else
68         {
69             if( vout_Control( p_vout, VOUT_REPARENT ) != VLC_SUCCESS )
70                 vout_Control( p_vout, VOUT_CLOSE );
71         }
72     }
73     vlc_mutex_unlock( &lock );
74     vlc_mutex_destroy( &lock );
75 }
76
77 QSize VideoWidget::sizeHint() const
78 {
79     fprintf( stderr, "Video Size %ix%i\n", widgetSize.width(), widgetSize.height() );
80     return widgetSize;
81 }
82
83 void *VideoWidget::request( vout_thread_t *p_nvout, int *pi_x, int *pi_y,
84                            unsigned int *pi_width, unsigned int *pi_height )
85 {
86     if( p_vout )
87     {
88         msg_Dbg( p_intf, "embedded video already in use" );
89         return NULL;
90     }
91     p_vout = p_nvout;
92     setMinimumSize( 1,1 );
93     return (void*)winId();
94 }
95
96 void VideoWidget::release( void *p_win )
97 {
98     p_vout = NULL;
99 }
100 /**********************************************************************
101  * Background Widget. Show a simple image background. Currently,
102  * it's a static cone.
103  **********************************************************************/
104 BackgroundWidget::BackgroundWidget( intf_thread_t *_p_i ) :
105                                         QFrame( NULL ), p_intf( _p_i )
106 {
107
108     setAutoFillBackground( true );
109     plt =  palette();
110     plt.setColor( QPalette::Active, QPalette::Window , Qt::black );
111     plt.setColor( QPalette::Inactive, QPalette::Window , Qt::black );
112     setPalette( plt );
113
114     backgroundLayout = new QHBoxLayout;
115     label = new QLabel( "" );
116     label->setMaximumHeight( ICON_SIZE );
117     label->setMaximumWidth( ICON_SIZE );
118     label->setScaledContents( true );
119     label->setPixmap( QPixmap( ":/vlc128.png" ) );
120     backgroundLayout = new QHBoxLayout;
121     backgroundLayout->addWidget( label );
122     setLayout( backgroundLayout );
123 }
124
125 BackgroundWidget::~BackgroundWidget()
126 {
127     backgroundLayout->takeAt(0);
128     delete backgroundLayout;
129 }
130
131 QSize BackgroundWidget::sizeHint() const
132 {
133     fprintf( stderr, "BG %ix%i\n", widgetSize.width(), widgetSize.height() );
134     return widgetSize;
135 }
136
137 void BackgroundWidget::resizeEvent( QResizeEvent *e )
138 {
139     if( e->size().height() < ICON_SIZE -1 )
140         label->setMaximumWidth( e->size().height() );
141     else
142         label->setMaximumWidth( ICON_SIZE );
143 }
144
145 /**********************************************************************
146  * Visualization selector panel
147  **********************************************************************/
148 VisualSelector::VisualSelector( intf_thread_t *_p_i ) :
149                                                 QFrame( NULL ), p_intf( _p_i )
150 {
151     QHBoxLayout *layout = new QHBoxLayout( this );
152     layout->setMargin( 0 );
153     QPushButton *prevButton = new QPushButton( "Prev" );
154     QPushButton *nextButton = new QPushButton( "Next");
155     layout->addWidget( prevButton );
156     layout->addWidget( nextButton );
157     setLayout( layout );
158     setMaximumHeight( 35 );
159 }
160
161 VisualSelector::~VisualSelector()
162 {
163 }
164
165 /**********************************************************************
166  * Playlist Widget. The embedded playlist
167  **********************************************************************/
168 #include "components/playlist/panels.hpp"
169 #include "components/playlist/selector.hpp"
170
171 PlaylistWidget::PlaylistWidget( intf_thread_t *_p_intf ) :
172                                 BasePlaylistWidget ( _p_intf)
173 {
174     QVBoxLayout *left = new QVBoxLayout( );
175
176     selector = new PLSelector( this, p_intf, THEPL );
177     selector->setMaximumWidth( 130 );
178     left->addWidget( selector );
179
180     QLabel *art = new QLabel( "" );
181     art->setMaximumHeight( 128 );
182     art->setMaximumWidth( 128 );
183     art->setScaledContents( true );
184     art->setPixmap( QPixmap( art_xpm ) ); //":/vlc128.png" ) );
185     left->addWidget( art );
186
187     playlist_item_t *p_root = playlist_GetPreferredNode( THEPL,
188                                                 THEPL->p_local_category );
189
190     rightPanel = qobject_cast<PLPanel *>(new StandardPLPanel( this,
191                               p_intf, THEPL, p_root ) );
192
193     CONNECT( selector, activated( int ), rightPanel, setRoot( int ) );
194
195     connect( selector, SIGNAL(activated( int )),
196              this, SIGNAL( rootChanged( int ) ) );
197     emit rootChanged( p_root->i_id );
198
199     QHBoxLayout *layout = new QHBoxLayout(this);
200     layout->addLayout( left, 0 );
201     layout->addWidget( rightPanel, 10 );
202     setLayout( layout );
203 }
204
205 PlaylistWidget::~PlaylistWidget()
206 {
207 }
208
209 QSize PlaylistWidget::sizeHint() const
210 {
211     return widgetSize;
212 }
213