Merge pull request #4105 from paperbagcorner/transcoderdestination
Add the ability to choose destination folder in the transcoder dialog. Fixes #2776.
This commit is contained in:
commit
062889b50f
@ -20,6 +20,7 @@
|
|||||||
#include "transcoderoptionsdialog.h"
|
#include "transcoderoptionsdialog.h"
|
||||||
#include "ui_transcodedialog.h"
|
#include "ui_transcodedialog.h"
|
||||||
#include "ui_transcodelogdialog.h"
|
#include "ui_transcodelogdialog.h"
|
||||||
|
#include "ui/iconloader.h"
|
||||||
#include "ui/mainwindow.h"
|
#include "ui/mainwindow.h"
|
||||||
#include "widgets/fileview.h"
|
#include "widgets/fileview.h"
|
||||||
|
|
||||||
@ -35,6 +36,7 @@
|
|||||||
|
|
||||||
const char* TranscodeDialog::kSettingsGroup = "Transcoder";
|
const char* TranscodeDialog::kSettingsGroup = "Transcoder";
|
||||||
const int TranscodeDialog::kProgressInterval = 500;
|
const int TranscodeDialog::kProgressInterval = 500;
|
||||||
|
const int TranscodeDialog::kMaxDestinationItems = 10;
|
||||||
|
|
||||||
static bool ComparePresetsByName(const TranscoderPreset& left,
|
static bool ComparePresetsByName(const TranscoderPreset& left,
|
||||||
const TranscoderPreset& right) {
|
const TranscoderPreset& right) {
|
||||||
@ -103,6 +105,8 @@ TranscodeDialog::TranscodeDialog(QWidget *parent)
|
|||||||
connect(close_button_, SIGNAL(clicked()), SLOT(hide()));
|
connect(close_button_, SIGNAL(clicked()), SLOT(hide()));
|
||||||
connect(ui_->details, SIGNAL(clicked()), log_dialog_, SLOT(show()));
|
connect(ui_->details, SIGNAL(clicked()), log_dialog_, SLOT(show()));
|
||||||
connect(ui_->options, SIGNAL(clicked()), SLOT(Options()));
|
connect(ui_->options, SIGNAL(clicked()), SLOT(Options()));
|
||||||
|
connect(ui_->select, SIGNAL(clicked()), SLOT(AddDestination()));
|
||||||
|
|
||||||
|
|
||||||
connect(transcoder_, SIGNAL(JobComplete(QString,bool)), SLOT(JobComplete(QString,bool)));
|
connect(transcoder_, SIGNAL(JobComplete(QString,bool)), SLOT(JobComplete(QString,bool)));
|
||||||
connect(transcoder_, SIGNAL(LogLine(QString)), SLOT(LogLine(QString)));
|
connect(transcoder_, SIGNAL(LogLine(QString)), SLOT(LogLine(QString)));
|
||||||
@ -138,7 +142,8 @@ void TranscodeDialog::Start() {
|
|||||||
// Add jobs to the transcoder
|
// Add jobs to the transcoder
|
||||||
for (int i=0 ; i<file_model->rowCount() ; ++i) {
|
for (int i=0 ; i<file_model->rowCount() ; ++i) {
|
||||||
QString filename = file_model->index(i, 0).data(Qt::UserRole).toString();
|
QString filename = file_model->index(i, 0).data(Qt::UserRole).toString();
|
||||||
transcoder_->AddJob(filename, preset);
|
QString outfilename = GetOutputFileName(filename, preset);
|
||||||
|
transcoder_->AddJob(filename, preset, outfilename);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set up the progressbar
|
// Set up the progressbar
|
||||||
@ -265,3 +270,50 @@ void TranscodeDialog::Options() {
|
|||||||
dialog.exec();
|
dialog.exec();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Adds a folder to the destination box.
|
||||||
|
void TranscodeDialog::AddDestination() {
|
||||||
|
int index = ui_->destination->currentIndex();
|
||||||
|
QString initial_dir = (!ui_->destination->itemData(index).isNull() ?
|
||||||
|
ui_->destination->itemData(index).toString() :
|
||||||
|
QDir::homePath());
|
||||||
|
QString dir = QFileDialog::getExistingDirectory(
|
||||||
|
this, tr("Add folder"), initial_dir);
|
||||||
|
|
||||||
|
if (!dir.isEmpty()) {
|
||||||
|
// Keep only a finite number of items in the box.
|
||||||
|
while (ui_->destination->count() >= kMaxDestinationItems) {
|
||||||
|
ui_->destination->removeItem(1); // The oldest folder item.
|
||||||
|
}
|
||||||
|
|
||||||
|
QIcon icon = IconLoader::Load("folder");
|
||||||
|
QVariant data = QVariant::fromValue(dir);
|
||||||
|
// Do not insert duplicates.
|
||||||
|
int duplicate_index = ui_->destination->findData(data);
|
||||||
|
if (duplicate_index == -1) {
|
||||||
|
ui_->destination->addItem(icon, dir, data);
|
||||||
|
ui_->destination->setCurrentIndex(ui_->destination->count() - 1);
|
||||||
|
} else {
|
||||||
|
ui_->destination->setCurrentIndex(duplicate_index);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Returns the rightmost non-empty part of 'path'.
|
||||||
|
QString TranscodeDialog::TrimPath(const QString& path) const {
|
||||||
|
return path.section('/', -1, -1, QString::SectionSkipEmpty);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString TranscodeDialog::GetOutputFileName(const QString& input,
|
||||||
|
const TranscoderPreset &preset) const {
|
||||||
|
QString path = ui_->destination->itemData(
|
||||||
|
ui_->destination->currentIndex()).toString();
|
||||||
|
if (path.isEmpty()) {
|
||||||
|
// Keep the original path.
|
||||||
|
return input.section('.', 0, -2) + '.' + preset.extension_;
|
||||||
|
} else {
|
||||||
|
QString file_name = TrimPath(input);
|
||||||
|
file_name = file_name.section('.', 0, -2);
|
||||||
|
return path + '/' + file_name + '.' + preset.extension_;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -25,6 +25,8 @@ class Transcoder;
|
|||||||
class Ui_TranscodeDialog;
|
class Ui_TranscodeDialog;
|
||||||
class Ui_TranscodeLogDialog;
|
class Ui_TranscodeLogDialog;
|
||||||
|
|
||||||
|
struct TranscoderPreset;
|
||||||
|
|
||||||
class TranscodeDialog : public QDialog {
|
class TranscodeDialog : public QDialog {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@ -34,6 +36,7 @@ class TranscodeDialog : public QDialog {
|
|||||||
|
|
||||||
static const char* kSettingsGroup;
|
static const char* kSettingsGroup;
|
||||||
static const int kProgressInterval;
|
static const int kProgressInterval;
|
||||||
|
static const int kMaxDestinationItems;
|
||||||
|
|
||||||
void SetFilenames(const QStringList& filenames);
|
void SetFilenames(const QStringList& filenames);
|
||||||
|
|
||||||
@ -49,11 +52,15 @@ class TranscodeDialog : public QDialog {
|
|||||||
void LogLine(const QString& message);
|
void LogLine(const QString& message);
|
||||||
void AllJobsComplete();
|
void AllJobsComplete();
|
||||||
void Options();
|
void Options();
|
||||||
|
void AddDestination();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void SetWorking(bool working);
|
void SetWorking(bool working);
|
||||||
void UpdateStatusText();
|
void UpdateStatusText();
|
||||||
void UpdateProgress();
|
void UpdateProgress();
|
||||||
|
QString TrimPath(const QString& path) const;
|
||||||
|
QString GetOutputFileName(const QString& input,
|
||||||
|
const TranscoderPreset& preset) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Ui_TranscodeDialog* ui_;
|
Ui_TranscodeDialog* ui_;
|
||||||
|
@ -98,7 +98,7 @@
|
|||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Output options</string>
|
<string>Output options</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QFormLayout" name="formLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QLabel" name="label">
|
<widget class="QLabel" name="label">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@ -107,25 +107,21 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="0" column="1">
|
<item row="0" column="1">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
<widget class="QComboBox" name="format">
|
||||||
<item>
|
<property name="sizePolicy">
|
||||||
<widget class="QComboBox" name="format">
|
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||||
<property name="sizePolicy">
|
<horstretch>0</horstretch>
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
<verstretch>0</verstretch>
|
||||||
<horstretch>0</horstretch>
|
</sizepolicy>
|
||||||
<verstretch>0</verstretch>
|
</property>
|
||||||
</sizepolicy>
|
</widget>
|
||||||
</property>
|
</item>
|
||||||
</widget>
|
<item row="0" column="2">
|
||||||
</item>
|
<widget class="QPushButton" name="options">
|
||||||
<item>
|
<property name="text">
|
||||||
<widget class="QPushButton" name="options">
|
<string>Options...</string>
|
||||||
<property name="text">
|
</property>
|
||||||
<string>Options...</string>
|
</widget>
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
</layout>
|
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="1" column="0">
|
||||||
<widget class="QLabel" name="label_2">
|
<widget class="QLabel" name="label_2">
|
||||||
@ -136,6 +132,15 @@
|
|||||||
</item>
|
</item>
|
||||||
<item row="1" column="1">
|
<item row="1" column="1">
|
||||||
<widget class="QComboBox" name="destination">
|
<widget class="QComboBox" name="destination">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
<item>
|
<item>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Alongside the originals</string>
|
<string>Alongside the originals</string>
|
||||||
@ -143,6 +148,13 @@
|
|||||||
</item>
|
</item>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="1" column="2">
|
||||||
|
<widget class="QPushButton" name="select">
|
||||||
|
<property name="text">
|
||||||
|
<string>Select...</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@ -196,7 +208,6 @@
|
|||||||
<tabstop>add</tabstop>
|
<tabstop>add</tabstop>
|
||||||
<tabstop>remove</tabstop>
|
<tabstop>remove</tabstop>
|
||||||
<tabstop>format</tabstop>
|
<tabstop>format</tabstop>
|
||||||
<tabstop>destination</tabstop>
|
|
||||||
<tabstop>button_box</tabstop>
|
<tabstop>button_box</tabstop>
|
||||||
</tabstops>
|
</tabstops>
|
||||||
<resources/>
|
<resources/>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user