Revision
16168
Author
jmesquita
Date
2010-01-05 21:45:00 -0600 (Tue, 05 Jan 2010)

Log Message

A couple of more changes to the portaudio configuration.

Modified Paths

Diff

Modified: freeswitch/trunk/fscomm/prefdialog.ui (16167 => 16168)


--- freeswitch/trunk/fscomm/prefdialog.ui	2010-01-06 03:04:04 UTC (rev 16167)
+++ freeswitch/trunk/fscomm/prefdialog.ui	2010-01-06 03:45:00 UTC (rev 16168)
@@ -6,7 +6,7 @@
    <rect>
     <x>0</x>
     <y>0</y>
-    <width>661</width>
+    <width>711</width>
     <height>437</height>
    </rect>
   </property>
@@ -197,7 +197,27 @@
            </widget>
           </item>
           <item row="1" column="1">
-           <widget class="QComboBox" name="PaOutdevCombo"/>
+           <layout class="QHBoxLayout" name="horizontalLayout_3">
+            <item>
+             <widget class="QComboBox" name="PaOutdevCombo"/>
+            </item>
+            <item>
+             <widget class="QPushButton" name="PaOutdevTestBtn">
+              <property name="enabled">
+               <bool>false</bool>
+              </property>
+              <property name="maximumSize">
+               <size>
+                <width>86</width>
+                <height>27</height>
+               </size>
+              </property>
+              <property name="text">
+               <string>Test</string>
+              </property>
+             </widget>
+            </item>
+           </layout>
           </item>
           <item row="2" column="0">
            <widget class="QLabel" name="label_9">
@@ -207,7 +227,27 @@
            </widget>
           </item>
           <item row="2" column="1">
-           <widget class="QComboBox" name="PaRingdevCombo"/>
+           <layout class="QHBoxLayout" name="horizontalLayout_2">
+            <item>
+             <widget class="QComboBox" name="PaRingdevCombo"/>
+            </item>
+            <item>
+             <widget class="QPushButton" name="PaRingdevTestBtn">
+              <property name="enabled">
+               <bool>false</bool>
+              </property>
+              <property name="maximumSize">
+               <size>
+                <width>86</width>
+                <height>27</height>
+               </size>
+              </property>
+              <property name="text">
+               <string>Test</string>
+              </property>
+             </widget>
+            </item>
+           </layout>
           </item>
          </layout>
         </widget>
@@ -217,7 +257,7 @@
          <property name="title">
           <string>Files</string>
          </property>
-         <layout class="QGridLayout" name="gridLayout">
+         <layout class="QFormLayout" name="formLayout_5">
           <item row="0" column="0">
            <widget class="QLabel" name="label_10">
             <property name="text">
@@ -226,11 +266,22 @@
            </widget>
           </item>
           <item row="0" column="1">
-           <widget class="QLineEdit" name="PaRingFileEdit">
-            <property name="text">
-             <string>tone_stream://%(2000,4000,440.0,480.0);loops=20</string>
-            </property>
-           </widget>
+           <layout class="QHBoxLayout" name="horizontalLayout_4">
+            <item>
+             <widget class="QLineEdit" name="PaRingFileEdit">
+              <property name="text">
+               <string>tone_stream://%(2000,4000,440.0,480.0);loops=20</string>
+              </property>
+             </widget>
+            </item>
+            <item>
+             <widget class="QPushButton" name="PaRingFileBtn">
+              <property name="text">
+               <string>Open</string>
+              </property>
+             </widget>
+            </item>
+           </layout>
           </item>
           <item row="1" column="0">
            <widget class="QLabel" name="label_12">
@@ -240,7 +291,11 @@
            </widget>
           </item>
           <item row="1" column="1">
-           <widget class="QSpinBox" name="PaRingIntervalSpin"/>
+           <widget class="QSpinBox" name="PaRingIntervalSpin">
+            <property name="value">
+             <number>5</number>
+            </property>
+           </widget>
           </item>
           <item row="2" column="0">
            <widget class="QLabel" name="label_11">
@@ -250,7 +305,22 @@
            </widget>
           </item>
           <item row="2" column="1">
-           <widget class="QLineEdit" name="PaHoldFileEdit"/>
+           <layout class="QHBoxLayout" name="horizontalLayout">
+            <item>
+             <widget class="QLineEdit" name="PaHoldFileEdit">
+              <property name="readOnly">
+               <bool>true</bool>
+              </property>
+             </widget>
+            </item>
+            <item>
+             <widget class="QPushButton" name="PaHoldFileBtn">
+              <property name="text">
+               <string>Open</string>
+              </property>
+             </widget>
+            </item>
+           </layout>
           </item>
          </layout>
         </widget>

Modified: freeswitch/trunk/fscomm/prefportaudio.cpp (16167 => 16168)


