File indexing completed on 2025-02-16 04:56:04
0001 /* 0002 SPDX-FileCopyrightText: 2013-2024 Laurent Montel <montel@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 #include "sieveeditorloadprogressindicator.h" 0007 0008 #include <KIconLoader> 0009 #include <KPixmapSequenceLoader> 0010 0011 #include <QPixmap> 0012 #include <QTimer> 0013 using namespace KSieveUi; 0014 SieveEditorLoadProgressIndicator::SieveEditorLoadProgressIndicator(QObject *parent) 0015 : QObject(parent) 0016 , mProgressTimer(new QTimer(this)) 0017 { 0018 mProgressPix = KPixmapSequenceLoader::load(QStringLiteral("process-working"), KIconLoader::SizeSmallMedium); 0019 connect(mProgressTimer, &QTimer::timeout, this, &SieveEditorLoadProgressIndicator::slotTimerDone); 0020 } 0021 0022 SieveEditorLoadProgressIndicator::~SieveEditorLoadProgressIndicator() = default; 0023 0024 void SieveEditorLoadProgressIndicator::startAnimation() 0025 { 0026 mProgressCount = 0; 0027 mProgressTimer->start(300); 0028 } 0029 0030 void SieveEditorLoadProgressIndicator::stopAnimation(bool success) 0031 { 0032 if (mProgressTimer->isActive()) { 0033 mProgressTimer->stop(); 0034 } 0035 Q_EMIT loadFinished(success); 0036 } 0037 0038 void SieveEditorLoadProgressIndicator::slotTimerDone() 0039 { 0040 Q_EMIT pixmapChanged(mProgressPix.frameAt(mProgressCount)); 0041 ++mProgressCount; 0042 if (mProgressCount == 8) { 0043 mProgressCount = 0; 0044 } 0045 0046 mProgressTimer->start(300); 0047 } 0048 0049 #include "moc_sieveeditorloadprogressindicator.cpp"