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 @@
* $Id$
*
* 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
* it under the terms of the GNU General Public License as published by
......@@ -27,6 +28,7 @@
#include <vlc/vlc.h>
#include <vlc_interface.h>
#include <vlc_aout.h>
#include "qt4.hpp"
#include <QWidget>
......@@ -98,12 +100,12 @@ private slots:
};
class QPushButton;
class ControlsWidget : public QFrame
class AdvControlsWidget : public QFrame
{
Q_OBJECT
public:
ControlsWidget( intf_thread_t *);
virtual ~ControlsWidget();
AdvControlsWidget( intf_thread_t *);
virtual ~AdvControlsWidget();
void enableInput( bool );
void enableVideo( bool );
private:
......@@ -118,6 +120,64 @@ private slots:
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 ****************/
#include <QModelIndex>
......
......@@ -5,6 +5,7 @@
* $Id$
*
* 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
* it under the terms of the GNU General Public License as published by
......@@ -24,7 +25,6 @@
#include "qt4.hpp"
#include "main_interface.hpp"
#include "input_manager.hpp"
#include "util/input_slider.hpp"
#include "util/qvlcframe.hpp"
#include "util/customwidgets.hpp"
#include "dialogs_provider.hpp"
......@@ -152,6 +152,7 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
this, showSpeedMenu( QPoint ) );
CONNECT( timeLabel, customContextMenuRequested( QPoint ),
this, showTimeMenu( QPoint ) );
/* Systray */
sysTray = NULL;
if( config_GetInt( p_intf, "qt-start-minimized") )
......@@ -172,12 +173,8 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
* CONNECTs
**/
/* Volume control */
CONNECT( ui.volumeSlider, valueChanged(int), this, updateVolume(int) );
/* Connect the input manager to the GUI elements it manages */
CONNECT( THEMIM->getIM(), positionUpdated( float, int, int ),
slider, setPosition( float,int, int ) );
/* It is also connected to the control->slider */
CONNECT( THEMIM->getIM(), positionUpdated( float, int, int ),
this, setDisplay( float, int, int ) );
......@@ -197,23 +194,11 @@ MainInterface::MainInterface( intf_thread_t *_p_intf ) : QVLCMW( _p_intf )
/* PLAY_STATUS */
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 )
{
CONNECT( THEMIM->getIM(), statusChanged( int ), this,
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
......@@ -281,7 +266,7 @@ void MainInterface::setVLCWindowsTitle( QString aTitle )
void MainInterface::handleMainUi( QSettings *settings )
{
QWidget *main = new QWidget( this );
QVBoxLayout *mainLayout = new QVBoxLayout( main );
mainLayout = new QVBoxLayout( main );
setCentralWidget( main );
/* Margins, spacing */
......@@ -289,36 +274,13 @@ void MainInterface::handleMainUi( QSettings *settings )
mainLayout->setMargin( 0 );
/* CONTROLS */
QWidget *controls = new QWidget;
ui.setupUi( controls );
controls = new ControlsWidget( p_intf );
/* Configure the UI */
slider = new InputSlider( Qt::Horizontal, NULL );
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,
BUTTON_SET_IMG( controls->playlistButton, "" , playlist_icon.png,
playlistEmbeddedFlag ? qtr( "Show playlist" ) :
qtr( "Open playlist" ) );
BUTTONACT( ui.playlistButton, playlist() );
BUTTONACT( controls->playlistButton, playlist() );
#if DEBUG_COLOR
QPalette palette;
......@@ -335,7 +297,7 @@ void MainInterface::handleMainUi( QSettings *settings )
addSize = QSize( mainLayout->margin() * 2, PREF_H );
/* advanced Controls handling */
advControls = new ControlsWidget( p_intf );
advControls = new AdvControlsWidget( p_intf );
mainLayout->insertWidget( 0, advControls );
advControls->updateGeometry();
if( !advControlsEnabled ) advControls->hide();
......@@ -731,7 +693,7 @@ void MainInterface::playlist()
{
PlaylistDialog::killInstance();
playlistWidget = new PlaylistWidget( p_intf );
ui.vboxLayout->insertWidget( 0, playlistWidget );
mainLayout->insertWidget( 0, playlistWidget );
playlistWidget->widgetSize = settings->value( "playlistSize",
QSize( 650, 310 ) ).toSize();
playlistWidget->hide();
......@@ -779,7 +741,7 @@ void MainInterface::undockPlaylist()
{
playlistWidget->hide();
playlistWidget->deleteLater();
ui.vboxLayout->removeWidget( playlistWidget );
mainLayout->removeWidget( playlistWidget );
playlistWidget = NULL;
playlistEmbeddedFlag = false;
......@@ -897,33 +859,6 @@ void MainInterface::wheelEvent( QWheelEvent *e )
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 )
{
char psz_length[MSTRTIME_MAX_SIZE], psz_time[MSTRTIME_MAX_SIZE];
......@@ -942,48 +877,15 @@ void MainInterface::setName( QString name )
void MainInterface::setStatus( int status )
{
if( status == 1 ) // Playing
ui.playButton->setIcon( QIcon( ":/pixmaps/pause.png" ) );
else
ui.playButton->setIcon( QIcon( ":/pixmaps/play.png" ) );
controls->setStatus( status );
if( systrayMenu )
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()
{
/* \todo Make this event-driven */
// TO MOVE TO controls
advControls->enableInput( THEMIM->getIM()->hasInput() );
advControls->enableVideo( THEMIM->getIM()->hasVideo() );
......@@ -998,17 +900,7 @@ void MainInterface::updateOnTimer()
need_components_update = false;
}
audio_volume_t i_volume;
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;
}
controls->updateOnTimer();
}
void MainInterface::closeEvent( QCloseEvent *e )
......@@ -1017,16 +909,6 @@ void MainInterface::closeEvent( QCloseEvent *e )
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,
const char *psz_var, vlc_value_t old_val,
vlc_value_t new_val, void *param )
......
......@@ -5,6 +5,7 @@
* $Id$
*
* 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
* it under the terms of the GNU General Public License as published by
......@@ -39,12 +40,11 @@ class QKeyEvent;
class QLabel;
class QEvent;
class InputManager;
class InputSlider;
class VideoWidget;
class BackgroundWidget;
class PlaylistWidget;
class VolumeClickHandler;
class VisualSelector;
class AdvControlsWidget;
class ControlsWidget;
class QMenu;
class QSize;
......@@ -70,7 +70,7 @@ protected:
void dragMoveEvent( QDragMoveEvent * );
void dragLeaveEvent( QDragLeaveEvent * );
void closeEvent( QCloseEvent *);
Ui::MainInterfaceUI ui;
//Ui::MainInterfaceUI ui;
friend class VolumeClickHandler;
private:
QSettings *settings;
......@@ -78,6 +78,8 @@ private:
QSystemTrayIcon *sysTray;
QMenu *systrayMenu;
QString input_name;
QVBoxLayout *mainLayout;
ControlsWidget *controls;
bool need_components_update;
void calculateInterfaceSize();
......@@ -98,7 +100,7 @@ private:
BackgroundWidget *bgWidget;
VisualSelector *visualSelector;
ControlsWidget *advControls;
AdvControlsWidget *advControls;
PlaylistWidget *playlistWidget;
bool playlistEmbeddedFlag;
......@@ -108,7 +110,6 @@ private:
bool visualSelectorEnabled;
InputManager *main_input_manager;
InputSlider *slider;
input_thread_t *p_input; ///< Main input associated to the playlist
QLabel *timeLabel;
......@@ -122,19 +123,13 @@ public slots:
void playlist();
void toggleUpdateSystrayMenu();
private slots:
void setNavigation( int );
void setStatus( int );
void setName( QString );
void setVLCWindowsTitle( QString title = "" );
void setDisplay( float, int, int );
void updateOnTimer();
void play();
void stop();
void prev();
void next();
void visual();
void advanced();
void updateVolume( int sliderVolume );
void handleSystrayClick( QSystemTrayIcon::ActivationReason );
void updateSystrayMenu( int );
void updateSystrayTooltipName( QString );
......@@ -143,25 +138,4 @@ private slots:
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
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