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"
32 #include <QHBoxLayout>
36 /**********************************************************************
37 * Video Widget. A simple frame on which video is drawn
38 * This class handles resize issues
39 **********************************************************************/
40 static void *DoRequest( intf_thread_t *, vout_thread_t *, int*,int*,
41 unsigned int *, unsigned int * );
42 static void DoRelease( intf_thread_t *, void * );
43 static int DoControl( intf_thread_t *, void *, int, va_list );
45 VideoWidget::VideoWidget( intf_thread_t *_p_i ) : QFrame( NULL ), p_intf( _p_i )
47 vlc_mutex_init( p_intf, &lock );
49 setFrameStyle(QFrame::Panel | QFrame::Raised);
51 setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred );
54 VideoWidget::~VideoWidget()
56 vlc_mutex_lock( &lock );
59 if( !p_intf->psz_switch_intf )
61 if( vout_Control( p_vout, VOUT_CLOSE ) != VLC_SUCCESS )
62 vout_Control( p_vout, VOUT_REPARENT );
66 if( vout_Control( p_vout, VOUT_REPARENT ) != VLC_SUCCESS )
67 vout_Control( p_vout, VOUT_CLOSE );
70 vlc_mutex_unlock( &lock );
71 vlc_mutex_destroy( &lock );
74 QSize VideoWidget::sizeHint() const
76 fprintf( stderr, "Video Size %ix%i\n", widgetSize.width(), widgetSize.height() );
80 void *VideoWidget::request( vout_thread_t *p_nvout, int *pi_x, int *pi_y,
81 unsigned int *pi_width, unsigned int *pi_height )
85 msg_Dbg( p_intf, "embedded video already in use" );
89 setMinimumSize( 1,1 );
90 return (void*)winId();
93 void VideoWidget::release( void *p_win )
97 /**********************************************************************
98 * Background Widget. Show a simple image background. Currently,
100 **********************************************************************/
101 BackgroundWidget::BackgroundWidget( intf_thread_t *_p_i ) :
102 QFrame( NULL ), p_intf( _p_i )
104 setFrameStyle(QFrame::StyledPanel | QFrame::Raised);
108 BackgroundWidget::~BackgroundWidget()
113 int BackgroundWidget::DrawBackground()
115 setAutoFillBackground( true );
117 plt.setColor( QPalette::Active, QPalette::Window , Qt::black );
118 plt.setColor( QPalette::Inactive, QPalette::Window , Qt::black );
121 backgroundLayout = new QHBoxLayout;
122 label = new QLabel( "" );
123 label->setMaximumHeight( ICON_SIZE );
124 label->setMaximumWidth( ICON_SIZE );
125 label->setScaledContents( true );
126 label->setPixmap( QPixmap( ":/vlc128.png" ) );
127 backgroundLayout = new QHBoxLayout;
128 backgroundLayout->addWidget( label );
129 setLayout( backgroundLayout );
133 int BackgroundWidget::CleanBackground()
135 backgroundLayout->takeAt(0);
136 delete backgroundLayout;
140 QSize BackgroundWidget::sizeHint() const
142 fprintf( stderr, "BG %ix%i\n", widgetSize.width(), widgetSize.height() );
146 void BackgroundWidget::resizeEvent( QResizeEvent *e )
148 if( e->size().height() < ICON_SIZE -1 )
149 label->setMaximumWidth( e->size().height() );
151 label->setMaximumWidth( ICON_SIZE );
154 /**********************************************************************
155 * Playlist Widget. The embedded playlist
156 **********************************************************************/
157 #include "components/playlist/panels.hpp"
158 #include "components/playlist/selector.hpp"
160 PlaylistWidget::PlaylistWidget( intf_thread_t *_p_intf ) : QFrame(NULL),
163 setFrameStyle(QFrame::StyledPanel | QFrame::Sunken );
164 selector = new PLSelector( this, p_intf, THEPL );
165 selector->setMaximumWidth( 130 );
167 playlist_item_t *p_root = playlist_GetPreferredNode( THEPL,
168 THEPL->p_local_category );
170 rightPanel = qobject_cast<PLPanel *>(new StandardPLPanel( this,
171 p_intf, THEPL, p_root ) );
173 CONNECT( selector, activated( int ), rightPanel, setRoot( int ) );
175 QHBoxLayout *layout = new QHBoxLayout();
176 layout->addWidget( selector, 0 );
177 layout->addWidget( rightPanel, 10 );
181 PlaylistWidget::~PlaylistWidget()
185 QSize PlaylistWidget::sizeHint() const
187 fprintf( stderr, "PL Size %ix%i\n", widgetSize.width(), widgetSize.height() );