Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 14 files changed
  • 0 commit comments
  • 1 contributor
View
119 src-qt4/pc-mixer/DeviceWidget.cpp
@@ -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);
+ }
+}
+
View
44 src-qt4/pc-mixer/DeviceWidget.h
@@ -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
View
144 src-qt4/pc-mixer/DeviceWidget.ui
@@ -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>
View
17 src-qt4/pc-mixer/MixerGUI.cpp
@@ -17,11 +17,14 @@ MixerGUI::~MixerGUI(){
void MixerGUI::updateGUI(){
//Load the list of available devices
QStringList devList = Mixer::getDevices();
- devList.sort();
+ //devList.sort();
//Clear the UI
ui->combo_default->disconnect();
ui->combo_default->clear();
-
+ delete ui->scrollArea->widget(); //delete the widget and all children
+ ui->scrollArea->setWidget( new QWidget() ); //create a new widget in the scroll area
+ ui->scrollArea->widget()->setContentsMargins(0,0,0,0);
+ QHBoxLayout *layout = new QHBoxLayout;
//Now Fill the UI with the devices
QString cdefault = settings->value("tray-device", "vol").toString();
for(int i=0; i<devList.length(); i++){
@@ -30,13 +33,21 @@ void MixerGUI::updateGUI(){
int Lval = devList[i].section(":",1,1).toInt();
int Rval = devList[i].section(":",2,2).toInt();
//Now create the device widget
-
+ DeviceWidget *device = new DeviceWidget(this);
+ device->setupDevice(dev, Lval, Rval);
+ layout->addWidget(device);
+ connect(device, SIGNAL(deviceChanged(QString)), this, SLOT(itemChanged(QString)) );
//Now add the device to the default List
ui->combo_default->addItem(dev);
if(dev == cdefault){
ui->combo_default->setCurrentIndex(i);
}
}
+ layout->addStretch(); //add spacer to the end
+ layout->setContentsMargins(2,2,2,2);
+ layout->setSpacing(4);
+ ui->scrollArea->widget()->setLayout(layout);
+ ui->scrollArea->setMinimumHeight(ui->scrollArea->widget()->minimumSizeHint().height()+ui->scrollArea->horizontalScrollBar()->height());
//re-connect combobox signal
connect(ui->combo_default, SIGNAL(currentIndexChanged(QString)), this, SLOT(changeDefaultTrayDevice(QString)) );
}
View
3  src-qt4/pc-mixer/MixerGUI.h
@@ -5,7 +5,10 @@
#include <QSettings>
#include <QCloseEvent>
#include <QCoreApplication>
+#include <QHBoxLayout>
+#include <QScrollBar>
+#include "DeviceWidget.h"
#include "MixerBackend.h"
namespace Ui{
View
22 src-qt4/pc-mixer/MixerGUI.ui
@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>396</width>
- <height>238</height>
+ <width>399</width>
+ <height>294</height>
</rect>
</property>
<property name="windowTitle">
@@ -45,8 +45,8 @@
<rect>
<x>0</x>
<y>0</y>
- <width>380</width>
- <height>153</height>
+ <width>383</width>
+ <height>209</height>
</rect>
</property>
</widget>
@@ -59,7 +59,7 @@
<rect>
<x>0</x>
<y>0</y>
- <width>396</width>
+ <width>399</width>
<height>20</height>
</rect>
</property>
@@ -75,16 +75,26 @@
</widget>
<widget class="QStatusBar" name="statusbar"/>
<action name="actionClose_Mixer_and_Tray">
+ <property name="icon">
+ <iconset resource="pc-mixer.qrc">
+ <normaloff>:/icons/application-exit.png</normaloff>:/icons/application-exit.png</iconset>
+ </property>
<property name="text">
<string>Close Mixer and Tray</string>
</property>
</action>
<action name="actionClose_Mixer">
+ <property name="icon">
+ <iconset resource="pc-mixer.qrc">
+ <normaloff>:/icons/window-close.png</normaloff>:/icons/window-close.png</iconset>
+ </property>
<property name="text">
<string>Hide Mixer</string>
</property>
</action>
</widget>
- <resources/>
+ <resources>
+ <include location="pc-mixer.qrc"/>
+ </resources>
<connections/>
</ui>
View
2  src-qt4/pc-mixer/MixerTray.cpp
@@ -16,6 +16,8 @@ MixerTray::MixerTray() : QSystemTrayIcon(){
muteA->setDefaultWidget(mute);
mixer = new QToolButton(0);
mixer->setText(tr("Mixer"));
+ mixer->setIcon(QIcon(":icons/configure.png"));
+ mixer->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);
mixerA = new QWidgetAction(0);
mixerA->setDefaultWidget(mixer);
actionMenu = new QMenu(0);
View
BIN  src-qt4/pc-mixer/icons/application-exit.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  src-qt4/pc-mixer/icons/configure.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  src-qt4/pc-mixer/icons/link.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  src-qt4/pc-mixer/icons/link_break.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  src-qt4/pc-mixer/icons/window-close.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
9 src-qt4/pc-mixer/pc-mixer.pro
@@ -6,15 +6,18 @@ CONFIG += qt warn_on release
HEADERS += MixerBackend.h \
MixerTray.h \
- MixerGUI.h
+ MixerGUI.h \
+ DeviceWidget.h
SOURCES += main.cpp \
MixerTray.cpp \
- MixerGUI.cpp
+ MixerGUI.cpp \
+ DeviceWidget.cpp
RESOURCES += pc-mixer.qrc
-FORMS = MixerGUI.ui
+FORMS = MixerGUI.ui \
+ DeviceWidget.ui
TARGET=pc-mixer
target.path=/usr/local/bin
View
5 src-qt4/pc-mixer/pc-mixer.qrc
@@ -1,5 +1,10 @@
<RCC>
<qresource>
+ <file>icons/window-close.png</file>
+ <file>icons/application-exit.png</file>
+ <file>icons/configure.png</file>
+ <file>icons/link_break.png</file>
+ <file>icons/link.png</file>
<file>icons/audio-volume-high.png</file>
<file>icons/audio-volume-medium.png</file>
<file>icons/audio-volume-low.png</file>

No commit comments for this range

Something went wrong with that request. Please try again.