70 lines
1.7 KiB
C++
70 lines
1.7 KiB
C++
#ifndef OLLIE_KATE_PLUGIN_H
|
|
#define OLLIE_KATE_PLUGIN_H
|
|
|
|
#include <KTextEditor/Plugin>
|
|
#include <KTextEditor/MainWindow>
|
|
#include <KTextEditor/View>
|
|
#include <KPluginMetaData>
|
|
|
|
#include <QDBusInterface>
|
|
#include <QDBusConnection>
|
|
#include <QTextEdit>
|
|
#include <QLineEdit>
|
|
#include <QLabel>
|
|
#include <QAction>
|
|
|
|
class OllieKateView;
|
|
|
|
class OllieKatePlugin : public KTextEditor::Plugin
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit OllieKatePlugin(QObject *parent, const KPluginMetaData &data, const QVariantList &args = {});
|
|
~OllieKatePlugin() override = default;
|
|
|
|
QObject *createView(KTextEditor::MainWindow *mainWindow) override;
|
|
};
|
|
|
|
class OllieKateView : public QObject
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit OllieKateView(OllieKatePlugin *plugin, KTextEditor::MainWindow *mainWindow);
|
|
~OllieKateView() override;
|
|
|
|
private slots:
|
|
void onChatUpdated(const QString &session_id, qlonglong offset, const QString &new_text);
|
|
void onStateChanged(const QString &session_id, const QString &new_state);
|
|
void onSessionCreated(const QString &session_id);
|
|
void onSessionKilled(const QString &session_id);
|
|
|
|
void submitPrompt();
|
|
void askAboutFile();
|
|
void explainSelection();
|
|
void newSession();
|
|
void refreshSessions();
|
|
|
|
private:
|
|
void ensureSession();
|
|
QString activeSessionId();
|
|
void appendChat(const QString &text);
|
|
|
|
KTextEditor::MainWindow *m_mainWindow;
|
|
QDBusInterface *m_iface;
|
|
QWidget *m_toolView;
|
|
QLabel *m_sessionLabel;
|
|
QLabel *m_cwdLabel;
|
|
QTextEdit *m_chatView;
|
|
QLineEdit *m_promptInput;
|
|
QAction *m_askFileAction;
|
|
QAction *m_explainAction;
|
|
QAction *m_newSessionAction;
|
|
|
|
QString m_sessionId;
|
|
qlonglong m_chatOffset = 0;
|
|
};
|
|
|
|
#endif // OLLIE_KATE_PLUGIN_H
|