summaryrefslogtreecommitdiff
path: root/src/ui/preferencesdlg.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/preferencesdlg.cpp')
-rw-r--r--src/ui/preferencesdlg.cpp142
1 files changed, 120 insertions, 22 deletions
diff --git a/src/ui/preferencesdlg.cpp b/src/ui/preferencesdlg.cpp
index fa69bd3..9797c93 100644
--- a/src/ui/preferencesdlg.cpp
+++ b/src/ui/preferencesdlg.cpp
@@ -29,22 +29,32 @@ static TQString autostartPath()
#include "../model/alsadevice.h"
#endif
+#ifdef WITH_OSS
+#include "../model/ossmodel.h"
+#include "../model/ossdevice.h"
+#endif
+
+#define PREFS_INIT_LIST \
+ m_backend(0), m_dockInTray(0), m_popupMode(0), \
+ m_scrollStep(0), m_confirmQuit(0), m_middleClickMute(0), \
+ m_startOnLogin(0), m_backendStack(0), \
+ m_popupShowOutput(0), m_popupShowMic(0), m_popupShowApps(0), \
+ m_showRecTray(0), \
+ m_noTabs(0), m_showTabsLabel(0), m_showOutput(0), m_showInput(0), \
+ m_showPlayback(0), m_showRecording(0)
+
// ── Pulse constructor ─────────────────────────────────────────────────────────
PreferencesDlg::PreferencesDlg( TQWidget *parent )
: KDialogBase( Tabbed, i18n("Configure TMix"),
Ok | Apply | Cancel, Ok, parent, 0, false ),
- m_backend(0), m_dockInTray(0), m_popupMode(0),
- m_scrollStep(0), m_confirmQuit(0), m_middleClickMute(0),
- m_startOnLogin(0),
- m_backendStack(0),
- m_popupShowOutput(0), m_popupShowMic(0), m_popupShowApps(0),
- m_showRecTray(0),
- m_noTabs(0), m_showTabsLabel(0), m_showOutput(0), m_showInput(0),
- m_showPlayback(0), m_showRecording(0)
+ PREFS_INIT_LIST
#ifdef WITH_ALSA
, m_alsaModel(0), m_trayDevice(0)
#endif
+#ifdef WITH_OSS
+ , m_ossModel(0), m_ossTrayDevice(0)
+#endif
{
buildGeneralPage();
buildBackendPage();
@@ -58,15 +68,31 @@ PreferencesDlg::PreferencesDlg( TQWidget *parent )
PreferencesDlg::PreferencesDlg( AlsaModel *model, TQWidget *parent )
: KDialogBase( Tabbed, i18n("Configure TMix"),
Ok | Apply | Cancel, Ok, parent, 0, false ),
- m_backend(0), m_dockInTray(0), m_popupMode(0),
- m_scrollStep(0), m_confirmQuit(0), m_middleClickMute(0),
- m_startOnLogin(0),
- m_backendStack(0),
- m_popupShowOutput(0), m_popupShowMic(0), m_popupShowApps(0),
- m_showRecTray(0),
- m_noTabs(0), m_showTabsLabel(0), m_showOutput(0), m_showInput(0),
- m_showPlayback(0), m_showRecording(0),
+ PREFS_INIT_LIST,
m_alsaModel(model), m_trayDevice(0)
+#ifdef WITH_OSS
+ , m_ossModel(0), m_ossTrayDevice(0)
+#endif
+{
+ buildGeneralPage();
+ buildBackendPage();
+ load();
+}
+
+#endif
+
+#ifdef WITH_OSS
+
+// ── OSS constructor ───────────────────────────────────────────────────────────
+
+PreferencesDlg::PreferencesDlg( OssModel *model, TQWidget *parent )
+ : KDialogBase( Tabbed, i18n("Configure TMix"),
+ Ok | Apply | Cancel, Ok, parent, 0, false ),
+ PREFS_INIT_LIST
+#ifdef WITH_ALSA
+ , m_alsaModel(0), m_trayDevice(0)
+#endif
+ , m_ossModel(model), m_ossTrayDevice(0)
{
buildGeneralPage();
buildBackendPage();
@@ -85,9 +111,17 @@ void PreferencesDlg::buildGeneralPage()
TQHBoxLayout *backendRow = new TQHBoxLayout( 0, 0, spacingHint() );
backendRow->addWidget( new TQLabel( i18n("Audio backend:"), gen ) );
m_backend = new TQComboBox( false, gen );
+#ifdef WITH_PULSE
m_backend->insertItem( i18n("PulseAudio") );
+ m_backendIds << "pulse";
+#endif
#ifdef WITH_ALSA
m_backend->insertItem( i18n("ALSA") );
+ m_backendIds << "alsa";
+#endif
+#ifdef WITH_OSS
+ m_backend->insertItem( i18n("OSS") );
+ m_backendIds << "oss";
#endif
backendRow->addWidget( m_backend );
backendRow->addStretch();
@@ -204,10 +238,11 @@ void PreferencesDlg::buildBackendPage()
pl->addWidget( viewBox );
pl->addStretch();
- m_backendStack->addWidget( pulseWidget, 0 );
+ int nextPage = 0;
+ m_backendStack->addWidget( pulseWidget, nextPage++ );
#ifdef WITH_ALSA
- // ── ALSA page (stack index 1) ─────────────────────────────────────────────
+ // ── ALSA page ────────────────────────────────────────────────────────────
TQWidget *alsaWidget = new TQWidget( m_backendStack );
TQVBoxLayout *al = new TQVBoxLayout( alsaWidget, 0, spacingHint() );
@@ -235,14 +270,46 @@ void PreferencesDlg::buildBackendPage()
al->addLayout( trayRow );
al->addStretch();
- m_backendStack->addWidget( alsaWidget, 1 );
+ m_backendStack->addWidget( alsaWidget, nextPage++ );
+#endif
+
+#ifdef WITH_OSS
+ // ── OSS page ─────────────────────────────────────────────────────────────
+ TQWidget *ossWidget = new TQWidget( m_backendStack );
+ TQVBoxLayout *ol = new TQVBoxLayout( ossWidget, 0, spacingHint() );
+
+ TQHBoxLayout *ossTrayRow = new TQHBoxLayout( 0, 0, spacingHint() );
+ ossTrayRow->addWidget( new TQLabel( i18n("Tray device:"), ossWidget ) );
+ m_ossTrayDevice = new TQComboBox( false, ossWidget );
+
+ if ( m_ossModel ) {
+ TQPtrList<OssDevice> devs = m_ossModel->devices();
+ for ( TQPtrListIterator<OssDevice> it(devs); *it; ++it ) {
+ OssDevice *dev = *it;
+ if ( dev->category() == OssDevice::Output ) {
+ m_ossTrayDevice->insertItem(
+ TQString("%1 - %2").arg(dev->cardPath()).arg(dev->name()) );
+ m_ossTrayCardIndices.append( dev->cardIndex() );
+ m_ossTrayDeviceNames.append( dev->name() );
+ }
+ }
+ } else {
+ m_ossTrayDevice->setEnabled( false );
+ }
+
+ ossTrayRow->addWidget( m_ossTrayDevice, 1 );
+ ol->addLayout( ossTrayRow );
+ ol->addStretch();
+
+ m_backendStack->addWidget( ossWidget, nextPage++ );
#endif
// Show the page matching the current backend
TDEConfig *cfg = TDEGlobal::config();
cfg->setGroup("General");
TQString backend = cfg->readEntry("Backend", "pulse");
- m_backendStack->raiseWidget( backend == "alsa" ? 1 : 0 );
+ int backendPage = m_backendIds.findIndex(backend);
+ m_backendStack->raiseWidget( backendPage >= 0 ? backendPage : 0 );
connect( m_backend, TQ_SIGNAL(activated(int)),
this, TQ_SLOT(onBackendComboChanged(int)) );
@@ -283,7 +350,8 @@ void PreferencesDlg::load()
cfg->setGroup("General");
TQString backend = cfg->readEntry("Backend", "pulse");
- m_backend->setCurrentItem( backend == "alsa" ? 1 : 0 );
+ int backendIdx = m_backendIds.findIndex(backend);
+ m_backend->setCurrentItem( backendIdx >= 0 ? backendIdx : 0 );
m_confirmQuit->setChecked( cfg->readBoolEntry("ConfirmQuit", false) );
m_startOnLogin->setChecked( TQFile::exists( autostartPath() ) );
@@ -322,13 +390,31 @@ void PreferencesDlg::load()
}
}
#endif
+
+#ifdef WITH_OSS
+ if ( m_ossTrayDevice && !m_ossTrayCardIndices.isEmpty() ) {
+ cfg->setGroup("OssTray");
+ int preferredCard = cfg->readNumEntry("TrayCard", -1);
+ TQString preferredName = cfg->readEntry( "TrayDevice", "");
+ TQValueListConstIterator<int> ci = m_ossTrayCardIndices.begin();
+ TQValueListConstIterator<TQString> ni = m_ossTrayDeviceNames.begin();
+ for ( int i = 0; ci != m_ossTrayCardIndices.end(); ++ci, ++ni, ++i ) {
+ if ( *ci == preferredCard && *ni == preferredName ) {
+ m_ossTrayDevice->setCurrentItem(i);
+ break;
+ }
+ }
+ }
+#endif
}
void PreferencesDlg::save()
{
TDEConfig *cfg = TDEGlobal::config();
cfg->setGroup("General");
- cfg->writeEntry( "Backend", m_backend->currentItem() == 1 ? "alsa" : "pulse" );
+ int bi = m_backend->currentItem();
+ TQString backendKey = (bi >= 0 && bi < (int)m_backendIds.count()) ? m_backendIds[bi] : "pulse";
+ cfg->writeEntry( "Backend", backendKey );
cfg->writeEntry( "ConfirmQuit", m_confirmQuit->isChecked() );
// Autostart: create or remove ~/.trinity/Autostart/tmix.desktop
@@ -378,6 +464,18 @@ void PreferencesDlg::save()
}
#endif
+#ifdef WITH_OSS
+ if ( m_ossTrayDevice && m_ossModel ) {
+ int ti = m_ossTrayDevice->currentItem();
+ if ( ti >= 0 && ti < (int)m_ossTrayCardIndices.count() ) {
+ TQValueListConstIterator<int> ci = m_ossTrayCardIndices.begin();
+ TQValueListConstIterator<TQString> ni = m_ossTrayDeviceNames.begin();
+ for ( int i = 0; i < ti; ++i ) { ++ci; ++ni; }
+ m_ossModel->setPreferredOutput( *ci, *ni );
+ }
+ }
+#endif
+
cfg->sync();
emit settingsChanged();
}