prepare for selectable backends
This commit is contained in:
19
kateai.h
19
kateai.h
@ -7,22 +7,21 @@
|
||||
#include <KTextEditor/Plugin>
|
||||
#include <KXMLGUIClient>
|
||||
|
||||
#include <QList>
|
||||
#include <QSet>
|
||||
#include <QAction>
|
||||
#include <QWebSocket>
|
||||
#include <QPointer>
|
||||
#include <QtCore>
|
||||
|
||||
#include "backend.h"
|
||||
|
||||
class KateAiPlugin : public KTextEditor::Plugin
|
||||
{
|
||||
Q_OBJECT
|
||||
private:
|
||||
QWebSocket m_webSocket;
|
||||
QPointer<AiBackend> m_ai;
|
||||
QUrl m_serverUrl;
|
||||
|
||||
private:
|
||||
void onConnected();
|
||||
|
||||
int configPages() const override
|
||||
{
|
||||
return 1;
|
||||
@ -52,24 +51,24 @@ private:
|
||||
};
|
||||
|
||||
KTextEditor::MainWindow *m_mainWindow;
|
||||
QPointer<QWebSocket> m_webSocket;
|
||||
QHash<int, Request> m_requests;
|
||||
inline static QPointer<AiBackend> m_ai;
|
||||
bool m_useInstruct = false;
|
||||
|
||||
private:
|
||||
void generate();
|
||||
void socketMessage(const QString& message);
|
||||
void gotResponse(AiBackend::Response respons);
|
||||
static QStringList getIncludePaths(const QString& text);
|
||||
QString assembleContext(QPointer<KTextEditor::Document> document, const KTextEditor::Cursor& cursor);
|
||||
|
||||
QPointer<KTextEditor::Document> activeDocument() const;
|
||||
KTextEditor::Cursor getCurrentCursor() const;
|
||||
QHash<uint32_t, Request> m_requests;
|
||||
|
||||
public:
|
||||
KateAiPluginView(KateAiPlugin *plugin, KTextEditor::MainWindow *mainwindow, QPointer<QWebSocket> webSocket,
|
||||
bool instruct = false);
|
||||
KateAiPluginView(KateAiPlugin *plugin, KTextEditor::MainWindow *mainwindow, bool instruct = false);
|
||||
~KateAiPluginView() override;
|
||||
void setInstruct(bool instruct);
|
||||
static void setAi(QPointer<AiBackend> ai){m_ai = ai;}
|
||||
|
||||
Q_SIGNAL void reconnect();
|
||||
};
|
||||
|
Reference in New Issue
Block a user