source: src-qt4/pc-mixer/MixerGUI.cpp @ 0c784d0

releng/10.0.1releng/10.0.2releng/10.0.3
Last change on this file since 0c784d0 was 0c784d0, checked in by Ken Moore <ken@…>, 6 months ago

Finish up the new pc-mixer utility. The main Mixer GUI is done now, and it all works great!

  • Property mode set to 100644
File size: 2.3 KB
Line 
1#include "MixerGUI.h"
2#include "ui_MixerGUI.h"
3
4MixerGUI::MixerGUI(QSettings *set) : QMainWindow(), ui(new Ui::MixerGUI){
5  ui->setupUi(this); //load the designer file
6  settings = set; //save this settings access for later
7  closing = false;
8  //connect the signals/slots
9  connect(ui->actionClose_Mixer, SIGNAL(triggered()), this, SLOT(hideGUI()) );
10  connect(ui->actionClose_Mixer_and_Tray, SIGNAL(triggered()), this, SLOT(closeApplication()) );
11}
12
13MixerGUI::~MixerGUI(){
14       
15}
16
17void MixerGUI::updateGUI(){
18  //Load the list of available devices
19  QStringList devList = Mixer::getDevices();
20  //devList.sort();
21  //Clear the UI
22  ui->combo_default->disconnect();
23  ui->combo_default->clear();
24  delete ui->scrollArea->widget(); //delete the widget and all children
25  ui->scrollArea->setWidget( new QWidget() ); //create a new widget in the scroll area
26  ui->scrollArea->widget()->setContentsMargins(0,0,0,0);
27  QHBoxLayout *layout = new QHBoxLayout;
28  //Now Fill the UI with the devices
29  QString cdefault = settings->value("tray-device", "vol").toString();
30  for(int i=0; i<devList.length(); i++){
31    //Get the individual pieces
32    QString dev = devList[i].section(":",0,0);
33    int Lval = devList[i].section(":",1,1).toInt();
34    int Rval = devList[i].section(":",2,2).toInt();
35    //Now create the device widget
36    DeviceWidget *device = new DeviceWidget(this);
37      device->setupDevice(dev, Lval, Rval);
38      layout->addWidget(device);
39      connect(device, SIGNAL(deviceChanged(QString)), this, SLOT(itemChanged(QString)) );
40    //Now add the device to the default List
41    ui->combo_default->addItem(dev);
42    if(dev == cdefault){
43      ui->combo_default->setCurrentIndex(i);
44    }
45  }
46  layout->addStretch(); //add spacer to the end
47  layout->setContentsMargins(2,2,2,2);
48  layout->setSpacing(4);
49  ui->scrollArea->widget()->setLayout(layout);
50  ui->scrollArea->setMinimumHeight(ui->scrollArea->widget()->minimumSizeHint().height()+ui->scrollArea->horizontalScrollBar()->height());
51  //re-connect combobox signal
52  connect(ui->combo_default, SIGNAL(currentIndexChanged(QString)), this, SLOT(changeDefaultTrayDevice(QString)) );
53}
54
55void MixerGUI::changeDefaultTrayDevice(QString device){
56  settings->setValue("tray-device", device);
57  emit updateTray();
58}
59
60void MixerGUI::itemChanged(QString device){
61  if(device == ui->combo_default->currentText()){
62    emit updateTray();
63  }
64}
Note: See TracBrowser for help on using the repository browser.