]> git.sesse.net Git - vlc/commitdiff
Qt: First step of splitting the controller widgets from the controller layout code.
authorJean-Baptiste Kempf <jb@videolan.org>
Sun, 28 Dec 2008 21:24:05 +0000 (22:24 +0100)
committerJean-Baptiste Kempf <jb@videolan.org>
Tue, 30 Dec 2008 12:19:34 +0000 (13:19 +0100)
Signed-off-by: Jean-Baptiste Kempf <jb@videolan.org>
modules/gui/qt4/Modules.am
modules/gui/qt4/components/controller.cpp
modules/gui/qt4/components/controller.hpp
modules/gui/qt4/components/controller_widget.cpp [new file with mode: 0644]
modules/gui/qt4/components/controller_widget.hpp [new file with mode: 0644]
modules/gui/qt4/components/interface_widgets.hpp

index daeb2f4e29d2c2ba0aa9cc1b5872357c6a96b5b5..5e2f7c453c97c81b658eb4f00a8a5661a35ccf92 100644 (file)
@@ -42,6 +42,7 @@ nodist_SOURCES_qt4 = \
                components/open_panels.moc.cpp \
                components/interface_widgets.moc.cpp \
                components/controller.moc.cpp \
+               components/controller_widget.moc.cpp \
                components/playlist/playlist_model.moc.cpp \
                components/playlist/playlist_item.moc.cpp \
                components/playlist/playlist.moc.cpp \
@@ -206,6 +207,7 @@ SOURCES_qt4 =       qt4.cpp \
                components/open_panels.cpp \
                components/interface_widgets.cpp \
                components/controller.cpp \
+               components/controller_widget.cpp \
                components/playlist/playlist_model.cpp \
                components/playlist/playlist_item.cpp \
                components/playlist/standardpanel.cpp \
@@ -246,6 +248,7 @@ noinst_HEADERS = \
        components/open_panels.hpp \
        components/interface_widgets.hpp \
        components/controller.hpp \
+       components/controller_widget.hpp \
        components/playlist/playlist_model.hpp \
        components/playlist/playlist_item.hpp \
        components/playlist/panels.hpp \
index c66e03fd581f7269610179fb980f49f578e8c5a9..05fbf70b0ec3b5af6c000c29e5f98828e4fe4aff 100644 (file)
@@ -533,128 +533,6 @@ QWidget *AbstractController::telexFrame()
 #undef ENABLE_ON_VIDEO
 #undef ENABLE_ON_INPUT
 
