summaryrefslogtreecommitdiffstats
path: root/plugins/oss-sound/oss-sound-configuration.cpp
blob: ace3048e2a35bf252ba3dd3b945c524bab545d90 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/***************************************************************************
                       oss-sound-configuration.cpp  -  description
                             -------------------
    begin                : Thu Sep 30 2004
    copyright            : (C) 2004 by Martin Witte
    email                : witte@kawo1.rwth-aachen.de
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/

#include <tqcheckbox.h>

#include <kurlrequester.h>
#include <knuminput.h>

#include "oss-sound-configuration.h"
#include "oss-sound.h"

OSSSoundConfiguration::OSSSoundConfiguration (TQWidget *parent, OSSSoundDevice *dev)
 : OSSSoundConfigurationUI(parent),
   m_SoundDevice (dev),
   m_dirty(true),
   m_ignore_gui_updates(false)
{
    connect(editDSPDevice,      TQ_SIGNAL(textChanged(const TQString &)), this, TQ_SLOT(slotSetDirty()));
    connect(editMixerDevice,    TQ_SIGNAL(textChanged(const TQString &)), this, TQ_SLOT(slotSetDirty()));
    connect(editBufferSize,     TQ_SIGNAL(valueChanged(int)),            this, TQ_SLOT(slotSetDirty()));
    connect(chkDisablePlayback, TQ_SIGNAL(toggled(bool)),                this, TQ_SLOT(slotSetDirty()));
    connect(chkDisableCapture,  TQ_SIGNAL(toggled(bool)),                this, TQ_SLOT(slotSetDirty()));
    slotCancel();
}


OSSSoundConfiguration::~OSSSoundConfiguration ()
{
}


void OSSSoundConfiguration::slotOK()
{
    if (m_SoundDevice && m_dirty) {
        m_SoundDevice->setBufferSize     ( editBufferSize    ->value() * 1024);
        m_SoundDevice->enablePlayback    (!chkDisablePlayback->isChecked());
        m_SoundDevice->enableCapture     (!chkDisableCapture ->isChecked());
        m_SoundDevice->setDSPDeviceName  ( editDSPDevice     ->url());
        m_SoundDevice->setMixerDeviceName( editMixerDevice   ->url());
        m_dirty = false;
    }
}


void OSSSoundConfiguration::slotCancel()
{
    if (m_dirty) {
        m_ignore_gui_updates = true;
        editDSPDevice     ->setURL    (m_SoundDevice ?  m_SoundDevice->getDSPDeviceName()   : TQString());
        editMixerDevice   ->setURL    (m_SoundDevice ?  m_SoundDevice->getMixerDeviceName() : TQString());
        editBufferSize    ->setValue  (m_SoundDevice ?  m_SoundDevice->getBufferSize()/1024 : 4);
        chkDisablePlayback->setChecked(m_SoundDevice ? !m_SoundDevice->isPlaybackEnabled()  : false);
        chkDisableCapture ->setChecked(m_SoundDevice ? !m_SoundDevice->isCaptureEnabled()   : false);
        m_ignore_gui_updates = false;
        m_dirty = false;
    }
}

void OSSSoundConfiguration::slotUpdateConfig()
{
    slotSetDirty();
    slotCancel();
}

void OSSSoundConfiguration::slotSetDirty()
{
    if (!m_ignore_gui_updates) {
        m_dirty = true;
    }
}

#include "oss-sound-configuration.moc"