]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/components/controller.cpp
Qt4: DVB-T and DVB-C should be in Hz on Windows.
[vlc] / modules / gui / qt4 / components / controller.cpp
index 3cb2d23b96d6f9186edb7f19af8836417506daf3..af1da21c16c43c663f5e27d0660b4bed3f036203 100644 (file)
@@ -79,6 +79,9 @@ void AbstractController::setStatus( int status )
 
     emit inputIsRecordable( b_hasInput &&
                             var_GetBool( THEMIM->getInput(), "can-record" ) );
+
+    emit inputIsTrickPlayable( b_hasInput &&
+                            var_GetBool( THEMIM->getInput(), "can-rewind" ) );
 }
 
 /* Generic button setup */
@@ -96,7 +99,7 @@ void AbstractController::setupButton( QAbstractButton *aButton )
 
 /* Open the generic config line for the toolbar, parse it
  * and create the widgets accordingly */
-void AbstractController::parseAndCreate( QString config,
+void AbstractController::parseAndCreate( const QString& config,
                                          QBoxLayout *controlLayout )
 {
     QStringList list = config.split( ";", QString::SkipEmptyParts ) ;
@@ -163,7 +166,7 @@ void AbstractController::createAndAddWidget( QBoxLayout *controlLayout,
     CONNECT_MAP( a ); \
     SET_MAPPING( a, b );
 #define BUTTON_SET_BAR( a_button ) \
-    a_button->setToolTip( tooltipL[button] );          \
+    a_button->setToolTip( qtr( tooltipL[button] ) ); \
     a_button->setIcon( QIcon( iconL[button] ) );
 #define BUTTON_SET_BAR2( button, image, tooltip ) \
     button->setToolTip( tooltip );          \
@@ -317,6 +320,7 @@ QWidget *AbstractController::createWidget( buttonType_e button, int options )
     case ATOB_BUTTON: {
         AtoB_Button *ABButton = new AtoB_Button;
         setupButton( ABButton );
+        ABButton->setShortcut( qtr("Shift+L") );
         BUTTON_SET_BAR( ABButton );
         ENABLE_ON_INPUT( ABButton );
         CONNECT_MAP_SET( ABButton, ATOB_ACTION );
@@ -383,7 +387,7 @@ QWidget *AbstractController::createWidget( buttonType_e button, int options )
         reverseButton->setCheckable( true );
         /* You should, of COURSE change this to the correct event,
            when/if we have one, that tells us if trickplay is possible . */
-        CONNECT( this, inputExists( bool ), reverseButton, setVisible( bool ) );
+        CONNECT( this, inputIsTrickPlayable( bool ), reverseButton, setVisible( bool ) );
         reverseButton->setVisible( false );
         widget = reverseButton;
         }
@@ -422,21 +426,37 @@ QWidget *AbstractController::createWidget( buttonType_e button, int options )
     /* Customize Buttons */
     if( b_flat || b_big )
     {
-        QToolButton *tmpButton = qobject_cast<QToolButton *>(widget);
-        if( tmpButton )
+        QFrame *frame = qobject_cast<QFrame *>(widget);
+        if( frame )
         {
-            if( b_flat )
-                tmpButton->setAutoRaise( b_flat );
-            if( b_big )
-            {
-                tmpButton->setFixedSize( QSize( 32, 32 ) );
-                tmpButton->setIconSize( QSize( 26, 26 ) );
-            }
+            QList<QToolButton *> allTButtons = frame->findChildren<QToolButton *>();
+            for( int i = 0; i < allTButtons.size(); i++ )
+                applyAttributes( allTButtons[i], b_flat, b_big );
+        }
+        else
+        {
+            QToolButton *tmpButton = qobject_cast<QToolButton *>(widget);
+            if( tmpButton )
+                applyAttributes( tmpButton, b_flat, b_big );
         }
     }
     return widget;
 }
 
+void AbstractController::applyAttributes( QToolButton *tmpButton, bool b_flat, bool b_big )
+{
+    if( tmpButton )
+    {
+        if( b_flat )
+            tmpButton->setAutoRaise( b_flat );
+        if( b_big )
+        {
+            tmpButton->setFixedSize( QSize( 32, 32 ) );
+            tmpButton->setIconSize( QSize( 26, 26 ) );
+        }
+    }
+}
+
 QFrame *AbstractController::discFrame()
 {
     /** Disc and Menus handling */
@@ -475,6 +495,8 @@ QFrame *AbstractController::discFrame()
             sectionNext() );
     CONNECT( menuButton, clicked(), THEMIM->getIM(),
             sectionMenu() );
+    connect( THEMIM->getIM(), SIGNAL( titleChanged( bool ) ),
+             this, SIGNAL( sizeChanged() ) );
 
     return discFrame;
 }
@@ -489,6 +511,8 @@ QFrame *AbstractController::telexFrame()
     telexLayout->setSpacing( 0 ); telexLayout->setMargin( 0 );
     CONNECT( THEMIM->getIM(), teletextPossible( bool ),
              telexFrame, setVisible( bool ) );
+    connect( THEMIM->getIM(), SIGNAL( teletextPossible( bool ) ),
+             this, SIGNAL( sizeChanged() ) );
 
     /* On/Off button */
     QToolButton *telexOn = new QToolButton;
@@ -657,7 +681,7 @@ FullscreenControllerWidget::FullscreenControllerWidget( intf_thread_t *_p_i )
     setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum );
 
     QVBoxLayout *controlLayout2 = new QVBoxLayout( this );
