4
* Copyright (c) 2000 Stefan Schimanski <1Stein@gmx.de>
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27
#include <qgroupbox.h>
28
#include <qcheckbox.h>
29
#include <qlistview.h>
30
#include <qpushbutton.h>
39
#include <qtextstream.h>
40
#include <kiconloader.h>
42
#include <kmessagebox.h>
43
#include <knuminput.h>
44
#include <qwhatsthis.h>
45
#include <qprogressdialog.h>
47
#include "mixconfig.h"
49
KMixConfig::KMixConfig(QWidget *parent, const char *name)
50
: KCModule(parent, name)
52
QVBoxLayout *topLayout = new QVBoxLayout(this, 5);
55
QGroupBox *restGrp = new QGroupBox( i18n("Default Volumes"), this );
56
topLayout->addWidget( restGrp );
57
QBoxLayout *restLayout =
58
new QVBoxLayout( restGrp, KDialog::marginHint(), KDialog::spacingHint());
59
restLayout->addSpacing( fontMetrics().lineSpacing() );
62
QHBoxLayout *profLayout = new QHBoxLayout( restLayout, 5 );
63
QPushButton *saveProf = new QPushButton( i18n("Save current volumes"), restGrp );
64
profLayout->addWidget( saveProf );
65
connect( saveProf, SIGNAL(clicked()), this, SLOT(saveVolumes()) );
68
QPushButton *loadProf = new QPushButton( i18n("Load volumes"), restGrp );
69
profLayout->addWidget( loadProf );
70
connect( loadProf, SIGNAL(clicked()), this, SLOT(loadVolumes()) );
73
m_startkdeRestore = new QCheckBox( i18n("Load volumes on login"), restGrp );
74
restLayout->addWidget( m_startkdeRestore );
75
connect( m_startkdeRestore, SIGNAL(clicked()), this, SLOT(configChanged()) );
78
QGroupBox *hdwGrp = new QGroupBox( i18n("Hardware Settings"), this );
79
topLayout->addWidget( hdwGrp );
80
QBoxLayout *hdwLayout =
81
new QVBoxLayout( hdwGrp, KDialog::marginHint(), KDialog::spacingHint());
82
hdwLayout->addSpacing( fontMetrics().lineSpacing() );
84
m_maxCards = new KIntNumInput( hdwGrp );
85
m_maxCards->setLabel( i18n("Maximum number of probed mixers") );
86
m_maxCards->setRange( 1, 16 );
87
hdwLayout->addWidget( m_maxCards );
88
connect( m_maxCards, SIGNAL(valueChanged(int)), this, SLOT(configChanged()) );
89
QWhatsThis::add( m_maxCards, i18n("Change this value to optimize the startup time "
91
"High values mean that kmix probes for "
92
"many soundcards. If you have more mixers "
93
"installed than kmix detects, increase this "
96
m_maxDevices = new KIntNumInput( hdwGrp );
97
m_maxDevices->setLabel( i18n("Maximum number of probed devices per mixer") );
98
m_maxDevices->setRange( 1, 16 );
99
hdwLayout->addWidget( m_maxDevices );
100
connect( m_maxDevices, SIGNAL(valueChanged(int)), this, SLOT(configChanged()) );
101
QWhatsThis::add( m_maxDevices,
102
i18n("Change this value to optimize the startup time "
103
"of kmix. High values mean that kmix probes for "
104
"many devices per soundcard driver.\n"
105
"If there are more mixer sub devices in a "
106
"driver than kmix detects, increase this value") );
108
topLayout->addStretch( 1 );
113
KMixConfig::~KMixConfig() {}
115
void KMixConfig::configChanged()
120
void KMixConfig::loadVolumes()
122
QProgressDialog progress( i18n("Restoring default volumes"), i18n("Cancel"), 1, this );
123
KProcess *ctrl = new KProcess;
124
QString ctrlExe = KGlobal::dirs()->findExe("kmixctrl");
127
kdDebug() << "can't find kmixctrl" << endl;
129
KMessageBox::sorry ( this, i18n("The kmixctrl executable can't be found.") );
134
*ctrl << "--restore";
137
while ( ctrl->isRunning() )
139
if ( progress.wasCancelled() ) break;
140
kapp->processEvents();
142
progress.setProgress( 1 );
147
void KMixConfig::saveVolumes()
149
QProgressDialog progress( i18n("Saving default volumes"), i18n("Cancel"), 1, this );
150
KProcess *ctrl = new KProcess;
151
QString ctrlExe = KGlobal::dirs()->findExe("kmixctrl");
154
kdDebug() << "can't find kmixctrl" << endl;
156
KMessageBox::sorry ( this, i18n("The kmixctrl executable can't be found.") );
164
while ( ctrl->isRunning() )
166
if ( progress.wasCancelled() ) break;
167
kapp->processEvents();
169
progress.setProgress( 1 );
174
void KMixConfig::load()
176
KConfig *config = new KConfig("kcmkmixrc", true);
178
config->setGroup("Misc");
179
m_startkdeRestore->setChecked( config->readBoolEntry( "startkdeRestore", true ) );
180
m_maxCards->setValue( config->readNumEntry( "maxCards", 2 ) );
181
m_maxDevices->setValue( config->readNumEntry( "maxDevices", 2 ) );
187
void KMixConfig::save()
190
KConfig *config= new KConfig("kcmkmixrc", false);
192
config->setGroup("Misc");
193
config->writeEntry( "startkdeRestore", m_startkdeRestore->isChecked() );
194
config->writeEntry( "maxCards", m_maxCards->value() );
195
config->writeEntry( "maxDevices", m_maxDevices->value() );
202
void KMixConfig::defaults()
204
m_startkdeRestore->setChecked( true );
205
m_maxCards->setValue( 2 );
206
m_maxDevices->setValue( 2 );
212
KCModule *create_kmix(QWidget *parent, const char *name)
214
KGlobal::locale()->insertCatalogue("kcmkmix");
215
return new KMixConfig(parent, name);
220
KConfig *config = new KConfig("kcmkmixrc", true, false);
222
config->setGroup("Misc");
223
bool start = config->readBoolEntry( "startkdeRestore", true );
227
kapp->startServiceByDesktopName( "kmixctrl_restore" );
231
#include "mixconfig.moc"