]> git.sesse.net Git - vlc/blobdiff - modules/gui/qt4/components/controller.hpp
Qt, controller: put all buttons in QHBoxLayouts
[vlc] / modules / gui / qt4 / components / controller.hpp
index 21b6d307cbbedbfa151ae4b860bf52583e7fa6ef..0edb09d5ad989a8f3ceb69d6c5e23802efd43a43 100644 (file)
@@ -1,12 +1,10 @@
 /*****************************************************************************
- * interface_widgets.hpp : Custom widgets for the main interface
+ * Controller.hpp : Controller for the main interface
  ****************************************************************************
- * Copyright (C) 2006 the VideoLAN team
+ * 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>
+ * Authors: Jean-Baptiste Kempf <jb@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
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  *****************************************************************************/
 
-#ifndef _CONTROLLER_H_
-#define _CONTROLLER_H_
+#ifndef QVLC_CONTROLLER_H_
+#define QVLC_CONTROLLER_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>
+#include <QString>
 
-#define I_PLAY_TOOLTIP N_("Play\nIf the playlist is empty, open a media")
+#define MAIN_TB1_DEFAULT "64;39;64;38;65"
+#define MAIN_TB2_DEFAULT "0-2;64;3;1;4;64;7;9;64;10;20;19;64-4;37;65;35-4"
+#define ADV_TB_DEFAULT "12;11;13;14"
+#define INPT_TB_DEFAULT "5-1;15-1;33;6-1"
+#define FSC_TB_DEFAULT "0-2;64;3;1;4;64;37;64;38;64;8;65;35-4;34"
+
+#define I_PLAY_TOOLTIP N_("Play\nIf the playlist is empty, open a medium")
 
 class QPixmap;
 class QLabel;
+
 class QGridLayout;
+class QHBoxLayout;
+class QBoxLayout;
 
-class InputSlider;
 class QAbstractSlider;
-
 class QAbstractButton;
+class SeekSlider;
+class QToolButton;
 
 class VolumeClickHandler;
-class QSignalMapper;
+class WidgetListing;
 
+class QSignalMapper;
 class QTimer;
-class WidgetListing;
 
 typedef enum buttonType_e
 {
@@ -76,12 +77,19 @@ typedef enum buttonType_e
     ATOB_BUTTON,
     FRAME_BUTTON,
     REVERSE_BUTTON,
+    SKIP_BACK_BUTTON,
+    SKIP_FW_BUTTON,
+    QUIT_BUTTON,
+    RANDOM_BUTTON,
+    LOOP_BUTTON,
+    INFO_BUTTON,
     BUTTON_MAX,
 
     SPLITTER = 0x20,
     INPUT_SLIDER,
-    VOLUME,
     TIME_LABEL,
+    VOLUME,
+    VOLUME_SPECIAL,
     MENU_BUTTONS,
     TELETEXT_BUTTONS,
     ADVANCED_CONTROLLER,
@@ -92,42 +100,31 @@ typedef enum buttonType_e
     WIDGET_MAX,
 } buttonType_e;
 
-#include <QString>
 
