[PC-BSD Commits] r17653 - pcbsd/current/src-qt4/pc-soundconfig

svn at pcbsd.org svn at pcbsd.org
Thu Jul 5 12:44:22 PDT 2012


Author: kris
Date: 2012-07-05 19:44:22 +0000 (Thu, 05 Jul 2012)
New Revision: 17653

Modified:
   pcbsd/current/src-qt4/pc-soundconfig/pc-soundconfig.pro
   pcbsd/current/src-qt4/pc-soundconfig/snddialog.cpp
   pcbsd/current/src-qt4/pc-soundconfig/snddialog.h
   pcbsd/current/src-qt4/pc-soundconfig/snddialog.ui
   pcbsd/current/src-qt4/pc-soundconfig/sound.png
Log:

Welcome the new sound-config GUI. Now we can list, test and set between
the devices reported via /dev/sndstat



Modified: pcbsd/current/src-qt4/pc-soundconfig/pc-soundconfig.pro
===================================================================
--- pcbsd/current/src-qt4/pc-soundconfig/pc-soundconfig.pro	2012-07-05 19:37:54 UTC (rev 17652)
+++ pcbsd/current/src-qt4/pc-soundconfig/pc-soundconfig.pro	2012-07-05 19:44:22 UTC (rev 17653)
@@ -13,6 +13,8 @@
 
 HEADERS += snddialog.h
 
+LIBS    += -lpcbsd
+
 RESOURCES = SoundConfig.qrc
 
 TRANSLATIONS =  i18n/SoundConfig_af.ts \

Modified: pcbsd/current/src-qt4/pc-soundconfig/snddialog.cpp
===================================================================
--- pcbsd/current/src-qt4/pc-soundconfig/snddialog.cpp	2012-07-05 19:37:54 UTC (rev 17652)
+++ pcbsd/current/src-qt4/pc-soundconfig/snddialog.cpp	2012-07-05 19:44:22 UTC (rev 17653)
@@ -9,47 +9,98 @@
 ** These will automatically be called by the form's constructor and
 ** destructor.
 *****************************************************************************/
+#include <QProcess>
 #include "snddialog.h"
-#include <qtextstream.h>
-#include <QMessageBox>
-#include <QFileDialog>
+#include "pcbsd-utils.h"
 
 
 void sndDialog::programInit()
 {
   // Connect our pushbuttons
-  connect(pushDiagnostic, SIGNAL( clicked() ), this, SLOT( slotDiagnostic() ) );
+  connect(pushTest, SIGNAL( clicked() ), this, SLOT( slotDiagnostic() ) );
   connect(pushClose, SIGNAL( clicked() ), this, SLOT( slotClose() ) );
-  connect(pushNeverShow, SIGNAL( clicked() ), this, SLOT( slotNeverOpen() ) );
+  connect(pushApply, SIGNAL( clicked() ), this, SLOT( slotSave() ) );
+  connect(comboSound, SIGNAL( currentIndexChanged(int) ), this, SLOT( slotEnableApply() ) );
 
+  refreshDevices();
 }
 
+void sndDialog::slotEnableApply()
+{
+  pushApply->setEnabled(true);
+}
+
+void sndDialog::refreshDevices()
+{
+  defaultUnit = -1 ;
+  comboSound->clear();
+
+  // List the sound devices
+  QString tmp, snd;
+  QProcess d;
+  d.start(QString("cat"), QStringList() << "/dev/sndstat");
+  while(d.state() == QProcess::Starting || d.state() == QProcess::Running) {
+     d.waitForFinished(200);
+     QCoreApplication::processEvents();
+  }
+    
+  int i = 0;
+  while (d.canReadLine()) {
+    tmp = d.readLine().simplified();
+    if ( tmp.indexOf("pcm") == 0 ) {
+      comboSound->addItem(tmp);
+      if ( tmp.indexOf("default") != -1 ) {
+        defaultUnit=i;
+        comboSound->setCurrentIndex(i);
+      }
+      i++;
+    }
+  } 
+
+  if ( defaultUnit == -1 ) {
+     labelDesc->setText(tr("No sound devices detected!"));
+     pushTest->setEnabled(false);
+     pushApply->setEnabled(false);
+     comboSound->setEnabled(false);
+  }
+     
+  pushApply->setEnabled(false);
+}
+
 // Close the dialog and exit
 void sndDialog::slotClose()
 {
   close();
 }
 