-SoundWidget::SoundWidget( QWidget *_parent, intf_thread_t * _p_intf,
-                          bool b_shiny )
-                         : b_my_volume( false ), QWidget( _parent )
-{
-    p_intf = _p_intf;
-    QHBoxLayout *layout = new QHBoxLayout( this );
-    layout->setSpacing( 0 ); layout->setMargin( 0 );
-    hVolLabel = new VolumeClickHandler( p_intf, this );
-
-    volMuteLabel = new QLabel;
-    volMuteLabel->setPixmap( QPixmap( ":/volume-medium" ) );
-    volMuteLabel->installEventFilter( hVolLabel );
-    layout->addWidget( volMuteLabel );
-
-    if( b_shiny )
-    {
-        volumeSlider = new SoundSlider( this,
-            config_GetInt( p_intf, "volume-step" ),
-            config_GetInt( p_intf, "qt-volume-complete" ),
-            config_GetPsz( p_intf, "qt-slider-colours" ) );
-    }
-    else
-    {
-        volumeSlider = new QSlider( this );
-        volumeSlider->setOrientation( Qt::Horizontal );
-    }
-    volumeSlider->setMaximumSize( QSize( 200, 40 ) );
-    volumeSlider->setMinimumSize( QSize( 85, 30 ) );
-    volumeSlider->setFocusPolicy( Qt::NoFocus );
-    layout->addWidget( volumeSlider );
-
-    /* Set the volume from the config */
-    volumeSlider->setValue( ( config_GetInt( p_intf, "volume" ) ) *
-                              VOLUME_MAX / (AOUT_VOLUME_MAX/2) );
-
-    /* Force the update at build time in order to have a muted icon if needed */
-    updateVolume( volumeSlider->value() );
-
-    /* Volume control connection */
-    CONNECT( volumeSlider, valueChanged( int ), this, updateVolume( int ) );
-    CONNECT( THEMIM, volumeChanged( void ), this, updateVolume( void ) );
-}
-
-void SoundWidget::updateVolume( int i_sliderVolume )
-{
-    if( !b_my_volume )
-    {
-        int i_res = i_sliderVolume  * (AOUT_VOLUME_MAX / 2) / VOLUME_MAX;
-        aout_VolumeSet( p_intf, i_res );
-    }
-    if( i_sliderVolume == 0 )
-    {
-        volMuteLabel->setPixmap( QPixmap(":/volume-muted" ) );
-        volMuteLabel->setToolTip( qtr( "Unmute" ) );
-        return;
-    }
-
-    if( i_sliderVolume < VOLUME_MAX / 3 )
-        volMuteLabel->setPixmap( QPixmap( ":/volume-low" ) );
-    else if( i_sliderVolume > (VOLUME_MAX * 2 / 3 ) )
-        volMuteLabel->setPixmap( QPixmap( ":/volume-high" ) );
-    else volMuteLabel->setPixmap( QPixmap( ":/volume-medium" ) );
-    volMuteLabel->setToolTip( qtr( "Mute" ) );
-}
-
-void SoundWidget::updateVolume()
-{
-    /* Audio part */
-    audio_volume_t i_volume;
-    aout_VolumeGet( p_intf, &i_volume );
-    i_volume = ( i_volume *  VOLUME_MAX )/ (AOUT_VOLUME_MAX/2);
-    int i_gauge = volumeSlider->value();
-    b_my_volume = false;
-    if( i_volume - i_gauge > 1 || i_gauge - i_volume > 1 )
-    {
-        b_my_volume = true;
-        volumeSlider->setValue( i_volume );
-        b_my_volume = false;
-    }
-}
-
-void TeletextController::toggleTeletextTransparency( bool b_transparent )
-{
-    telexTransparent->setIcon( b_transparent ? QIcon( ":/tvtelx" )
-                                             : QIcon( ":/tvtelx-trans" ) );
-}
-
-void TeletextController::enableTeletextButtons( bool b_enabled )
-{
-    telexOn->setChecked( b_enabled );
-    telexTransparent->setEnabled( b_enabled );
-    telexPage->setEnabled( b_enabled );
-}
-
-void PlayButton::updateButton( bool b_playing )
-{
-    setIcon( b_playing ? QIcon( ":/pause_b" ) : QIcon( ":/play_b" ) );
-    setToolTip( b_playing ? qtr( "Pause the playback" )
-                          : qtr( I_PLAY_TOOLTIP ) );
-}
-
-void AtoB_Button::setIcons( bool timeA, bool timeB )
-{
-    if( !timeA && !timeB)
-    {
-        setIcon( QIcon( ":/atob_nob" ) );
-        setToolTip( qtr( "Loop from point A to point B continuously\n"
-                         "Click to set point A" ) );
-    }
-    else if( timeA && !timeB )
-    {
-        setIcon( QIcon( ":/atob_noa" ) );
-        setToolTip( qtr( "Click to set point B" ) );
-    }
-    else if( timeA && timeB )
-    {
-        setIcon( QIcon( ":/atob" ) );
-        setToolTip( qtr( "Stop the A to B loop" ) );
-    }
-}
-
-
 //* Actions */
 void AbstractController::doAction( int id_action )
 {
@@ -1342,3 +1220,4 @@ void FullscreenControllerWidget::fullscreenChanged( vout_thread_t *p_vout,
     }
     vlc_mutex_unlock( &lock );
 }
