Commit f3c5b0ad authored by Jean-Baptiste Kempf's avatar Jean-Baptiste Kempf

Qt4 : Changes in the main interface:

 - Don't use the .ui, do all by hand :)
 - Use a ControlWidgets to design all the controls, and implement the functions
 - Change a bit the advanced widget, that must be integrated in the
   controlsWidget
There is a lot of Not Yet Implemented, so feel free to add some.
parent 489efb13
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
* $Id$ * $Id$
* *
* Authors: Clément Stenac <zorglub@videolan.org> * Authors: Clément Stenac <zorglub@videolan.org>
* Jean-Baptiste Kempf <jb@videolan.org>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
...@@ -27,6 +28,7 @@ ...@@ -27,6 +28,7 @@
#include <vlc/vlc.h> #include <vlc/vlc.h>
#include <vlc_interface.h> #include <vlc_interface.h>
#include <vlc_aout.h>
#include "qt4.hpp" #include "qt4.hpp"
#include <QWidget> #include <QWidget>
...@@ -98,12 +100,12 @@ private slots: ...@@ -98,12 +100,12 @@ private slots:
}; };
class QPushButton; class QPushButton;
class ControlsWidget : public QFrame class AdvControlsWidget : public QFrame
{ {
Q_OBJECT Q_OBJECT
public: public:
ControlsWidget( intf_thread_t *); AdvControlsWidget( intf_thread_t *);
virtual ~ControlsWidget(); virtual ~AdvControlsWidget();
void enableInput( bool ); void enableInput( bool );
void enableVideo( bool ); void enableVideo( bool );
private: private:
...@@ -118,6 +120,64 @@ private slots: ...@@ -118,6 +120,64 @@ private slots:
void fullscreen(); void fullscreen();
}; };
class InputSlider;
class QSlider;
class QGridLayout;
class VolumeClickHandler;
class ControlsWidget : public QFrame
{
Q_OBJECT
public:
ControlsWidget( intf_thread_t *);
virtual ~ControlsWidget();
QPushButton *playlistButton;
QSlider *volumeSlider;
void setStatus( int );
public slots:
void setNavigation( int );
void updateOnTimer();
protected:
friend class MainInterface;
friend class VolumeClickHandler;
private:
intf_thread_t *p_intf;
QFrame *discFrame;
QGridLayout *controlLayout;
InputSlider *slider;
QPushButton *prevSectionButton, *nextSectionButton, *menuButton;
QPushButton *playButton;
private slots:
void play();
void stop();
void prev();
void next();
void updateVolume( int );
void fullscreen();
void extSettings();
void prefs();
};
class VolumeClickHandler : public QObject
{
public:
VolumeClickHandler( intf_thread_t *_p_intf, ControlsWidget *_m ) :QObject(_m)
{m = _m; p_intf = _p_intf; }
virtual ~VolumeClickHandler() {};
bool eventFilter( QObject *obj, QEvent *e )
{
if (e->type() == QEvent::MouseButtonPress )
{
aout_VolumeMute( p_intf, NULL );
return true;
}
return false;
}
private:
ControlsWidget *m;
intf_thread_t *p_intf;
};
/******************** Playlist Widgets ****************/ /******************** Playlist Widgets ****************/
#include <QModelIndex> #include <QModelIndex>
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
* $Id$ * $Id$
* *
* Authors: Clément Stenac <zorglub@videolan.org> * Authors: Clément Stenac <zorglub@videolan.org>
* Jean-Baptiste Kempf <jb@videolan.org>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
...@@ -24,7 +25,6 @@ ...@@ -24,7 +25,6 @@
#include "qt4.hpp" #include "qt4.hpp"
#include "main_interface.hpp" #include "main_interface.hpp"
#include "input_manager.hpp" #include "input_manager.hpp"
#include "util/input_slider.hpp"
#include "util/qvlcframe.hpp" #include "util/qvlcframe.hpp"
#include "util/customwidgets.hpp" #include "util/customwidgets.hpp"
#include "dialogs_provider.hpp" #include "dialogs_provider.hpp"
...@@ -152,6 +152,7 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ) ...@@ -152,6 +152,7 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
this, showSpeedMenu( QPoint ) ); this, showSpeedMenu( QPoint ) );
CONNECT( timeLabel, customContextMenuRequested( QPoint ), CONNECT( timeLabel, customContextMenuRequested( QPoint ),
this, showTimeMenu( QPoint ) ); this, showTimeMenu( QPoint ) );
/* Systray */ /* Systray */
sysTray = NULL; sysTray = NULL;
if( config_GetInt( p_intf, "qt-start-minimized") ) if( config_GetInt( p_intf, "qt-start-minimized") )
...@@ -172,12 +173,8 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ) ...@@ -172,12 +173,8 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
* CONNECTs * CONNECTs
**/ **/
/* Volume control */
CONNECT( ui.volumeSlider, valueChanged(int), this, updateVolume(int) );
/* Connect the input manager to the GUI elements it manages */ /* Connect the input manager to the GUI elements it manages */
CONNECT( THEMIM->getIM(), positionUpdated( float, int, int ), /* It is also connected to the control->slider */
slider, setPosition( float,int, int ) );
CONNECT( THEMIM->getIM(), positionUpdated( float, int, int ), CONNECT( THEMIM->getIM(), positionUpdated( float, int, int ),
this, setDisplay( float, int, int ) ); this, setDisplay( float, int, int ) );
...@@ -197,23 +194,11 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf ) ...@@ -197,23 +194,11 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
/* PLAY_STATUS */ /* PLAY_STATUS */
CONNECT( THEMIM->getIM(), statusChanged( int ), this, setStatus( int ) ); CONNECT( THEMIM->getIM(), statusChanged( int ), this, setStatus( int ) );
CONNECT( THEMIM->getIM(), navigationChanged( int ),
this, setNavigation(int) );
if( config_GetInt( p_intf, "qt-system-tray" ) && sysTray ) if( config_GetInt( p_intf, "qt-system-tray" ) && sysTray )
{ {
CONNECT( THEMIM->getIM(), statusChanged( int ), this, CONNECT( THEMIM->getIM(), statusChanged( int ), this,
updateSystrayTooltipStatus( int ) ); updateSystrayTooltipStatus( int ) );
} }
CONNECT( slider, sliderDragged( float ),
THEMIM->getIM(), sliderUpdate( float ) );
/* Buttons */
CONNECT( ui.prevSectionButton, clicked(), THEMIM->getIM(),
sectionPrev() );
CONNECT( ui.nextSectionButton, clicked(), THEMIM->getIM(),
sectionNext() );
CONNECT( ui.menuButton, clicked(), THEMIM->getIM(),
sectionMenu() );
/** /**
* Callbacks * Callbacks
...@@ -281,7 +266,7 @@ void MainInterface::setVLCWindowsTitle( QString aTitle ) ...@@ -281,7 +266,7 @@ void MainInterface::setVLCWindowsTitle( QString aTitle )
void MainInterface::handleMainUi( QSettings *settings ) void MainInterface::handleMainUi( QSettings *settings )
{ {
QWidget *main = new QWidget( this ); QWidget *main = new QWidget( this );
QVBoxLayout *mainLayout = new QVBoxLayout( main ); mainLayout = new QVBoxLayout( main );
setCentralWidget( main ); setCentralWidget( main );
/* Margins, spacing */ /* Margins, spacing */
...@@ -289,36 +274,13 @@ void MainInterface::handleMainUi( QSettings *settings ) ...@@ -289,36 +274,13 @@ void MainInterface::handleMainUi( QSettings *settings )
mainLayout->setMargin( 0 ); mainLayout->setMargin( 0 );
/* CONTROLS */ /* CONTROLS */
QWidget *controls = new QWidget; controls = new ControlsWidget( p_intf );
ui.setupUi( controls );
/* Configure the UI */ /* Configure the UI */
slider = new InputSlider( Qt::Horizontal, NULL ); BUTTON_SET_IMG( controls->playlistButton, "" , playlist_icon.png,
mainLayout->insertWidget( 0, slider );
ui.discFrame->hide();
BUTTON_SET_IMG( ui.prevSectionButton, "", previous.png, "" );
BUTTON_SET_IMG( ui.nextSectionButton, "", next.png, "" );
BUTTON_SET_IMG( ui.menuButton, "", previous.png, "" );
BUTTON_SET_ACT_I( ui.prevButton, "" , previous.png,
qtr("Previous"), prev() );
BUTTON_SET_ACT_I( ui.nextButton, "", next.png, qtr("Next"), next() );
BUTTON_SET_ACT_I( ui.playButton, "", play.png, qtr("Play"), play() );
BUTTON_SET_ACT_I( ui.stopButton, "", stop.png, qtr("Stop"), stop() );
/* Volume */
ui.volMuteLabel->setPixmap( QPixmap( ":/pixmaps/volume-low.png" ) );
ui.volumeSlider->setMaximum( 100 );
ui.volMuteLabel->setToolTip( qtr( "Mute" ) );
VolumeClickHandler *h = new VolumeClickHandler( p_intf, this );
ui.volMuteLabel->installEventFilter(h);
ui.volumeSlider->setFocusPolicy( Qt::NoFocus );
BUTTON_SET_IMG( ui.playlistButton, "" , playlist_icon.png,
playlistEmbeddedFlag ? qtr( "Show playlist" ) : playlistEmbeddedFlag ? qtr( "Show playlist" ) :
qtr( "Open playlist" ) ); qtr( "Open playlist" ) );
BUTTONACT( ui.playlistButton, playlist() ); BUTTONACT( controls->playlistButton, playlist() );
#if DEBUG_COLOR #if DEBUG_COLOR
QPalette palette; QPalette palette;
...@@ -335,7 +297,7 @@ void MainInterface::handleMainUi( QSettings *settings ) ...@@ -335,7 +297,7 @@ void MainInterface::handleMainUi( QSettings *settings )
addSize = QSize( mainLayout->margin() * 2, PREF_H ); addSize = QSize( mainLayout->margin() * 2, PREF_H );
/* advanced Controls handling */ /* advanced Controls handling */
advControls = new ControlsWidget( p_intf ); advControls = new AdvControlsWidget( p_intf );
mainLayout->insertWidget( 0, advControls ); mainLayout->insertWidget( 0, advControls );
advControls->updateGeometry(); advControls->updateGeometry();
if( !advControlsEnabled ) advControls->hide(); if( !advControlsEnabled ) advControls->hide();
...@@ -731,7 +693,7 @@ void MainInterface::playlist() ...@@ -731,7 +693,7 @@ void MainInterface::playlist()
{ {
PlaylistDialog::killInstance(); PlaylistDialog::killInstance();
playlistWidget = new PlaylistWidget( p_intf ); playlistWidget = new PlaylistWidget( p_intf );
ui.vboxLayout->insertWidget( 0, playlistWidget ); mainLayout->insertWidget( 0, playlistWidget );
playlistWidget->widgetSize = settings->value( "playlistSize", playlistWidget->widgetSize = settings->value( "playlistSize",
QSize( 650, 310 ) ).toSize(); QSize( 650, 310 ) ).toSize();
playlistWidget->hide(); playlistWidget->hide();
...@@ -779,7 +741,7 @@ void MainInterface::undockPlaylist() ...@@ -779,7 +741,7 @@ void MainInterface::undockPlaylist()
{ {
playlistWidget->hide(); playlistWidget->hide();
playlistWidget->deleteLater(); playlistWidget->deleteLater();
ui.vboxLayout->removeWidget( playlistWidget ); mainLayout->removeWidget( playlistWidget );
playlistWidget = NULL; playlistWidget = NULL;
playlistEmbeddedFlag = false; playlistEmbeddedFlag = false;
...@@ -897,33 +859,6 @@ void MainInterface::wheelEvent( QWheelEvent *e ) ...@@ -897,33 +859,6 @@ void MainInterface::wheelEvent( QWheelEvent *e )
e->accept(); e->accept();
} }
void MainInterface::stop()
{
THEMIM->stop();
}
void MainInterface::play()
{
if( playlist_IsEmpty(THEPL) )
{
/* The playlist is empty, open a file requester */
THEDP->openFileDialog();
setStatus( 0 );
return;
}
THEMIM->togglePlayPause();
}
void MainInterface::prev()
{
THEMIM->prev();
}
void MainInterface::next()
{
THEMIM->next();
}
void MainInterface::setDisplay( float pos, int time, int length ) void MainInterface::setDisplay( float pos, int time, int length )
{ {
char psz_length[MSTRTIME_MAX_SIZE], psz_time[MSTRTIME_MAX_SIZE]; char psz_length[MSTRTIME_MAX_SIZE], psz_time[MSTRTIME_MAX_SIZE];
...@@ -942,48 +877,15 @@ void MainInterface::setName( QString name ) ...@@ -942,48 +877,15 @@ void MainInterface::setName( QString name )
void MainInterface::setStatus( int status ) void MainInterface::setStatus( int status )
{ {
if( status == 1 ) // Playing controls->setStatus( status );
ui.playButton->setIcon( QIcon( ":/pixmaps/pause.png" ) );
else
ui.playButton->setIcon( QIcon( ":/pixmaps/play.png" ) );
if( systrayMenu ) if( systrayMenu )
updateSystrayMenu( status ); updateSystrayMenu( status );
} }
#define HELP_MENU N_("Menu")
#define HELP_PCH N_("Previous chapter")
#define HELP_NCH N_("Next chapter")
#define HELP_PTR N_("Previous track")
#define HELP_NTR N_("Next track")
void MainInterface::setNavigation( int navigation )
{
// 1 = chapter, 2 = title, 0 = no
if( navigation == 0 )
{
ui.discFrame->hide();
} else if( navigation == 1 ) {
ui.prevSectionButton->show();
ui.prevSectionButton->setToolTip( qfu(HELP_PCH) );
ui.nextSectionButton->show();
ui.nextSectionButton->setToolTip( qfu(HELP_NCH) );
ui.menuButton->show();
ui.discFrame->show();
} else {
ui.prevSectionButton->show();
ui.prevSectionButton->setToolTip( qfu(HELP_PCH) );
ui.nextSectionButton->show();
ui.nextSectionButton->setToolTip( qfu(HELP_NCH) );
ui.menuButton->hide();
ui.discFrame->show();
}
}
static bool b_my_volume;
void MainInterface::updateOnTimer() void MainInterface::updateOnTimer()
{ {
/* \todo Make this event-driven */ /* \todo Make this event-driven */
// TO MOVE TO controls
advControls->enableInput( THEMIM->getIM()->hasInput() ); advControls->enableInput( THEMIM->getIM()->hasInput() );
advControls->enableVideo( THEMIM->getIM()->hasVideo() ); advControls->enableVideo( THEMIM->getIM()->hasVideo() );
...@@ -998,17 +900,7 @@ void MainInterface::updateOnTimer() ...@@ -998,17 +900,7 @@ void MainInterface::updateOnTimer()
need_components_update = false; need_components_update = false;
} }
audio_volume_t i_volume; controls->updateOnTimer();
aout_VolumeGet( p_intf, &i_volume );
i_volume = (i_volume * 200 )/ AOUT_VOLUME_MAX ;
int i_gauge = ui.volumeSlider->value();
b_my_volume = false;
if( i_volume - i_gauge > 1 || i_gauge - i_volume > 1 )
{
b_my_volume = true;
ui.volumeSlider->setValue( i_volume );
b_my_volume = false;
}
} }
void MainInterface::closeEvent( QCloseEvent *e ) void MainInterface::closeEvent( QCloseEvent *e )
...@@ -1017,16 +909,6 @@ void MainInterface::closeEvent( QCloseEvent *e ) ...@@ -1017,16 +909,6 @@ void MainInterface::closeEvent( QCloseEvent *e )
vlc_object_kill( p_intf ); vlc_object_kill( p_intf );
} }
void MainInterface::updateVolume( int sliderVolume )
{
if( !b_my_volume )
{
int i_res = sliderVolume * AOUT_VOLUME_MAX /
(2*ui.volumeSlider->maximum() );
aout_VolumeSet( p_intf, i_res );
}
}
static int InteractCallback( vlc_object_t *p_this, static int InteractCallback( vlc_object_t *p_this,
const char *psz_var, vlc_value_t old_val, const char *psz_var, vlc_value_t old_val,
vlc_value_t new_val, void *param ) vlc_value_t new_val, void *param )
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
* $Id$ * $Id$
* *
* Authors: Clément Stenac <zorglub@videolan.org> * Authors: Clément Stenac <zorglub@videolan.org>
* Jean-Baptiste Kempf <jb@videolan.org>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
...@@ -39,12 +40,11 @@ class QKeyEvent; ...@@ -39,12 +40,11 @@ class QKeyEvent;
class QLabel; class QLabel;
class QEvent; class QEvent;
class InputManager; class InputManager;
class InputSlider;
class VideoWidget; class VideoWidget;
class BackgroundWidget; class BackgroundWidget;
class PlaylistWidget; class PlaylistWidget;
class VolumeClickHandler;
class VisualSelector; class VisualSelector;
class AdvControlsWidget;
class ControlsWidget; class ControlsWidget;
class QMenu; class QMenu;
class QSize; class QSize;
...@@ -70,7 +70,7 @@ protected: ...@@ -70,7 +70,7 @@ protected:
void dragMoveEvent( QDragMoveEvent * ); void dragMoveEvent( QDragMoveEvent * );
void dragLeaveEvent( QDragLeaveEvent * ); void dragLeaveEvent( QDragLeaveEvent * );
void closeEvent( QCloseEvent *); void closeEvent( QCloseEvent *);
Ui::MainInterfaceUI ui; //Ui::MainInterfaceUI ui;
friend class VolumeClickHandler; friend class VolumeClickHandler;
private: private:
QSettings *settings; QSettings *settings;
...@@ -78,6 +78,8 @@ private: ...@@ -78,6 +78,8 @@ private:
QSystemTrayIcon *sysTray; QSystemTrayIcon *sysTray;
QMenu *systrayMenu; QMenu *systrayMenu;
QString input_name; QString input_name;
QVBoxLayout *mainLayout;
ControlsWidget *controls;
bool need_components_update; bool need_components_update;
void calculateInterfaceSize(); void calculateInterfaceSize();
...@@ -98,7 +100,7 @@ private: ...@@ -98,7 +100,7 @@ private:
BackgroundWidget *bgWidget; BackgroundWidget *bgWidget;
VisualSelector *visualSelector; VisualSelector *visualSelector;
ControlsWidget *advControls; AdvControlsWidget *advControls;
PlaylistWidget *playlistWidget; PlaylistWidget *playlistWidget;
bool playlistEmbeddedFlag; bool playlistEmbeddedFlag;
...@@ -108,7 +110,6 @@ private: ...@@ -108,7 +110,6 @@ private:
bool visualSelectorEnabled; bool visualSelectorEnabled;
InputManager *main_input_manager; InputManager *main_input_manager;
InputSlider *slider;
input_thread_t *p_input; ///< Main input associated to the playlist input_thread_t *p_input; ///< Main input associated to the playlist
QLabel *timeLabel; QLabel *timeLabel;
...@@ -122,19 +123,13 @@ public slots: ...@@ -122,19 +123,13 @@ public slots:
void playlist(); void playlist();
void toggleUpdateSystrayMenu(); void toggleUpdateSystrayMenu();
private slots: private slots:
void setNavigation( int );
void setStatus( int ); void setStatus( int );
void setName( QString ); void setName( QString );
void setVLCWindowsTitle( QString title = "" ); void setVLCWindowsTitle( QString title = "" );
void setDisplay( float, int, int ); void setDisplay( float, int, int );
void updateOnTimer(); void updateOnTimer();
void play();
void stop();
void prev();
void next();
void visual(); void visual();
void advanced(); void advanced();
void updateVolume( int sliderVolume );
void handleSystrayClick( QSystemTrayIcon::ActivationReason ); void handleSystrayClick( QSystemTrayIcon::ActivationReason );
void updateSystrayMenu( int ); void updateSystrayMenu( int );
void updateSystrayTooltipName( QString ); void updateSystrayTooltipName( QString );
...@@ -143,25 +138,4 @@ private slots: ...@@ -143,25 +138,4 @@ private slots:
void showTimeMenu( QPoint ); void showTimeMenu( QPoint );
}; };
class VolumeClickHandler : public QObject
{
public:
VolumeClickHandler( intf_thread_t *_p_intf, MainInterface *_m ) :QObject(_m)
{m = _m; p_intf = _p_intf; }
virtual ~VolumeClickHandler() {};
bool eventFilter( QObject *obj, QEvent *e )
{
if (e->type() == QEvent::MouseButtonPress )
{
aout_VolumeMute( p_intf, NULL );
return true;
}
return false;
}
private:
MainInterface *m;
intf_thread_t *p_intf;
};
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment