#endif
#include "controller_widget.hpp"
+#include "controller.hpp"
#include "input_manager.hpp" /* Get notification of Volume Change */
#include "util/input_slider.hpp" /* SoundSlider */
#include <QLabel>
#include <QHBoxLayout>
#include <QSpinBox>
+#include <QMenu>
+#include <QWidgetAction>
+#include <QMouseEvent>
SoundWidget::SoundWidget( QWidget *_parent, intf_thread_t * _p_intf,
- bool b_shiny )
- : QWidget( _parent ), b_my_volume( false )
+ bool b_shiny, bool b_special )
+ : QWidget( _parent ), b_my_volume( false ),
+ p_intf( _p_intf)
{
- p_intf = _p_intf;
+ /* We need a layout for this widget */
QHBoxLayout *layout = new QHBoxLayout( this );
layout->setSpacing( 0 ); layout->setMargin( 0 );
- hVolLabel = new VolumeClickHandler( p_intf, this );
+ /* We need a Label for the pix */
volMuteLabel = new QLabel;
volMuteLabel->setPixmap( QPixmap( ":/volume-medium" ) );
- volMuteLabel->installEventFilter( hVolLabel );
+
+ /* We might need a subLayout too */
+ QVBoxLayout *subLayout;
+
+ volMuteLabel->installEventFilter( this );
+
+ /* Normal View, click on icon mutes */
+ if( !b_special )
+ {
+ volumeMenu = NULL; subLayout = NULL;
+ }
+ else
+ {
+ /* Special view, click on button shows the slider */
+ b_shiny = false;
+
+ QFrame *volumeControlWidget = new QFrame;
+ subLayout = new QVBoxLayout( volumeControlWidget );
+ subLayout->setLayoutMargins( 4, 4, 4, 4, 4 );
+ volumeMenu = new QMenu( this );
+
+ QWidgetAction *widgetAction = new QWidgetAction( volumeControlWidget );
+ widgetAction->setDefaultWidget( volumeControlWidget );
+ volumeMenu->addAction( widgetAction );
+ }
+
+ /* And add the label */
layout->addWidget( volMuteLabel );
+ /* Slider creation: shiny or clean */
if( b_shiny )
{
volumeSlider = new SoundSlider( this,
}
else
{
- volumeSlider = new QSlider( this );
- volumeSlider->setOrientation( Qt::Horizontal );
+ volumeSlider = new QSlider( NULL );
+ volumeSlider->setOrientation( b_special ? Qt::Vertical
+ : Qt::Horizontal );
volumeSlider->setMaximum( config_GetInt( p_intf, "qt-volume-complete" )
? 400 : 200 );
}
- volumeSlider->setMaximumSize( QSize( 200, 40 ) );
- volumeSlider->setMinimumSize( QSize( 85, 30 ) );
+ if( volumeSlider->orientation() == Qt::Horizontal )
+ {
+ volumeSlider->setMaximumSize( QSize( 200, 40 ) );
+ volumeSlider->setMinimumSize( QSize( 85, 30 ) );
+ }
+
volumeSlider->setFocusPolicy( Qt::NoFocus );
- layout->addWidget( volumeSlider );
+ if( b_special )
+ subLayout->addWidget( volumeSlider );
+ else
+ layout->addWidget( volumeSlider );
/* Set the volume from the config */
volumeSlider->setValue( ( config_GetInt( p_intf, "volume" ) ) *
/* Audio part */
audio_volume_t i_volume;
aout_VolumeGet( p_intf, &i_volume );
- i_volume = ( i_volume * VOLUME_MAX )/ (AOUT_VOLUME_MAX/2);
+ i_volume = ( ( i_volume + 1 ) * 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 )
}
}
-void TeletextController::enableTeletextButtons( bool b_enabled )
+void SoundWidget::showVolumeMenu( QPoint pos )
+{
+ volumeMenu->exec( QCursor::pos() - pos - QPoint( 0, volumeMenu->height()/2 )
+ + QPoint( width(), height() /2) );
+}
+
+bool SoundWidget::eventFilter( QObject *obj, QEvent *e )
{
- telexOn->setChecked( b_enabled );
- telexTransparent->setEnabled( b_enabled );
- telexPage->setEnabled( b_enabled );
+ VLC_UNUSED( obj );
+ if (e->type() == QEvent::MouseButtonPress )
+ {
+ if( volumeSlider->orientation() == Qt::Vertical )
+ {
+ QMouseEvent *event = static_cast<QMouseEvent*>(e);
+ showVolumeMenu( event->pos() );
+ }
+ else
+ {
+ aout_VolumeMute( p_intf, NULL );
+ }
+ e->accept();
+ return true;
+ }
+ else
+ {
+ e->ignore();
+ return false;
+ }
}
+/**
+ * Play Button
+ **/
void PlayButton::updateButton( bool b_playing )
{
setIcon( b_playing ? QIcon( ":/pause_b" ) : QIcon( ":/play_b" ) );
}
}
-bool VolumeClickHandler::eventFilter( QObject *obj, QEvent *e )
-{
- VLC_UNUSED( obj );
- if (e->type() == QEvent::MouseButtonPress )
- {
- aout_VolumeMute( p_intf, NULL );
- audio_volume_t i_volume;
- aout_VolumeGet( p_intf, &i_volume );
-// m->updateVolume( i_volume * VOLUME_MAX / (AOUT_VOLUME_MAX/2) );
- e->accept();
- return true;
- }
- else
- {
- e->ignore();
- return false;
- }
-}