-    controlLayout2->setLayoutMargins( 5, 2, 5, 2, 5 );
+    controlLayout2->setLayoutMargins( 4, 6, 4, 2, 5 );
 
     /* First line */
     InputControlsWidget *inputC = new InputControlsWidget( p_intf, this );
@@ -690,7 +714,23 @@ FullscreenControllerWidget::FullscreenControllerWidget( intf_thread_t *_p_i )
 
     vlc_mutex_init_recursive( &lock );
 
-    CONNECT( THEMIM->getIM(), voutListChanged( vout_thread_t **, int ), this, setVoutList( vout_thread_t **, int ) );
+    CONNECT( THEMIM->getIM(), voutListChanged( vout_thread_t **, int ),
+             this, setVoutList( vout_thread_t **, int ) );
+
+    /* First Move */
+    QPoint pos1 = getSettings()->value( "FullScreen/pos" ).toPoint();
+    int number = QApplication::desktop()->screenNumber( p_intf->p_sys->p_mi );
+    if( QApplication::desktop()->screenGeometry( number ).contains( pos1, true ) )
+    {
+        move( pos1 );
+        i_screennumber = number;
+        screenRes = QApplication::desktop()->screenGeometry(number);
+    }
+    else
+    {
+        centerFSC( number );
+    }
+
 }
 
 FullscreenControllerWidget::~FullscreenControllerWidget()
@@ -700,24 +740,29 @@ FullscreenControllerWidget::~FullscreenControllerWidget()
     vlc_mutex_destroy( &lock );
 }
 
+void FullscreenControllerWidget::centerFSC( int number )
+{
+    screenRes = QApplication::desktop()->screenGeometry(number);
+    /* screen has changed, calculate new position */
+    QPoint pos = QPoint( screenRes.x() + (screenRes.width() / 2) - (width() / 2),
+            screenRes.y() + screenRes.height() - height());
+    move( pos );
+    i_screennumber = number;
+}
+
 /**
  * Show fullscreen controller
  */
 void FullscreenControllerWidget::showFSC()
 {
     adjustSize();
-    /* center down */
+
     int number = QApplication::desktop()->screenNumber( p_intf->p_sys->p_mi );
+
     if( number != i_screennumber ||
         screenRes != QApplication::desktop()->screenGeometry(number) )
     {
-        screenRes = QApplication::desktop()->screenGeometry(number);
-        msg_Dbg( p_intf, "Calculation fullscreen controllers center");
-        /* screen has changed, calculate new position */
-        QPoint pos = QPoint( screenRes.x() + (screenRes.width() / 2) - (width() / 2),
-                             screenRes.y() + screenRes.height() - height());
-        move( pos );
-        i_screennumber = number;
+        centerFSC( number );
     }
 #ifdef WIN32TRICK
     // after quiting and going to fs, we need to call show()
@@ -865,8 +910,11 @@ void FullscreenControllerWidget::customEvent( QEvent *event )
  */
 void FullscreenControllerWidget::mouseMoveEvent( QMouseEvent *event )
 {
-    if ( event->buttons() == Qt::LeftButton )
+    if( event->buttons() == Qt::LeftButton )
     {
+        if( i_mouse_last_x == -1 || i_mouse_last_y == -1 )
+            return;
+
         int i_moveX = event->globalX() - i_mouse_last_x;
         int i_moveY = event->globalY() - i_mouse_last_y;
 
@@ -887,6 +935,12 @@ void FullscreenControllerWidget::mousePressEvent( QMouseEvent *event )
     i_mouse_last_y = event->globalY();
 }
 
+void FullscreenControllerWidget::mouseReleaseEvent( QMouseEvent *event )
+{
+    i_mouse_last_x = -1;
+    i_mouse_last_y = -1;
+}
+
 /**
  * On mouse go above FSC
  */
@@ -991,6 +1045,8 @@ void FullscreenControllerWidget::setVoutList( vout_thread_t **pp_vout, int i_vou
         fullscreenChanged( p_vout, false, 0 );
         vout.removeAll( p_vout );
         vlc_mutex_unlock( &lock );
+
+        vlc_object_release( VLC_OBJECT(p_vout) );
     }
 
     /* Vout to track */
@@ -1004,7 +1060,7 @@ void FullscreenControllerWidget::setVoutList( vout_thread_t **pp_vout, int i_vou
 
     foreach( vout_thread_t *p_vout, add )
     {
-        vlc_object_hold( (vlc_object_t*)p_vout );
+        vlc_object_hold( VLC_OBJECT(p_vout) );
 
         vlc_mutex_lock( &lock );
         vout.append( p_vout );
@@ -1048,6 +1104,7 @@ void FullscreenControllerWidget::fullscreenChanged( vout_thread_t *p_vout,
     }
     vlc_mutex_unlock( &lock );
 }
+
 /**
  * Mouse change callback (show/hide the controller on mouse movement)
  */