From c38202bd3067772625b735a2cc5a42a6e2ece13f Mon Sep 17 00:00:00 2001 From: zhupengfei Date: Sat, 22 Feb 2020 11:18:55 +0800 Subject: [PATCH] dumping_dialog: Add a line edit for the options So that users can just paste a set of parameters they found elsewhere. --- src/citra_qt/dumping/dumping_dialog.cpp | 38 +++++++------- src/citra_qt/dumping/dumping_dialog.h | 7 ++- src/citra_qt/dumping/dumping_dialog.ui | 68 ++++++++++++++++++------- 3 files changed, 72 insertions(+), 41 deletions(-) diff --git a/src/citra_qt/dumping/dumping_dialog.cpp b/src/citra_qt/dumping/dumping_dialog.cpp index ee5fe6b2a..0c39f86e7 100644 --- a/src/citra_qt/dumping/dumping_dialog.cpp +++ b/src/citra_qt/dumping/dumping_dialog.cpp @@ -21,33 +21,33 @@ DumpingDialog::DumpingDialog(QWidget* parent) accept(); }); connect(ui->buttonBox, &QDialogButtonBox::rejected, this, &DumpingDialog::reject); - connect(ui->formatOptionsButton, &QPushButton::clicked, [this] { + connect(ui->formatOptionsButton, &QToolButton::clicked, [this] { OpenOptionsDialog(formats.at(ui->formatComboBox->currentData().toUInt()).options, - format_options); + ui->formatOptionsLineEdit); }); - connect(ui->videoEncoderOptionsButton, &QPushButton::clicked, [this] { + connect(ui->videoEncoderOptionsButton, &QToolButton::clicked, [this] { OpenOptionsDialog( video_encoders.at(ui->videoEncoderComboBox->currentData().toUInt()).options, - video_encoder_options); + ui->videoEncoderOptionsLineEdit); }); - connect(ui->audioEncoderOptionsButton, &QPushButton::clicked, [this] { + connect(ui->audioEncoderOptionsButton, &QToolButton::clicked, [this] { OpenOptionsDialog( audio_encoders.at(ui->audioEncoderComboBox->currentData().toUInt()).options, - audio_encoder_options); + ui->audioEncoderOptionsLineEdit); }); SetConfiguration(); connect(ui->formatComboBox, qOverload(&QComboBox::currentIndexChanged), [this] { ui->pathLineEdit->setText(QString{}); - format_options.clear(); + ui->formatOptionsLineEdit->clear(); PopulateEncoders(); }); connect(ui->videoEncoderComboBox, qOverload(&QComboBox::currentIndexChanged), - [this] { video_encoder_options.clear(); }); + [this] { ui->videoEncoderOptionsLineEdit->clear(); }); connect(ui->audioEncoderComboBox, qOverload(&QComboBox::currentIndexChanged), - [this] { audio_encoder_options.clear(); }); + [this] { ui->audioEncoderOptionsLineEdit->clear(); }); } DumpingDialog::~DumpingDialog() = default; @@ -174,21 +174,23 @@ void DumpingDialog::OnToolButtonClicked() { } void DumpingDialog::OpenOptionsDialog(const std::vector& options, - std::string& current_value) { - OptionsDialog dialog(this, options, current_value); + QLineEdit* line_edit) { + OptionsDialog dialog(this, options, line_edit->text().toStdString()); if (dialog.exec() != QDialog::DialogCode::Accepted) { return; } - current_value = dialog.GetCurrentValue(); + line_edit->setText(QString::fromStdString(dialog.GetCurrentValue())); } void DumpingDialog::SetConfiguration() { Populate(); - format_options = Settings::values.format_options; - video_encoder_options = Settings::values.video_encoder_options; - audio_encoder_options = Settings::values.audio_encoder_options; + ui->formatOptionsLineEdit->setText(QString::fromStdString(Settings::values.format_options)); + ui->videoEncoderOptionsLineEdit->setText( + QString::fromStdString(Settings::values.video_encoder_options)); + ui->audioEncoderOptionsLineEdit->setText( + QString::fromStdString(Settings::values.audio_encoder_options)); last_path = UISettings::values.video_dumping_path; ui->videoBitrateSpinBox->setValue(static_cast(Settings::values.video_bitrate)); ui->audioBitrateSpinBox->setValue(static_cast(Settings::values.audio_bitrate)); @@ -196,14 +198,14 @@ void DumpingDialog::SetConfiguration() { void DumpingDialog::ApplyConfiguration() { Settings::values.output_format = formats.at(ui->formatComboBox->currentData().toUInt()).name; - Settings::values.format_options = format_options; + Settings::values.format_options = ui->formatOptionsLineEdit->text().toStdString(); Settings::values.video_encoder = video_encoders.at(ui->videoEncoderComboBox->currentData().toUInt()).name; - Settings::values.video_encoder_options = video_encoder_options; + Settings::values.video_encoder_options = ui->videoEncoderOptionsLineEdit->text().toStdString(); Settings::values.video_bitrate = ui->videoBitrateSpinBox->value(); Settings::values.audio_encoder = audio_encoders.at(ui->audioEncoderComboBox->currentData().toUInt()).name; - Settings::values.audio_encoder_options = audio_encoder_options; + Settings::values.audio_encoder_options = ui->audioEncoderOptionsLineEdit->text().toStdString(); Settings::values.audio_bitrate = ui->audioBitrateSpinBox->value(); UISettings::values.video_dumping_path = last_path; Settings::Apply(); diff --git a/src/citra_qt/dumping/dumping_dialog.h b/src/citra_qt/dumping/dumping_dialog.h index 7476770ba..c2b0999ea 100644 --- a/src/citra_qt/dumping/dumping_dialog.h +++ b/src/citra_qt/dumping/dumping_dialog.h @@ -10,6 +10,8 @@ namespace Ui { class DumpingDialog; } +class QLineEdit; + class DumpingDialog : public QDialog { Q_OBJECT @@ -26,12 +28,9 @@ private: void SetConfiguration(); void OnToolButtonClicked(); void OpenOptionsDialog(const std::vector& options, - std::string& current_value); + QLineEdit* line_edit); std::unique_ptr ui; - std::string format_options; - std::string video_encoder_options; - std::string audio_encoder_options; QString last_path; diff --git a/src/citra_qt/dumping/dumping_dialog.ui b/src/citra_qt/dumping/dumping_dialog.ui index a3468ed3f..6e33d47d8 100644 --- a/src/citra_qt/dumping/dumping_dialog.ui +++ b/src/citra_qt/dumping/dumping_dialog.ui @@ -7,7 +7,7 @@ 0 0 600 - 360 + 420 @@ -30,24 +30,34 @@ - - + + - Options... + Options: - + + + + + + + ... + + + + Path: - + - + ... @@ -80,21 +90,31 @@ - - + + - Options... + Options: - + + + + + + + ... + + + + Bitrate: - + 10000000 @@ -104,7 +124,7 @@ - + bps @@ -137,21 +157,31 @@ - - + + - Options... + Options: - + + + + + + + ... + + + + Bitrate: - + 1000000 @@ -161,7 +191,7 @@ - + bps