This repository has been archived by the owner on Dec 4, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Finish up the new pc-mixer utility. The main Mixer GUI is done now, a…
…nd it all works great!
- Loading branch information
Ken Moore
committed
Mar 7, 2014
1 parent
86c3cc9
commit 0c784d0
Showing
14 changed files
with
353 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
#include "DeviceWidget.h" | ||
#include "ui_DeviceWidget.h" | ||
|
||
DeviceWidget::DeviceWidget(QWidget *parent) : QWidget(parent), ui(new Ui::DeviceWidget){ | ||
ui->setupUi(this); //Load the designer file | ||
//Initialize the rest of the items | ||
islinked = true; | ||
ismuted = false; | ||
changing = false; //if true, slots will be de-activated | ||
CRV = 0; CLV = 0; | ||
//connect the signals/slots | ||
connect(ui->slider_L, SIGNAL(valueChanged(int)), this, SLOT(LSliderChanged(int)) ); | ||
connect(ui->slider_R, SIGNAL(valueChanged(int)), this, SLOT(RSliderChanged(int)) ); | ||
connect(ui->push_mute, SIGNAL(clicked()), this, SLOT(muteClicked()) ); | ||
connect(ui->tool_chain, SIGNAL(clicked()), this, SLOT(linkClicked()) ); | ||
} | ||
|
||
DeviceWidget::~DeviceWidget(){ | ||
|
||
} | ||
|
||
//=============== | ||
// PUBLIC | ||
//=============== | ||
void DeviceWidget::setupDevice(QString device, int Lvol, int Rvol){ | ||
changing = true; //going to change the sliders | ||
ui->label_device->setText(device); | ||
ui->slider_L->setValue(Lvol); | ||
ui->slider_R->setValue(Rvol); | ||
islinked = (Lvol == Rvol); | ||
ismuted = (islinked && (Lvol == 0) ); | ||
changing = false; //done making changes | ||
updateButtons(); | ||
} | ||
|
||
QString DeviceWidget::device(){ | ||
return ui->label_device->text(); | ||
} | ||
|
||
int DeviceWidget::LVolume(){ | ||
return ui->slider_L->value(); | ||
} | ||
|
||
int DeviceWidget::RVolume(){ | ||
return ui->slider_R->value(); | ||
} | ||
|
||
//=============== | ||
// PRIVATE | ||
//=============== | ||
void DeviceWidget::updateButtons(){ | ||
//Update the button icons/text as necessary | ||
if(islinked){ | ||
ui->tool_chain->setIcon(QIcon(":icons/link.png")); | ||
}else{ | ||
ui->tool_chain->setIcon(QIcon(":icons/link_break.png")); | ||
} | ||
if(ismuted){ | ||
ui->push_mute->setIcon( QIcon(":icons/audio-volume-high.png") ); | ||
ui->push_mute->setText( tr("Unmute") ); | ||
}else{ | ||
ui->push_mute->setIcon( QIcon(":icons/audio-volume-muted.png") ); | ||
ui->push_mute->setText( tr("Mute") ); | ||
} | ||
} | ||
|
||
void DeviceWidget::updateVolumes(int Lvol, int Rvol){ | ||
changing=true; //going to change the sliders | ||
//Update the sliders | ||
if(ui->slider_L->value() != Lvol){ ui->slider_L->setValue(Lvol); } | ||
if(ui->slider_R->value() != Rvol){ ui->slider_R->setValue(Rvol); } | ||
changing = false; //done making changes to sliders | ||
ismuted = (Lvol==Rvol) && (Lvol ==0); | ||
updateButtons(); //make sure to update the buttons now | ||
//Now adjust the backend mixer to reflect the changes | ||
Mixer::setValues(ui->label_device->text(), Lvol, Rvol); | ||
emit deviceChanged( ui->label_device->text() ); | ||
} | ||
|
||
//=============== | ||
// PRIVATE SLOTS | ||
//=============== | ||
void DeviceWidget::muteClicked(){ | ||
if(ismuted){ | ||
if(CLV==0 && CRV==0){ | ||
updateVolumes(50,50); | ||
}else{ | ||
updateVolumes(CLV, CRV); | ||
} | ||
}else{ | ||
CLV = ui->slider_L->value(); CRV = ui->slider_R->value(); //save for later | ||
updateVolumes(0,0); | ||
} | ||
} | ||
|
||
void DeviceWidget::linkClicked(){ | ||
islinked = !islinked; //flip to the other | ||
updateButtons(); | ||
} | ||
|
||
void DeviceWidget::LSliderChanged(int Lvol){ | ||
if(changing){ return; } //no double-taps while class is making adjustments | ||
if(islinked){ | ||
updateVolumes(Lvol, Lvol); | ||
}else{ | ||
updateVolumes(Lvol, ui->slider_R->value() ); | ||
} | ||
|
||
} | ||
|
||
void DeviceWidget::RSliderChanged(int Rvol){ | ||
if(changing){ return; } //no double-taps while class is making adjustments | ||
if(islinked){ | ||
updateVolumes(Rvol, Rvol); | ||
}else{ | ||
updateVolumes(ui->slider_L->value(), Rvol); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#ifndef _MIXER_DEVICE_WIDGET_H | ||
#define _MIXER_DEVICE_WIDGET_H | ||
|
||
#include <QWidget> | ||
#include <QString> | ||
|
||
#include "MixerBackend.h" | ||
|
||
namespace Ui{ | ||
class DeviceWidget; | ||
}; | ||
|
||
class DeviceWidget : public QWidget{ | ||
Q_OBJECT | ||
public: | ||
DeviceWidget(QWidget *parent = 0); | ||
~DeviceWidget(); | ||
|
||
void setupDevice(QString device, int Lvol, int Rvol); | ||
|
||
QString device(); | ||
int LVolume(); | ||
int RVolume(); | ||
|
||
private: | ||
Ui::DeviceWidget *ui; | ||
int CRV, CLV; //Current R/L volume (in case it was muted) | ||
bool changing, ismuted, islinked; // internal status flags | ||
|
||
void updateVolumes(int, int); | ||
void updateButtons(); | ||
|
||
private slots: | ||
void muteClicked(); | ||
void linkClicked(); | ||
void LSliderChanged(int); | ||
void RSliderChanged(int); | ||
|
||
signals: | ||
void deviceChanged(QString); | ||
|
||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ui version="4.0"> | ||
<class>DeviceWidget</class> | ||
<widget class="QWidget" name="DeviceWidget"> | ||
<property name="geometry"> | ||
<rect> | ||
<x>0</x> | ||
<y>0</y> | ||
<width>87</width> | ||
<height>191</height> | ||
</rect> | ||
</property> | ||
<property name="windowTitle"> | ||
<string>Form</string> | ||
</property> | ||
<layout class="QVBoxLayout" name="verticalLayout"> | ||
<property name="sizeConstraint"> | ||
<enum>QLayout::SetFixedSize</enum> | ||
</property> | ||
<property name="margin"> | ||
<number>0</number> | ||
</property> | ||
<item> | ||
<widget class="QFrame" name="frame"> | ||
<property name="frameShape"> | ||
<enum>QFrame::StyledPanel</enum> | ||
</property> | ||
<property name="frameShadow"> | ||
<enum>QFrame::Raised</enum> | ||
</property> | ||
<layout class="QVBoxLayout" name="verticalLayout_2"> | ||
<property name="margin"> | ||
<number>0</number> | ||
</property> | ||
<item> | ||
<widget class="QLabel" name="label_device"> | ||
<property name="text"> | ||
<string notr="true">device</string> | ||
</property> | ||
<property name="alignment"> | ||
<set>Qt::AlignCenter</set> | ||
</property> | ||
</widget> | ||
</item> | ||
<item> | ||
<widget class="Line" name="line_2"> | ||
<property name="orientation"> | ||
<enum>Qt::Horizontal</enum> | ||
</property> | ||
</widget> | ||
</item> | ||
<item> | ||
<layout class="QGridLayout" name="gridLayout"> | ||
<item row="1" column="1"> | ||
<widget class="QSlider" name="slider_R"> | ||
<property name="maximum"> | ||
<number>100</number> | ||
</property> | ||
<property name="orientation"> | ||
<enum>Qt::Vertical</enum> | ||
</property> | ||
</widget> | ||
</item> | ||
<item row="1" column="0"> | ||
<widget class="QSlider" name="slider_L"> | ||
<property name="maximum"> | ||
<number>100</number> | ||
</property> | ||
<property name="orientation"> | ||
<enum>Qt::Vertical</enum> | ||
</property> | ||
<property name="tickPosition"> | ||
<enum>QSlider::NoTicks</enum> | ||
</property> | ||
<property name="tickInterval"> | ||
<number>0</number> | ||
</property> | ||
</widget> | ||
</item> | ||
<item row="0" column="0" colspan="2"> | ||
<layout class="QHBoxLayout" name="horizontalLayout"> | ||
<item> | ||
<widget class="QLabel" name="label_2"> | ||
<property name="text"> | ||
<string>L</string> | ||
</property> | ||
<property name="alignment"> | ||
<set>Qt::AlignCenter</set> | ||
</property> | ||
</widget> | ||
</item> | ||
<item> | ||
<widget class="QToolButton" name="tool_chain"> | ||
<property name="text"> | ||
<string>...</string> | ||
</property> | ||
<property name="icon"> | ||
<iconset resource="pc-mixer.qrc"> | ||
<normaloff>:/icons/link.png</normaloff>:/icons/link.png</iconset> | ||
</property> | ||
</widget> | ||
</item> | ||
<item> | ||
<widget class="QLabel" name="label_3"> | ||
<property name="text"> | ||
<string>R</string> | ||
</property> | ||
<property name="alignment"> | ||
<set>Qt::AlignCenter</set> | ||
</property> | ||
</widget> | ||
</item> | ||
</layout> | ||
</item> | ||
</layout> | ||
</item> | ||
<item> | ||
<widget class="Line" name="line"> | ||
<property name="orientation"> | ||
<enum>Qt::Horizontal</enum> | ||
</property> | ||
</widget> | ||
</item> | ||
<item> | ||
<widget class="QPushButton" name="push_mute"> | ||
<property name="text"> | ||
<string>Mute</string> | ||
</property> | ||
<property name="icon"> | ||
<iconset resource="pc-mixer.qrc"> | ||
<normaloff>:/icons/audio-volume-muted.png</normaloff>:/icons/audio-volume-muted.png</iconset> | ||
</property> | ||
</widget> | ||
</item> | ||
</layout> | ||
</widget> | ||
</item> | ||
</layout> | ||
</widget> | ||
<resources> | ||
<include location="pc-mixer.qrc"/> | ||
</resources> | ||
<connections/> | ||
</ui> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.