]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/main_interface.cpp
Don't show unsaveable options in the preferences
[vlc] / modules / gui / qt4 / main_interface.cpp
index 8d58682f5e76c9af43a1b758fa204020a77896ff..77982c11f8a98d1f343db33ec5371420b380d379 100644 (file)
@@ -42,6 +42,8 @@
 #include <QSize>
 #include <QMenu>
 #include <QLabel>
+#include <QSlider>
+#include <QWidgetAction>
 
 #include <assert.h>
 #include <vlc_keys.h>
@@ -51,8 +53,8 @@
     #define PREF_W 410
     #define PREF_H 151
 #else
-    #define PREF_W 450
-    #define PREF_H 160
+    #define PREF_W 400
+    #define PREF_H 140
 #endif
 
 #define SET_WIDTH(i,j) i->widgetSize.setWidth(j)
@@ -94,7 +96,7 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
     /**
      *  Configuration and settings
      **/
-    settings = new QSettings( "VideoLAN", "VLC" );
+    settings = new QSettings( "vlc", "vlc-qt-interface" );
     settings->beginGroup( "MainWindow" );
 
     /* Main settings */
@@ -135,9 +137,9 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
      * TODO: do we add a label for the current Volume ?
      **/
     b_remainingTime = false;
-    timeLabel = new QLabel;
+    timeLabel = new TimeLabel;
     nameLabel = new QLabel;
-    speedLabel = new QLabel( "1.0x" );
+    speedLabel = new QLabel( "1.00x" );
     timeLabel->setFrameStyle( QFrame::Sunken | QFrame::Panel );
     speedLabel->setFrameStyle( QFrame::Sunken | QFrame::Panel );
     statusBar()->addWidget( nameLabel, 8 );
@@ -145,7 +147,7 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
     statusBar()->addPermanentWidget( timeLabel, 2 );
     speedLabel->setContextMenuPolicy ( Qt::CustomContextMenu );
     timeLabel->setContextMenuPolicy ( Qt::CustomContextMenu );
-    timeLabel->installEventFilter( this );
+    CONNECT( timeLabel, timeLabelClicked(), this, toggleTimeDisplay() );
     CONNECT( speedLabel, customContextMenuRequested( QPoint ),
              this, showSpeedMenu( QPoint ) );
     CONNECT( timeLabel, customContextMenuRequested( QPoint ),
@@ -184,9 +186,9 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
     /* It is also connected to the control->slider, see the ControlsWidget */
     CONNECT( THEMIM->getIM(), positionUpdated( float, int, int ),
              this, setDisplayPosition( float, int, int ) );
-    
+
     CONNECT( THEMIM->getIM(), rateChanged( int ), this, setRate( int ) );
-    
+
     /** Connects on nameChanged() */
     /* Naming in the controller statusbar */
     CONNECT( THEMIM->getIM(), nameChanged( QString ), this,
@@ -302,6 +304,12 @@ void MainInterface::handleMainUi( QSettings *settings )
     /* Add the controls Widget to the main Widget */
     mainLayout->addWidget( controls );
 
+    /* Create the Speed Control Widget */
+    speedControl = new SpeedControlWidget( p_intf );
+    speedControlMenu = new QMenu( this );
+    QWidgetAction *widgetAction = new QWidgetAction( this );
+    widgetAction->setDefaultWidget( speedControl );
+    speedControlMenu->addAction( widgetAction );
 
     /* Set initial size */
     resize( PREF_W, PREF_H );
@@ -397,9 +405,7 @@ void MainInterface::resizeEvent( QResizeEvent *e )
  ****************************************************************************/
 void MainInterface::showSpeedMenu( QPoint pos )
 {
-    QMenu menu( this );
-    menu.addAction( "Not Implemented Yet" );
-    menu.exec( QCursor::pos() );
+    speedControlMenu->exec( QCursor::pos() - pos + QPoint( 0, speedLabel->height() ) );
 }
 
 void MainInterface::showTimeMenu( QPoint pos )
@@ -407,7 +413,7 @@ void MainInterface::showTimeMenu( QPoint pos )
     QMenu menu( this );
     menu.addAction(  qtr("Elapsed Time") , this, SLOT( setElapsedTime() ) );
     menu.addAction(  qtr("Remaining Time") , this, SLOT( setRemainTime() ) );
-    menu.exec( QCursor::pos() );
+    menu.exec( QCursor::pos() - pos +QPoint( 0, timeLabel->height() ) );
 }
 
 /****************************************************************************
@@ -443,7 +449,7 @@ void *MainInterface::requestVideo( vout_thread_t *p_nvout, int *pi_x,
             // videoWidget->widgetSize = bgWidget->widgeTSize;
             videoWidget->widgetSize = QSize( *pi_width, *pi_height );
         }
-//        videoWidget->updateGeometry(); /// FIXME: Needed ?
+        videoWidget->updateGeometry(); // Needed for deinterlace
         need_components_update = true;
     }
     return ret;
@@ -629,7 +635,6 @@ void MainInterface::visual()
 
 void MainInterface::toggleMenus()
 {
-    msg_Dbg( p_intf, "I HAS HERE, HIDING YOUR MENUZ: \\_o<~~ coin coin" );
     TOGGLEV( controls );
     TOGGLEV( statusBar() );
     updateGeometry();
@@ -691,9 +696,10 @@ void MainInterface::setStatus( int status )
 void MainInterface::setRate( int rate )
 {
     QString str;
-    str.setNum( ( 1000/(double)rate), 'f', 2 );
+    str.setNum( ( 1000 / (double)rate), 'f', 2 );
     str.append( "x" );
     speedLabel->setText( str );
+    speedControl->updateControls( rate );
 }
 
 void MainInterface::updateOnTimer()
@@ -733,7 +739,7 @@ void MainInterface::createSystray()
     QVLCMenu::updateSystrayMenu( this, p_intf, true );
     sysTray->show();
 
-    CONNECT( sysTray, activated(  QSystemTrayIcon::ActivationReason ),
+    CONNECT( sysTray, activated( QSystemTrayIcon::ActivationReason ),
             this, handleSystrayClick( QSystemTrayIcon::ActivationReason ) );
 }
 
@@ -757,6 +763,11 @@ void MainInterface::toggleUpdateSystrayMenu()
         show();
         activateWindow();
     }
+    else if( isMinimized() )
+    {
+        showNormal();
+        activateWindow();
+    }
     else
     {
 #ifdef WIN32
@@ -814,7 +825,7 @@ void MainInterface::updateSystrayTooltipName( QString name )
     else
     {
         sysTray->setToolTip( name );
-        if( notificationEnabled )
+        if( notificationEnabled && ( isHidden() || isMinimized() ) )
         {
             sysTray->showMessage( qtr( "VLC media player" ), name,
                     QSystemTrayIcon::NoIcon, 4000 );
@@ -920,12 +931,6 @@ void MainInterface::customEvent( QEvent *event )
     }
 }
 
-bool MainInterface::eventFilter(QObject *obj, QEvent *event)
-{
-    if( (obj == timeLabel) && (event->type() == QEvent::MouseButtonPress) ) toggleTimeDisplay();
-}
-
-
 void MainInterface::keyPressEvent( QKeyEvent *e )
 {
     int i_vlck = qtEventToVLCKey( e );