-static const QString nameL[BUTTON_MAX] = { "Play", "Stop", "Open",
-    "Previous", "Next", "Slower", "Faster", "Fullscreen", "De-Fullscreen",
-    "Extended panel", "Playlist", "Snapshot", "Record", "A->B Loop",
-    "Frame By Frame", "Reverse" };
-static const QString tooltipL[BUTTON_MAX] = { I_PLAY_TOOLTIP,
-    _("Stop playback"),
-    _("Previous media in the playlist"),
-    _("Next media in the playlist"), _("Slower"), _("Faster"),
-    _("Toggle the video in fullscreen"), _("Toggle the video out fullscreen"),
-    _("Show extended settings" ), _( "Show playlist" ), _( "Take a snapshot" ),
-    _( "Record" ), _( "Loop from point A to point B continuously." ),
-    _("Frame by frame"), _("Reverse") };
-static const QString iconL[BUTTON_MAX] ={ ":/play_b", ":/stop_b", "",
-    ":/previous_b", ":/next_b", ":/slower", ":/faster", ":/fullscreen",
-    ":/defullscreen", ":/extended", ":/playlist", ":/snapshot", ":/record",
-    ":/atob_nob", ":/frame", ":/reverse" };
-
-typedef enum actionType_e
-{
-    PLAY_ACTION,
-    STOP_ACTION,
-    PREVIOUS_ACTION,
-    NEXT_ACTION,
-    SLOWER_ACTION,
-    FASTER_ACTION,
-    FULLSCREEN_ACTION,
-    EXTENDED_ACTION,
-    PLAYLIST_ACTION,
-    SNAPSHOT_ACTION,
-    RECORD_ACTION,
-    FRAME_ACTION,
-    ATOB_ACTION,
-    REVERSE_ACTION,
-} actionType_e;
+static const char* const nameL[BUTTON_MAX] = { N_("Play"), N_("Stop"), N_("Open"),
+    N_("Previous"), N_("Next"), N_("Slower"), N_("Faster"), N_("Fullscreen"),
+   N_("De-Fullscreen"), N_("Extended panel"), N_("Playlist"), N_("Snapshot"),
+   N_("Record"), N_("A->B Loop"), N_("Frame By Frame"), N_("Trickplay Reverse"),
+   N_("Step backward" ), N_("Step forward"), N_("Quit"), N_("Random"),
+   N_("Loop/Repeat mode"), N_("Information") };
+static const char* const tooltipL[BUTTON_MAX] = { I_PLAY_TOOLTIP,
+    N_("Stop playback"), N_("Open a medium"),
+    N_("Previous media in the playlist"),
+    N_("Next media in the playlist"), N_("Slower"), N_("Faster"),
+    N_("Toggle the video in fullscreen"), N_("Toggle the video out fullscreen"),
+    N_("Show extended settings" ), N_( "Show playlist" ),
+    N_( "Take a snapshot" ), N_( "Record" ),
+    N_( "Loop from point A to point B continuously." ), N_("Frame by frame"),
+    N_("Reverse"), N_("Step backward"), N_("Step forward"), N_("Quit"),
+    N_("Random"), N_("Change the loop and repeat modes"), N_("Information") };
+static const QString iconL[BUTTON_MAX] ={ ":/toolbar/play_b", ":/toolbar/stop_b",
+    ":/toolbar/eject", ":/toolbar/previous_b", ":/toolbar/next_b",
+    ":/toolbar/slower", ":/toolbar/faster", ":/toolbar/fullscreen",
+    ":/toolbar/defullscreen", ":/toolbar/extended", ":/toolbar/playlist",
+    ":/toolbar/snapshot", ":/toolbar/record", ":/toolbar/atob_nob",
+    ":/toolbar/frame", ":/toolbar/reverse", ":/toolbar/skip_back",
+    ":/toolbar/skip_fw", ":/toolbar/clear", ":/buttons/playlist/shuffle_on",
+    ":/buttons/playlist/repeat_all", ":/menu/info" };
 
 enum
 {
@@ -137,13 +134,14 @@ enum
    WIDGET_SHINY  = 0x4,
 };
 
+class AdvControlsWidget;
 class AbstractController : public QFrame
 {
     friend class WidgetListing; /* For ToolBar Edition HACKS */
 
     Q_OBJECT
 public:
-    AbstractController( intf_thread_t  *_p_i );
+    AbstractController( intf_thread_t  *_p_i, QWidget *_parent = 0 );
 
 protected:
     intf_thread_t       *p_intf;
@@ -154,7 +152,7 @@ protected:
 
     AdvControlsWidget   *advControls;
 
-    void parseAndCreate( QString config, QBoxLayout *controlLayout );
+    void parseAndCreate( const QString& config, QBoxLayout *controlLayout );
 
     virtual void createAndAddWidget( QBoxLayout *controlLayout, int i_index,
                                      buttonType_e i_type, int i_option );
@@ -162,88 +160,19 @@ protected:
     QWidget *createWidget( buttonType_e, int options = WIDGET_NORMAL );
 private:
     static void setupButton( QAbstractButton * );
-    QWidget *discFrame();
-    QWidget *telexFrame();
+    QFrame *discFrame();
+    QFrame *telexFrame();
+    void applyAttributes( QToolButton *, bool b_flat, bool b_big );
 
+    QHBoxLayout         *buttonGroupLayout;
 protected slots:
-    virtual void doAction( int );
-
-protected slots:
-    void play();
-    void stop();
-    void prev();
-    void next();
-    void fullscreen();
-    void extSettings();
-    void faster();
-    void slower();
-    void reverse();
-    void playlist();
-    void snapshot();
-    void record();
-    void frame();
-
     virtual void setStatus( int );
 
 signals:
-    void inputExists( bool ); /// This might be usefull in the IM ?
-    void inputPlaying( bool ); /// This might be usefull in the IM ?
+    void inputExists( bool ); /// This might be useful in the IM ?
+    void inputPlaying( bool ); /// This might be useful in the IM ?
     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 );
