diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index bb83a4ee5..ec90425f5 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -319,6 +319,7 @@ set(SOURCES
transcoder/transcoder.cpp
transcoder/transcoderoptionsaac.cpp
transcoder/transcoderoptionsdialog.cpp
+ transcoder/transcoderoptionserror.cpp
transcoder/transcoderoptionsflac.cpp
transcoder/transcoderoptionsmp3.cpp
transcoder/transcoderoptionsopus.cpp
@@ -745,6 +746,7 @@ set(UI
transcoder/transcodelogdialog.ui
transcoder/transcoderoptionsaac.ui
transcoder/transcoderoptionsdialog.ui
+ transcoder/transcoderoptionserror.ui
transcoder/transcoderoptionsflac.ui
transcoder/transcoderoptionsmp3.ui
transcoder/transcoderoptionsopus.ui
diff --git a/src/transcoder/transcoderoptionsdialog.cpp b/src/transcoder/transcoderoptionsdialog.cpp
index 4531085d2..fcde413b7 100644
--- a/src/transcoder/transcoderoptionsdialog.cpp
+++ b/src/transcoder/transcoderoptionsdialog.cpp
@@ -21,6 +21,7 @@
#include "core/utilities.h"
#include "transcoder.h"
#include "transcoderoptionsaac.h"
+#include "transcoderoptionserror.h"
#include "transcoderoptionsflac.h"
#include "transcoderoptionsmp3.h"
#include "transcoderoptionsopus.h"
@@ -34,44 +35,12 @@ TranscoderOptionsDialog::TranscoderOptionsDialog(const TranscoderPreset& preset,
: QDialog(parent), ui_(new Ui_TranscoderOptionsDialog), options_(nullptr) {
ui_->setupUi(this);
- QString element =
- Transcoder::GetEncoderFactoryForMimeType(preset.codec_mimetype_);
-
- qLog(Debug) << "Options for element" << element;
- if (element == "flacenc") {
- options_ = new TranscoderOptionsFlac(this);
- } else if (element == "faac") {
- options_ = new TranscoderOptionsAAC(this);
- } else if (element == "lamemp3enc") {
- options_ = new TranscoderOptionsMP3(this);
- } else if (element == "vorbisenc") {
- options_ = new TranscoderOptionsVorbis(this);
- } else if (element == "opusenc") {
- options_ = new TranscoderOptionsOpus(this);
- } else if (element == "speexenc") {
- options_ = new TranscoderOptionsSpeex(this);
- } else if (element == "ffenc_wmav2") {
- options_ = new TranscoderOptionsWma(this);
- } else if (element.isEmpty()) {
- ui_->errorMessage->setText(tr("Could not find a suitable encoder element "
- "for %1.")
- .arg(preset.name_));
- } else {
- QString url = Utilities::MakeBugReportUrl(
- QString("transcoder settings: Unknown encoder element: ") + element);
- ui_->errorMessage->setText(tr("No settings page available for encoder "
- "element %1. "
- "Please report this issue:
"
- "%2")
- .arg(element)
- .arg(url));
- }
+ options_ = MakeOptionsPage(preset.codec_mimetype_, this);
setWindowTitle(tr("Transcoding options - %1").arg(preset.name_));
- // Show options widget if available.
+ // Show options widget
if (options_) {
- ui_->errorMessage->setVisible(false);
options_->layout()->setContentsMargins(0, 0, 0, 0);
ui_->verticalLayout->insertWidget(0, options_);
resize(width(), minimumHeight());
@@ -99,3 +68,27 @@ void TranscoderOptionsDialog::set_settings_postfix(
options_->settings_postfix_ = settings_postfix;
}
}
+
+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);
+ } 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);
+ }
+}
diff --git a/src/transcoder/transcoderoptionsdialog.h b/src/transcoder/transcoderoptionsdialog.h
index e31a83e7b..907a2e8d7 100644
--- a/src/transcoder/transcoderoptionsdialog.h
+++ b/src/transcoder/transcoderoptionsdialog.h
@@ -37,6 +37,9 @@ class TranscoderOptionsDialog : public QDialog {
void set_settings_postfix(const QString& settings_postfix);
+ static TranscoderOptionsInterface* MakeOptionsPage(const QString& mime_type,
+ QWidget* parent = nullptr);
+
protected:
void showEvent(QShowEvent* e);
diff --git a/src/transcoder/transcoderoptionsdialog.ui b/src/transcoder/transcoderoptionsdialog.ui
index 59ec70cf2..9bc4844a9 100644
--- a/src/transcoder/transcoderoptionsdialog.ui
+++ b/src/transcoder/transcoderoptionsdialog.ui
@@ -14,25 +14,6 @@
Transcoding options
- -
-
-
- true
-
-
- Error
-
-
- Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop
-
-
- true
-
-
- true
-
-
-
-
diff --git a/src/transcoder/transcoderoptionserror.cpp b/src/transcoder/transcoderoptionserror.cpp
new file mode 100644
index 000000000..dec2043b9
--- /dev/null
+++ b/src/transcoder/transcoderoptionserror.cpp
@@ -0,0 +1,51 @@
+/* This file is part of Clementine.
+ Copyright 2021, Jim Broadus
+
+ 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 .
+*/
+
+#include "transcoderoptionserror.h"
+
+#include "core/utilities.h"
+#include "transcoder.h"
+#include "ui_transcoderoptionserror.h"
+
+TranscoderOptionsError::TranscoderOptionsError(const QString& mime_type,
+ const QString& element,
+ QWidget* parent)
+ : TranscoderOptionsInterface(parent), ui_(new Ui_TranscoderOptionsError) {
+ ui_->setupUi(this);
+
+ if (mime_type.isEmpty()) {
+ // No codec for raw formats such as wav.
+ ui_->info->setText(tr("No settings available for this type."));
+ } else if (element.isEmpty()) {
+ // Didn't find a suitable element.
+ ui_->info->setText(tr("Could not find a suitable encoder element "
+ "for %1.")
+ .arg(mime_type));
+ } else {
+ // No settings page available for element.
+ QString url = Utilities::MakeBugReportUrl(
+ QString("transcoder settings: Unknown encoder element: ") + element);
+ ui_->info->setText(tr("No settings page available for encoder "
+ "element %1. "
+ "Please report this issue:
"
+ "%2")
+ .arg(element)
+ .arg(url));
+ }
+}
+
+TranscoderOptionsError::~TranscoderOptionsError() { delete ui_; }
diff --git a/src/transcoder/transcoderoptionserror.h b/src/transcoder/transcoderoptionserror.h
new file mode 100644
index 000000000..3713561d8
--- /dev/null
+++ b/src/transcoder/transcoderoptionserror.h
@@ -0,0 +1,38 @@
+/* This file is part of Clementine.
+ Copyright 2021, Jim Broadus
+
+ 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 .
+*/
+
+#ifndef TRANSCODEROPTIONSERROR_H
+#define TRANSCODEROPTIONSERROR_H
+
+#include "transcoderoptionsinterface.h"
+
+class Ui_TranscoderOptionsError;
+
+class TranscoderOptionsError : public TranscoderOptionsInterface {
+ public:
+ TranscoderOptionsError(const QString& mime_type, const QString& element,
+ QWidget* parent = nullptr);
+ ~TranscoderOptionsError();
+
+ void Load(){};
+ void Save(){};
+
+ private:
+ Ui_TranscoderOptionsError* ui_;
+};
+
+#endif // TRANSCODEROPTIONSERROR_H
diff --git a/src/transcoder/transcoderoptionserror.ui b/src/transcoder/transcoderoptionserror.ui
new file mode 100644
index 000000000..14c65665a
--- /dev/null
+++ b/src/transcoder/transcoderoptionserror.ui
@@ -0,0 +1,40 @@
+
+
+ TranscoderOptionsError
+
+
+
+ 0
+ 0
+ 400
+ 102
+
+
+
+ Form
+
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+
+
+
+ true
+
+
+ true
+
+
+
+
+
+
+
+