-// Disable this dialog from opening at system startup
-void sndDialog::slotNeverOpen()
+void sndDialog::slotSave()
 {
-  system("pbreg set /PC-BSD/SoundErrorDisable Y");
-  close();
+  QString tmp;
+  tmp.setNum(comboSound->currentIndex());
+  system("sysctl hw.snd.default_unit=" + tmp.toLatin1());
+  Utils::setConfFileValue( "/etc/sysctl.conf", "hw.snd.default_unit=", "hw.snd.default_unit=" + tmp );
+  refreshDevices();
 }
 
-// Generate the diagnostic sheet and place it somewhere on the system
+// Play some sound for the user to detect this new device
 void sndDialog::slotDiagnostic()
 {
-  QString diagFile = QFileDialog::getSaveFileName( this,
-	"Select a location to save the Diagnostic",
-	"/usr/home", 
-	"*.diag|Diagnostic Files");
+  QString tmp;
+  tmp.setNum(comboSound->currentIndex());
 
-  system("echo 'PC-BSD Sound Diagnostic\n\npciconf -lv:\n' >'" + diagFile.toLatin1() + "'");
-  system("pciconf -lv >> '" + diagFile.toLatin1() + "'");
-  system("echo '\ndmesg:\n' >> '" + diagFile.toLatin1() + "'");
-  system("dmesg >> '" + diagFile.toLatin1() + "'");
+  // Change the sysctl, and play a sound
+  system("sysctl hw.snd.default_unit=" + tmp.toLatin1());
+  system("mixer vol 100:100");
+  system("mixer pcm 100:100");
+  system("mixer speaker 100:100");
 
-  QMessageBox::information(0, tr("Your diagnostic has been saved at: ") + diagFile, tr("Diagnostic Saved"));
+  QProcess d;
+  d.start(QString("mplayer"), QStringList() << "/usr/local/share/sounds/testsound.ogg");
+  while(d.state() == QProcess::Starting || d.state() == QProcess::Running) {
+     d.waitForFinished(200);
+     QCoreApplication::processEvents();
+  }
 
+  tmp.setNum(defaultUnit);
+  system("sysctl hw.snd.default_unit=" + tmp.toLatin1());
 }

Modified: pcbsd/current/src-qt4/pc-soundconfig/snddialog.h
===================================================================
--- pcbsd/current/src-qt4/pc-soundconfig/snddialog.h	2012-07-05 19:37:54 UTC (rev 17652)
+++ pcbsd/current/src-qt4/pc-soundconfig/snddialog.h	2012-07-05 19:44:22 UTC (rev 17653)
@@ -1,5 +1,5 @@
-#ifndef SOUNDERROR_H
-#define SOUNDERROR_H
+#ifndef SOUNDCONFIG_H
+#define SOUNDCONFIG_H
 
 #include <qdialog.h>
 #include "ui_snddialog.h"
@@ -21,12 +21,15 @@
 private slots:
     void slotClose();
     void slotDiagnostic();
-    void slotNeverOpen();
+    void slotSave();
+    void slotEnableApply();
 
 private:
+    void refreshDevices();
+    int defaultUnit;
 
 signals:
 
 } ;
-#endif // SOUNDERROR_H
+#endif // SOUNDCONFIG_H
 

Modified: pcbsd/current/src-qt4/pc-soundconfig/snddialog.ui
===================================================================
--- pcbsd/current/src-qt4/pc-soundconfig/snddialog.ui	2012-07-05 19:37:54 UTC (rev 17652)
+++ pcbsd/current/src-qt4/pc-soundconfig/snddialog.ui	2012-07-05 19:44:22 UTC (rev 17653)
@@ -1,152 +1,109 @@
-<ui version="4.0" >
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
  <class>sndDialog</class>
