Commit d726a580 authored by Michael Pyne's avatar Michael Pyne

Make volume popup actually popup.

This still needs work to cleanup the connections and for HiDPI displays
but it's close to working now.
parent be4fbb0e
......@@ -28,6 +28,8 @@
#include <QToolBar>
#include <QWheelEvent>
#include <QWidgetAction>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include "playermanager.h"
#include "juk.h"
......@@ -40,33 +42,37 @@ VolumePopupButton::VolumePopupButton( QWidget * parent )
//create the volume popup
m_volumeMenu = new QMenu( this );
KVBox *mainBox = new KVBox( this );
auto mainWidget = new QWidget( this );
mainWidget->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Preferred );
m_volumeLabel= new QLabel( mainBox );
auto mainBox = new QVBoxLayout( mainWidget );
mainBox->setMargin( 0 );
mainBox->setSpacing( 0 );
m_volumeLabel = new QLabel;
m_volumeLabel->setAlignment( Qt::AlignHCenter );
mainBox->addWidget( m_volumeLabel );
auto sliderBox = new QWidget;
sliderBox->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Preferred );
auto sliderBoxLayout = new QHBoxLayout( sliderBox );
sliderBoxLayout->setSpacing( 0 );
sliderBoxLayout->setMargin( 0 );
mainBox->addWidget(sliderBox);
KHBox *sliderBox = new KHBox( mainBox );
m_volumeSlider = new VolumeSlider( 100, sliderBox, false );
m_volumeSlider->setFixedHeight( 170 );
mainBox->setMargin( 0 );
mainBox->setSpacing( 0 );
sliderBox->setSpacing( 0 );
sliderBox->setMargin( 0 );
mainBox->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Fixed );
sliderBox->setSizePolicy( QSizePolicy::MinimumExpanding, QSizePolicy::Fixed );
m_volumeSlider->setFixedHeight( 200 ); // FIXME HiDPI
sliderBoxLayout->addWidget(m_volumeSlider);
PlayerManager *player = JuK::JuKInstance()->playerManager();
QWidgetAction *sliderActionWidget = new QWidgetAction( this );
sliderActionWidget->setDefaultWidget( mainBox );
sliderActionWidget->setDefaultWidget( mainWidget );
connect( m_volumeSlider, SIGNAL(volumeChanged(float)), player, SLOT(setVolume(float)) );
QToolBar *muteBar = new QToolBar( QString(), mainBox );
muteBar->setContentsMargins( 0, 0, 0, 0 );
muteBar->setIconSize( QSize( 16, 16 ) );
m_muteAction = new QAction( QIcon::fromTheme(QStringLiteral("audio-volume-muted")), QString(), muteBar );
m_muteAction = new QAction( QIcon::fromTheme(QStringLiteral("audio-volume-muted")), QString(), this );
m_muteAction->setToolTip( i18n( "Mute/Unmute" ) );
m_muteAction->setCheckable( true );
m_muteAction->setChecked( player->muted() );
......@@ -75,7 +81,7 @@ VolumePopupButton::VolumePopupButton( QWidget * parent )
connect( player, SIGNAL(mutedChanged(bool)), this, SLOT(muteStateChanged(bool)) );
m_volumeMenu->addAction( sliderActionWidget );
muteBar->addAction( m_muteAction );
m_volumeMenu->addAction( m_muteAction );
// set correct icon and label initially
volumeChanged( player->volume() );
......
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