104 lines
2.4 KiB
C++
104 lines
2.4 KiB
C++
#ifndef OLLIE_KATE_PLUGIN_H
|
|
#define OLLIE_KATE_PLUGIN_H
|
|
|
|
#include <KTextEditor/Plugin>
|
|
#include <KTextEditor/MainWindow>
|
|
#include <KTextEditor/View>
|
|
#if QT_VERSION_MAJOR >= 6
|
|
#include <KPluginMetaData>
|
|
#endif
|
|
|
|
#include <QPointer>
|
|
#include <QLabel>
|
|
#include <QAction>
|
|
#include <QEvent>
|
|
#include <QTimer>
|
|
|
|
#include "lib9pclient.h"
|
|
|
|
class OllieKateView;
|
|
class OllieGhostProvider;
|
|
|
|
class OllieKatePlugin : public KTextEditor::Plugin
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
#if QT_VERSION_MAJOR >= 6
|
|
explicit OllieKatePlugin(QObject *parent, const KPluginMetaData &data, const QVariantList &args = {});
|
|
#else
|
|
explicit OllieKatePlugin(QObject *parent, const QVariantList &args = {});
|
|
#endif
|
|
~OllieKatePlugin() override = default;
|
|
|
|
QObject *createView(KTextEditor::MainWindow *mainWindow) override;
|
|
|
|
// Completion config accessors
|
|
QString completionBackend() const { return m_completionBackend; }
|
|
QString completionModel() const { return m_completionModel; }
|
|
bool completionEnabled() const { return m_completionEnabled; }
|
|
|
|
private:
|
|
void loadConfig();
|
|
|
|
QString m_completionBackend;
|
|
QString m_completionModel;
|
|
bool m_completionEnabled = true;
|
|
};
|
|
|
|
class OllieKateView : public QObject
|
|
{
|
|
Q_OBJECT
|
|
|
|
public:
|
|
explicit OllieKateView(OllieKatePlugin *plugin, KTextEditor::MainWindow *mainWindow);
|
|
~OllieKateView() override;
|
|
|
|
OllieKatePlugin *plugin() const { return m_plugin; }
|
|
|
|
protected:
|
|
bool eventFilter(QObject *obj, QEvent *event) override;
|
|
|
|
private slots:
|
|
void onProjectChanged();
|
|
void heartbeat();
|
|
|
|
private:
|
|
// Actions
|
|
void askAboutFile();
|
|
void explainSelection();
|
|
void submitSelectionPrompt(const QString &action);
|
|
void sendVerbatim();
|
|
void reviewDiff();
|
|
|
|
// Agent management
|
|
void ensureAgent();
|
|
bool selectAgentForProject();
|
|
void switchToAgent(const QString &agentId);
|
|
QString projectBaseDir();
|
|
QString agentPath() const;
|
|
void updateStatusLabel();
|
|
|
|
// Context menu
|
|
void setupContextMenu(KTextEditor::View *view);
|
|
void setupGitPlusPlusDiffAction();
|
|
|
|
// Ghost text
|
|
void setupGhostProvider();
|
|
|
|
OllieKatePlugin *m_plugin;
|
|
KTextEditor::MainWindow *m_mainWindow;
|
|
Lib9pClient *m_9p;
|
|
|
|
QString m_sessionId;
|
|
QString m_agentId;
|
|
bool m_connected = false;
|
|
|
|
QTimer *m_heartbeatTimer;
|
|
QLabel *m_statusLabel = nullptr;
|
|
QPointer<OllieGhostProvider> m_ghost;
|
|
bool m_ghostPrefix = false;
|
|
};
|
|
|
|
#endif // OLLIE_KATE_PLUGIN_H
|