mirror of
https://github.com/clementine-player/Clementine
synced 2024-12-23 00:09:14 +01:00
Added option to remove/replace originals in transcoder dialog (fixed).
This is a squashed and fixed version of previous commits6b6547095a
dd1393ea3a
This commit is contained in:
parent
7ce9928779
commit
1aaf74788c
@ -98,6 +98,9 @@ TranscodeDialog::TranscodeDialog(QWidget* parent)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ui_->remove_original->setChecked(
|
||||||
|
s.value("overwrite_existing", false).toBool());
|
||||||
|
|
||||||
// Add a start button
|
// Add a start button
|
||||||
start_button_ = ui_->button_box->addButton(tr("Start transcoding"),
|
start_button_ = ui_->button_box->addButton(tr("Start transcoding"),
|
||||||
QDialogButtonBox::ActionRole);
|
QDialogButtonBox::ActionRole);
|
||||||
@ -183,6 +186,7 @@ void TranscodeDialog::Start() {
|
|||||||
QSettings s;
|
QSettings s;
|
||||||
s.beginGroup(kSettingsGroup);
|
s.beginGroup(kSettingsGroup);
|
||||||
s.setValue("last_output_format", preset.codec_mimetype_);
|
s.setValue("last_output_format", preset.codec_mimetype_);
|
||||||
|
s.setValue("overwrite_existing", ui_->remove_original->isChecked());
|
||||||
}
|
}
|
||||||
|
|
||||||
void TranscodeDialog::Cancel() {
|
void TranscodeDialog::Cancel() {
|
||||||
@ -206,6 +210,23 @@ void TranscodeDialog::JobComplete(const QUrl& input, const QString& output,
|
|||||||
|
|
||||||
UpdateStatusText();
|
UpdateStatusText();
|
||||||
UpdateProgress();
|
UpdateProgress();
|
||||||
|
|
||||||
|
bool overwrite_existing = ui_->remove_original->isChecked();
|
||||||
|
|
||||||
|
if (success && overwrite_existing && input.isLocalFile()) {
|
||||||
|
QFileInfo input_fileinfo(input.toLocalFile());
|
||||||
|
QFileInfo output_fileinfo(output);
|
||||||
|
|
||||||
|
bool same_extension = input_fileinfo.suffix() == output_fileinfo.suffix();
|
||||||
|
bool same_path =
|
||||||
|
input_fileinfo.absolutePath() == output_fileinfo.absolutePath();
|
||||||
|
|
||||||
|
QFile(input_fileinfo.absoluteFilePath()).remove();
|
||||||
|
if (same_path && same_extension) {
|
||||||
|
QFile(output_fileinfo.absoluteFilePath())
|
||||||
|
.rename(input_fileinfo.fileName());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TranscodeDialog::UpdateProgress() {
|
void TranscodeDialog::UpdateProgress() {
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>499</width>
|
<width>499</width>
|
||||||
<height>448</height>
|
<height>482</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@ -165,6 +165,16 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="QCheckBox" name="remove_original">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>If enabled the original files will be removed. If transcoded files have the same file extension and the destination is the same directory as the original files, the original files will be replaced.</string>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Remove or replace original files </string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
Loading…
Reference in New Issue
Block a user