2011-04-17 01:04:15 +02:00
|
|
|
/* This file is part of Clementine.
|
|
|
|
Copyright 2010, David Sansome <me@davidsansome.com>
|
|
|
|
|
|
|
|
Clementine 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 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
Clementine 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 Clementine. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "transcoderoptionsdialog.h"
|
2020-09-18 16:15:19 +02:00
|
|
|
|
2021-01-31 09:10:17 +01:00
|
|
|
#include "core/logging.h"
|
|
|
|
#include "core/utilities.h"
|
2021-01-31 08:34:01 +01:00
|
|
|
#include "transcoder.h"
|
2020-09-18 16:15:19 +02:00
|
|
|
#include "transcoderoptionsaac.h"
|
2021-02-04 19:26:31 +01:00
|
|
|
#include "transcoderoptionserror.h"
|
2021-02-07 00:08:37 +01:00
|
|
|
#include "transcoderoptionsfdkaac.h"
|
2011-04-17 01:04:15 +02:00
|
|
|
#include "transcoderoptionsflac.h"
|
|
|
|
#include "transcoderoptionsmp3.h"
|
2020-09-18 16:15:19 +02:00
|
|
|
#include "transcoderoptionsopus.h"
|
2011-04-17 01:04:15 +02:00
|
|
|
#include "transcoderoptionsspeex.h"
|
2021-02-07 00:14:04 +01:00
|
|
|
#include "transcoderoptionsvoaac.h"
|
2011-04-17 01:04:15 +02:00
|
|
|
#include "transcoderoptionsvorbis.h"
|
|
|
|
#include "transcoderoptionswma.h"
|
|
|
|
#include "ui_transcoderoptionsdialog.h"
|
|
|
|
|
2021-01-31 08:34:01 +01:00
|
|
|
TranscoderOptionsDialog::TranscoderOptionsDialog(const TranscoderPreset& preset,
|
2014-02-07 16:34:20 +01:00
|
|
|
QWidget* parent)
|
|
|
|
: QDialog(parent), ui_(new Ui_TranscoderOptionsDialog), options_(nullptr) {
|
2011-04-17 01:04:15 +02:00
|
|
|
ui_->setupUi(this);
|
|
|
|
|
2021-02-04 19:26:31 +01:00
|
|
|
options_ = MakeOptionsPage(preset.codec_mimetype_, this);
|
2011-04-17 01:04:15 +02:00
|
|
|
|
2021-01-31 09:10:17 +01:00
|
|
|
setWindowTitle(tr("Transcoding options - %1").arg(preset.name_));
|
|
|
|
|
2021-02-04 19:26:31 +01:00
|
|
|
// Show options widget
|
2011-04-17 01:04:15 +02:00
|
|
|
if (options_) {
|
|
|
|
options_->layout()->setContentsMargins(0, 0, 0, 0);
|
|
|
|
ui_->verticalLayout->insertWidget(0, options_);
|
|
|
|
resize(width(), minimumHeight());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-07 16:34:20 +01:00
|
|
|
TranscoderOptionsDialog::~TranscoderOptionsDialog() { delete ui_; }
|
2011-04-17 01:04:15 +02:00
|
|
|
|
|
|
|
void TranscoderOptionsDialog::showEvent(QShowEvent* e) {
|
|
|
|
if (options_) {
|
|
|
|
options_->Load();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void TranscoderOptionsDialog::accept() {
|
|
|
|
if (options_) {
|
|
|
|
options_->Save();
|
|
|
|
}
|
|
|
|
QDialog::accept();
|
|
|
|
}
|
2014-11-13 22:31:49 +01:00
|
|
|
|
2020-09-18 16:15:19 +02:00
|
|
|
void TranscoderOptionsDialog::set_settings_postfix(
|
|
|
|
const QString& settings_postfix) {
|
2014-11-13 22:31:49 +01:00
|
|
|
if (options_) {
|
|
|
|
options_->settings_postfix_ = settings_postfix;
|
|
|
|
}
|
|
|
|
}
|
2021-02-04 19:26:31 +01:00
|
|
|
|
|
|
|
TranscoderOptionsInterface* TranscoderOptionsDialog::MakeOptionsPage(
|
|
|
|
const QString& mime_type, QWidget* parent) {
|
|
|
|
QString element = Transcoder::GetEncoderFactoryForMimeType(mime_type);
|
|
|
|
|
|
|
|
qLog(Debug) << "Options for element" << element;
|
|
|
|
if (element == "flacenc") {
|
|
|
|
return new TranscoderOptionsFlac(parent);
|
|
|
|
} else if (element == "faac") {
|
|
|
|
return new TranscoderOptionsAAC(parent);
|
2021-02-07 00:08:37 +01:00
|
|
|
} else if (element == "fdkaacenc") {
|
|
|
|
return new TranscoderOptionsFDKAAC(parent);
|
2021-02-07 00:14:04 +01:00
|
|
|
} else if (element == "voaacenc") {
|
|
|
|
return new TranscoderOptionsVOAAC(parent);
|
2021-02-04 19:26:31 +01:00
|
|
|
} else if (element == "lamemp3enc") {
|
|
|
|
return new TranscoderOptionsMP3(parent);
|
|
|
|
} else if (element == "vorbisenc") {
|
|
|
|
return new TranscoderOptionsVorbis(parent);
|
|
|
|
} else if (element == "opusenc") {
|
|
|
|
return new TranscoderOptionsOpus(parent);
|
|
|
|
} else if (element == "speexenc") {
|
|
|
|
return new TranscoderOptionsSpeex(parent);
|
|
|
|
} else if (element == "ffenc_wmav2") {
|
|
|
|
return new TranscoderOptionsWma(parent);
|
|
|
|
} else {
|
|
|
|
return new TranscoderOptionsError(mime_type, element, parent);
|
|
|
|
}
|
|
|
|
}
|