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

Qt: First step of splitting the controller widgets from the controller layout code.

Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent e14417af
......@@ -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 \
......
......@@ -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 );
}
/*****************************************************************************
* 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
{
......
/*****************************************************************************
* 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" ) );
}
}
/*****************************************************************************
* 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
......@@ -37,6 +37,7 @@
#include "qt4.hpp"
#include "main_interface.hpp"
#include "components/controller.hpp"
#include "components/controller_widget.hpp"
#include <QWidget>
#include <QFrame>
......
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