mirror of
https://github.com/Palm1r/QodeAssist.git
synced 2025-06-04 01:28:58 -04:00
feat: add animation
This commit is contained in:
parent
444b679ada
commit
77aca17dcc
@ -63,7 +63,6 @@ add_qtc_plugin(QodeAssist
|
|||||||
qodeassist.cpp
|
qodeassist.cpp
|
||||||
QodeAssistConstants.hpp
|
QodeAssistConstants.hpp
|
||||||
QodeAssisttr.h
|
QodeAssisttr.h
|
||||||
CompletionProgressHandler.hpp CompletionProgressHandler.cpp
|
|
||||||
LLMClientInterface.hpp LLMClientInterface.cpp
|
LLMClientInterface.hpp LLMClientInterface.cpp
|
||||||
templates/Templates.hpp
|
templates/Templates.hpp
|
||||||
templates/CodeLlamaFim.hpp
|
templates/CodeLlamaFim.hpp
|
||||||
@ -102,6 +101,8 @@ add_qtc_plugin(QodeAssist
|
|||||||
ConfigurationManager.hpp ConfigurationManager.cpp
|
ConfigurationManager.hpp ConfigurationManager.cpp
|
||||||
CodeHandler.hpp CodeHandler.cpp
|
CodeHandler.hpp CodeHandler.cpp
|
||||||
UpdateStatusWidget.hpp UpdateStatusWidget.cpp
|
UpdateStatusWidget.hpp UpdateStatusWidget.cpp
|
||||||
|
widgets/CompletionProgressHandler.hpp widgets/CompletionProgressHandler.cpp
|
||||||
|
widgets/ProgressWidget.hpp widgets/ProgressWidget.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
get_target_property(QtCreatorCorePath QtCreator::Core LOCATION)
|
get_target_property(QtCreatorCorePath QtCreator::Core LOCATION)
|
||||||
|
@ -24,9 +24,9 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "CompletionProgressHandler.hpp"
|
|
||||||
#include "LLMClientInterface.hpp"
|
#include "LLMClientInterface.hpp"
|
||||||
#include "LSPCompletion.hpp"
|
#include "LSPCompletion.hpp"
|
||||||
|
#include "widgets/CompletionProgressHandler.hpp"
|
||||||
#include <languageclient/client.h>
|
#include <languageclient/client.h>
|
||||||
#include <llmcore/IPromptProvider.hpp>
|
#include <llmcore/IPromptProvider.hpp>
|
||||||
#include <llmcore/IProviderRegistry.hpp>
|
#include <llmcore/IProviderRegistry.hpp>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2024 Petr Mironychev
|
* Copyright (C) 2025 Petr Mironychev
|
||||||
*
|
*
|
||||||
* This file is part of QodeAssist.
|
* This file is part of QodeAssist.
|
||||||
*
|
*
|
||||||
@ -18,9 +18,20 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "CompletionProgressHandler.hpp"
|
#include "CompletionProgressHandler.hpp"
|
||||||
#include <texteditor/texteditor.h>
|
|
||||||
#include <utils/tooltip/tooltip.h>
|
#include <QGraphicsBlurEffect>
|
||||||
|
#include <QGraphicsPixmapItem>
|
||||||
|
#include <QGraphicsScene>
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
|
#include <QPainter>
|
||||||
|
#include <QVBoxLayout>
|
||||||
|
|
||||||
|
#include <texteditor/texteditor.h>
|
||||||
|
#include <utils/progressindicator.h>
|
||||||
|
#include <utils/theme/theme.h>
|
||||||
|
#include <utils/tooltip/tooltip.h>
|
||||||
|
|
||||||
|
#include "ProgressWidget.hpp"
|
||||||
|
|
||||||
namespace QodeAssist {
|
namespace QodeAssist {
|
||||||
|
|
||||||
@ -30,7 +41,6 @@ void CompletionProgressHandler::showProgress(TextEditor::TextEditorWidget *widge
|
|||||||
m_isActive = true;
|
m_isActive = true;
|
||||||
|
|
||||||
if (m_widget) {
|
if (m_widget) {
|
||||||
// Используем тот же метод получения позиции что и в TextSuggestion
|
|
||||||
const QRect cursorRect = m_widget->cursorRect(m_widget->textCursor());
|
const QRect cursorRect = m_widget->cursorRect(m_widget->textCursor());
|
||||||
m_iconPosition = m_widget->viewport()->mapToGlobal(cursorRect.topLeft())
|
m_iconPosition = m_widget->viewport()->mapToGlobal(cursorRect.topLeft())
|
||||||
- Utils::ToolTip::offsetFromPosition();
|
- Utils::ToolTip::offsetFromPosition();
|
||||||
@ -65,14 +75,12 @@ void CompletionProgressHandler::operateTooltip(
|
|||||||
if (!m_isActive || !editorWidget)
|
if (!m_isActive || !editorWidget)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto progressLabel = new QLabel;
|
auto progressWidget = new ProgressWidget(editorWidget);
|
||||||
progressLabel->setPixmap(QPixmap(":/resources/images/qoderassist-icon.png")
|
|
||||||
.scaled(16, 16, Qt::KeepAspectRatio, Qt::SmoothTransformation));
|
|
||||||
|
|
||||||
QPoint showPoint = point;
|
QPoint showPoint = point;
|
||||||
showPoint.ry() -= progressLabel->sizeHint().height();
|
showPoint.ry() -= progressWidget->height();
|
||||||
|
|
||||||
Utils::ToolTip::show(showPoint, progressLabel, editorWidget);
|
Utils::ToolTip::show(showPoint, progressWidget, editorWidget);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace QodeAssist
|
} // namespace QodeAssist
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (C) 2024 Petr Mironychev
|
* Copyright (C) 2025 Petr Mironychev
|
||||||
*
|
*
|
||||||
* This file is part of QodeAssist.
|
* This file is part of QodeAssist.
|
||||||
*
|
*
|
||||||
@ -29,7 +29,6 @@ class CompletionProgressHandler : public TextEditor::BaseHoverHandler
|
|||||||
public:
|
public:
|
||||||
void showProgress(TextEditor::TextEditorWidget *widget);
|
void showProgress(TextEditor::TextEditorWidget *widget);
|
||||||
void hideProgress();
|
void hideProgress();
|
||||||
void abort() override {}
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void identifyMatch(
|
void identifyMatch(
|
114
widgets/ProgressWidget.cpp
Normal file
114
widgets/ProgressWidget.cpp
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2025 Petr Mironychev
|
||||||
|
*
|
||||||
|
* This file is part of QodeAssist.
|
||||||
|
*
|
||||||
|
* QodeAssist is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* QodeAssist is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with QodeAssist. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "ProgressWidget.hpp"
|
||||||
|
|
||||||
|
namespace QodeAssist {
|
||||||
|
|
||||||
|
ProgressWidget::ProgressWidget(QWidget *parent)
|
||||||
|
: QWidget(parent)
|
||||||
|
{
|
||||||
|
m_dotPosition = 0;
|
||||||
|
m_timer.setInterval(300);
|
||||||
|
connect(&m_timer, &QTimer::timeout, this, [this]() {
|
||||||
|
m_dotPosition = (m_dotPosition + 1) % 4;
|
||||||
|
update();
|
||||||
|
});
|
||||||
|
m_timer.start();
|
||||||
|
|
||||||
|
m_textColor = Utils::creatorTheme()->color(Utils::Theme::TextColorNormal);
|
||||||
|
m_backgroundColor = Utils::creatorTheme()->color(Utils::Theme::BackgroundColorNormal);
|
||||||
|
|
||||||
|
m_logoPixmap = QPixmap(":/resources/images/qoderassist-icon.png");
|
||||||
|
|
||||||
|
if (!m_logoPixmap.isNull()) {
|
||||||
|
QImage image = m_logoPixmap.toImage();
|
||||||
|
image = image.convertToFormat(QImage::Format_ARGB32);
|
||||||
|
|
||||||
|
for (int y = 0; y < image.height(); ++y) {
|
||||||
|
for (int x = 0; x < image.width(); ++x) {
|
||||||
|
QColor pixelColor = QColor::fromRgba(image.pixel(x, y));
|
||||||
|
|
||||||
|
int brightness = (pixelColor.red() + pixelColor.green() + pixelColor.blue()) / 3;
|
||||||
|
|
||||||
|
if (brightness > 200) {
|
||||||
|
pixelColor.setAlpha(0);
|
||||||
|
image.setPixelColor(x, y, pixelColor);
|
||||||
|
} else if (pixelColor.alpha() > 0) {
|
||||||
|
int alpha = pixelColor.alpha();
|
||||||
|
pixelColor = m_textColor;
|
||||||
|
pixelColor.setAlpha(alpha);
|
||||||
|
image.setPixelColor(x, y, pixelColor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_logoPixmap = QPixmap::fromImage(image);
|
||||||
|
m_logoPixmap = m_logoPixmap.scaled(24, 24, Qt::KeepAspectRatio, Qt::SmoothTransformation);
|
||||||
|
}
|
||||||
|
|
||||||
|
setFixedSize(40, 40);
|
||||||
|
}
|
||||||
|
|
||||||
|
ProgressWidget::~ProgressWidget()
|
||||||
|
{
|
||||||
|
m_timer.stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ProgressWidget::paintEvent(QPaintEvent *)
|
||||||
|
{
|
||||||
|
QPainter painter(this);
|
||||||
|
painter.setRenderHint(QPainter::Antialiasing);
|
||||||
|
|
||||||
|
painter.fillRect(rect(), m_backgroundColor);
|
||||||
|
|
||||||
|
if (!m_logoPixmap.isNull()) {
|
||||||
|
QRect logoRect(
|
||||||
|
(width() - m_logoPixmap.width()) / 2, 5, m_logoPixmap.width(), m_logoPixmap.height());
|
||||||
|
painter.drawPixmap(logoRect, m_logoPixmap);
|
||||||
|
}
|
||||||
|
|
||||||
|
int dotSpacing = 6;
|
||||||
|
int dotSize = 4;
|
||||||
|
int totalDotWidth = 3 * dotSize + 2 * dotSpacing;
|
||||||
|
int startX = (width() - totalDotWidth) / 2;
|
||||||
|
int dotY = height() - 8;
|
||||||
|
|
||||||
|
for (int i = 0; i < 3; ++i) {
|
||||||
|
QColor dotColor = m_textColor;
|
||||||
|
|
||||||
|
if (m_dotPosition == 0) {
|
||||||
|
dotColor.setAlpha(128);
|
||||||
|
} else {
|
||||||
|
if (i == m_dotPosition - 1) {
|
||||||
|
dotColor.setAlpha(255);
|
||||||
|
} else {
|
||||||
|
dotColor.setAlpha(80);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
painter.setPen(Qt::NoPen);
|
||||||
|
painter.setBrush(dotColor);
|
||||||
|
|
||||||
|
int x = startX + i * (dotSize + dotSpacing);
|
||||||
|
painter.drawEllipse(x, dotY, dotSize, dotSize);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace QodeAssist
|
48
widgets/ProgressWidget.hpp
Normal file
48
widgets/ProgressWidget.hpp
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2025 Petr Mironychev
|
||||||
|
*
|
||||||
|
* This file is part of QodeAssist.
|
||||||
|
*
|
||||||
|
* QodeAssist is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* QodeAssist is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with QodeAssist. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <QPainter>
|
||||||
|
#include <QTimer>
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
|
#include <utils/progressindicator.h>
|
||||||
|
#include <utils/theme/theme.h>
|
||||||
|
|
||||||
|
namespace QodeAssist {
|
||||||
|
|
||||||
|
class ProgressWidget : public QWidget
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ProgressWidget(QWidget *parent = nullptr);
|
||||||
|
~ProgressWidget();
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void paintEvent(QPaintEvent *) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
QTimer m_timer;
|
||||||
|
int m_dotPosition;
|
||||||
|
QColor m_textColor;
|
||||||
|
QColor m_backgroundColor;
|
||||||
|
QPixmap m_logoPixmap;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace QodeAssist
|
Loading…
x
Reference in New Issue
Block a user