52 lines
1.0 KiB
C++
52 lines
1.0 KiB
C++
#ifndef YOUDAOSERVICE_H
|
|
#define YOUDAOSERVICE_H
|
|
|
|
#include "../WingTool/plugin/iwingtoolplg.h"
|
|
#include "settingdialog.h"
|
|
#include "transdialog.h"
|
|
#include <QDomDocument>
|
|
#include <QObject>
|
|
#include <QtNetwork/QNetworkAccessManager>
|
|
#include <QtNetwork/QNetworkReply>
|
|
|
|
class YoudaoService : public QObject {
|
|
Q_OBJECT
|
|
public:
|
|
YoudaoService(QObject *parent = nullptr);
|
|
virtual ~YoudaoService();
|
|
|
|
bool enabled() const;
|
|
void setEnabled(bool enabled);
|
|
|
|
bool cp() const;
|
|
bool sel() const;
|
|
|
|
// 用于本地化
|
|
void translation() {
|
|
tr("translate");
|
|
tr("toggle");
|
|
}
|
|
|
|
public slots:
|
|
PLUGINSRV void translate(QString word);
|
|
PLUGINSRV void toggle();
|
|
|
|
void parse(QByteArray &content);
|
|
QString parseCustomTrans(QDomElement &ele);
|
|
QString parseYoudaoTrans(QDomElement &ele);
|
|
|
|
bool isVaildWord(QString &word);
|
|
void showSettings();
|
|
void loadSettings();
|
|
void saveSettings();
|
|
|
|
private:
|
|
bool m_enabled;
|
|
bool m_cp, m_sel;
|
|
QNetworkAccessManager *net;
|
|
SettingDialog *sm;
|
|
TransDialog *dialog;
|
|
};
|
|
|
|
#endif // YOUDAOSERVICE_H
|