Libksieve

sieveeditorloadprogressindicator.cpp
1 /*
2  Copyright (C) 2013-2020 Laurent Montel <[email protected]>
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Library General Public
6  License as published by the Free Software Foundation; either
7  version 2 of the License, or (at your option) any later version.
8 
9  This library is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  Library General Public License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to
16  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  Boston, MA 02110-1301, USA.
18 */
19 #include "sieveeditorloadprogressindicator.h"
20 
21 #include <KIconLoader>
22 
23 #include <QTimer>
24 #include <QPixmap>
25 using namespace KSieveUi;
26 SieveEditorLoadProgressIndicator::SieveEditorLoadProgressIndicator(QObject *parent)
27  : QObject(parent)
28  , mProgressCount(0)
29 {
30  mProgressPix = KIconLoader::global()->loadPixmapSequence(QStringLiteral("process-working"), KIconLoader::SizeSmallMedium);
31  mProgressTimer = new QTimer(this);
32  connect(mProgressTimer, &QTimer::timeout, this, &SieveEditorLoadProgressIndicator::slotTimerDone);
33 }
34 
35 SieveEditorLoadProgressIndicator::~SieveEditorLoadProgressIndicator()
36 {
37 }
38 
39 void SieveEditorLoadProgressIndicator::startAnimation()
40 {
41  mProgressCount = 0;
42  mProgressTimer->start(300);
43 }
44 
45 void SieveEditorLoadProgressIndicator::stopAnimation(bool success)
46 {
47  if (mProgressTimer->isActive()) {
48  mProgressTimer->stop();
49  }
50  Q_EMIT loadFinished(success);
51 }
52 
53 void SieveEditorLoadProgressIndicator::slotTimerDone()
54 {
55  Q_EMIT pixmapChanged(mProgressPix.frameAt(mProgressCount));
56  ++mProgressCount;
57  if (mProgressCount == 8) {
58  mProgressCount = 0;
59  }
60 
61  mProgressTimer->start(300);
62 }
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-2020 The KDE developers.
Generated on Fri Jun 5 2020 23:09:20 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.