- <widget class="QDialog" name="sndDialog" >
-  <property name="geometry" >
+ <widget class="QDialog" name="sndDialog">
+  <property name="geometry">
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>401</width>
-    <height>212</height>
+    <width>612</width>
+    <height>195</height>
    </rect>
   </property>
-  <property name="sizePolicy" >
-   <sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
+  <property name="sizePolicy">
+   <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
     <horstretch>0</horstretch>
     <verstretch>0</verstretch>
    </sizepolicy>
   </property>
-  <property name="windowTitle" >
-   <string>No sound card detected</string>
+  <property name="windowTitle">
+   <string>Sound Configuration</string>
   </property>
-  <property name="windowIcon" >
-   <iconset resource="SoundError.qrc" >
+  <property name="windowIcon">
+   <iconset resource="SoundConfig.qrc">
     <normaloff>:/sound.png</normaloff>:/sound.png</iconset>
   </property>
-  <layout class="QGridLayout" name="gridLayout_2" >
-   <item row="0" column="0" >
-    <layout class="QHBoxLayout" name="horizontalLayout_3" >
-     <item>
-      <layout class="QGridLayout" name="gridLayout" >
-       <item row="0" column="0" >
-        <widget class="QGraphicsView" name="graphicsView" >
-         <property name="sizePolicy" >
-          <sizepolicy vsizetype="Fixed" hsizetype="Fixed" >
-           <horstretch>0</horstretch>
-           <verstretch>0</verstretch>
-          </sizepolicy>
-         </property>
-         <property name="maximumSize" >
-          <size>
-           <width>70</width>
-           <height>70</height>
-          </size>
-         </property>
-         <property name="styleSheet" >
-          <string notr="true" >background-image: url(:/sound.png);</string>
-         </property>
-         <property name="frameShape" >
-          <enum>QFrame::NoFrame</enum>
-         </property>
-        </widget>
-       </item>
-       <item row="1" column="0" >
-        <spacer name="verticalSpacer_2" >
-         <property name="orientation" >
-          <enum>Qt::Vertical</enum>
-         </property>
-         <property name="sizeHint" stdset="0" >
-          <size>
-           <width>20</width>
-           <height>13</height>
-          </size>
-         </property>
-        </spacer>
-       </item>
-      </layout>
-     </item>
-     <item>
-      <widget class="QLabel" name="label" >
-       <property name="sizePolicy" >
-        <sizepolicy vsizetype="Preferred" hsizetype="Expanding" >
-         <horstretch>0</horstretch>
-         <verstretch>0</verstretch>
-        </sizepolicy>
-       </property>
-       <property name="text" >
-        <string>PC-BSD was unable to detect a sound card. If this system has a sound card, please generate the diagnostic below and send it to support at pcbsd.org. </string>
-       </property>
-       <property name="wordWrap" >
-        <bool>true</bool>
-       </property>
-      </widget>
-     </item>
-    </layout>
+  <layout class="QGridLayout" name="gridLayout_2">
+   <item row="0" column="0">
+    <widget class="QGroupBox" name="groupBox">
+     <property name="title">
+      <string>Sound Configuration</string>
+     </property>
+     <layout class="QGridLayout" name="gridLayout">
+      <item row="0" column="0">
+       <widget class="QLabel" name="labelDesc">
+        <property name="text">
+         <string>Below you may change the default sound device, and test sound playback</string>
+        </property>
+        <property name="wordWrap">
+         <bool>true</bool>
+        </property>
+       </widget>
+      </item>
+      <item row="1" column="0">
+       <widget class="QComboBox" name="comboSound"/>
+      </item>
+      <item row="2" column="0">
+       <layout class="QHBoxLayout" name="horizontalLayout_2">
+        <item>
+         <spacer name="horizontalSpacer_2">
+          <property name="orientation">
+           <enum>Qt::Horizontal</enum>
+          </property>
+          <property name="sizeHint" stdset="0">
+           <size>
+            <width>40</width>
+            <height>20</height>
+           </size>
+          </property>
+         </spacer>
+        </item>
+        <item>
+         <widget class="QPushButton" name="pushTest">
+          <property name="text">
+           <string>&Test sound</string>
+          </property>
+         </widget>
+        </item>
+        <item>
+         <spacer name="horizontalSpacer_3">
+          <property name="orientation">
+           <enum>Qt::Horizontal</enum>
+          </property>
+          <property name="sizeHint" stdset="0">
+           <size>
+            <width>40</width>
+            <height>20</height>
+           </size>
+          </property>
+         </spacer>
+        </item>
+       </layout>
+      </item>
+     </layout>
+    </widget>
    </item>
