Krita Source Code Documentation
Loading...
Searching...
No Matches
kis_busy_progress_indicator.cpp
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2015 Dmitry Kazakov <dimula73@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0-or-later
5 */
6
8
9#include <QTimer>
10#include <QAtomicInt>
11
12#include "KoProgressProxy.h"
13
14
16{
18 : timer(new QTimer(_q))
19 {}
20
21 QTimer *timer {nullptr}; // owned by QObject hierarchy
23 QAtomicInt numUpdates;
24 QAtomicInt timerStarted;
26
27 bool isStarted {false};
28
30 {
31 if (!progressProxy) {
32 return;
33 }
34 isStarted = true;
36 }
37
39 {
40 if (!isStarted || !progressProxy) {
41 return;
42 }
43 progressProxy->setRange(0, 100);
45 isStarted = false;
46 }
47};
48
49
51 : m_d(new Private(this))
52{
53 connect(m_d->timer, SIGNAL(timeout()), SLOT(timerFinished()));
54 connect(this, SIGNAL(sigStartTimer()), SLOT(slotStartTimer()));
55 m_d->timer->setInterval(200);
56 m_d->progressProxy = progressProxy;
57}
58
60{
61 m_d->stopProgressReport();
62}
63
65{
66 m_d->progressProxy = 0;
67}
68
70{
71 int value = m_d->numUpdates.fetchAndStoreOrdered(0);
72
73 if (!value) {
74 m_d->numEmptyTicks++;
75
76 if (m_d->numEmptyTicks > 2) {
77 m_d->timerStarted = 0;
78 m_d->timer->stop();
79 m_d->stopProgressReport();
80 }
81 } else {
82 m_d->numEmptyTicks = 0;
83 }
84}
85
87{
88 m_d->numUpdates.ref();
89
90 if (!m_d->timerStarted) {
91 Q_EMIT sigStartTimer();
92 }
93}
94
96{
97 m_d->timerStarted.ref();
98 m_d->timer->start();
99 m_d->startProgressReport();
100}
float value(const T *src, size_t ch)
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
KisBusyProgressIndicator(KoProgressProxy *progressProxy)
const QScopedPointer< Private > m_d
virtual void setValue(int value)=0
virtual void setRange(int minimum, int maximum)=0