1 /*****************************************************************************
2 * Controller_widget.cpp : Controller Widget for the controllers
3 ****************************************************************************
4 * Copyright ( C ) 2006-2008 the VideoLAN team
7 * Authors: Clément Stenac <zorglub@videolan.org>
8 * Jean-Baptiste Kempf <jb@videolan.org>
9 * Rafaël Carré <funman@videolanorg>
10 * Ilkka Ollakka <ileoo@videolan.org>
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * ( at your option ) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
25 *****************************************************************************/
31 //#include <vlc_vout.h>
32 //#include <vlc_keys.h>
34 #include "controller_widget.hpp"
36 #include "dialogs_provider.hpp"
37 #include "components/interface_widgets.hpp"
38 #include "main_interface.hpp"
39 #include "input_manager.hpp"
41 #include "util/input_slider.hpp"
42 #include "util/customwidgets.hpp"
45 #include <QSpacerItem>
47 #include <QToolButton>
48 #include <QHBoxLayout>
51 #include <QResizeEvent>
53 #include <QSignalMapper>
57 SoundWidget::SoundWidget( QWidget *_parent, intf_thread_t * _p_intf,
59 : b_my_volume( false ), QWidget( _parent )
62 QHBoxLayout *layout = new QHBoxLayout( this );
63 layout->setSpacing( 0 ); layout->setMargin( 0 );
64 hVolLabel = new VolumeClickHandler( p_intf, this );
66 volMuteLabel = new QLabel;
67 volMuteLabel->setPixmap( QPixmap( ":/volume-medium" ) );
68 volMuteLabel->installEventFilter( hVolLabel );
69 layout->addWidget( volMuteLabel );
73 volumeSlider = new SoundSlider( this,
74 config_GetInt( p_intf, "volume-step" ),
75 config_GetInt( p_intf, "qt-volume-complete" ),
76 config_GetPsz( p_intf, "qt-slider-colours" ) );
80 volumeSlider = new QSlider( this );
81 volumeSlider->setOrientation( Qt::Horizontal );
83 volumeSlider->setMaximumSize( QSize( 200, 40 ) );
84 volumeSlider->setMinimumSize( QSize( 85, 30 ) );
85 volumeSlider->setFocusPolicy( Qt::NoFocus );
86 layout->addWidget( volumeSlider );
88 /* Set the volume from the config */
89 volumeSlider->setValue( ( config_GetInt( p_intf, "volume" ) ) *
90 VOLUME_MAX / (AOUT_VOLUME_MAX/2) );
92 /* Force the update at build time in order to have a muted icon if needed */
93 updateVolume( volumeSlider->value() );
95 /* Volume control connection */
96 CONNECT( volumeSlider, valueChanged( int ), this, updateVolume( int ) );
97 CONNECT( THEMIM, volumeChanged( void ), this, updateVolume( void ) );
100 void SoundWidget::updateVolume( int i_sliderVolume )
104 int i_res = i_sliderVolume * (AOUT_VOLUME_MAX / 2) / VOLUME_MAX;
105 aout_VolumeSet( p_intf, i_res );
107 if( i_sliderVolume == 0 )
109 volMuteLabel->setPixmap( QPixmap(":/volume-muted" ) );
110 volMuteLabel->setToolTip( qtr( "Unmute" ) );
114 if( i_sliderVolume < VOLUME_MAX / 3 )
115 volMuteLabel->setPixmap( QPixmap( ":/volume-low" ) );
116 else if( i_sliderVolume > (VOLUME_MAX * 2 / 3 ) )
117 volMuteLabel->setPixmap( QPixmap( ":/volume-high" ) );
118 else volMuteLabel->setPixmap( QPixmap( ":/volume-medium" ) );
119 volMuteLabel->setToolTip( qtr( "Mute" ) );
122 void SoundWidget::updateVolume()
125 audio_volume_t i_volume;
126 aout_VolumeGet( p_intf, &i_volume );
127 i_volume = ( i_volume * VOLUME_MAX )/ (AOUT_VOLUME_MAX/2);
128 int i_gauge = volumeSlider->value();
130 if( i_volume - i_gauge > 1 || i_gauge - i_volume > 1 )
133 volumeSlider->setValue( i_volume );
138 void TeletextController::toggleTeletextTransparency( bool b_transparent )
140 telexTransparent->setIcon( b_transparent ? QIcon( ":/tvtelx" )
141 : QIcon( ":/tvtelx-trans" ) );
144 void TeletextController::enableTeletextButtons( bool b_enabled )
146 telexOn->setChecked( b_enabled );
147 telexTransparent->setEnabled( b_enabled );
148 telexPage->setEnabled( b_enabled );
151 void PlayButton::updateButton( bool b_playing )
153 setIcon( b_playing ? QIcon( ":/pause_b" ) : QIcon( ":/play_b" ) );
154 setToolTip( b_playing ? qtr( "Pause the playback" )
155 : qtr( I_PLAY_TOOLTIP ) );
158 void AtoB_Button::setIcons( bool timeA, bool timeB )
160 if( !timeA && !timeB)
162 setIcon( QIcon( ":/atob_nob" ) );
163 setToolTip( qtr( "Loop from point A to point B continuously\n"
164 "Click to set point A" ) );
166 else if( timeA && !timeB )
168 setIcon( QIcon( ":/atob_noa" ) );
169 setToolTip( qtr( "Click to set point B" ) );
171 else if( timeA && timeB )
173 setIcon( QIcon( ":/atob" ) );
174 setToolTip( qtr( "Stop the A to B loop" ) );