-   <item row="1" column="0" >
-    <layout class="QHBoxLayout" name="horizontalLayout_2" >
-     <item>
-      <spacer name="horizontalSpacer_2" >
-       <property name="orientation" >
-        <enum>Qt::Horizontal</enum>
-       </property>
-       <property name="sizeHint" stdset="0" >
-        <size>
-         <width>40</width>
-         <height>20</height>
-        </size>
-       </property>
-      </spacer>
-     </item>
-     <item>
-      <widget class="QPushButton" name="pushDiagnostic" >
-       <property name="text" >
-        <string>&Generate Diagnostic</string>
-       </property>
-      </widget>
-     </item>
-     <item>
-      <spacer name="horizontalSpacer_3" >
-       <property name="orientation" >
-        <enum>Qt::Horizontal</enum>
-       </property>
-       <property name="sizeHint" stdset="0" >
-        <size>
-         <width>40</width>
-         <height>20</height>
-        </size>
-       </property>
-      </spacer>
-     </item>
-    </layout>
-   </item>
-   <item row="2" column="0" >
-    <spacer name="verticalSpacer" >
-     <property name="orientation" >
+   <item row="1" column="0">
+    <spacer name="verticalSpacer">
+     <property name="orientation">
       <enum>Qt::Vertical</enum>
      </property>
-     <property name="sizeHint" stdset="0" >
+     <property name="sizeHint" stdset="0">
       <size>
        <width>20</width>
-       <height>40</height>
+       <height>5</height>
       </size>
      </property>
     </spacer>
    </item>
-   <item row="3" column="0" >
-    <layout class="QHBoxLayout" name="horizontalLayout" >
+   <item row="2" column="0">
+    <layout class="QHBoxLayout" name="horizontalLayout">
      <item>
-      <widget class="QPushButton" name="pushNeverShow" >
-       <property name="text" >
-        <string>Never Show</string>
-       </property>
-      </widget>
-     </item>
-     <item>
-      <spacer name="horizontalSpacer" >
-       <property name="orientation" >
+      <spacer name="horizontalSpacer">
+       <property name="orientation">
         <enum>Qt::Horizontal</enum>
        </property>
-       <property name="sizeHint" stdset="0" >
+       <property name="sizeHint" stdset="0">
         <size>
          <width>40</width>
          <height>20</height>
@@ -155,8 +112,18 @@
       </spacer>
      </item>
      <item>
-      <widget class="QPushButton" name="pushClose" >
-       <property name="text" >
+      <widget class="QPushButton" name="pushApply">
+       <property name="enabled">
+        <bool>false</bool>
+       </property>
+       <property name="text">
+        <string>&Apply</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QPushButton" name="pushClose">
+       <property name="text">
         <string>&Close</string>
        </property>
       </widget>
@@ -166,7 +133,7 @@
   </layout>
  </widget>
  <resources>
-  <include location="SoundError.qrc" />
+  <include location="SoundConfig.qrc"/>
  </resources>
  <connections/>
 </ui>

Modified: pcbsd/current/src-qt4/pc-soundconfig/sound.png
===================================================================
(Binary files differ)



More information about the Commits mailing list