--- freeswitch/trunk/fscomm/prefportaudio.cpp	2010-01-06 03:04:04 UTC (rev 16167)
+++ freeswitch/trunk/fscomm/prefportaudio.cpp	2010-01-06 03:45:00 UTC (rev 16168)
@@ -7,8 +7,57 @@
         _ui(ui)
 {
     _settings = new QSettings();
+    connect(_ui->PaRingFileBtn, SIGNAL(clicked()), this, SLOT(ringFileChoose()));
+    connect(_ui->PaHoldFileBtn, SIGNAL(clicked()), this, SLOT(holdFileChoose()));
+    connect(_ui->PaOutdevCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(outdevChangeDev(int)));
+    connect(_ui->PaRingdevCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(ringdevChangeDev(int)));
 }
 
+void PrefPortaudio::ringdevChangeDev(int dev)
+{
+    QString result;
+    if (g_FSHost.sendCmd("pa", QString("ringdev #%1").arg(dev).toAscii().constData(), &result) != SWITCH_STATUS_SUCCESS)
+    {
+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting ringdev to #%d on mod_portaudio!\n", dev);
+        QMessageBox::critical(0, tr("Unable to change device."),
+                              tr("There was an error changing the ringdev.\nPlease report this bug."),
+                              QMessageBox::Ok);
+
+    }
+}
+
+void PrefPortaudio::outdevChangeDev(int dev)
+{
+    QString result;
+    if (g_FSHost.sendCmd("pa", QString("outdev #%1").arg(dev).toAscii().constData(), &result) != SWITCH_STATUS_SUCCESS)
+    {
+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting outdev to #%d on mod_portaudio!\n", dev);
+        QMessageBox::critical(0, tr("Unable to change device."),
+                              tr("There was an error changing the outdev.\nPlease report this bug."),
+                              QMessageBox::Ok);
+    }
+}
+
+void PrefPortaudio::holdFileChoose()
+{
+    QString fileName = QFileDialog::getOpenFileName(0,
+                                                    tr("Select file"),
+                                                    QDir::homePath(),
+                                                    NULL);
+    if (!fileName.isNull())
+        _ui->PaHoldFileEdit->setText(fileName);
+}
+
+void PrefPortaudio::ringFileChoose()
+{
+    QString fileName = QFileDialog::getOpenFileName(0,
+                                                    tr("Select file"),
+                                                    QDir::homePath(),
+                                                    NULL);
+    if (!fileName.isNull())
+        _ui->PaRingFileEdit->setText(fileName);
+}
+
 void PrefPortaudio::writeConfig()
 {
     _settings->beginGroup("FreeSWITCH/conf");
@@ -79,33 +128,11 @@
 
     if (noutdev!= outdev)
     {
-        if (g_FSHost.sendCmd("pa", QString("outdev #%1").arg(noutdev).toAscii().constData(), &result) == SWITCH_STATUS_SUCCESS)
-        {
-            _settings->setValue("outdev", noutdev);
-        }
-        else
-        {
-            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting outdev from #%d to #%d on mod_portaudio!\n",
-                              outdev, noutdev);
-            QMessageBox::critical(0, tr("Unable to save settings"),
-                                  tr("There was an error changing the outdev.\nPlease report this bug."),
-                                  QMessageBox::Ok);
-        }
+        _settings->setValue("outdev", noutdev);
     }
     if (nringdev != ringdev)
     {
-        if (g_FSHost.sendCmd("pa", QString("ringdev #%1").arg(nringdev).toAscii().constData(), &result) == SWITCH_STATUS_SUCCESS)
-        {
-            _settings->setValue("ringdev", nringdev);
-        }
-        else
-        {
-            switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error setting ringdev from #%d to #%d on mod_portaudio!\n",
-                              nringdev, nringdev);
-            QMessageBox::critical(0, tr("Unable to save settings"),
-                                  tr("There was an error changing the ringdev.\nPlease report this bug."),
-                                  QMessageBox::Ok);
-        }
+        _settings->setValue("ringdev", nringdev);
     }
 
     _settings->endGroup();

Modified: freeswitch/trunk/fscomm/prefportaudio.h (16167 => 16168)


--- freeswitch/trunk/fscomm/prefportaudio.h	2010-01-06 03:04:04 UTC (rev 16167)
+++ freeswitch/trunk/fscomm/prefportaudio.h	2010-01-06 03:45:00 UTC (rev 16168)
@@ -15,6 +15,12 @@
     void writeConfig();
     void readConfig();
 
+private slots:
+    void ringFileChoose();
+    void holdFileChoose();
+    void outdevChangeDev(int);
+    void ringdevChangeDev(int);
+
 private:
     void getPaDevlist(void);
     QSettings *_settings;