UI: Batch remux and drag/drop support on remux dialog
This changes the remux dialog to support a collection of input/output pairs, presented as a QTableView. Standard Qt icons are used to indicate the state of each entry during a remux operation. Drag/drop support is added to populate the list quickly. Both Dark and Rachni themes are updated to make QTableView look reasonable. Relevant text is added in the localization files. Closes obsproject/obs-studio#1153
This commit is contained in:
@@ -17,6 +17,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QFileInfo>
|
||||
#include <QMutex>
|
||||
#include <QPointer>
|
||||
#include <QThread>
|
||||
#include <memory>
|
||||
@@ -25,11 +27,25 @@
|
||||
#include <media-io/media-remux.h>
|
||||
#include <util/threading.h>
|
||||
|
||||
class RemuxQueueModel;
|
||||
class RemuxWorker;
|
||||
|
||||
enum RemuxEntryState
|
||||
{
|
||||
Empty,
|
||||
Ready,
|
||||
Pending,
|
||||
InProgress,
|
||||
Complete,
|
||||
InvalidPath,
|
||||
Error
|
||||
};
|
||||
Q_DECLARE_METATYPE(RemuxEntryState);
|
||||
|
||||
class OBSRemux : public QDialog {
|
||||
Q_OBJECT
|
||||
|
||||
QPointer<RemuxQueueModel> queueModel;
|
||||
QThread remuxer;
|
||||
QPointer<RemuxWorker> worker;
|
||||
|
||||
@@ -37,11 +53,6 @@ class OBSRemux : public QDialog {
|
||||
|
||||
const char *recPath;
|
||||
|
||||
void BrowseInput();
|
||||
void BrowseOutput();
|
||||
|
||||
bool Stop();
|
||||
|
||||
virtual void closeEvent(QCloseEvent *event) override;
|
||||
virtual void reject() override;
|
||||
|
||||
@@ -51,32 +62,89 @@ public:
|
||||
|
||||
using job_t = std::shared_ptr<struct media_remux_job>;
|
||||
|
||||
protected:
|
||||
void dropEvent(QDropEvent *ev);
|
||||
void dragEnterEvent(QDragEnterEvent *ev);
|
||||
|
||||
void remuxNextEntry();
|
||||
|
||||
private slots:
|
||||
void inputChanged(const QString &str);
|
||||
void rowCountChanged(const QModelIndex &parent, int first, int last);
|
||||
|
||||
public slots:
|
||||
void updateProgress(float percent);
|
||||
void remuxFinished(bool success);
|
||||
void Remux();
|
||||
void beginRemux();
|
||||
bool stopRemux();
|
||||
void clearFinished();
|
||||
void clearAll();
|
||||
|
||||
signals:
|
||||
void remux();
|
||||
void remux(const QString &source, const QString &target);
|
||||
};
|
||||
|
||||
class RemuxQueueModel : public QAbstractTableModel {
|
||||
Q_OBJECT
|
||||
|
||||
friend class OBSRemux;
|
||||
|
||||
public:
|
||||
RemuxQueueModel(QObject *parent = 0)
|
||||
: QAbstractTableModel(parent)
|
||||
, isProcessing(false) {}
|
||||
|
||||
int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
||||
int columnCount(const QModelIndex &parent = QModelIndex()) const;
|
||||
QVariant data(const QModelIndex &index, int role) const;
|
||||
QVariant headerData(int section, Qt::Orientation orientation,
|
||||
int role = Qt::DisplayRole) const;
|
||||
Qt::ItemFlags flags(const QModelIndex &index) const;
|
||||
bool setData(const QModelIndex &index, const QVariant &value,
|
||||
int role);
|
||||
|
||||
QFileInfoList checkForOverwrites() const;
|
||||
bool checkForErrors() const;
|
||||
void beginProcessing();
|
||||
void endProcessing();
|
||||
bool beginNextEntry(QString &inputPath, QString &outputPath);
|
||||
void finishEntry(bool success);
|
||||
bool canClearFinished() const;
|
||||
void clearFinished();
|
||||
void clearAll();
|
||||
|
||||
private:
|
||||
struct RemuxQueueEntry
|
||||
{
|
||||
RemuxEntryState state;
|
||||
|
||||
QString sourcePath;
|
||||
QString targetPath;
|
||||
};
|
||||
|
||||
QList<RemuxQueueEntry> queue;
|
||||
bool isProcessing;
|
||||
|
||||
static QVariant getIcon(RemuxEntryState state);
|
||||
|
||||
void checkInputPath(int row);
|
||||
};
|
||||
|
||||
class RemuxWorker : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
OBSRemux::job_t job;
|
||||
os_event_t *stop;
|
||||
QMutex updateMutex;
|
||||
|
||||
bool isWorking;
|
||||
|
||||
float lastProgress;
|
||||
void UpdateProgress(float percent);
|
||||
|
||||
explicit RemuxWorker();
|
||||
virtual ~RemuxWorker();
|
||||
explicit RemuxWorker()
|
||||
: isWorking(false) { }
|
||||
virtual ~RemuxWorker() {};
|
||||
|
||||
private slots:
|
||||
void remux();
|
||||
void remux(const QString &source, const QString &target);
|
||||
|
||||
signals:
|
||||
void updateProgress(float percent);
|
||||
|
Reference in New Issue
Block a user