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"
33 #include <QPushButton>
34 #include <QHBoxLayout>
38 /**********************************************************************
39 * Video Widget. A simple frame on which video is drawn
40 * This class handles resize issues
41 **********************************************************************/
42 static void *DoRequest( intf_thread_t *, vout_thread_t *, int*,int*,
43 unsigned int *, unsigned int * );
44 static void DoRelease( intf_thread_t *, void * );
45 static int DoControl( intf_thread_t *, void *, int, va_list );
47 VideoWidget::VideoWidget( intf_thread_t *_p_i ) : QFrame( NULL ), p_intf( _p_i )
49 vlc_mutex_init( p_intf, &lock );
51 setFrameStyle(QFrame::Panel | QFrame::Raised);
53 setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred );
56 VideoWidget::~VideoWidget()
58 vlc_mutex_lock( &lock );
61 if( !p_intf->psz_switch_intf )
63 if( vout_Control( p_vout, VOUT_CLOSE ) != VLC_SUCCESS )
64 vout_Control( p_vout, VOUT_REPARENT );
68 if( vout_Control( p_vout, VOUT_REPARENT ) != VLC_SUCCESS )
69 vout_Control( p_vout, VOUT_CLOSE );
72 vlc_mutex_unlock( &lock );
73 vlc_mutex_destroy( &lock );
76 QSize VideoWidget::sizeHint() const
78 fprintf( stderr, "Video Size %ix%i\n", widgetSize.width(), widgetSize.height() );
82 void *VideoWidget::request( vout_thread_t *p_nvout, int *pi_x, int *pi_y,
83 unsigned int *pi_width, unsigned int *pi_height )
87 msg_Dbg( p_intf, "embedded video already in use" );
91 setMinimumSize( 1,1 );
92 return (void*)winId();
95 void VideoWidget::release( void *p_win )
99 /**********************************************************************
100 * Background Widget. Show a simple image background. Currently,
101 * it's a static cone.
102 **********************************************************************/
103 BackgroundWidget::BackgroundWidget( intf_thread_t *_p_i ) :
104 QFrame( NULL ), p_intf( _p_i )
106 setFrameStyle(QFrame::StyledPanel | QFrame::Raised);
110 BackgroundWidget::~BackgroundWidget()
115 int BackgroundWidget::DrawBackground()
117 setAutoFillBackground( true );
119 plt.setColor( QPalette::Active, QPalette::Window , Qt::black );
120 plt.setColor( QPalette::Inactive, QPalette::Window , Qt::black );
123 backgroundLayout = new QHBoxLayout;
124 label = new QLabel( "" );
125 label->setMaximumHeight( ICON_SIZE );
126 label->setMaximumWidth( ICON_SIZE );
127 label->setScaledContents( true );
128 label->setPixmap( QPixmap( ":/vlc128.png" ) );
129 backgroundLayout = new QHBoxLayout;
130 backgroundLayout->addWidget( label );
131 setLayout( backgroundLayout );
135 int BackgroundWidget::CleanBackground()
137 backgroundLayout->takeAt(0);
138 delete backgroundLayout;
142 QSize BackgroundWidget::sizeHint() const
144 fprintf( stderr, "BG %ix%i\n", widgetSize.width(), widgetSize.height() );
148 void BackgroundWidget::resizeEvent( QResizeEvent *e )
150 if( e->size().height() < ICON_SIZE -1 )
151 label->setMaximumWidth( e->size().height() );
153 label->setMaximumWidth( ICON_SIZE );
156 /**********************************************************************
157 * Playlist Widget. The embedded playlist
158 **********************************************************************/
159 #include "components/playlist/panels.hpp"
160 #include "components/playlist/selector.hpp"
162 PlaylistWidget::PlaylistWidget( intf_thread_t *_p_intf ) : QFrame(NULL),
165 QVBoxLayout *left = new QVBoxLayout( );
166 QHBoxLayout *middle = new QHBoxLayout;
168 setFrameStyle(QFrame::StyledPanel | QFrame::Sunken );
169 selector = new PLSelector( this, p_intf, THEPL );
170 selector->setMaximumWidth( 130 );
171 left->addWidget( selector );
173 QPushButton *undockButton = new QPushButton( "UN", this );
174 undockButton->setMaximumWidth( 25 );
175 undockButton->setToolTip( qtr( "Undock playlist for main interface" ) );
176 QPushButton *sourcesButton = new QPushButton( "Sources", this );
177 sourcesButton->setToolTip( qtr( "Select additional stream sources" ) );
178 middle->addWidget( undockButton );
179 middle->addWidget( sourcesButton );
180 left->addLayout( middle );
182 QLabel *art = new QLabel( "" );
183 art->setMaximumHeight( 128 );
184 art->setMaximumWidth( 128 );
185 art->setScaledContents( true );
186 art->setPixmap( QPixmap( art_xpm ) ); //":/vlc128.png" ) );
187 left->addWidget( art );
189 playlist_item_t *p_root = playlist_GetPreferredNode( THEPL,
190 THEPL->p_local_category );
192 rightPanel = qobject_cast<PLPanel *>(new StandardPLPanel( this,
193 p_intf, THEPL, p_root ) );
195 CONNECT( selector, activated( int ), rightPanel, setRoot( int ) );
197 QHBoxLayout *layout = new QHBoxLayout(this);
198 layout->addLayout( left, 0 );
199 layout->addWidget( rightPanel, 10 );
203 PlaylistWidget::~PlaylistWidget()
207 QSize PlaylistWidget::sizeHint() const
209 fprintf( stderr, "PL Size %ix%i\n", widgetSize.width(), widgetSize.height() );