Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ai_processing/include/ai_processing.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ enum struct process_with_ai_error
consteval auto adl_enum_bounds(process_with_ai_error)
{
using enum process_with_ai_error;
return simple_enum::adl_info{other_error, no_valid_command};
return simple_enum::adl_info{.first = other_error, .last = no_valid_command};
}

struct model_response_text_t
Expand Down
12 changes: 6 additions & 6 deletions ai_processing/include/aiprocess/app_settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
namespace aiprocess
{

enum struct backend_type_e
enum struct backend_type_e : std::uint8_t
{
kate,
kdevelop
Expand All @@ -22,15 +22,15 @@ enum struct backend_type_e
consteval auto adl_enum_bounds(backend_type_e)
{
using enum backend_type_e;
return simple_enum::adl_info{kate, kdevelop};
return simple_enum::adl_info{.first = kate, .last = kdevelop};
}

inline constexpr string_view kdevcxx_with_ai_app_settings_file_name{"kdevcxx_with_ai_app_settings.json"};
inline constexpr string_view kate_with_ai_app_settings_file_name{"kate_with_ai_app_settings.json"};

inline constexpr string_view kdevcxx_with_ai_ai_settings_file_name{"kdevcxx_with_ai_ai_settings.json"};

enum struct app_settings_version_e
enum struct app_settings_version_e : std::uint8_t
{
v1 = 1,

Expand All @@ -40,7 +40,7 @@ enum struct app_settings_version_e
consteval auto adl_enum_bounds(app_settings_version_e)
{
using enum app_settings_version_e;
return simple_enum::adl_info{v1, latest};
return simple_enum::adl_info{.first = v1, .last = latest};
}

struct app_settings_t
Expand Down Expand Up @@ -80,7 +80,7 @@ auto store_app_settings(app_settings_t const & cfg) noexcept -> bool;
extern template auto store_app_settings<backend_type_e::kdevelop>(app_settings_t const & cfg) noexcept -> bool;
extern template auto store_app_settings<backend_type_e::kate>(app_settings_t const & cfg) noexcept -> bool;

enum struct ai_settings_version_e
enum struct ai_settings_version_e : std::uint8_t
{
v1 = 1,
v2,
Expand All @@ -90,7 +90,7 @@ enum struct ai_settings_version_e
consteval auto adl_enum_bounds(ai_settings_version_e)
{
using enum ai_settings_version_e;
return simple_enum::adl_info{v1, latest};
return simple_enum::adl_info{.first = v1, .last = latest};
}

//
Expand Down
2 changes: 1 addition & 1 deletion ai_processing/include/aiprocess/change_current_dir.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ enum struct change_directory_error
consteval auto adl_enum_bounds(change_directory_error)
{
using enum change_directory_error;
return simple_enum::adl_info{unhandled_exception, filesystem_error};
return simple_enum::adl_info{.first = unhandled_exception, .last = filesystem_error};
}

[[nodiscard]]
Expand Down
2 changes: 1 addition & 1 deletion ai_processing/include/network.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ struct url_components

// auto parse(std::string_view url) -> url_components;

enum struct send_text_to_gpt_error
enum struct send_text_to_gpt_error : std::uint8_t
{
network_error,
other_exception,
Expand Down
4 changes: 2 additions & 2 deletions ai_processing/source/ai_processing.cc
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ try
{
using enum process_with_ai_error;

aiprocess::ai_settings_t aisettings{aiprocess::load_ai_settings()};
const aiprocess::ai_settings_t aisettings{aiprocess::load_ai_settings()};
info("checking api key ..");
if(!is_valid_openai_bearer_key(aisettings.api_key)) [[unlikely]]
return unexpected_error(invalid_api_key, "invalid key bailing out");
Expand All @@ -149,7 +149,7 @@ try
if(command_text.empty()) [[unlikely]]
return unexpected_error(no_valid_command, "command_text is empty nothing to do ..");

std::string code_text = user_data.substr(end_pos + command_end_delim.length());
const std::string code_text = user_data.substr(end_pos + command_end_delim.length());

#ifndef ENABLE_CHAT_COMPLETIONS
ai_command_json command{.prompt = fmt::format("[{},{}] {}", ai_rules, command_text, code_text)};
Expand Down
6 changes: 3 additions & 3 deletions ai_processing/source/log.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ static auto create_log_sink(std::string const & path, std::string const & filena
return std::make_shared<spdlog::sinks::basic_file_sink_mt>(stralgo::stl::merge(path, '/', filename), false);
}

static std::shared_ptr<spdlog::logger> create_logger(std::string name, spdlog::sinks_init_list sinks)
static std::shared_ptr<spdlog::logger> create_logger(std::string const & name, spdlog::sinks_init_list sinks)
{
auto logger = std::make_shared<spdlog::logger>(name, sinks.begin(), sinks.end());
logger->flush_on(spdlog::level::err);
Expand All @@ -43,8 +43,8 @@ static std::shared_ptr<spdlog::logger> create_logger(std::string name, spdlog::s

void setup_loggers(app_settings_t const & cfg)
{
std::string app_path{get_config_path()};
std::string log_path{stralgo::stl::merge(app_path, '/', cfg.log_path)};
const std::string app_path{get_config_path()};
const std::string log_path{stralgo::stl::merge(app_path, '/', cfg.log_path)};

console_sink = std::make_shared<spdlog::sinks::stdout_color_sink_mt>();
console_sink->set_level(cfg.console_log_level);
Expand Down
14 changes: 7 additions & 7 deletions src/kate_with_ai/kate_with_ai.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,36 +22,36 @@ using aiprocess::warn;

K_PLUGIN_FACTORY_WITH_JSON(kate_with_aiFactory, "kate_with_ai.json", registerPlugin<kate_with_ai>();)

kate_with_ai::kate_with_ai(QObject * parent, QList<QVariant> const &) : KTextEditor::Plugin(parent)
kate_with_ai::kate_with_ai(QObject * parent, QList<QVariant> const &) : KTextEditor::Plugin{parent}
{
log(aiprocess::level::info, "Starting plugin Kate_With_Ai");
settings = aiprocess::load_app_settings<aiprocess::backend_type_e::kate>();
aiprocess::setup_loggers(settings);
info("Settings loaded");
}

kate_with_ai::~kate_with_ai() {}
kate_with_ai::~kate_with_ai() = default;

int kate_with_ai::configPages() const { return 1; }

KTextEditor::ConfigPage * kate_with_ai::configPage(int number, QWidget * parent)
{
if(number == 0)
return new kate_with_ai_config_page(parent);
return new kate_with_ai_config_page{parent};
return nullptr; // No other pages to return
}

QObject * kate_with_ai::createView(KTextEditor::MainWindow * main_window)
{
auto * view = new kate_with_ai_view(this, main_window);
auto * view = new kate_with_ai_view{this, main_window};
return view;
}

kate_with_ai_view::kate_with_ai_view(kate_with_ai * plugin, KTextEditor::MainWindow * main_window) :
plugin_{plugin},
main_window_(main_window)
main_window_{main_window}
{
openai_process_action = new QAction(tr("Process with OpenAI"), this);
openai_process_action = new QAction{tr("Process with OpenAI"), this};
connect(openai_process_action, &QAction::triggered, this, &kate_with_ai_view::on_process_with_ai);

// Connect to the signal that notifies about the current view change
Expand All @@ -63,7 +63,7 @@ kate_with_ai_view::kate_with_ai_view(kate_with_ai * plugin, KTextEditor::MainWin

void kate_with_ai_view::on_view_changed(KTextEditor::View * view) { init_view(view); }

void kate_with_ai_view::init_view(KTextEditor::View * view)
void kate_with_ai_view::init_view(KTextEditor::View * view) const
{
if(!view) [[unlikely]]
return;
Expand Down
11 changes: 6 additions & 5 deletions src/kate_with_ai/kate_with_ai.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,19 @@ class kate_with_ai_view;
class kate_with_ai : public KTextEditor::Plugin
{
Q_OBJECT
Q_DISABLE_COPY_MOVE(kate_with_ai)
friend class kate_with_ai_view;

aiprocess::app_settings_t settings;

public:
explicit kate_with_ai(QObject * parent, QList<QVariant> const & = QList<QVariant>());
explicit kate_with_ai(QObject * parent, QList<QVariant> const & = QList<QVariant>{});
~kate_with_ai() override;

QObject * createView(KTextEditor::MainWindow * mainWindow) override;
[[nodiscard]] auto createView(KTextEditor::MainWindow * main_window) -> QObject * override;

int configPages() const override;
KTextEditor::ConfigPage * configPage(int number, QWidget * parent) override;
[[nodiscard]] auto configPages() const -> int override;
[[nodiscard]] auto configPage(int number, QWidget * parent) -> KTextEditor::ConfigPage* override;
};

class kate_with_ai_view : public QWidget
Expand All @@ -45,7 +46,7 @@ private slots:
void on_context_menu_about_to_show(KTextEditor::View * view, QMenu * menu);

private:
void init_view(KTextEditor::View * view);
void init_view(KTextEditor::View * view) const;
void on_process_with_ai();

kate_with_ai * plugin_;
Expand Down
10 changes: 6 additions & 4 deletions src/kate_with_ai/kate_with_ai_config_page.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,22 @@
#include <aiprocess/log.h>
#endif

kate_with_ai_config_page::kate_with_ai_config_page(QWidget * parent) : KTextEditor::ConfigPage(parent)
kate_with_ai_config_page::kate_with_ai_config_page(QWidget * parent) : KTextEditor::ConfigPage{parent}
{
kdevcxxai::config_page::construct<aiprocess::backend_type_e::kate>(
*this, ui, std::bind(&kate_with_ai_config_page::emit_changed, this)
);
}

kate_with_ai_config_page::~kate_with_ai_config_page() = default;

void kate_with_ai_config_page::emit_changed() { emit changed(); }

QString kate_with_ai_config_page::name() const { return i18n("OpenAI Configuration"); }
auto kate_with_ai_config_page::name() const -> QString { return i18n("OpenAI Configuration"); }

QString kate_with_ai_config_page::fullName() const { return i18n("Configure Open AI Settings"); }
auto kate_with_ai_config_page::fullName() const -> QString { return i18n("Configure Open AI Settings"); }

QIcon kate_with_ai_config_page::icon() const { return QIcon::fromTheme("preferences-other"); }
auto kate_with_ai_config_page::icon() const -> QIcon { return QIcon::fromTheme("preferences-other"); }

void kate_with_ai_config_page::apply() { kdevcxxai::config_page::apply<aiprocess::backend_type_e::kate>(ui); }

Expand Down
8 changes: 5 additions & 3 deletions src/kate_with_ai/kate_with_ai_config_page.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@
class kate_with_ai_config_page : public KTextEditor::ConfigPage
{
Q_OBJECT
Q_DISABLE_COPY_MOVE(kate_with_ai_config_page)

public:
explicit kate_with_ai_config_page(QWidget * parent = nullptr);
~kate_with_ai_config_page() override;

QString name() const override;
QString fullName() const override;
QIcon icon() const override;
[[nodiscard]] auto name() const -> QString override;
[[nodiscard]] auto fullName() const -> QString override;
[[nodiscard]] auto icon() const -> QIcon override;

void apply() override;
void reset() override;
Expand Down
10 changes: 5 additions & 5 deletions src/kdevcxx_with_ai/kdevcxx_with_ai.cc
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ using aiprocess::warn;

K_PLUGIN_FACTORY_WITH_JSON(cxx_with_gptFactory, "kdevcxx_with_ai.json", registerPlugin<kdevcxx_with_ai>();)

kdevcxx_with_ai::kdevcxx_with_ai(QObject * parent, QVariantList const &) : KDevelop::IPlugin("kdevcxx_with_ai", parent)
kdevcxx_with_ai::kdevcxx_with_ai(QObject * parent, QVariantList const &) : KDevelop::IPlugin{"kdevcxx_with_ai", parent}
{
log(aiprocess::level::info, "Starting plugin KDevCxx_With_Ai");
settings = aiprocess::load_app_settings<aiprocess::backend_type_e::kdevelop>();
Expand Down Expand Up @@ -75,7 +75,7 @@ void kdevcxx_with_ai::on_process_with_ai()

void kdevcxx_with_ai::createActionsForMainWindow(Sublime::MainWindow *, QString &, KActionCollection & actions)
{
QAction * process_with_ai_action = new QAction(QIcon(":/icons/my_icon.png"), tr("Process with OpenAI"), this);
auto * process_with_ai_action = new QAction{QIcon(":/icons/my_icon.png"), tr("Process with OpenAI"), this};
process_with_ai_action->setToolTip(tr("Do something interesting with AI"));

process_with_ai_action->setShortcut(settings.activation_keys);
Expand All @@ -94,7 +94,7 @@ auto kdevcxx_with_ai::contextMenuExtension(KDevelop::Context * context, QWidget
{
info("Context menu registered for AI");
// This is just an example; customize it based on your plugin's functionality
QAction * process_with_ai_action = new QAction(QIcon::fromTheme("system-run"), tr("Process with OpenAI"), parent);
auto * process_with_ai_action = new QAction{QIcon::fromTheme("system-run"), tr("Process with OpenAI"), parent};
connect(process_with_ai_action, &QAction::triggered, this, &kdevcxx_with_ai::on_process_with_ai);

// Add your action to the extension
Expand All @@ -109,13 +109,13 @@ int kdevcxx_with_ai::configPages() const { return 1; }
auto kdevcxx_with_ai::configPage(int number, QWidget * parent) -> KDevelop::ConfigPage *
{
if(number == 0)
return new kdevcxx_with_ai_config_page(this, parent);
return new kdevcxx_with_ai_config_page{this, parent};
return nullptr; // No other pages to return
}

void kdevcxx_with_ai::unload() {}

kdevcxx_with_ai::~kdevcxx_with_ai() {}
kdevcxx_with_ai::~kdevcxx_with_ai() = default;

#include "kdevcxx_with_ai.moc"
// #include "moc_kdevcxx_with_ai.cpp"
9 changes: 5 additions & 4 deletions src/kdevcxx_with_ai/kdevcxx_with_ai.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,22 @@
class kdevcxx_with_ai : public KDevelop::IPlugin
{
Q_OBJECT
Q_DISABLE_COPY_MOVE(kdevcxx_with_ai)
aiprocess::app_settings_t settings;

public:
kdevcxx_with_ai(QObject * parent, QVariantList const & args);
~kdevcxx_with_ai() override;

auto contextMenuExtension(KDevelop::Context * context, QWidget * parent) -> KDevelop::ContextMenuExtension override;
[[nodiscard]] auto contextMenuExtension(KDevelop::Context * context, QWidget * parent) -> KDevelop::ContextMenuExtension override;

auto createActionsForMainWindow(Sublime::MainWindow * window, QString & xmlFile, KActionCollection & actions)
-> void override;

void unload() override;
auto unload() -> void override;

KDevelop::ConfigPage * configPage(int number, QWidget * parent) override;
int configPages() const override;
[[nodiscard]] auto configPage(int number, QWidget * parent) ->KDevelop::ConfigPage* override;
[[nodiscard]] auto configPages() const -> int override;

private slots:

Expand Down
10 changes: 6 additions & 4 deletions src/kdevcxx_with_ai/kdevcxx_with_ai_config_page.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,22 @@
#endif

kdevcxx_with_ai_config_page::kdevcxx_with_ai_config_page(KDevelop::IPlugin * plugin, QWidget * parent) :
KDevelop::ConfigPage(plugin, nullptr, parent)
KDevelop::ConfigPage{plugin, nullptr, parent}
{
kdevcxxai::config_page::construct<aiprocess::backend_type_e::kdevelop>(
*this, ui, std::bind(&kdevcxx_with_ai_config_page::emit_changed, this)
);
}

kdevcxx_with_ai_config_page::~kdevcxx_with_ai_config_page() = default;

void kdevcxx_with_ai_config_page::emit_changed() { emit changed(); }

QString kdevcxx_with_ai_config_page::name() const { return i18n("OpenAI Configuration"); }
auto kdevcxx_with_ai_config_page::name() const -> QString { return i18n("OpenAI Configuration"); }

QString kdevcxx_with_ai_config_page::fullName() const { return i18n("Configure Open AI Settings"); }
auto kdevcxx_with_ai_config_page::fullName() const -> QString { return i18n("Configure Open AI Settings"); }

QIcon kdevcxx_with_ai_config_page::icon() const { return QIcon::fromTheme("preferences-other"); }
auto kdevcxx_with_ai_config_page::icon() const -> QIcon { return QIcon::fromTheme("preferences-other"); }

void kdevcxx_with_ai_config_page::apply() { kdevcxxai::config_page::apply<aiprocess::backend_type_e::kdevelop>(ui); }

Expand Down
7 changes: 4 additions & 3 deletions src/kdevcxx_with_ai/kdevcxx_with_ai_config_page.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ class kdevcxx_with_ai_config_page : public KDevelop::ConfigPage

public:
explicit kdevcxx_with_ai_config_page(KDevelop::IPlugin * plugin, QWidget * parent = nullptr);
~kdevcxx_with_ai_config_page() override;

QString name() const override;
QString fullName() const override;
QIcon icon() const override;
auto name() const -> QString override;
auto fullName() const -> QString override;
auto icon() const -> QIcon override;

void apply() override;
void reset() override;
Expand Down
2 changes: 1 addition & 1 deletion src/plugin_common/include/plugin_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ inline constexpr auto fist_time_message
"negating the necessity for a KDevelop restart.\n"
"Alterations to AI settings will be effective upon the next invocation.";

enum class get_view_file_path_error
enum class get_view_file_path_error : std::uint8_t
{
no_document,
unhandled_exception
Expand Down
12 changes: 6 additions & 6 deletions src/plugin_common/info_dialog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,22 @@
#include <qlabel.h>
#include <qpushbutton.h>

info_dialog::info_dialog(QString const & title, QString const & text, QWidget * parent) : QDialog(parent)
info_dialog::info_dialog(QString const & title, QString const & text, QWidget * parent) : QDialog{parent}
{
setWindowTitle(title);

QVBoxLayout * layout = new QVBoxLayout(this);
QLabel * label = new QLabel(text, this);
auto * layout = new QVBoxLayout{this};
auto * label = new QLabel{text, this};
layout->addWidget(label);

// Optional: Add a button to close the dialog
QPushButton * close_button = new QPushButton("Close", this);
auto * close_button = new QPushButton{"Close", this};
connect(close_button, &QPushButton::clicked, this, &info_dialog::accept);
layout->addWidget(close_button);

setLayout(layout);
}

info_dialog::~info_dialog()
{}
info_dialog::~info_dialog() = default;


Loading