+    void inputIsTrickPlayable( bool ); /// same ?
 };
 
 /* Advanced Button Bar */
@@ -251,7 +180,7 @@ class AdvControlsWidget : public AbstractController
 {
     Q_OBJECT
 public:
-    AdvControlsWidget( intf_thread_t * );
+    AdvControlsWidget( intf_thread_t *, QWidget *_parent = 0 );
 };
 
 /* Slider Bar */
@@ -259,7 +188,7 @@ class InputControlsWidget : public AbstractController
 {
     Q_OBJECT
 public:
-    InputControlsWidget( intf_thread_t * );
+    InputControlsWidget( intf_thread_t * , QWidget *_parent = 0 );
 };
 
 /* Button Bar */
@@ -268,13 +197,13 @@ class ControlsWidget : public AbstractController
     Q_OBJECT
 public:
     /* p_intf, advanced control visible or not, blingbling or not */
-    ControlsWidget( intf_thread_t *_p_i, bool b_advControls );
-    virtual ~ControlsWidget();
+    ControlsWidget( intf_thread_t *_p_i, bool b_advControls,
+                    QWidget *_parent = 0 );
 
 protected:
     friend class MainInterface;
 
-    bool                 b_advancedVisible;
+    bool b_advancedVisible;
 
 protected slots:
     void toggleAdvanced();
@@ -283,23 +212,14 @@ signals:
     void advancedControlsToggled( bool );
 };
 
-/* on WIN32 hide() for fullscreen controller doesnt work, so it have to be
-   done by trick with setting the opacity of window */
-#ifdef WIN32
-    #define WIN32TRICK
-#endif
 
 /* to trying transparency with fullscreen controller on windows enable that */
 /* it can be enabled on-non windows systems,
    but it will be transparent only with composite manager */
-#ifndef WIN32
-    #define HAVE_TRANSPARENCY 1
-#else
-    #define HAVE_TRANSPARENCY 0
-#endif
+#define HAVE_TRANSPARENCY 1
 
 /* Default value of opacity for FS controller */
-#define DEFAULT_OPACITY 0.75
+#define DEFAULT_OPACITY 0.70
 
 /***********************************
  * Fullscreen controller
@@ -308,23 +228,25 @@ class FullscreenControllerWidget : public AbstractController
 {
     Q_OBJECT
 public:
-    FullscreenControllerWidget( intf_thread_t * );
+    FullscreenControllerWidget( intf_thread_t *, QWidget *_parent = 0  );
     virtual ~FullscreenControllerWidget();
 
     /* Vout */
-    vout_thread_t *p_vout;
-    void attachVout( vout_thread_t *p_vout );
-    void detachVout();
     void fullscreenChanged( vout_thread_t *, bool b_fs, int i_timeout );
+    void mouseChanged( vout_thread_t *, int i_mousex, int i_mousey );
 
-    int i_mouse_last_move_x;
-    int i_mouse_last_move_y;
+signals:
+    void keyPressed( QKeyEvent * );
+
+public slots:
+    void setVoutList( vout_thread_t **, int );
 
 protected:
     friend class MainInterface;
 
     virtual void mouseMoveEvent( QMouseEvent *event );
     virtual void mousePressEvent( QMouseEvent *event );
+    virtual void mouseReleaseEvent( QMouseEvent *event );
     virtual void enterEvent( QEvent *event );
     virtual void leaveEvent( QEvent *event );
     virtual void keyPressEvent( QKeyEvent *event );
@@ -332,8 +254,9 @@ protected:
 private slots:
     void showFSC();
     void planHideFSC();
-    void hideFSC();
+    void hideFSC() { hide(); }
     void slowHideFSC();
+    void centerFSC( int );
 
 private:
     virtual void customEvent( QEvent *event );
@@ -348,15 +271,17 @@ private:
     int i_mouse_last_x, i_mouse_last_y;
     bool b_mouse_over;
     int i_screennumber;
+    QRect screenRes;
 
-#ifdef WIN32TRICK
-    bool b_fscHidden;
-#endif
+    /* List of vouts currently tracked */
+    QList<vout_thread_t *> vout;
 
     /* Shared variable between FSC and VLC (protected by a lock) */
     vlc_mutex_t lock;
     bool        b_fullscreen;
     int         i_hide_timeout;  /* FSC hiding timeout, same as mouse hiding timeout */
+    int i_mouse_last_move_x;
+    int i_mouse_last_move_y;
 };
 
 #endif