Libksieve

sieveeditorloadprogressindicator.cpp
1/*
2 SPDX-FileCopyrightText: 2013-2024 Laurent Montel <montel@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6#include "sieveeditorloadprogressindicator.h"
7
8#include <KIconLoader>
9#include <KPixmapSequenceLoader>
10
11#include <QPixmap>
12#include <QTimer>
13using namespace KSieveUi;
14SieveEditorLoadProgressIndicator::SieveEditorLoadProgressIndicator(QObject *parent)
15 : QObject(parent)
16 , mProgressTimer(new QTimer(this))
17{
18 mProgressPix = KPixmapSequenceLoader::load(QStringLiteral("process-working"), KIconLoader::SizeSmallMedium);
19 connect(mProgressTimer, &QTimer::timeout, this, &SieveEditorLoadProgressIndicator::slotTimerDone);
20}
21
22SieveEditorLoadProgressIndicator::~SieveEditorLoadProgressIndicator() = default;
23
24void SieveEditorLoadProgressIndicator::startAnimation()
25{
26 mProgressCount = 0;
27 mProgressTimer->start(300);
28}
29
30void SieveEditorLoadProgressIndicator::stopAnimation(bool success)
31{
32 if (mProgressTimer->isActive()) {
33 mProgressTimer->stop();
34 }
35 Q_EMIT loadFinished(success);
36}
37
38void SieveEditorLoadProgressIndicator::slotTimerDone()
39{
40 Q_EMIT pixmapChanged(mProgressPix.frameAt(mProgressCount));
41 ++mProgressCount;
42 if (mProgressCount == 8) {
43 mProgressCount = 0;
44 }
45
46 mProgressTimer->start(300);
47}
48
49#include "moc_sieveeditorloadprogressindicator.cpp"
QPixmap frameAt(int index) const
Q_EMITQ_EMIT
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
bool isActive() const const
void start()
void stop()
void timeout()
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:14:30 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.