ScreenTranslator/WebTranslator.h

58 lines
1.3 KiB
C
Raw Normal View History

2015-10-08 22:36:02 +07:00
#ifndef WEBTRANSLATOR_H
#define WEBTRANSLATOR_H
#include <QObject>
#include <QMap>
#include <QTimer>
#include "ProcessingItem.h"
class QWebView;
class QNetworkReply;
2017-05-27 17:03:17 +07:00
class QSslError;
2015-10-08 22:36:02 +07:00
class WebTranslatorProxy;
2015-10-10 03:33:35 +07:00
class TranslatorHelper;
2015-10-08 22:36:02 +07:00
class WebTranslator : public QObject {
Q_OBJECT
public:
explicit WebTranslator ();
~WebTranslator ();
signals:
void translated (ProcessingItem item);
void error (QString text);
public slots:
void translate (ProcessingItem item);
void applySettings ();
void setDebugMode (bool isOn);
private slots:
void loadFinished (bool ok);
void replyFinished (QNetworkReply *reply);
void addProxyToView ();
void abortTranslation ();
void proxyTranslated (const QString &text);
2017-05-27 17:03:17 +07:00
void handleSslErrors (QNetworkReply *reply, const QList<QSslError> &errors);
2015-10-08 22:36:02 +07:00
private:
void translateQueued ();
void finishTranslation (bool markAsTranslated = true);
2015-10-10 03:33:35 +07:00
bool tryNextTranslator (bool firstTime = false);
2015-10-08 22:36:02 +07:00
private:
WebTranslatorProxy *proxy_;
QWebView *view_;
2015-10-10 03:33:35 +07:00
TranslatorHelper *translatorHelper_;
2015-10-08 22:36:02 +07:00
QVector<ProcessingItem> queue_;
bool isReady_;
2017-05-27 17:03:17 +07:00
bool ignoreSslErrors_;
2018-02-23 01:31:24 +07:00
bool forceRotateTranslators_;
2015-10-08 22:36:02 +07:00
QTimer translationTimeout_;
};
#endif // WEBTRANSLATOR_H