新增对话历史面板

This commit is contained in:
2026-05-29 16:49:00 +08:00
parent 27d63965f4
commit da803da2de
5 changed files with 412 additions and 38 deletions
+37
View File
@@ -0,0 +1,37 @@
#pragma once
#include "../ai/LLMTypes.h"
#include <QDialog>
#include <QPoint>
#include <QRect>
#include <QVector>
class QEvent;
class QTextEdit;
class ChatHistoryPanel : public QDialog
{
public:
explicit ChatHistoryPanel(QWidget *parent = nullptr);
~ChatHistoryPanel() override;
void setMessages(const QVector<ChatMessage> &messages);
void showAt(const QPoint &anchorPosition);
void showNear(const QRect &avoidRect);
protected:
bool event(QEvent *event) override;
bool eventFilter(QObject *watched, QEvent *event) override;
private:
bool isOwnObject(QObject *object) const;
QRect availableGeometryForPoint(const QPoint &point) const;
QRect availableGeometryForRect(const QRect &rect) const;
QPoint constrainedTopLeft(const QPoint &preferredTopLeft, const QRect &availableGeometry) const;
QPoint smartTopLeftNear(const QRect &avoidRect) const;
void updateContent();
QTextEdit *m_textEdit;
QVector<ChatMessage> m_messages;
};