ScreenTranslator/src/task.h

48 lines
1.1 KiB
C
Raw Normal View History

2020-02-21 00:45:53 +07:00
#pragma once
#include "stfwd.h"
2020-04-11 17:48:44 +07:00
#include <QDebug>
2020-02-21 00:45:53 +07:00
#include <QPixmap>
class Task
{
public:
bool isNull() const { return captured.isNull() && !sourceLanguage.isEmpty(); }
bool isValid() const { return error.isEmpty(); }
2020-04-05 01:03:27 +07:00
Generation generation{};
2020-02-21 00:45:53 +07:00
QPoint capturePoint;
QPixmap captured;
QString recognized;
QString corrected;
2020-03-06 00:47:38 +07:00
QString translated;
2020-02-21 00:45:53 +07:00
2020-03-06 00:47:38 +07:00
LanguageId sourceLanguage;
LanguageId targetLanguage;
2020-02-21 00:45:53 +07:00
2020-03-06 00:47:38 +07:00
QStringList translators;
2020-04-05 16:51:39 +07:00
QString usedTranslator;
2020-02-21 00:45:53 +07:00
QString error;
2020-03-11 01:11:09 +07:00
QStringList translatorErrors;
2020-02-21 00:45:53 +07:00
};
using TaskPtr = std::shared_ptr<Task>;
Q_DECLARE_METATYPE(TaskPtr);
2020-04-11 17:48:44 +07:00
inline QDebug operator<<(QDebug debug, const TaskPtr &c)
{
QDebugStateSaver saver(debug);
debug.nospace() << "Task(Gen=" << c->generation
<< ", pix=" << c->captured.size() << ", rec=" << c->recognized
<< ", cor=" << c->corrected << ", tr=" << c->translated
<< ", lang=" << qPrintable(c->sourceLanguage) << '-'
<< qPrintable(c->targetLanguage) << ", err=" << c->error
<< ')';
return debug;
}