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);
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 setFrameStyle(QFrame::StyledPanel | QFrame::Raised);
152 QHBoxLayout *layout = new QHBoxLayout( this );
153 layout->setMargin( 0 );
154 QPushButton *prevButton = new QPushButton( "Prev" );
155 QPushButton *nextButton = new QPushButton( "Next");
156 layout->addWidget( prevButton );
157 layout->addWidget( nextButton );
159 setMaximumHeight( 35 );
162 VisualSelector::~VisualSelector()
166 /**********************************************************************
167 * Playlist Widget. The embedded playlist
168 **********************************************************************/
169 #include "components/playlist/panels.hpp"
170 #include "components/playlist/selector.hpp"
172 PlaylistWidget::PlaylistWidget( intf_thread_t *_p_intf ) : QFrame(NULL),
175 QVBoxLayout *left = new QVBoxLayout( );
176 QHBoxLayout *middle = new QHBoxLayout;
178 setFrameStyle(QFrame::StyledPanel | QFrame::Sunken );
179 selector = new PLSelector( this, p_intf, THEPL );
180 selector->setMaximumWidth( 130 );
181 left->addWidget( selector );
183 QPushButton *undockButton = new QPushButton( "UN", this );
184 undockButton->setMaximumWidth( 25 );
185 undockButton->setToolTip( qtr( "Undock playlist for main interface" ) );
186 QPushButton *sourcesButton = new QPushButton( "Sources", this );
187 sourcesButton->setToolTip( qtr( "Select additional stream sources" ) );
188 middle->addWidget( undockButton );
189 middle->addWidget( sourcesButton );
190 left->addLayout( middle );
192 QLabel *art = new QLabel( "" );
193 art->setMaximumHeight( 128 );
194 art->setMaximumWidth( 128 );
195 art->setScaledContents( true );
196 art->setPixmap( QPixmap( art_xpm ) ); //":/vlc128.png" ) );
197 left->addWidget( art );
199 playlist_item_t *p_root = playlist_GetPreferredNode( THEPL,
200 THEPL->p_local_category );
202 rightPanel = qobject_cast<PLPanel *>(new StandardPLPanel( this,
203 p_intf, THEPL, p_root ) );
205 CONNECT( selector, activated( int ), rightPanel, setRoot( int ) );
207 QHBoxLayout *layout = new QHBoxLayout(this);
208 layout->addLayout( left, 0 );
209 layout->addWidget( rightPanel, 10 );
213 PlaylistWidget::~PlaylistWidget()
217 QSize PlaylistWidget::sizeHint() const
219 fprintf( stderr, "PL Size %ix%i\n", widgetSize.width(), widgetSize.height() );