Update 更新文档

This commit is contained in:
2026-02-25 23:01:42 +08:00
parent 40aff32fb0
commit 80518309a7
679 changed files with 4611263 additions and 0 deletions

View File

@@ -0,0 +1,64 @@
#include "QBreathingLight.h"
#include <QPainter>
#include <QColor>
#include <algorithm>
QBreathingLight::QBreathingLight(QWidget *parent)
: QWidget(parent)
, m_opacity(1.0f)
, m_isFlashing(false)
, m_flashColor(Qt::red)
, m_flashDuration(3000)
{
setFixedSize(40, 40);
connect(&m_animationTimer, &QTimer::timeout, this, &QBreathingLight::updateAnimation);
}
void QBreathingLight::setFlashDuration(int milliseconds)
{
m_flashDuration = milliseconds;
}
void QBreathingLight::setFlashColor(const QColor &color)
{
m_flashColor = color;
}
void QBreathingLight::triggerSignal()
{
if (!m_isFlashing) {
m_isFlashing = true;
m_flashStartTime = QTime::currentTime();
m_animationTimer.start(30);
}
}
void QBreathingLight::paintEvent(QPaintEvent *event)
{
Q_UNUSED(event);
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing);
painter.fillRect(rect(), QBrush(QColor(240, 240, 240)));
QPoint center = rect().center();
int radius = qMin(width(), height()) / 3;
QColor color;
if (m_isFlashing) {
color = m_flashColor;
color.setAlphaF(m_opacity);
}
else {
color = Qt::green;
}
painter.setBrush(QBrush(color));
painter.setPen(Qt::NoPen);
painter.drawEllipse(center, radius, radius);
}
void QBreathingLight::updateAnimation()
{
int elapsed = m_flashStartTime.msecsTo(QTime::currentTime());
if (elapsed >= m_flashDuration) {
m_isFlashing = false;
m_opacity = 1.0f;
m_animationTimer.stop();
update();
return;
}
float progress = static_cast<float>(elapsed) / m_flashDuration;
m_opacity = 0.5f * (1.0f + sin(progress * 2 * 3.14 * 5));
update();
}