mirror of
https://github.com/Palm1r/QodeAssist.git
synced 2026-05-30 02:49:12 -04:00
* refactor: Uses single QML engine for all QML code * fix: Adds missing `QPointer` include * Parents QML engine instance to plugin instance. --------- Co-authored-by: Ivan Lebedev <ilebedev@flightpath3d.com> Co-authored-by: Ivan Lebedev <ilebedev1988@gmail.com>
35 lines
890 B
C++
35 lines
890 B
C++
// Copyright (C) 2024-2026 Petr Mironychev
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
#include "ChatWidget.hpp"
|
|
|
|
#include <QQmlContext>
|
|
#include <QQmlEngine>
|
|
|
|
namespace QodeAssist::Chat {
|
|
|
|
ChatWidget::ChatWidget(QQmlEngine* engine, QWidget *parent)
|
|
: QQuickWidget{engine, parent}
|
|
{
|
|
/// @note setup quick view content
|
|
{
|
|
auto context = new QQmlContext{engine, this};
|
|
auto component = new QQmlComponent{engine, QUrl{"qrc:/qt/qml/ChatView/qml/RootItem.qml"}, this};
|
|
auto rootItem = component->create(context);
|
|
|
|
setContent(component->url(), component, rootItem);
|
|
}
|
|
setResizeMode(QQuickWidget::SizeRootObjectToView);
|
|
}
|
|
|
|
void ChatWidget::clear()
|
|
{
|
|
QMetaObject::invokeMethod(rootObject(), "clearChat");
|
|
}
|
|
|
|
void ChatWidget::scrollToBottom()
|
|
{
|
|
QMetaObject::invokeMethod(rootObject(), "scrollToBottom");
|
|
}
|
|
} // namespace QodeAssist::Chat
|