mirror of
https://github.com/Palm1r/QodeAssist.git
synced 2026-07-21 10:40:57 -04:00
refactor: Restructure project into sources/tests layout and dissolve PluginLLMCore
This commit is contained in:
48
sources/chat/ChatDocument.cpp
Normal file
48
sources/chat/ChatDocument.cpp
Normal file
@@ -0,0 +1,48 @@
|
||||
// Copyright (C) 2024-2026 Petr Mironychev
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
// Additional attribution terms under GPLv3 §7(b) apply — see LICENSE
|
||||
|
||||
#include "ChatDocument.hpp"
|
||||
|
||||
#include <utils/result.h>
|
||||
|
||||
#include "plugin/QodeAssistConstants.hpp"
|
||||
#include "plugin/QodeAssisttr.h"
|
||||
|
||||
namespace QodeAssist::Chat {
|
||||
|
||||
ChatDocument::ChatDocument(QObject *parent)
|
||||
: Core::IDocument(parent)
|
||||
{
|
||||
setId(Constants::QODE_ASSIST_CHAT_EDITOR_ID);
|
||||
setMimeType("text/plain");
|
||||
setTemporary(true);
|
||||
setPreferredDisplayName(Tr::tr("QodeAssist Chat"));
|
||||
}
|
||||
|
||||
QByteArray ChatDocument::contents() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
Utils::Result<> ChatDocument::setContents(const QByteArray &)
|
||||
{
|
||||
return Utils::ResultOk;
|
||||
}
|
||||
|
||||
bool ChatDocument::isModified() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ChatDocument::isSaveAsAllowed() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ChatDocument::shouldAutoSave() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace QodeAssist::Chat
|
||||
28
sources/chat/ChatDocument.hpp
Normal file
28
sources/chat/ChatDocument.hpp
Normal file
@@ -0,0 +1,28 @@
|
||||
// Copyright (C) 2024-2026 Petr Mironychev
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
// Additional attribution terms under GPLv3 §7(b) apply — see LICENSE
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <coreplugin/idocument.h>
|
||||
|
||||
namespace QodeAssist::Chat {
|
||||
|
||||
// Backing document for a chat editor view. The chat persists itself through its own
|
||||
// autosave history file, so this document is purely a placeholder for the editor area
|
||||
// and never participates in Qt Creator's save infrastructure.
|
||||
class ChatDocument : public Core::IDocument
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ChatDocument(QObject *parent = nullptr);
|
||||
|
||||
QByteArray contents() const override;
|
||||
Utils::Result<> setContents(const QByteArray &contents) override;
|
||||
bool isModified() const override;
|
||||
bool isSaveAsAllowed() const override;
|
||||
bool shouldAutoSave() const override;
|
||||
};
|
||||
|
||||
} // namespace QodeAssist::Chat
|
||||
76
sources/chat/ChatEditor.cpp
Normal file
76
sources/chat/ChatEditor.cpp
Normal file
@@ -0,0 +1,76 @@
|
||||
// Copyright (C) 2024-2026 Petr Mironychev
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
// Additional attribution terms under GPLv3 §7(b) apply — see LICENSE
|
||||
|
||||
#include "ChatEditor.hpp"
|
||||
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
|
||||
#include "ChatDocument.hpp"
|
||||
#include "ChatView/ChatRootView.hpp"
|
||||
#include "ChatView/ChatWidget.hpp"
|
||||
#include "plugin/QodeAssistConstants.hpp"
|
||||
#include "plugin/QodeAssisttr.h"
|
||||
|
||||
namespace QodeAssist::Chat {
|
||||
|
||||
ChatEditor::ChatEditor(
|
||||
QQmlEngine *engine,
|
||||
SessionFileRegistry *sessionFileRegistry,
|
||||
Skills::SkillsManager *skillsManager)
|
||||
: m_engine(engine)
|
||||
, m_sessionFileRegistry(sessionFileRegistry)
|
||||
, m_skillsManager(skillsManager)
|
||||
, m_document(new ChatDocument(this))
|
||||
, m_chatWidget(new ChatWidget(engine, sessionFileRegistry, skillsManager, false))
|
||||
{
|
||||
setWidget(m_chatWidget);
|
||||
setContext(Core::Context(Constants::QODE_ASSIST_CHAT_CONTEXT));
|
||||
setDuplicateSupported(false);
|
||||
|
||||
if (auto rootView = qobject_cast<ChatRootView *>(m_chatWidget->rootObject())) {
|
||||
rootView->setInEditor(true);
|
||||
connect(
|
||||
rootView,
|
||||
&ChatRootView::closeHostRequested,
|
||||
this,
|
||||
[this] { Core::EditorManager::closeEditors({this}); },
|
||||
Qt::QueuedConnection);
|
||||
|
||||
auto syncTitle = [this, rootView] {
|
||||
const QString title = rootView->chatTitle();
|
||||
m_document->setPreferredDisplayName(
|
||||
title.isEmpty() ? Tr::tr("QodeAssist Chat") : QStringLiteral("QodeAssist - ") + title);
|
||||
};
|
||||
connect(rootView, &ChatRootView::chatTitleChanged, this, syncTitle);
|
||||
syncTitle();
|
||||
}
|
||||
}
|
||||
|
||||
void ChatEditor::consumePendingChatFile()
|
||||
{
|
||||
if (auto rootView = qobject_cast<ChatRootView *>(m_chatWidget->rootObject()))
|
||||
rootView->consumePendingChatFile();
|
||||
}
|
||||
|
||||
ChatEditor::~ChatEditor()
|
||||
{
|
||||
delete m_chatWidget;
|
||||
}
|
||||
|
||||
Core::IDocument *ChatEditor::document() const
|
||||
{
|
||||
return m_document;
|
||||
}
|
||||
|
||||
QWidget *ChatEditor::toolBar()
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Core::IEditor *ChatEditor::duplicate()
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
} // namespace QodeAssist::Chat
|
||||
46
sources/chat/ChatEditor.hpp
Normal file
46
sources/chat/ChatEditor.hpp
Normal file
@@ -0,0 +1,46 @@
|
||||
// Copyright (C) 2024-2026 Petr Mironychev
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
// Additional attribution terms under GPLv3 §7(b) apply — see LICENSE
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <coreplugin/editormanager/ieditor.h>
|
||||
|
||||
class QQmlEngine;
|
||||
|
||||
namespace QodeAssist::Skills {
|
||||
class SkillsManager;
|
||||
}
|
||||
|
||||
namespace QodeAssist::Chat {
|
||||
|
||||
class ChatDocument;
|
||||
class ChatWidget;
|
||||
class SessionFileRegistry;
|
||||
|
||||
class ChatEditor : public Core::IEditor
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ChatEditor(
|
||||
QQmlEngine *engine,
|
||||
SessionFileRegistry *sessionFileRegistry,
|
||||
Skills::SkillsManager *skillsManager);
|
||||
~ChatEditor() override;
|
||||
|
||||
Core::IDocument *document() const override;
|
||||
QWidget *toolBar() override;
|
||||
Core::IEditor *duplicate() override;
|
||||
|
||||
void consumePendingChatFile();
|
||||
|
||||
private:
|
||||
QQmlEngine *m_engine;
|
||||
SessionFileRegistry *m_sessionFileRegistry;
|
||||
Skills::SkillsManager *m_skillsManager;
|
||||
ChatDocument *m_document;
|
||||
ChatWidget *m_chatWidget;
|
||||
};
|
||||
|
||||
} // namespace QodeAssist::Chat
|
||||
25
sources/chat/ChatEditorFactory.cpp
Normal file
25
sources/chat/ChatEditorFactory.cpp
Normal file
@@ -0,0 +1,25 @@
|
||||
// Copyright (C) 2024-2026 Petr Mironychev
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
// Additional attribution terms under GPLv3 §7(b) apply — see LICENSE
|
||||
|
||||
#include "ChatEditorFactory.hpp"
|
||||
|
||||
#include "ChatEditor.hpp"
|
||||
#include "plugin/QodeAssistConstants.hpp"
|
||||
#include "plugin/QodeAssisttr.h"
|
||||
|
||||
namespace QodeAssist::Chat {
|
||||
|
||||
ChatEditorFactory::ChatEditorFactory(
|
||||
QQmlEngine *engine,
|
||||
SessionFileRegistry *sessionFileRegistry,
|
||||
Skills::SkillsManager *skillsManager)
|
||||
{
|
||||
setId(Constants::QODE_ASSIST_CHAT_EDITOR_ID);
|
||||
setDisplayName(Tr::tr("QodeAssist Chat"));
|
||||
setEditorCreator([engine, sessionFileRegistry, skillsManager] {
|
||||
return new ChatEditor(engine, sessionFileRegistry, skillsManager);
|
||||
});
|
||||
}
|
||||
|
||||
} // namespace QodeAssist::Chat
|
||||
28
sources/chat/ChatEditorFactory.hpp
Normal file
28
sources/chat/ChatEditorFactory.hpp
Normal file
@@ -0,0 +1,28 @@
|
||||
// Copyright (C) 2024-2026 Petr Mironychev
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
// Additional attribution terms under GPLv3 §7(b) apply — see LICENSE
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <coreplugin/editormanager/ieditorfactory.h>
|
||||
|
||||
class QQmlEngine;
|
||||
|
||||
namespace QodeAssist::Skills {
|
||||
class SkillsManager;
|
||||
}
|
||||
|
||||
namespace QodeAssist::Chat {
|
||||
|
||||
class SessionFileRegistry;
|
||||
|
||||
class ChatEditorFactory : public Core::IEditorFactory
|
||||
{
|
||||
public:
|
||||
ChatEditorFactory(
|
||||
QQmlEngine *engine,
|
||||
SessionFileRegistry *sessionFileRegistry,
|
||||
Skills::SkillsManager *skillsManager);
|
||||
};
|
||||
|
||||
} // namespace QodeAssist::Chat
|
||||
86
sources/chat/ChatOutputPane.cpp
Normal file
86
sources/chat/ChatOutputPane.cpp
Normal file
@@ -0,0 +1,86 @@
|
||||
// Copyright (C) 2024-2026 Petr Mironychev
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
// Additional attribution terms under GPLv3 §7(b) apply — see LICENSE
|
||||
|
||||
#include "ChatOutputPane.h"
|
||||
|
||||
#include "plugin/QodeAssisttr.h"
|
||||
|
||||
namespace QodeAssist::Chat {
|
||||
|
||||
ChatOutputPane::ChatOutputPane(
|
||||
QQmlEngine *engine,
|
||||
SessionFileRegistry *sessionFileRegistry,
|
||||
Skills::SkillsManager *skillsManager,
|
||||
QObject *parent)
|
||||
: Core::IOutputPane(parent)
|
||||
, m_chatWidget{new ChatWidget{engine, sessionFileRegistry, skillsManager}}
|
||||
{
|
||||
setId("QodeAssistChat");
|
||||
setDisplayName(Tr::tr("QodeAssist Chat"));
|
||||
setPriorityInStatusBar(-40);
|
||||
}
|
||||
|
||||
ChatOutputPane::~ChatOutputPane()
|
||||
{
|
||||
delete m_chatWidget;
|
||||
}
|
||||
|
||||
QWidget *ChatOutputPane::outputWidget(QWidget *)
|
||||
{
|
||||
return m_chatWidget;
|
||||
}
|
||||
|
||||
QList<QWidget *> ChatOutputPane::toolBarWidgets() const
|
||||
{
|
||||
return {};
|
||||
}
|
||||
|
||||
void ChatOutputPane::clearContents()
|
||||
{
|
||||
m_chatWidget->clear();
|
||||
}
|
||||
|
||||
void ChatOutputPane::visibilityChanged(bool visible)
|
||||
{
|
||||
if (visible) {
|
||||
m_chatWidget->scrollToBottom();
|
||||
m_chatWidget->focusInput();
|
||||
}
|
||||
}
|
||||
|
||||
void ChatOutputPane::setFocus()
|
||||
{
|
||||
m_chatWidget->focusInput();
|
||||
}
|
||||
|
||||
bool ChatOutputPane::hasFocus() const
|
||||
{
|
||||
return m_chatWidget->isChatFocused();
|
||||
}
|
||||
|
||||
bool ChatOutputPane::canFocus() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChatOutputPane::canNavigate() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ChatOutputPane::canNext() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ChatOutputPane::canPrevious() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
void ChatOutputPane::goToNext() {}
|
||||
|
||||
void ChatOutputPane::goToPrev() {}
|
||||
|
||||
} // namespace QodeAssist::Chat
|
||||
47
sources/chat/ChatOutputPane.h
Normal file
47
sources/chat/ChatOutputPane.h
Normal file
@@ -0,0 +1,47 @@
|
||||
// Copyright (C) 2024-2026 Petr Mironychev
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
// Additional attribution terms under GPLv3 §7(b) apply — see LICENSE
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ChatView/ChatWidget.hpp"
|
||||
#include <coreplugin/ioutputpane.h>
|
||||
|
||||
namespace QodeAssist::Skills {
|
||||
class SkillsManager;
|
||||
}
|
||||
|
||||
namespace QodeAssist::Chat {
|
||||
|
||||
class SessionFileRegistry;
|
||||
|
||||
class ChatOutputPane : public Core::IOutputPane
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit ChatOutputPane(
|
||||
QQmlEngine *engine,
|
||||
SessionFileRegistry *sessionFileRegistry,
|
||||
Skills::SkillsManager *skillsManager,
|
||||
QObject *parent = nullptr);
|
||||
~ChatOutputPane() override;
|
||||
|
||||
QWidget *outputWidget(QWidget *parent) override;
|
||||
QList<QWidget *> toolBarWidgets() const override;
|
||||
void clearContents() override;
|
||||
void visibilityChanged(bool visible) override;
|
||||
void setFocus() override;
|
||||
bool hasFocus() const override;
|
||||
bool canFocus() const override;
|
||||
bool canNavigate() const override;
|
||||
bool canNext() const override;
|
||||
bool canPrevious() const override;
|
||||
void goToNext() override;
|
||||
void goToPrev() override;
|
||||
|
||||
private:
|
||||
ChatWidget *m_chatWidget;
|
||||
};
|
||||
|
||||
} // namespace QodeAssist::Chat
|
||||
35
sources/chat/NavigationPanel.cpp
Normal file
35
sources/chat/NavigationPanel.cpp
Normal file
@@ -0,0 +1,35 @@
|
||||
// Copyright (C) 2024-2026 Petr Mironychev
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
// Additional attribution terms under GPLv3 §7(b) apply — see LICENSE
|
||||
|
||||
#include "NavigationPanel.hpp"
|
||||
|
||||
#include "ChatView/ChatWidget.hpp"
|
||||
#include "ChatView/SessionFileRegistry.hpp"
|
||||
#include "plugin/QodeAssistConstants.hpp"
|
||||
#include "skills/SkillsManager.hpp"
|
||||
|
||||
namespace QodeAssist::Chat {
|
||||
|
||||
NavigationPanel::NavigationPanel(
|
||||
QQmlEngine *engine,
|
||||
SessionFileRegistry *sessionFileRegistry,
|
||||
Skills::SkillsManager *skillsManager)
|
||||
: m_engine{engine}
|
||||
, m_sessionFileRegistry{sessionFileRegistry}
|
||||
, m_skillsManager{skillsManager}
|
||||
{
|
||||
setDisplayName(tr("QodeAssist Chat"));
|
||||
setPriority(500);
|
||||
setId(Constants::QODE_ASSIST_CHAT_NAV_ID);
|
||||
setActivationSequence(QKeySequence(Qt::CTRL | Qt::ALT | Qt::Key_C));
|
||||
}
|
||||
|
||||
NavigationPanel::~NavigationPanel() {}
|
||||
|
||||
Core::NavigationView NavigationPanel::createWidget()
|
||||
{
|
||||
return {.widget = new ChatWidget{m_engine, m_sessionFileRegistry, m_skillsManager}};
|
||||
}
|
||||
|
||||
} // namespace QodeAssist::Chat
|
||||
39
sources/chat/NavigationPanel.hpp
Normal file
39
sources/chat/NavigationPanel.hpp
Normal file
@@ -0,0 +1,39 @@
|
||||
// Copyright (C) 2024-2026 Petr Mironychev
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
// Additional attribution terms under GPLv3 §7(b) apply — see LICENSE
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <coreplugin/inavigationwidgetfactory.h>
|
||||
#include <QObject>
|
||||
#include <QPointer>
|
||||
|
||||
class QQmlEngine;
|
||||
|
||||
namespace QodeAssist::Skills {
|
||||
class SkillsManager;
|
||||
}
|
||||
|
||||
namespace QodeAssist::Chat {
|
||||
|
||||
class SessionFileRegistry;
|
||||
|
||||
class NavigationPanel : public Core::INavigationWidgetFactory
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit NavigationPanel(
|
||||
QQmlEngine *engine,
|
||||
SessionFileRegistry *sessionFileRegistry,
|
||||
Skills::SkillsManager *skillsManager);
|
||||
~NavigationPanel();
|
||||
|
||||
Core::NavigationView createWidget() override;
|
||||
|
||||
private:
|
||||
QPointer<QQmlEngine> m_engine;
|
||||
QPointer<SessionFileRegistry> m_sessionFileRegistry;
|
||||
QPointer<Skills::SkillsManager> m_skillsManager;
|
||||
};
|
||||
|
||||
} // namespace QodeAssist::Chat
|
||||
Reference in New Issue
Block a user