KTextAddons

textautogenerateselectedmessagebackgroundanimation.cpp
1/*
2 SPDX-FileCopyrightText: 2025 Laurent Montel <montel@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include "textautogenerateselectedmessagebackgroundanimation.h"
8#include "textautogeneratecolorsandmessageviewstyle.h"
9#include <QPropertyAnimation>
10using namespace Qt::Literals::StringLiterals;
11using namespace TextAutogenerateText;
12TextAutogenerateSelectedMessageBackgroundAnimation::TextAutogenerateSelectedMessageBackgroundAnimation(QObject *parent)
13 : QObject{parent}
14{
15}
16
17TextAutogenerateSelectedMessageBackgroundAnimation::~TextAutogenerateSelectedMessageBackgroundAnimation() = default;
18
19QColor TextAutogenerateSelectedMessageBackgroundAnimation::backgroundColor() const
20{
21 return m_backgroundColor;
22}
23
24QPersistentModelIndex TextAutogenerateSelectedMessageBackgroundAnimation::modelIndex() const
25{
26 return mModelIndex;
27}
28
29void TextAutogenerateSelectedMessageBackgroundAnimation::setModelIndex(const QPersistentModelIndex &newModelIndex)
30{
31 mModelIndex = newModelIndex;
32}
33
34void TextAutogenerateSelectedMessageBackgroundAnimation::setBackgroundColor(const QColor &newBackgroundColor)
35{
36 if (m_backgroundColor == newBackgroundColor)
37 return;
38 m_backgroundColor = newBackgroundColor;
39 Q_EMIT backgroundColorChanged();
40}
41
42void TextAutogenerateSelectedMessageBackgroundAnimation::start()
43{
44 auto animation = new QPropertyAnimation(this, "backgroundColor"_ba, this);
45 animation->setDuration(2000);
46 const auto color = TextAutogenerateColorsAndMessageViewStyle::self().schemeView().foreground(KColorScheme::NeutralText).color();
47 animation->setStartValue(color);
48 animation->setEndValue(QColor(Qt::transparent));
49 animation->setEasingCurve(QEasingCurve::InOutQuad);
50 animation->start();
51 connect(animation, &QPropertyAnimation::finished, this, [this]() {
52 Q_EMIT animationFinished();
54 });
55}
56
57#include "moc_textautogenerateselectedmessagebackgroundanimation.cpp"
Q_EMITQ_EMIT
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
void deleteLater()
transparent
This file is part of the KDE documentation.
Documentation copyright © 1996-2025 The KDE developers.
Generated on Fri May 2 2025 12:06:03 by doxygen 1.13.2 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.