You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
268 lines
9.1 KiB
268 lines
9.1 KiB
15 years ago
|
/*
|
||
|
Copyright (C) 2001 Carsten Duvenhorst <duvenhorst@m2.uni-hannover.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.
|
||
|
|
||
|
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
|
||
15 years ago
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||
15 years ago
|
*/
|
||
|
|
||
12 years ago
|
#include <tdeconfig.h>
|
||
15 years ago
|
#include <klineedit.h>
|
||
|
#include <klocale.h>
|
||
|
|
||
15 years ago
|
#include <tqcheckbox.h>
|
||
|
#include <tqcombobox.h>
|
||
|
#include <tqgroupbox.h>
|
||
|
#include <tqslider.h>
|
||
|
#include <tqtabwidget.h>
|
||
15 years ago
|
#include <kaboutdata.h>
|
||
|
#include <knuminput.h>
|
||
15 years ago
|
#include <tqregexp.h>
|
||
|
#include <tqlabel.h>
|
||
15 years ago
|
|
||
|
#include <audiocdencoder.h>
|
||
|
#include "kcmaudiocd.moc"
|
||
12 years ago
|
#include <tdeconfigdialogmanager.h>
|
||
15 years ago
|
|
||
13 years ago
|
KAudiocdModule::KAudiocdModule(TQWidget *parent, const char *name)
|
||
|
: AudiocdConfig(parent, name), configChanged(false)
|
||
15 years ago
|
{
|
||
15 years ago
|
TQString foo = i18n("Report errors found on the cd.");
|
||
15 years ago
|
|
||
|
setButtons(Default|Apply);
|
||
|
|
||
12 years ago
|
config = new TDEConfig("kcmaudiocdrc");
|
||
15 years ago
|
|
||
15 years ago
|
TQPtrList<AudioCDEncoder> encoders;
|
||
15 years ago
|
AudioCDEncoder::findAllPlugins(0, encoders);
|
||
|
AudioCDEncoder *encoder;
|
||
|
for ( encoder = encoders.first(); encoder; encoder = encoders.next() ){
|
||
|
if (encoder->init()) {
|
||
12 years ago
|
TDEConfigSkeleton *config = NULL;
|
||
15 years ago
|
TQWidget *widget = encoder->getConfigureWidget(&config);
|
||
15 years ago
|
if(widget && config){
|
||
13 years ago
|
tabWidget->addTab(widget, i18n("%1 Encoder").arg(encoder->type()));
|
||
12 years ago
|
TDEConfigDialogManager *configManager = new TDEConfigDialogManager(widget, config, TQString(encoder->type()+" EncoderConfigManager").latin1());
|
||
15 years ago
|
encoderSettings.append(configManager);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
load();
|
||
|
|
||
12 years ago
|
TDEConfigDialogManager *widget;
|
||
15 years ago
|
for ( widget = encoderSettings.first(); widget; widget = encoderSettings.next() ){
|
||
15 years ago
|
connect(widget, TQT_SIGNAL(widgetModified()), this, TQT_SLOT(slotModuleChanged()));
|
||
15 years ago
|
}
|
||
|
|
||
|
//CDDA Options
|
||
15 years ago
|
connect(cd_specify_device,TQT_SIGNAL(clicked()),this,TQT_SLOT(slotConfigChanged()));
|
||
|
connect(ec_enable_check,TQT_SIGNAL(clicked()),this,TQT_SLOT(slotEcEnable()));
|
||
|
connect(ec_skip_check,TQT_SIGNAL(clicked()),TQT_SLOT(slotConfigChanged()));
|
||
|
connect(cd_device_string,TQT_SIGNAL(textChanged(const TQString &)),TQT_SLOT(slotConfigChanged()));
|
||
|
connect(niceLevel,TQT_SIGNAL(valueChanged(int)),TQT_SLOT(slotConfigChanged()));
|
||
15 years ago
|
|
||
|
// File Name
|
||
15 years ago
|
connect(fileNameLineEdit, TQT_SIGNAL(textChanged(const TQString &)), this, TQT_SLOT(slotConfigChanged()));
|
||
|
connect(albumNameLineEdit, TQT_SIGNAL(textChanged(const TQString &)), this, TQT_SLOT(slotConfigChanged()));
|
||
|
connect( kcfg_replaceInput, TQT_SIGNAL( textChanged(const TQString&) ), this, TQT_SLOT( updateExample() ) );
|
||
|
connect( kcfg_replaceOutput, TQT_SIGNAL( textChanged(const TQString&) ), this, TQT_SLOT( updateExample() ) );
|
||
|
connect( example, TQT_SIGNAL( textChanged(const TQString&) ), this, TQT_SLOT( updateExample() ) );
|
||
|
connect( kcfg_replaceInput, TQT_SIGNAL( textChanged(const TQString&) ), this, TQT_SLOT( slotConfigChanged() ) );
|
||
|
connect( kcfg_replaceOutput, TQT_SIGNAL( textChanged(const TQString&) ), this, TQT_SLOT( slotConfigChanged() ) );
|
||
|
connect( example, TQT_SIGNAL( textChanged(const TQString&) ), this, TQT_SLOT( slotConfigChanged() ) );
|
||
15 years ago
|
|
||
12 years ago
|
TDEAboutData *about =
|
||
|
new TDEAboutData(I18N_NOOP("kcmaudiocd"), I18N_NOOP("TDE Audio CD IO Slave"),
|
||
|
0, 0, TDEAboutData::License_GPL,
|
||
15 years ago
|
I18N_NOOP("(c) 2000 - 2005 Audio CD developers"));
|
||
|
|
||
|
about->addAuthor("Benjamin C. Meyer", I18N_NOOP("Current Maintainer"), "ben@meyerhome.net");
|
||
|
about->addAuthor("Carsten Duvenhorst", 0, "duvenhorst@duvnet.de");
|
||
|
setAboutData(about);
|
||
|
}
|
||
|
|
||
|
KAudiocdModule::~KAudiocdModule()
|
||
|
{
|
||
|
delete config;
|
||
|
}
|
||
|
|
||
15 years ago
|
TQString removeQoutes(const TQString& text)
|
||
15 years ago
|
{
|
||
15 years ago
|
TQString deqoutedString=text;
|
||
|
TQRegExp qoutedStringRegExp("^\".*\"$");
|
||
15 years ago
|
if (qoutedStringRegExp.exactMatch(text))
|
||
|
{
|
||
|
deqoutedString=text.mid(1, text.length()-2);
|
||
|
}
|
||
|
return deqoutedString;
|
||
|
}
|
||
|
|
||
15 years ago
|
bool needsQoutes(const TQString& text)
|
||
15 years ago
|
{
|
||
15 years ago
|
TQRegExp spaceAtTheBeginning("^\\s+.*$");
|
||
|
TQRegExp spaceAtTheEnd("^.*\\s+$");
|
||
15 years ago
|
return (spaceAtTheBeginning.exactMatch(text) || spaceAtTheEnd.exactMatch(text));
|
||
|
|
||
|
|
||
|
}
|
||
|
|
||
|
void KAudiocdModule::updateExample()
|
||
|
{
|
||
15 years ago
|
TQString text = example->text();
|
||
|
TQString deqoutedReplaceInput=removeQoutes(kcfg_replaceInput->text());
|
||
|
TQString deqoutedReplaceOutput=removeQoutes(kcfg_replaceOutput->text());
|
||
15 years ago
|
|
||
13 years ago
|
text.replace( TQRegExp(deqoutedReplaceInput), deqoutedReplaceOutput );
|
||
15 years ago
|
exampleOutput->setText(text);
|
||
|
}
|
||
|
|
||
|
void KAudiocdModule::defaults() {
|
||
|
load( false );
|
||
|
}
|
||
|
|
||
|
void KAudiocdModule::save() {
|
||
|
if (!configChanged ) return;
|
||
|
|
||
|
{
|
||
12 years ago
|
TDEConfigGroupSaver saver(config, "CDDA");
|
||
15 years ago
|
|
||
|
// autosearch is the name of the config option, which has the
|
||
|
// reverse sense of the current text of the configuration option,
|
||
|
// which is specify the device. Therefore, invert the value on write.
|
||
|
//
|
||
|
config->writeEntry("autosearch", !(cd_specify_device->isChecked()) );
|
||
|
config->writeEntry("device",cd_device_string->text());
|
||
|
config->writeEntry("disable_paranoia",!(ec_enable_check->isChecked()));
|
||
|
config->writeEntry("never_skip",!(ec_skip_check->isChecked()));
|
||
|
config->writeEntry("niceLevel", niceLevel->value());
|
||
|
}
|
||
|
|
||
|
{
|
||
12 years ago
|
TDEConfigGroupSaver saver(config, "FileName");
|
||
15 years ago
|
config->writeEntry("file_name_template", fileNameLineEdit->text());
|
||
|
config->writeEntry("album_name_template", albumNameLineEdit->text());
|
||
|
config->writeEntry("regexp_example", example->text());
|
||
|
// save qouted if required
|
||
15 years ago
|
TQString replaceInput=kcfg_replaceInput->text();
|
||
|
TQString replaceOutput=kcfg_replaceOutput->text();
|
||
15 years ago
|
if (needsQoutes(replaceInput))
|
||
|
{
|
||
15 years ago
|
replaceInput=TQString("\"")+replaceInput+TQString("\"");
|
||
15 years ago
|
}
|
||
|
if (needsQoutes(replaceOutput))
|
||
|
{
|
||
15 years ago
|
replaceOutput=TQString("\"")+replaceOutput+TQString("\"");
|
||
15 years ago
|
}
|
||
|
config->writeEntry("regexp_search", replaceInput);
|
||
13 years ago
|
config->writeEntry("regexp_replace", replaceOutput);
|
||
15 years ago
|
}
|
||
|
|
||
12 years ago
|
TDEConfigDialogManager *widget;
|
||
15 years ago
|
for ( widget = encoderSettings.first(); widget; widget = encoderSettings.next() ){
|
||
|
widget->updateSettings();
|
||
|
}
|
||
|
|
||
|
config->sync();
|
||
|
|
||
|
configChanged = false;
|
||
|
|
||
|
}
|
||
|
|
||
|
void KAudiocdModule::load() {
|
||
|
load( false );
|
||
|
}
|
||
|
|
||
|
void KAudiocdModule::load(bool useDefaults) {
|
||
|
|
||
|
config->setReadDefaults( useDefaults );
|
||
|
|
||
|
{
|
||
12 years ago
|
TDEConfigGroupSaver saver(config, "CDDA");
|
||
15 years ago
|
|
||
|
|
||
|
// Specify <=> not autosearch, as explained above in ::save()
|
||
|
cd_specify_device->setChecked( !(config->readBoolEntry("autosearch",true)) );
|
||
|
cd_device_string->setText(config->readEntry("device","/dev/cdrom"));
|
||
|
ec_enable_check->setChecked(!(config->readBoolEntry("disable_paranoia",false)));
|
||
|
ec_skip_check->setChecked(!(config->readBoolEntry("never_skip",true)));
|
||
|
niceLevel->setValue(config->readNumEntry("niceLevel", 0));
|
||
|
}
|
||
|
|
||
|
{
|
||
12 years ago
|
TDEConfigGroupSaver saver(config, "FileName");
|
||
15 years ago
|
fileNameLineEdit->setText(config->readEntry("file_name_template", "%{albumartist} - %{number} - %{title}"));
|
||
|
albumNameLineEdit->setText(config->readEntry("album_name_template", "%{albumartist} - %{albumtitle}"));
|
||
|
kcfg_replaceInput->setText(config->readEntry("regexp_search"));
|
||
13 years ago
|
kcfg_replaceOutput->setText(config->readEntry("regexp_replace"));
|
||
15 years ago
|
example->setText(config->readEntry("example", i18n("Cool artist - example audio file.wav")));
|
||
|
}
|
||
|
|
||
12 years ago
|
TDEConfigDialogManager *widget;
|
||
15 years ago
|
for ( widget = encoderSettings.first(); widget; widget = encoderSettings.next() ){
|
||
|
widget->updateWidgets();
|
||
|
}
|
||
|
|
||
|
emit changed( useDefaults );
|
||
|
}
|
||
|
|
||
|
void KAudiocdModule::slotModuleChanged() {
|
||
12 years ago
|
TDEConfigDialogManager *widget;
|
||
15 years ago
|
for ( widget = encoderSettings.first(); widget; widget = encoderSettings.next() ){
|
||
|
if(widget->hasChanged()){
|
||
|
slotConfigChanged();
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
void KAudiocdModule::slotConfigChanged() {
|
||
|
configChanged = true;
|
||
|
emit changed(true);
|
||
|
}
|
||
|
|
||
|
/*
|
||
|
# slot for the error correction settings
|
||
|
*/
|
||
|
void KAudiocdModule::slotEcEnable() {
|
||
|
if (!(ec_skip_check->isChecked())) {
|
||
|
ec_skip_check->setChecked(true);
|
||
|
} else {
|
||
|
if (ec_skip_check->isEnabled()) {
|
||
|
ec_skip_check->setChecked(false);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
slotConfigChanged();
|
||
|
}
|
||
|
|
||
15 years ago
|
TQString KAudiocdModule::quickHelp() const
|
||
15 years ago
|
{
|
||
|
return i18n("<h1>Audio CDs</h1> The Audio CD IO-Slave enables you to easily"
|
||
|
" create wav, MP3 or Ogg Vorbis files from your audio CD-ROMs or DVDs."
|
||
|
" The slave is invoked by typing <i>\"audiocd:/\"</i> in Konqueror's location"
|
||
|
" bar. In this module, you can configure"
|
||
|
" encoding, and device settings. Note that MP3 and Ogg"
|
||
13 years ago
|
" Vorbis encoding are only available if TDE was built with a recent"
|
||
15 years ago
|
" version of the LAME or Ogg Vorbis libraries.");
|
||
|
}
|
||
|
|
||
|
extern "C"
|
||
|
{
|
||
12 years ago
|
TDECModule *create_audiocd(TQWidget *parent, const char */*name*/)
|
||
15 years ago
|
{
|
||
13 years ago
|
return new KAudiocdModule(parent, "kcmaudiocd");
|
||
15 years ago
|
}
|
||
|
|
||
|
}
|