2022-05-21 06:03:26 +00:00
|
|
|
#ifndef ANKICONNECTOR_H
|
|
|
|
#define ANKICONNECTOR_H
|
|
|
|
|
|
|
|
#include "config.hh"
|
|
|
|
|
|
|
|
#include <QNetworkAccessManager>
|
|
|
|
#include <QNetworkReply>
|
|
|
|
#include <QObject>
|
|
|
|
|
|
|
|
class AnkiConnector: public QObject
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
2023-07-20 08:02:22 +00:00
|
|
|
|
2022-05-21 06:03:26 +00:00
|
|
|
public:
|
|
|
|
explicit AnkiConnector( QObject * parent, Config::Class const & cfg );
|
|
|
|
|
2023-03-22 20:34:05 +00:00
|
|
|
void sendToAnki( QString const & word, QString text, QString const & sentence );
|
2023-03-22 02:04:54 +00:00
|
|
|
void ankiSearch( QString const & word );
|
2022-05-21 06:03:26 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
QNetworkAccessManager * mgr;
|
|
|
|
Config::Class const & cfg;
|
2023-03-22 02:04:54 +00:00
|
|
|
void postToAnki( QString const & postData );
|
2023-03-22 21:55:45 +00:00
|
|
|
static constexpr auto transfer_timeout = 3000;
|
2023-07-20 08:02:22 +00:00
|
|
|
|
2023-03-22 21:55:45 +00:00
|
|
|
public:
|
|
|
|
signals:
|
2022-05-21 06:03:26 +00:00
|
|
|
void errorText( QString const & );
|
|
|
|
private slots:
|
|
|
|
void finishedSlot( QNetworkReply * reply );
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // ANKICONNECTOR_H
|