1 /*****************************************************************************
2 * interface_widgets.cpp : Custom widgets for the main interface
3 ****************************************************************************
4 * Copyright (C) 2006 the VideoLAN team
7 * Authors: Clément Stenac <zorglub@videolan.org>
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.
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.
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 *****************************************************************************/
24 #include "dialogs_provider.hpp"
26 #include "components/interface_widgets.hpp"
27 #include "main_interface.hpp"
28 #include "input_manager.hpp"
30 #include "pixmaps/art.xpm"
34 #include <QPushButton>
35 #include <QHBoxLayout>
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 );
49 VideoWidget::VideoWidget( intf_thread_t *_p_i ) : QFrame( NULL ), p_intf( _p_i )
51 vlc_mutex_init( p_intf, &lock );
54 setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred );
57 VideoWidget::~VideoWidget()
59 vlc_mutex_lock( &lock );
62 if( !p_intf->psz_switch_intf )
64 if( vout_Control( p_vout, VOUT_CLOSE ) != VLC_SUCCESS )
65 vout_Control( p_vout, VOUT_REPARENT );
69 if( vout_Control( p_vout, VOUT_REPARENT ) != VLC_SUCCESS )
70 vout_Control( p_vout, VOUT_CLOSE );
73 vlc_mutex_unlock( &lock );
74 vlc_mutex_destroy( &lock );
77 QSize VideoWidget::sizeHint() const
79 fprintf( stderr, "Video Size %ix%i\n", widgetSize.width(), widgetSize.height() );
83 void *VideoWidget::request( vout_thread_t *p_nvout, int *pi_x, int *pi_y,
84 unsigned int *pi_width, unsigned int *pi_height )
88 msg_Dbg( p_intf, "embedded video already in use" );
92 setMinimumSize( 1,1 );
93 return (void*)winId();
96 void VideoWidget::release( void *p_win )
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 )
108 setAutoFillBackground( true );
110 plt.setColor( QPalette::Active, QPalette::Window , Qt::black );
111 plt.setColor( QPalette::Inactive, QPalette::Window , Qt::black );
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 );
125 BackgroundWidget::~BackgroundWidget()
127 backgroundLayout->takeAt(0);
128 delete backgroundLayout;
131 QSize BackgroundWidget::sizeHint() const
133 fprintf( stderr, "BG %ix%i\n", widgetSize.width(), widgetSize.height() );
137 void BackgroundWidget::resizeEvent( QResizeEvent *e )
139 if( e->size().height() < ICON_SIZE -1 )
140 label->setMaximumWidth( e->size().height() );
142 label->setMaximumWidth( ICON_SIZE );
145 /**********************************************************************
146 * Visualization selector panel
147 **********************************************************************/
148 VisualSelector::VisualSelector( intf_thread_t *_p_i ) :
149 QFrame( NULL ), p_intf( _p_i )
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 );
158 setMaximumHeight( 35 );
161 VisualSelector::~VisualSelector()
165 /**********************************************************************
166 * Playlist Widget. The embedded playlist
167 **********************************************************************/
168 #include "components/playlist/panels.hpp"
169 #include "components/playlist/selector.hpp"
171 PlaylistWidget::PlaylistWidget( intf_thread_t *_p_intf ) :
172 BasePlaylistWidget ( _p_intf)
174 QVBoxLayout *left = new QVBoxLayout( );
175 QHBoxLayout *middle = new QHBoxLayout;
177 selector = new PLSelector( this, p_intf, THEPL );
178 selector->setMaximumWidth( 130 );
179 left->addWidget( selector );
181 /* QPushButton *undockButton = new QPushButton( "UN", this );
182 undockButton->setMaximumWidth( 25 );
183 undockButton->setToolTip( qtr( "Undock playlist for main interface" ) );
184 BUTTONACT( undockButton, undock() );
185 middle->addWidget( undockButton );
187 left->addLayout( middle );
189 QLabel *art = new QLabel( "" );
190 art->setMaximumHeight( 128 );
191 art->setMaximumWidth( 128 );
192 art->setScaledContents( true );
193 art->setPixmap( QPixmap( art_xpm ) ); //":/vlc128.png" ) );
194 left->addWidget( art );
196 playlist_item_t *p_root = playlist_GetPreferredNode( THEPL,
197 THEPL->p_local_category );
199 rightPanel = qobject_cast<PLPanel *>(new StandardPLPanel( this,
200 p_intf, THEPL, p_root ) );
202 CONNECT( selector, activated( int ), rightPanel, setRoot( int ) );
204 connect( selector, SIGNAL(activated( int )),
205 this, SIGNAL( rootChanged( int ) ) );
206 emit rootChanged( p_root->i_id );
208 QHBoxLayout *layout = new QHBoxLayout(this);
209 layout->addLayout( left, 0 );
210 layout->addWidget( rightPanel, 10 );
214 PlaylistWidget::~PlaylistWidget()
218 QSize PlaylistWidget::sizeHint() const