summaryrefslogtreecommitdiffstats
path: root/kscd/configWidget.cpp
blob: 3a1ceff5e39679d0577844a5a76bbbfbbb7ed280 (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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
/*
 * configWidget - the config dialog page for KSCD settings
 *
 * $Id:
 *
 * Copyright (c) 2002 Aaron J. Seigo <aseigo@kde.org>
 * Copyright (c) 2004 Alexander Kern <alex.kern@gmx.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, or (at your option)
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 *
 */

#include <kdebug.h>
#include <klineedit.h>
#include <dcopref.h>
#include <kurlrequester.h>
#include <tqcheckbox.h>
#include <kcombobox.h>
#include <tqlayout.h>

#include <config.h>
extern "C" {
    // We don't have libWorkMan installed already, so get everything
    // from within our own directory
#include "libwm/include/wm_config.h"
}


#include "configWidget.h"
#include "kscd.h"
#include "prefs.h"

class SpecialComboBox : public KComboBox
{
public:
  SpecialComboBox(TQWidget* parent, const char* name)
   : KComboBox(parent, name)
   {}

  // TQComboBox::setCurrentText replaces the current text if
  // the list doesn't contain text, while
  // KComboBox::setCurrentItem doesn't
  void setCurrentText(const TQString& text)
  {
    setCurrentItem(text);
  }
} ;

/*
 *  Constructs a configWidget which is a child of 'parent', with the
 *  name 'name' and widget flags set to 'f'.
 *
 *  The dialog will by default be modeless, unless you set 'modal' to
 *  TRUE to construct a modal dialog.
 */
configWidget::configWidget(KSCD* player, TQWidget* parent, const char* name)
    : configWidgetUI(parent, name),
      mPlayer(player)
{
    if (!name)
    {
        setName("configWidget");
    }

    kcfg_cdDevice->comboBox()->setEditable(true);
    kcfg_cdDevice->comboBox()->insertItem(DEFAULT_CD_DEVICE);
    getMediaDevices();

    (new TQVBoxLayout(audioSystemFrame))->setAutoAdd(true);
    kcfg_AudioSystem = new SpecialComboBox(audioSystemFrame, "kcfg_AudioSystem");
    textLabel4->setBuddy(kcfg_AudioSystem);
    
#if defined(BUILD_CDDA)
    kcfg_DigitalPlayback_toggled(Prefs::digitalPlayback());
    
    // fill ComboBox audioBackend
    kcfg_AudioSystem->insertStringList(mPlayer->audioSystems());
#else
    kcfg_DigitalPlayback_toggled(false);
    
    kcfg_DigitalPlayback->setChecked(false);
    kcfg_DigitalPlayback->hide();
#endif
    kcfg_SelectEncoding_toggled(Prefs::selectEncoding());
}

configWidget::~configWidget()
{
}

void configWidget::kcfg_DigitalPlayback_toggled(bool toggle)
{
    kcfg_AudioSystem->setEnabled(toggle);
    textLabel4->setEnabled(toggle);
    kcfg_AudioDevice->setEnabled(toggle);
    textLabel5->setEnabled(toggle);
}

void configWidget::getMediaDevices()
{
    DCOPRef ref("kded","mediamanager");
    DCOPReply rep = ref.call("fullList()");
    if (!rep.isValid()) {
        return;
    }
    TQStringList list = rep;
    TQStringList::const_iterator it = list.begin();
    TQStringList::const_iterator itEnd = list.end();
    // it would be much better if libmediacommon was in tdelibs
    while (it != itEnd) {
        it++;
        if (it == itEnd) break;
        TQString url="media:/"+(*it); // is it always right? ervin?
        kdDebug() << "checking " << url << endl;
        for (int i=0;i<9;i++) ++it;  // go to mimetype (MIME_TYPE-NAME from medium.h)
        kdDebug() << "Mime: " << *it << endl;
        if (it!=itEnd && (*it)=="media/audiocd") {
            kcfg_cdDevice->comboBox()->insertItem(url);
        }
        while (it !=itEnd && (*it)!="---") ++it;  // go to end of current device's properties
        ++it;
    }
}
 

void configWidget::kcfg_SelectEncoding_toggled(bool toggle)
{
    kcfg_SelectedEncoding->setEnabled(toggle);
}

#include "configWidget.moc"