-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconversionthread.h
88 lines (73 loc) · 2.39 KB
/
conversionthread.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/*
* SPDX-FileCopyrightText: 2023 Rasyuqa A H <qampidh@gmail.com>
*
* SPDX-License-Identifier: GPL-3.0-or-later
**/
#ifndef CONVERSIONTHREAD_H
#define CONVERSIONTHREAD_H
#include "logcodes.h"
#include "utils/logstats.h"
#include <QProcess>
#include <QDirIterator>
#include <QThread>
#include <QMutex>
#include <QMap>
#include <QColor>
#include <QWaitCondition>
#include <QTimerEvent>
class ConversionThread : public QThread
{
Q_OBJECT
public:
ConversionThread(QObject *parent = nullptr);
~ConversionThread();
int processFiles(const QString &cjxlbin, QDirIterator &dit, const QString &fout, const QMap<QString, QString> &args);
int processFilesWithList(const QString &cjxlbin, const QStringList &fin, const QString &fout, const QMap<QString, QString> &args, const bool useList);
int processFiles(const QString &cjxlbin, const QStringList &fin, const QString &fout, const QMap<QString, QString> &args);
signals:
void sendLogs(const QString &logs, const QColor &col, const LogCode &isErr);
void sendProgress(const float &prog);
public slots:
void stopProcess();
protected:
void run() override;
void timerEvent(QTimerEvent *event) override;
private:
void initArgs(const QMap<QString, QString> &args);
void calculateStats();
void resetValues();
bool runCjxl(QProcess &jxlBin, const QFileInfo &fin, const QString &fout);
bool m_isJpegTran = false;
bool m_isOverwrite = false;
bool m_isSilent = false;
bool m_disableOutput = false;
bool m_stopOnError = false;
bool m_copyOnError = false;
bool m_haveCustomArgs = false;
bool m_useFileList = false;
bool m_isMultithread = false;
bool m_keepDateTime = false;
bool m_processNonAscii = false;
double m_averageMps = 0.0;
int m_mpsSamples = 0;
uint m_globalTimeout = 0;
qint64 m_totalBytesInput = 0;
qint64 m_totalBytesOutput = 0;
qint64 m_ticks = 0;
QString m_cjxlbin;
QString m_fin;
QString m_fout;
QString m_extension;
QString m_outSuffix;
QString m_tempFolderName;
QString m_tempFolderIn;
QString m_tempFolderOut;
QStringList m_args;
QStringList m_finBatch;
QStringList m_customArgs;
QMap<QString, QString> m_encOpts;
LogStats *m_ls = nullptr;
QMutex mutex;
bool m_abort = false;
};
#endif // CONVERSIONTHREAD_H