Libksieve

sieveeditorloadprogressindicator.cpp
1 /*
2  SPDX-FileCopyrightText: 2013-2021 Laurent Montel <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 #include "sieveeditorloadprogressindicator.h"
7 
8 #include <KIconLoader>
9 
10 #include <QPixmap>
11 #include <QTimer>
12 using namespace KSieveUi;
13 SieveEditorLoadProgressIndicator::SieveEditorLoadProgressIndicator(QObject *parent)
14  : QObject(parent)
15 {
16  mProgressPix = KIconLoader::global()->loadPixmapSequence(QStringLiteral("process-working"), KIconLoader::SizeSmallMedium);
17  mProgressTimer = new QTimer(this);
18  connect(mProgressTimer, &QTimer::timeout, this, &SieveEditorLoadProgressIndicator::slotTimerDone);
19 }
20 
21 SieveEditorLoadProgressIndicator::~SieveEditorLoadProgressIndicator()
22 {
23 }
24 
25 void SieveEditorLoadProgressIndicator::startAnimation()
26 {
27  mProgressCount = 0;
28  mProgressTimer->start(300);
29 }
30 
31 void SieveEditorLoadProgressIndicator::stopAnimation(bool success)
32 {
33  if (mProgressTimer->isActive()) {
34  mProgressTimer->stop();
35  }
36  Q_EMIT loadFinished(success);
37 }
38 
39 void SieveEditorLoadProgressIndicator::slotTimerDone()
40 {
41  Q_EMIT pixmapChanged(mProgressPix.frameAt(mProgressCount));
42  ++mProgressCount;
43  if (mProgressCount == 8) {
44  mProgressCount = 0;
45  }
46 
47  mProgressTimer->start(300);
48 }
void timeout()
static KIconLoader * global()
KPixmapSequence loadPixmapSequence(const QString &iconName, int size=SizeSmall) const
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
Q_EMITQ_EMIT
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sat Apr 17 2021 23:09:34 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.