|
|
@ -1,12 +1,15 @@
|
|
|
|
// (C) 2005 Max Howell (max.howell@methylblue.com)
|
|
|
|
// (C) 2005 Max Howell (max.howell@methylblue.com)
|
|
|
|
// See COPYING file for licensing information
|
|
|
|
// See COPYING file for licensing information
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <kiconloader.h>
|
|
|
|
#include <tdelocale.h>
|
|
|
|
#include <tdelocale.h>
|
|
|
|
#include <tdetoolbar.h>
|
|
|
|
#include <tdetoolbar.h>
|
|
|
|
#include <tqevent.h>
|
|
|
|
#include <tqevent.h>
|
|
|
|
#include <tqlabel.h>
|
|
|
|
#include <tqlabel.h>
|
|
|
|
#include <tqlayout.h>
|
|
|
|
#include <tqlayout.h>
|
|
|
|
#include <tqslider.h>
|
|
|
|
#include <tqslider.h>
|
|
|
|
|
|
|
|
#include <tqtoolbutton.h>
|
|
|
|
|
|
|
|
#include <tqtooltip.h>
|
|
|
|
|
|
|
|
|
|
|
|
#include "../debug.h"
|
|
|
|
#include "../debug.h"
|
|
|
|
#include "volumeAction.h"
|
|
|
|
#include "volumeAction.h"
|
|
|
@ -20,19 +23,45 @@ public:
|
|
|
|
VolumeSlider( TQWidget *parent )
|
|
|
|
VolumeSlider( TQWidget *parent )
|
|
|
|
: TQFrame( parent )
|
|
|
|
: TQFrame( parent )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
slider = new TQSlider( TQt::Vertical, this, "volume" );
|
|
|
|
slider = new TQSlider(TQt::Vertical, this, "volume");
|
|
|
|
label = new TQLabel( this );
|
|
|
|
label = new TQLabel(this);
|
|
|
|
|
|
|
|
|
|
|
|
TQBoxLayout *lay = new TQVBoxLayout( this );
|
|
|
|
mute = new TQToolButton(this, "volume_slider_mute");
|
|
|
|
lay->addWidget( slider, 0, TQt::AlignHCenter );
|
|
|
|
mute->setAutoRaise(true);
|
|
|
|
lay->addWidget( label, 0, TQt::AlignHCenter );
|
|
|
|
mute->setToggleButton(true);
|
|
|
|
lay->setMargin( 4 );
|
|
|
|
TQToolTip::add(mute, i18n("Toggle Mute"));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TQBoxLayout *lay = new TQVBoxLayout(this);
|
|
|
|
|
|
|
|
lay->addWidget(slider, 0, TQt::AlignHCenter);
|
|
|
|
|
|
|
|
lay->addWidget(label, 0, TQt::AlignHCenter);
|
|
|
|
|
|
|
|
lay->addWidget(mute, 0, TQt::AlignHCenter);
|
|
|
|
|
|
|
|
lay->setMargin(4);
|
|
|
|
|
|
|
|
|
|
|
|
slider->setRange( 0, 100 );
|
|
|
|
slider->setRange( 0, 100 );
|
|
|
|
|
|
|
|
|
|
|
|
setFrameStyle( TQFrame::Plain | TQFrame::Box );
|
|
|
|
setFrameStyle( TQFrame::Plain | TQFrame::Box );
|
|
|
|
setSizePolicy( TQSizePolicy::Preferred, TQSizePolicy::Preferred );
|
|
|
|
setSizePolicy( TQSizePolicy::Preferred, TQSizePolicy::Preferred );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Test for icon support
|
|
|
|
|
|
|
|
const char* mutedIcons[] = { "audio-volume-muted", "player_mute", "mute" };
|
|
|
|
|
|
|
|
bool iconFound = false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (size_t i = 0; i < (sizeof(mutedIcons) / sizeof(*mutedIcons)); ++i)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!TDEGlobal::iconLoader()->iconPath(mutedIcons[i], TDEIcon::Toolbar, true).isNull())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
mute->setIconSet(TDEGlobal::iconLoader()->loadIconSet(mutedIcons[i], TDEIcon::Toolbar));
|
|
|
|
|
|
|
|
iconFound = true;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!iconFound)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
mute->setAutoRaise(false);
|
|
|
|
|
|
|
|
mute->setText(i18n("Mute"));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Calculate width required for max label size
|
|
|
|
// Calculate width required for max label size
|
|
|
|
label->setText( "100%" );
|
|
|
|
label->setText( "100%" );
|
|
|
|
adjustSize();
|
|
|
|
adjustSize();
|
|
|
@ -41,9 +70,16 @@ public:
|
|
|
|
hide();
|
|
|
|
hide();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TQToolButton *mute;
|
|
|
|
TQLabel *label;
|
|
|
|
TQLabel *label;
|
|
|
|
TQSlider *slider;
|
|
|
|
TQSlider *slider;
|
|
|
|
int requiredWidth;
|
|
|
|
int requiredWidth;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void setMuted(bool muted)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// Behave correctly when VolumeAction's "setMuted" slot is invoked.
|
|
|
|
|
|
|
|
mute->setDown(muted);
|
|
|
|
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -53,7 +89,9 @@ VolumeAction::VolumeAction( TDEToolBar *bar, TDEActionCollection *ac )
|
|
|
|
{
|
|
|
|
{
|
|
|
|
m_widget = new VolumeSlider( bar->topLevelWidget() );
|
|
|
|
m_widget = new VolumeSlider( bar->topLevelWidget() );
|
|
|
|
|
|
|
|
|
|
|
|
connect( this, TQ_SIGNAL(toggled( bool )), TQ_SLOT(toggled( bool )) );
|
|
|
|
connect(this, TQ_SIGNAL(toggled(bool)), TQ_SLOT(toggled(bool)));
|
|
|
|
|
|
|
|
connect(m_widget->mute, TQ_SIGNAL(toggled(bool)), Codeine::engine(), TQ_SLOT(setMuted(bool)));
|
|
|
|
|
|
|
|
connect(m_widget->mute, TQ_SIGNAL(toggled(bool)), TQ_SLOT(setMuted(bool)));
|
|
|
|
connect(m_widget->slider, TQ_SIGNAL(valueChanged(int)), Codeine::engine(), TQ_SLOT(setStreamParameter(int)));
|
|
|
|
connect(m_widget->slider, TQ_SIGNAL(valueChanged(int)), Codeine::engine(), TQ_SLOT(setStreamParameter(int)));
|
|
|
|
connect(m_widget->slider, TQ_SIGNAL(valueChanged(int)), TQ_SLOT(sliderMoved(int)));
|
|
|
|
connect(m_widget->slider, TQ_SIGNAL(valueChanged(int)), TQ_SLOT(sliderMoved(int)));
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -90,10 +128,14 @@ VolumeAction::sliderMoved(int v)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
|
VolumeAction::setVolume(int volume)
|
|
|
|
VolumeAction::setMuted(bool mute)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
TQString vol = TQString("%1%").arg(volume);
|
|
|
|
m_widget->setMuted(mute);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
|
|
|
|
VolumeAction::setVolume(int volume)
|
|
|
|
|
|
|
|
{
|
|
|
|
// TQt sliders are the wrong way round when vertical.
|
|
|
|
// TQt sliders are the wrong way round when vertical.
|
|
|
|
m_widget->slider->setValue(100 - volume);
|
|
|
|
m_widget->slider->setValue(100 - volume);
|
|
|
|
}
|
|
|
|
}
|
|
|
|