#include "MixerChannel.h" #include "greenled.xpm" #include "redled.xpm" MixerChannel::MixerChannel(struct _channel &cinfo, QWidget* parent, const char* name, WFlags fl) : QWidget(parent, name, fl), redLed(redled_xpm), greenLed(greenled_xpm), info(cinfo) { const char *labels[] = SOUND_DEVICE_LABELS; layout = new QHBoxLayout(this, 0, 5); deviceName = new QLabel(this); deviceName->setFixedWidth(35); deviceName->setText(QString(labels[info.chan])); layout->addWidget(deviceName); volumeBar = new QSlider(0, 100, 10, ((info.left + info.right)/2), QSlider::Horizontal, this); layout->addWidget(volumeBar); balanceBar = new QSlider(QSlider::Horizontal, this); balanceBar->setRange(-100, 100); layout->addWidget(balanceBar); if(info.type == MONO) { balanceBar->setValue(0); balanceBar->setEnabled(false); } else { balanceBar->setValue((info.right - info.left)); connect(balanceBar, SIGNAL(valueChanged(int)), this, SLOT(balanceChange(int))); } deviceStatus = new QPushButton(this); deviceStatus->setMaximumSize(QSize(15, 15)); layout->addWidget(deviceStatus); if(isRecording(info.chan) == SUCCESS) { deviceStatus->setPixmap(redLed); } else { deviceStatus->setPixmap(greenLed); if(isRecordable(info.chan) == SUCCESS) { connect(deviceStatus, SIGNAL(clicked()), this, SLOT(setRecording())); } else { deviceStatus->setEnabled(false); } } mute = new QCheckBox(this); layout->addWidget(mute); if(!(info.left + info.right)) { mute->setChecked(true); connect(mute, SIGNAL(clicked()), this, SLOT(unMute())); } else { connect(mute, SIGNAL(clicked()), this, SLOT(setMute())); } languageChange(); connect(volumeBar, SIGNAL(valueChanged(int)), this, SLOT(volumeChange(int))); } void MixerChannel::languageChange() { QToolTip::add(deviceName, tr("Channel Name")); QToolTip::add(volumeBar, tr("Volume Bar")); QToolTip::add(balanceBar, tr("Balancement Bar")); QToolTip::add(deviceStatus, tr("Device Status")); QToolTip::add(mute, tr("Mute")); } void MixerChannel::setRecording() { modifySrc(info.chan, REC); disconnect(deviceStatus, SIGNAL(clicked()), this, SLOT(setRecording())); deviceStatus->setPixmap(redLed); } void MixerChannel::volumeChange(int value) { info.left=value - ((balanceBar->value()/2)); info.right=value + ((balanceBar->value()/2)); writeToDevice(info.chan, info.left, info.right); } void MixerChannel::balanceChange(int value) { value = 0; /* i don't really need this value */ volumeChange(volumeBar->value()); } void MixerChannel::setMute() { disconnect(balanceBar, SIGNAL(valueChanged(int)), this, SLOT(balanceChange(int))); disconnect(volumeBar, SIGNAL(valueChanged(int)), this, SLOT(volumeChange(int))); writeToDevice(info.chan, 0, 0); disconnect(mute, SIGNAL(clicked()), this, SLOT(setMute())); connect(mute, SIGNAL(clicked()), this, SLOT(unMute())); mute->setChecked(true); } void MixerChannel::unMute() { connect(volumeBar, SIGNAL(valueChanged(int)), this, SLOT(volumeChange(int))); connect(balanceBar, SIGNAL(valueChanged(int)), this, SLOT(balanceChange(int))); volumeChange(volumeBar->value()); connect(mute, SIGNAL(clicked()), this, SLOT(setMute())); disconnect(mute, SIGNAL(clicked()), this, SLOT(unMute())); mute->setChecked(false); } void MixerChannel::update() { if(isRecording(info.chan) == SUCCESS) { deviceStatus->setPixmap(redLed); disconnect(deviceStatus, SIGNAL(clicked()), this, SLOT(setRecording())); } else { deviceStatus->setPixmap(greenLed); if(isRecordable(info.chan) == SUCCESS) { connect(deviceStatus, SIGNAL(clicked()), this, SLOT(setRecording())); } else { deviceStatus->setEnabled(false); } } if(mute->isChecked()) { if(info.left + info.right) { volumeBar->setValue((info.left + info.right)/2); balanceBar->setValue((info.right - info.left)); unMute(); } } else { if(!(info.left + info.right)) { if(volumeBar->value()) { setMute(); } } else { volumeBar->setValue((info.left + info.right)/2); balanceBar->setValue((info.right - info.left)); } } } #include "MixerChannel.moc.cpp"