File indexing completed on 2022-09-27 13:19:28

0001 /*
0002     SPDX-FileCopyrightText: 2006 Paolo Capriotti <p.capriotti@gmail.com>
0003     SPDX-FileCopyrightText: 2010 Stefan Majewsky <majewsky@gmx.net>
0004 
0005     SPDX-License-Identifier: GPL-2.0-or-later
0006 */
0007 
0008 #include "highlightanimation.h"
0009 
0010 #include "settings.h"
0011 
0012 #include <QPen>
0013 #include <QPropertyAnimation>
0014 #include <QSequentialAnimationGroup>
0015 
0016 HighlightAnimation::HighlightAnimation(const QLineF &line)
0017     : QGraphicsLineItem(line)
0018 {
0019     setPen(QPen(Settings::highlightColor(), 8.0, Qt::SolidLine, Qt::RoundCap));
0020 
0021     auto animation = new QPropertyAnimation(this, "opacity", this);
0022     animation->setStartValue(1.0);
0023     animation->setEndValue(0.0);
0024     auto animGroup = new QSequentialAnimationGroup(this);
0025     animGroup->addPause(1000);
0026     animGroup->addAnimation(animation);
0027     animGroup->start(QAbstractAnimation::DeleteWhenStopped);
0028     connect(animGroup, &QSequentialAnimationGroup::finished, this, &HighlightAnimation::deleteLater);
0029 }
0030