transcoder: Add pipeline list to details dialog
List current running transcode pipelines when the details dialog is displayed. This will be allow the addition of cancel and debug options.
This commit is contained in:
parent
befaacebf9
commit
8c2ab8fa05
|
@ -69,7 +69,7 @@ void GstPipelineModel::RemovePipeline(int id) {
|
|||
removeRow(row);
|
||||
}
|
||||
|
||||
int GstPipelineModel::FindRowById(int id) {
|
||||
int GstPipelineModel::FindRowById(int id) const {
|
||||
for (int i = 0; i < rowCount(); i++) {
|
||||
if (item(i)->data(Role::Role_Id).toInt() == id) return i;
|
||||
}
|
||||
|
|
|
@ -49,8 +49,8 @@ static bool ComparePresetsByName(const TranscoderPreset& left,
|
|||
TranscodeDialog::TranscodeDialog(QWidget* parent)
|
||||
: QDialog(parent),
|
||||
ui_(new Ui_TranscodeDialog),
|
||||
log_ui_(new Ui_TranscodeLogDialog),
|
||||
log_dialog_(new QDialog(this)),
|
||||
details_ui_(new Ui_TranscodeLogDialog),
|
||||
details_dialog_(new QDialog(this)),
|
||||
transcoder_(new Transcoder(this)),
|
||||
queued_(0),
|
||||
finished_success_(0),
|
||||
|
@ -58,10 +58,11 @@ TranscodeDialog::TranscodeDialog(QWidget* parent)
|
|||
ui_->setupUi(this);
|
||||
ui_->files->header()->setSectionResizeMode(QHeaderView::ResizeToContents);
|
||||
|
||||
log_ui_->setupUi(log_dialog_);
|
||||
QPushButton* clear_button =
|
||||
log_ui_->buttonBox->addButton(tr("Clear"), QDialogButtonBox::ResetRole);
|
||||
connect(clear_button, SIGNAL(clicked()), log_ui_->log, SLOT(clear()));
|
||||
details_ui_->setupUi(details_dialog_);
|
||||
details_ui_->pipelines->setModel(transcoder_->model());
|
||||
QPushButton* clear_button = details_ui_->buttonBox->addButton(
|
||||
tr("Clear"), QDialogButtonBox::ResetRole);
|
||||
connect(clear_button, SIGNAL(clicked()), details_ui_->log, SLOT(clear()));
|
||||
|
||||
// Get presets
|
||||
QList<TranscoderPreset> presets = Transcoder::GetAllPresets();
|
||||
|
@ -107,7 +108,7 @@ TranscodeDialog::TranscodeDialog(QWidget* parent)
|
|||
connect(start_button_, SIGNAL(clicked()), SLOT(Start()));
|
||||
connect(cancel_button_, SIGNAL(clicked()), SLOT(Cancel()));
|
||||
connect(close_button_, SIGNAL(clicked()), SLOT(hide()));
|
||||
connect(ui_->details, SIGNAL(clicked()), log_dialog_, SLOT(show()));
|
||||
connect(ui_->details, SIGNAL(clicked()), details_dialog_, SLOT(show()));
|
||||
connect(ui_->options, SIGNAL(clicked()), SLOT(Options()));
|
||||
connect(ui_->select, SIGNAL(clicked()), SLOT(AddDestination()));
|
||||
|
||||
|
@ -117,10 +118,7 @@ TranscodeDialog::TranscodeDialog(QWidget* parent)
|
|||
connect(transcoder_, SIGNAL(AllJobsComplete()), SLOT(AllJobsComplete()));
|
||||
}
|
||||
|
||||
TranscodeDialog::~TranscodeDialog() {
|
||||
delete log_ui_;
|
||||
delete ui_;
|
||||
}
|
||||
TranscodeDialog::~TranscodeDialog() {}
|
||||
|
||||
void TranscodeDialog::SetWorking(bool working) {
|
||||
start_button_->setVisible(!working);
|
||||
|
@ -278,7 +276,7 @@ void TranscodeDialog::Remove() { qDeleteAll(ui_->files->selectedItems()); }
|
|||
|
||||
void TranscodeDialog::LogLine(const QString& message) {
|
||||
QString date(QDateTime::currentDateTime().toString(Qt::TextDate));
|
||||
log_ui_->log->appendPlainText(QString("%1: %2").arg(date, message));
|
||||
details_ui_->log->appendPlainText(QString("%1: %2").arg(date, message));
|
||||
}
|
||||
|
||||
void TranscodeDialog::timerEvent(QTimerEvent* e) {
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include <QBasicTimer>
|
||||
#include <QDialog>
|
||||
#include <QFileInfo>
|
||||
#include <memory>
|
||||
|
||||
class Transcoder;
|
||||
class Ui_TranscodeDialog;
|
||||
|
@ -64,9 +65,9 @@ class TranscodeDialog : public QDialog {
|
|||
const TranscoderPreset& preset) const;
|
||||
|
||||
private:
|
||||
Ui_TranscodeDialog* ui_;
|
||||
Ui_TranscodeLogDialog* log_ui_;
|
||||
QDialog* log_dialog_;
|
||||
std::unique_ptr<Ui_TranscodeDialog> ui_;
|
||||
std::unique_ptr<Ui_TranscodeLogDialog> details_ui_;
|
||||
QDialog* details_dialog_;
|
||||
|
||||
QBasicTimer progress_timer_;
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Transcoder Log</string>
|
||||
<string>Transcoder Details</string>
|
||||
</property>
|
||||
<property name="windowIcon">
|
||||
<iconset resource="../../data/data.qrc">
|
||||
|
@ -19,10 +19,56 @@
|
|||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<widget class="QPlainTextEdit" name="log">
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
<widget class="QGroupBox" name="pipelineBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Pipelines</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_3">
|
||||
<item>
|
||||
<widget class="QListView" name="pipelines">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QGroupBox" name="logBox">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="title">
|
||||
<string>Logs</string>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
||||
<item>
|
||||
<widget class="QPlainTextEdit" name="log">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="readOnly">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
|
|
|
@ -195,10 +195,16 @@ void Transcoder::JobState::PostFinished(bool success) {
|
|||
new Transcoder::JobFinishedEvent(this, success));
|
||||
}
|
||||
|
||||
QString Transcoder::JobState::GetDisplayName() {
|
||||
return QFileInfo(job_.input).fileName() + " => " +
|
||||
QFileInfo(job_.output).fileName();
|
||||
}
|
||||
|
||||
Transcoder::Transcoder(QObject* parent, const QString& settings_postfix)
|
||||
: QObject(parent),
|
||||
max_threads_(QThread::idealThreadCount()),
|
||||
settings_postfix_(settings_postfix) {
|
||||
settings_postfix_(settings_postfix),
|
||||
model_(new GstPipelineModel(this)) {
|
||||
if (JobFinishedEvent::sEventType == -1)
|
||||
JobFinishedEvent::sEventType = QEvent::registerEventType();
|
||||
|
||||
|
@ -459,6 +465,7 @@ bool Transcoder::StartJob(const Job& job) {
|
|||
// something else. Keep the JobState object around. It'll post an event
|
||||
// to our event loop when it finishes.
|
||||
current_jobs_ << state;
|
||||
model_->AddPipeline(state->id(), state->GetDisplayName());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -489,6 +496,7 @@ bool Transcoder::event(QEvent* e) {
|
|||
nullptr, nullptr, nullptr);
|
||||
|
||||
// Remove it from the list - this will also destroy the GStreamer pipeline
|
||||
model_->RemovePipeline((*it)->id());
|
||||
current_jobs_.erase(it);
|
||||
|
||||
// Emit the finished signal
|
||||
|
@ -527,6 +535,7 @@ void Transcoder::Cancel() {
|
|||
}
|
||||
|
||||
// Remove the job, this destroys the GStreamer pipeline too
|
||||
model_->RemovePipeline((*it)->id());
|
||||
it = current_jobs_.erase(it);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,6 +63,8 @@ class Transcoder : public QObject {
|
|||
QMap<QString, float> GetProgress() const;
|
||||
int QueuedJobsCount() const { return queued_jobs_.count(); }
|
||||
|
||||
GstPipelineModel* model() { return model_; }
|
||||
|
||||
public slots:
|
||||
void Start();
|
||||
void Cancel();
|
||||
|
@ -97,6 +99,7 @@ class Transcoder : public QObject {
|
|||
void ReportError(GstMessage* msg);
|
||||
|
||||
GstElement* Pipeline() { return pipeline_; }
|
||||
QString GetDisplayName();
|
||||
|
||||
Job job_;
|
||||
Transcoder* parent_;
|
||||
|
@ -143,6 +146,7 @@ class Transcoder : public QObject {
|
|||
QList<Job> queued_jobs_;
|
||||
JobStateList current_jobs_;
|
||||
QString settings_postfix_;
|
||||
GstPipelineModel* model_;
|
||||
};
|
||||
|
||||
#endif // TRANSCODER_H
|
||||
|
|
Loading…
Reference in New Issue