]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/components/interface_widgets.cpp
Qt4 - comment another thing to build on windows. L4|\/|3 contribs...
[vlc] / modules / gui / qt4 / components / interface_widgets.cpp
index 2e5e81c307b06b2a6ab919281be414da239ffedc..1ae3206daad5bdbb1c9fb8219794b1d344ea1116 100644 (file)
 #include "main_interface.hpp"
 #include "input_manager.hpp"
 
-#include "pixmaps/art.xpm"
-#include <vlc/vout.h>
+#include <vlc_vout.h>
 
+#include <QLabel>
+#include <QSpacerItem>
+#include <QCursor>
 #include <QPushButton>
 #include <QHBoxLayout>
+#include <QMenu>
 
 #define ICON_SIZE 128
 
@@ -48,7 +51,6 @@ VideoWidget::VideoWidget( intf_thread_t *_p_i ) : QFrame( NULL ), p_intf( _p_i )
 {
     vlc_mutex_init( p_intf, &lock );
     p_vout = NULL;
-    setFrameStyle(QFrame::Panel | QFrame::Raised);
 
     setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred );
 }
@@ -75,7 +77,6 @@ VideoWidget::~VideoWidget()
 
 QSize VideoWidget::sizeHint() const
 {
-    fprintf( stderr, "Video Size %ix%i\n", widgetSize.width(), widgetSize.height() );
     return widgetSize;
 }
 
@@ -88,7 +89,7 @@ void *VideoWidget::request( vout_thread_t *p_nvout, int *pi_x, int *pi_y,
         return NULL;
     }
     p_vout = p_nvout;
-    setMinimumSize( 1,1 );
+    setMinimumSize( 0, 0 );
     return (void*)winId();
 }
 
