You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
140 lines
4.2 KiB
140 lines
4.2 KiB
15 years ago
|
/***************************************************************************
|
||
|
alsa-mixer-element.cpp - description
|
||
|
-------------------
|
||
|
begin : Mon Aug 15 2005
|
||
|
copyright : (C) 2005 by Martin Witte
|
||
|
email : witte@kawo1.rwth-aachen.de
|
||
|
***************************************************************************/
|
||
|
|
||
|
/***************************************************************************
|
||
|
* *
|
||
|
* 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. *
|
||
|
* *
|
||
|
***************************************************************************/
|
||
|
|
||
|
#include "alsa-mixer-element.h"
|
||
|
|
||
|
#include <knuminput.h>
|
||
14 years ago
|
#include <tqslider.h>
|
||
|
#include <tqlabel.h>
|
||
|
#include <tqcheckbox.h>
|
||
15 years ago
|
|
||
|
#include <math.h>
|
||
|
|
||
14 years ago
|
QAlsaMixerElement::QAlsaMixerElement(TQWidget *parent, const TQString &label, bool has_switch, bool has_volume)
|
||
|
: AlsaMixerElementUI(parent),
|
||
15 years ago
|
m_HasVolume(has_volume),
|
||
|
m_HasSwitch(has_switch),
|
||
|
m_dirty(false),
|
||
|
m_ignore_updates(false)
|
||
|
{
|
||
|
setLabel(label);
|
||
|
setVolume(0);
|
||
|
|
||
14 years ago
|
TQObject::connect(m_spinboxVolume, TQT_SIGNAL(valueChanged(int)),
|
||
|
this, TQT_SLOT (slotSpinboxValueChanged(int)));
|
||
|
TQObject::connect(m_sliderVolume, TQT_SIGNAL(valueChanged(int)),
|
||
|
this, TQT_SLOT (slotSliderValueChanged(int)));
|
||
15 years ago
|
|
||
|
if (m_HasVolume) {
|
||
14 years ago
|
TQObject::connect(m_checkboxOverride, TQT_SIGNAL(toggled(bool)),
|
||
|
m_spinboxVolume, TQT_SLOT (setEnabled(bool)));
|
||
|
TQObject::connect(m_checkboxOverride, TQT_SIGNAL(toggled(bool)),
|
||
|
m_sliderVolume, TQT_SLOT (setEnabled(bool)));
|
||
15 years ago
|
} else {
|
||
|
m_spinboxVolume->hide();
|
||
|
m_sliderVolume->hide();
|
||
|
}
|
||
|
if (m_HasSwitch) {
|
||
14 years ago
|
TQObject::connect(m_checkboxOverride, TQT_SIGNAL(toggled(bool)),
|
||
|
m_checkboxActive, TQT_SLOT (setEnabled(bool)));
|
||
15 years ago
|
} else {
|
||
|
//m_checkboxActive->hide();
|
||
|
m_checkboxActive->setEnabled(false);
|
||
|
m_checkboxActive->setChecked(true);
|
||
|
}
|
||
|
|
||
14 years ago
|
connect(m_checkboxOverride, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(slotSetDirty()));
|
||
|
connect(m_checkboxActive, TQT_SIGNAL(toggled(bool)), this, TQT_SLOT(slotSetDirty()));
|
||
|
connect(m_spinboxVolume, TQT_SIGNAL(valueChanged(int)), this, TQT_SLOT(slotSetDirty()));
|
||
|
connect(m_sliderVolume, TQT_SIGNAL(valueChanged(int)), this, TQT_SLOT(slotSetDirty()));
|
||
15 years ago
|
}
|
||
|
|
||
|
|
||
14 years ago
|
QAlsaMixerElement::~QAlsaMixerElement()
|
||
15 years ago
|
{
|
||
|
}
|
||
|
|
||
14 years ago
|
float QAlsaMixerElement::getVolume() const
|
||
15 years ago
|
{
|
||
|
return ((float)m_spinboxVolume->value())/100.0;
|
||
|
}
|
||
|
|
||
14 years ago
|
bool QAlsaMixerElement::getActive() const
|
||
15 years ago
|
{
|
||
|
return m_checkboxActive->isChecked();
|
||
|
}
|
||
|
|
||
14 years ago
|
bool QAlsaMixerElement::getOverride() const
|
||
15 years ago
|
{
|
||
|
return m_checkboxOverride->isChecked();
|
||
|
}
|
||
|
|
||
14 years ago
|
void QAlsaMixerElement::setLabel(const TQString &label)
|
||
15 years ago
|
{
|
||
|
m_labelMixerElementName->setText(label);
|
||
|
}
|
||
|
|
||
14 years ago
|
void QAlsaMixerElement::setOverride(bool ov)
|
||
15 years ago
|
{
|
||
|
m_ignore_updates = true;
|
||
|
m_checkboxOverride->setChecked(ov);
|
||
|
m_ignore_updates = false;
|
||
|
}
|
||
|
|
||
14 years ago
|
void QAlsaMixerElement::setActive(bool active)
|
||
15 years ago
|
{
|
||
|
m_ignore_updates = true;
|
||
|
m_checkboxActive->setChecked(active);
|
||
|
m_ignore_updates = false;
|
||
|
}
|
||
|
|
||
14 years ago
|
void QAlsaMixerElement::setVolume(float vol)
|
||
15 years ago
|
{
|
||
|
m_ignore_updates = true;
|
||
|
int v = (int)rint(vol*100 + 0.5);
|
||
|
m_sliderVolume->setValue(100 - v);
|
||
|
m_spinboxVolume->setValue(v);
|
||
|
m_ignore_updates = false;
|
||
|
}
|
||
|
|
||
14 years ago
|
void QAlsaMixerElement::slotSpinboxValueChanged(int v)
|
||
15 years ago
|
{
|
||
|
m_sliderVolume->setValue(100-v);
|
||
|
}
|
||
|
|
||
14 years ago
|
void QAlsaMixerElement::slotSliderValueChanged(int v)
|
||
15 years ago
|
{
|
||
|
m_spinboxVolume->setValue(100-v);
|
||
|
}
|
||
|
|
||
|
|
||
14 years ago
|
void QAlsaMixerElement::slotSetDirty()
|
||
15 years ago
|
{
|
||
|
if (!m_dirty && !m_ignore_updates) {
|
||
|
m_dirty = true;
|
||
|
emit sigDirty();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
14 years ago
|
void QAlsaMixerElement::slotResetDirty()
|
||
15 years ago
|
{
|
||
|
m_dirty = false;
|
||
|
}
|
||
|
|
||
|
#include "alsa-mixer-element.moc"
|