+
index 79402b28c0e99c6349bacf2ea7e48f76d20510e6..45f64d2b9f56e876ffc329527ff6e176277c8fd5 100644 (file)
@@ -1,5 +1,5 @@
 /*****************************************************************************
- * interface_widgets.hpp : Custom widgets for the main interface
+ * Controller.hpp : Controller for the main interface
  ****************************************************************************
  * Copyright (C) 2006 the VideoLAN team
  * $Id$
@@ -196,61 +196,6 @@ signals:
     void inputIsRecordable( bool ); /// same ?
 };
 
-/**
- * SPECIAL Widgets that are a bit more than just a ToolButton
- * and have an icon/behaviour that changes depending on the context:
- * - playButton
- * - A->B Button
- * - Teletext group buttons
- * - Sound Widget group
- **/
-class PlayButton : public QToolButton
-{
-    Q_OBJECT
-private slots:
-    void updateButton( bool );
-};
-
-class AtoB_Button : public QToolButton
-{
-    Q_OBJECT
-private slots:
-    void setIcons( bool, bool );
-};
-
-class TeletextController : public QWidget
-{
-    Q_OBJECT
-    friend class AbstractController;
-private:
-    QToolButton         *telexTransparent, *telexOn;
-    QSpinBox            *telexPage;
-
-private slots:
-    void enableTeletextButtons( bool );
-    void toggleTeletextTransparency( bool );
-};
-
-class SoundWidget : public QWidget
-{
-    Q_OBJECT
-    friend class VolumeClickHandler;
-
-public:
-    SoundWidget( QWidget *parent, intf_thread_t  *_p_i, bool );
-
-private:
-    intf_thread_t       *p_intf;
-    QLabel              *volMuteLabel;
-    QAbstractSlider     *volumeSlider;
-    VolumeClickHandler  *hVolLabel;
-    bool                 b_my_volume;
-
-protected slots:
-    void updateVolume( int );
-    void updateVolume( void );
-};
-
 /* Advanced Button Bar */
 class AdvControlsWidget : public AbstractController
 {
diff --git a/modules/gui/qt4/components/controller_widget.cpp b/modules/gui/qt4/components/controller_widget.cpp
new file mode 100644 (file)
index 0000000..71b99a7
--- /dev/null
@@ -0,0 +1,177 @@
+/*****************************************************************************
+ * Controller_widget.cpp : Controller Widget for the controllers
+ ****************************************************************************
+ * Copyright ( C ) 2006-2008 the VideoLAN team
+ * $Id$
+ *
+ * Authors: Clément Stenac <zorglub@videolan.org>
+ *          Jean-Baptiste Kempf <jb@videolan.org>
+ *          Rafaël Carré <funman@videolanorg>
+ *          Ilkka Ollakka <ileoo@videolan.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * ( at your option ) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+//#include <vlc_vout.h>
+//#include <vlc_keys.h>
+
+#include "controller_widget.hpp"
+
+#include "dialogs_provider.hpp"
+#include "components/interface_widgets.hpp"
+#include "main_interface.hpp"
+#include "input_manager.hpp"
+#include "menus.hpp"
+#include "util/input_slider.hpp"
+#include "util/customwidgets.hpp"
+
+#include <QLabel>
+#include <QSpacerItem>
+#include <QCursor>
+#include <QToolButton>
+#include <QHBoxLayout>
+#include <QMenu>
+#include <QPalette>
+#include <QResizeEvent>
+#include <QDate>
+#include <QSignalMapper>
+#include <QTimer>
+
+
+SoundWidget::SoundWidget( QWidget *_parent, intf_thread_t * _p_intf,
+                          bool b_shiny )
+                         : b_my_volume( false ), QWidget( _parent )
+{
+    p_intf = _p_intf;
+    QHBoxLayout *layout = new QHBoxLayout( this );
+    layout->setSpacing( 0 ); layout->setMargin( 0 );
+    hVolLabel = new VolumeClickHandler( p_intf, this );
+
+    volMuteLabel = new QLabel;
+    volMuteLabel->setPixmap( QPixmap( ":/volume-medium" ) );
+    volMuteLabel->installEventFilter( hVolLabel );
+    layout->addWidget( volMuteLabel );
+
+    if( b_shiny )
+    {
+        volumeSlider = new SoundSlider( this,
+            config_GetInt( p_intf, "volume-step" ),
+            config_GetInt( p_intf, "qt-volume-complete" ),
+            config_GetPsz( p_intf, "qt-slider-colours" ) );
+    }
+    else
+    {
+        volumeSlider = new QSlider( this );
+        volumeSlider->setOrientation( Qt::Horizontal );
+    }
+    volumeSlider->setMaximumSize( QSize( 200, 40 ) );
+    volumeSlider->setMinimumSize( QSize( 85, 30 ) );
+    volumeSlider->setFocusPolicy( Qt::NoFocus );
+    layout->addWidget( volumeSlider );
+
+    /* Set the volume from the config */
+    volumeSlider->setValue( ( config_GetInt( p_intf, "volume" ) ) *
+                              VOLUME_MAX / (AOUT_VOLUME_MAX/2) );
+
+    /* Force the update at build time in order to have a muted icon if needed */
+    updateVolume( volumeSlider->value() );
+
+    /* Volume control connection */
+    CONNECT( volumeSlider, valueChanged( int ), this, updateVolume( int ) );
+    CONNECT( THEMIM, volumeChanged( void ), this, updateVolume( void ) );
+}
+
+void SoundWidget::updateVolume( int i_sliderVolume )
+{
+    if( !b_my_volume )
+    {
+        int i_res = i_sliderVolume  * (AOUT_VOLUME_MAX / 2) / VOLUME_MAX;
+        aout_VolumeSet( p_intf, i_res );
+    }
+    if( i_sliderVolume == 0 )
+    {
+        volMuteLabel->setPixmap( QPixmap(":/volume-muted" ) );
+        volMuteLabel->setToolTip( qtr( "Unmute" ) );
+        return;
+    }
+
+    if( i_sliderVolume < VOLUME_MAX / 3 )
+        volMuteLabel->setPixmap( QPixmap( ":/volume-low" ) );
+    else if( i_sliderVolume > (VOLUME_MAX * 2 / 3 ) )
+        volMuteLabel->setPixmap( QPixmap( ":/volume-high" ) );
+    else volMuteLabel->setPixmap( QPixmap( ":/volume-medium" ) );
+    volMuteLabel->setToolTip( qtr( "Mute" ) );
+}
+
+void SoundWidget::updateVolume()
+{
+    /* Audio part */
+    audio_volume_t i_volume;
+    aout_VolumeGet( p_intf, &i_volume );
+    i_volume = ( i_volume *  VOLUME_MAX )/ (AOUT_VOLUME_MAX/2);
+    int i_gauge = volumeSlider->value();
+    b_my_volume = false;
+    if( i_volume - i_gauge > 1 || i_gauge - i_volume > 1 )
+    {
+        b_my_volume = true;
+        volumeSlider->setValue( i_volume );
+        b_my_volume = false;
+    }
+}
+
+void TeletextController::toggleTeletextTransparency( bool b_transparent )
+{
+    telexTransparent->setIcon( b_transparent ? QIcon( ":/tvtelx" )
+                                             : QIcon( ":/tvtelx-trans" ) );
+}
+
+void TeletextController::enableTeletextButtons( bool b_enabled )
+{
+    telexOn->setChecked( b_enabled );
+    telexTransparent->setEnabled( b_enabled );
+    telexPage->setEnabled( b_enabled );
+}
+
+void PlayButton::updateButton( bool b_playing )
+{
+    setIcon( b_playing ? QIcon( ":/pause_b" ) : QIcon( ":/play_b" ) );
+    setToolTip( b_playing ? qtr( "Pause the playback" )
+                          : qtr( I_PLAY_TOOLTIP ) );
+}
+
+void AtoB_Button::setIcons( bool timeA, bool timeB )
+{
+    if( !timeA && !timeB)
+    {
+        setIcon( QIcon( ":/atob_nob" ) );
+        setToolTip( qtr( "Loop from point A to point B continuously\n"
+                         "Click to set point A" ) );
+    }
+    else if( timeA && !timeB )
+    {
+        setIcon( QIcon( ":/atob_noa" ) );
+        setToolTip( qtr( "Click to set point B" ) );
+    }
+    else if( timeA && timeB )
+    {
+        setIcon( QIcon( ":/atob" ) );
+        setToolTip( qtr( "Stop the A to B loop" ) );
+    }
+}
+
diff --git a/modules/gui/qt4/components/controller_widget.hpp b/modules/gui/qt4/components/controller_widget.hpp
new file mode 100644 (file)
index 0000000..8089a43
--- /dev/null
@@ -0,0 +1,116 @@
+/*****************************************************************************
+ * interface_widgets.hpp : Custom widgets for the main interface
+ ****************************************************************************
+ * Copyright (C) 2006 the VideoLAN team
+ * $Id$
+ *
+ * Authors: Clément Stenac <zorglub@videolan.org>
+ *          Jean-Baptiste Kempf <jb@videolan.org>
+ *          Rafaël Carré <funman@videolanorg>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#ifndef _CONTROLLER_WIDGET_H_
+#define _CONTROLLER_WIDGET_H_
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <vlc_common.h>
+#include <vlc_interface.h>
+
+#include "qt4.hpp"
+#include "main_interface.hpp"
+#include "input_manager.hpp"
+
+#include <QWidget>
+#include <QFrame>
+#include <QToolButton>
+
+#define I_PLAY_TOOLTIP N_("Play\nIf the playlist is empty, open a media")
+
+class QPixmap;
+class QLabel;
+class QGridLayout;
+
+class InputSlider;
+class QAbstractSlider;
+
+class QAbstractButton;
+
+class VolumeClickHandler;
+class QSignalMapper;
+
+class QTimer;
+class WidgetListing;
+
+/**
+ * SPECIAL Widgets that are a bit more than just a ToolButton
+ * and have an icon/behaviour that changes depending on the context:
+ * - playButton
+ * - A->B Button
+ * - Teletext group buttons
+ * - Sound Widget group
+ **/
+class PlayButton : public QToolButton
+{
+    Q_OBJECT
+private slots:
+    void updateButton( bool );
+};
+
+class AtoB_Button : public QToolButton
+{
+    Q_OBJECT
+private slots:
+    void setIcons( bool, bool );
+};
+
+class TeletextController : public QWidget
+{
+    Q_OBJECT
+    friend class AbstractController;
+private:
+    QToolButton         *telexTransparent, *telexOn;
+    QSpinBox            *telexPage;
+
+private slots:
+    void enableTeletextButtons( bool );
+    void toggleTeletextTransparency( bool );
+};
+
+class SoundWidget : public QWidget
+{
+    Q_OBJECT
+    friend class VolumeClickHandler;
+
+public:
+    SoundWidget( QWidget *parent, intf_thread_t  *_p_i, bool );
+
+private:
+    intf_thread_t       *p_intf;
+    QLabel              *volMuteLabel;
+    QAbstractSlider     *volumeSlider;
+    VolumeClickHandler  *hVolLabel;
+    bool                 b_my_volume;
+
+protected slots:
+    void updateVolume( int );
+    void updateVolume( void );
+};
+
+#endif
index 99a2eb1f2aaf2d997a9891561a2da7e411439437..9ef35877037d232557044ce63f9912f0b6cbe532 100644 (file)
@@ -37,6 +37,7 @@
 #include "qt4.hpp"
 #include "main_interface.hpp"
 #include "components/controller.hpp"
+#include "components/controller_widget.hpp"
 
 #include <QWidget>
 #include <QFrame>