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

releng/10.0.1releng/10.0.2releng/10.0.3releng/10.1releng/10.1.1releng/10.1.2
Last change on this file since 0d4dda3e was 0d4dda3e, checked in by Ken Moore <ken@…>, 14 months ago

Add new options to the pc-mixer GUI:
Links to run pc-soundconfig, pavucontrol, paprefs.
Also add some icons.

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