@@ -103,7 +104,6 @@ void VideoWidget::release( void *p_win )
 BackgroundWidget::BackgroundWidget( intf_thread_t *_p_i ) :
                                         QFrame( NULL ), p_intf( _p_i )
 {
-    setFrameStyle(QFrame::StyledPanel | QFrame::Raised);
 
     setAutoFillBackground( true );
     plt =  palette();
@@ -130,7 +130,6 @@ BackgroundWidget::~BackgroundWidget()
 
 QSize BackgroundWidget::sizeHint() const
 {
-    fprintf( stderr, "BG %ix%i\n", widgetSize.width(), widgetSize.height() );
     return widgetSize;
 }
 
@@ -148,51 +147,151 @@ void BackgroundWidget::resizeEvent( QResizeEvent *e )
 VisualSelector::VisualSelector( intf_thread_t *_p_i ) :
                                                 QFrame( NULL ), p_intf( _p_i )
 {
-    setFrameStyle(QFrame::StyledPanel | QFrame::Raised);
     QHBoxLayout *layout = new QHBoxLayout( this );
+    layout->setMargin( 0 );
     QPushButton *prevButton = new QPushButton( "Prev" );
     QPushButton *nextButton = new QPushButton( "Next");
     layout->addWidget( prevButton );
     layout->addWidget( nextButton );
+
+    layout->addItem( new QSpacerItem( 40,20,
+                              QSizePolicy::Expanding, QSizePolicy::Minimum) );
+    layout->addWidget( new QLabel( qtr("Current visualization:") ) );
+
+    current = new QLabel( qtr( "None" ) );
+    layout->addWidget( current );
+
+    BUTTONACT( prevButton, prev() );
+    BUTTONACT( nextButton, next() );
+
     setLayout( layout );
-    setMaximumHeight( 30 );
+    setMaximumHeight( 35 );
 }
 
 VisualSelector::~VisualSelector()
 {
 }
 
+void VisualSelector::prev()
+{
+    char *psz_new = aout_VisualPrev( p_intf );
+    if( psz_new )
+    {
+        current->setText( qfu( psz_new ) );
+        free( psz_new );
+    }
+}
+
+void VisualSelector::next()
+{
+    char *psz_new = aout_VisualNext( p_intf );
+    if( psz_new )
+    {
+        current->setText( qfu( psz_new ) );
+        free( psz_new );
+    }
+}
+
+/**********************************************************************
+ * More controls
+ **********************************************************************/
+ControlsWidget::ControlsWidget( intf_thread_t *_p_i ) :
+                                           QFrame( NULL ), p_intf( _p_i )
+{
+    QHBoxLayout *layout = new QHBoxLayout( this );
+    layout->setMargin( 0 );
+
+    slowerButton = new QPushButton( "S" );
+    BUTTON_SET_ACT( slowerButton, "S", qtr("Slower" ), slower() );
+    layout->addWidget( slowerButton );
+    slowerButton->setMaximumWidth( 35 );
+
+    normalButton = new QPushButton( "N" );
+    BUTTON_SET_ACT( normalButton, "N", qtr("Normal rate"), normal() );
+    layout->addWidget( normalButton );
+    normalButton->setMaximumWidth( 35 );
+
+    fasterButton = new QPushButton( "F" );
+    BUTTON_SET_ACT( fasterButton, "F", qtr("Faster" ), faster() );
+    layout->addWidget( fasterButton );
+    fasterButton->setMaximumWidth( 35 );
+
+    layout->addItem( new QSpacerItem( 100,20,
+                              QSizePolicy::Expanding, QSizePolicy::Minimum) );
+
+    snapshotButton = new QPushButton( "S" );
+    BUTTON_SET_ACT( snapshotButton, "S", qtr("Take a snapshot"), snapshot() );
+    layout->addWidget( snapshotButton );
+    snapshotButton->setMaximumWidth( 35 );
+
+    fullscreenButton = new QPushButton( "F" );
+    BUTTON_SET_ACT( fullscreenButton, "F", qtr("Fullscreen"), fullscreen() );
+    layout->addWidget( fullscreenButton );
+    fullscreenButton->setMaximumWidth( 35 );
+}
+
+ControlsWidget::~ControlsWidget()
+{
+}
+
+void ControlsWidget::enableInput( bool enable )
+{
+    slowerButton->setEnabled( enable );
+    normalButton->setEnabled( enable );
+    fasterButton->setEnabled( enable );
+}
+void ControlsWidget::enableVideo( bool enable )
+{
+    snapshotButton->setEnabled( enable );
+    fullscreenButton->setEnabled( enable );
+}
+
+void ControlsWidget::slower()
+{
+    THEMIM->getIM()->slower();
+}
+
+void ControlsWidget::faster()
+{
+    THEMIM->getIM()->faster();
+}
+
+void ControlsWidget::normal()
+{
+    THEMIM->getIM()->normalRate();
+}
+
+void ControlsWidget::snapshot()
+{
+}
+
+void ControlsWidget::fullscreen()
+{
+}
+
 /**********************************************************************
  * Playlist Widget. The embedded playlist
  **********************************************************************/
 #include "components/playlist/panels.hpp"
 #include "components/playlist/selector.hpp"
 
-PlaylistWidget::PlaylistWidget( intf_thread_t *_p_intf ) : QFrame(NULL),
-                                                            p_intf( _p_intf )
+PlaylistWidget::PlaylistWidget( intf_thread_t *_p_intf ) :
+                                BasePlaylistWidget ( _p_intf)
 {
     QVBoxLayout *left = new QVBoxLayout( );
-    QHBoxLayout *middle = new QHBoxLayout;
 
-    setFrameStyle(QFrame::StyledPanel | QFrame::Sunken );
     selector = new PLSelector( this, p_intf, THEPL );
     selector->setMaximumWidth( 130 );
     left->addWidget( selector );
 
-    QPushButton *undockButton = new QPushButton( "UN", this );
-    undockButton->setMaximumWidth( 25 );
-    undockButton->setToolTip( qtr( "Undock playlist for main interface" ) );
-    QPushButton *sourcesButton = new QPushButton( "Sources", this );
-    sourcesButton->setToolTip( qtr( "Select additional stream sources" ) );
-    middle->addWidget( undockButton );
-    middle->addWidget( sourcesButton );
-    left->addLayout( middle );
-
-    QLabel *art = new QLabel( "" );
+    art = new QLabel( "" );
+    art->setMinimumHeight( 128 );
+    art->setMinimumWidth( 128 );
     art->setMaximumHeight( 128 );
     art->setMaximumWidth( 128 );
     art->setScaledContents( true );
-    art->setPixmap( QPixmap( art_xpm ) ); //":/vlc128.png" ) );
+
+    art->setPixmap( QPixmap( ":/noart.png" ) );
     left->addWidget( art );
 
     playlist_item_t *p_root = playlist_GetPreferredNode( THEPL,
@@ -203,19 +302,38 @@ PlaylistWidget::PlaylistWidget( intf_thread_t *_p_intf ) : QFrame(NULL),
 
     CONNECT( selector, activated( int ), rightPanel, setRoot( int ) );
 
+    CONNECT( qobject_cast<StandardPLPanel *>(rightPanel)->model,
+             artSet( QString ) , this, setArt( QString ) );
+    /* Forward removal requests from the selector to the main panel */
+    CONNECT( qobject_cast<PLSelector *>(selector)->model,
+             shouldRemove( int ),
+             qobject_cast<StandardPLPanel *>(rightPanel), removeItem(int) );
+
+    connect( selector, SIGNAL(activated( int )),
+             this, SIGNAL( rootChanged( int ) ) );
+    emit rootChanged( p_root->i_id );
+
     QHBoxLayout *layout = new QHBoxLayout(this);
     layout->addLayout( left, 0 );
     layout->addWidget( rightPanel, 10 );
     setLayout( layout );
 }
 
+void PlaylistWidget::setArt( QString url )
+{
+    if( url.isNull() )
+        art->setPixmap( QPixmap( ":/noart.png" ) );
+    else if( prevArt != url )
+        art->setPixmap( QPixmap( url ) );
+    prevArt = url;
+}
+
 PlaylistWidget::~PlaylistWidget()
 {
 }
 
 QSize PlaylistWidget::sizeHint() const
 {
-    fprintf( stderr, "PL Size %ix%i\n", widgetSize.width(), widgetSize.height() );
     return widgetSize;
 }