forked from qt-creator/qt-creator
Core: Un-export and hide only locally used ProgressTimer
Change-Id: If67b0d55972620a59a38a811fda6238d9cd4ab56 Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -24,7 +24,8 @@
|
|||||||
|
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
#include <QEvent>
|
#include <QEvent>
|
||||||
#include <QHBoxLayout>
|
#include <QFuture>
|
||||||
|
#include <QFutureInterfaceBase>
|
||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QPropertyAnimation>
|
#include <QPropertyAnimation>
|
||||||
@@ -42,6 +43,38 @@ using namespace Core::Internal;
|
|||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
|
|
||||||
|
class ProgressTimer : public QObject
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
ProgressTimer(const QFutureInterfaceBase &futureInterface, int expectedSeconds, QObject *parent)
|
||||||
|
: QObject(parent),
|
||||||
|
m_futureInterface(futureInterface),
|
||||||
|
m_expectedTime(expectedSeconds)
|
||||||
|
{
|
||||||
|
m_futureInterface.setProgressRange(0, 100);
|
||||||
|
m_futureInterface.setProgressValue(0);
|
||||||
|
|
||||||
|
m_timer.setInterval(TimerInterval);
|
||||||
|
connect(&m_timer, &QTimer::timeout, this, &ProgressTimer::handleTimeout);
|
||||||
|
m_timer.start();
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
void handleTimeout()
|
||||||
|
{
|
||||||
|
++m_currentTime;
|
||||||
|
const int halfLife = qRound(1000.0 * m_expectedTime / TimerInterval);
|
||||||
|
const int progress = MathUtils::interpolateTangential(m_currentTime, halfLife, 0, 100);
|
||||||
|
m_futureInterface.setProgressValue(progress);
|
||||||
|
}
|
||||||
|
|
||||||
|
QFutureInterfaceBase m_futureInterface;
|
||||||
|
int m_expectedTime;
|
||||||
|
int m_currentTime = 0;
|
||||||
|
QTimer m_timer;
|
||||||
|
};
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\class Core::ProgressManager
|
\class Core::ProgressManager
|
||||||
\inheaderfile coreplugin/progressmanager/progressmanager.h
|
\inheaderfile coreplugin/progressmanager/progressmanager.h
|
||||||
@@ -789,29 +822,4 @@ void ProgressManager::cancelTasks(Id type)
|
|||||||
m_instance->doCancelTasks(type);
|
m_instance->doCancelTasks(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ProgressTimer::ProgressTimer(const QFutureInterfaceBase &futureInterface,
|
|
||||||
int expectedSeconds,
|
|
||||||
QObject *parent)
|
|
||||||
: QObject(parent),
|
|
||||||
m_futureInterface(futureInterface),
|
|
||||||
m_expectedTime(expectedSeconds)
|
|
||||||
{
|
|
||||||
m_futureInterface.setProgressRange(0, 100);
|
|
||||||
m_futureInterface.setProgressValue(0);
|
|
||||||
|
|
||||||
m_timer = new QTimer(this);
|
|
||||||
m_timer->setInterval(TimerInterval);
|
|
||||||
connect(m_timer, &QTimer::timeout, this, &ProgressTimer::handleTimeout);
|
|
||||||
m_timer->start();
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProgressTimer::handleTimeout()
|
|
||||||
{
|
|
||||||
++m_currentTime;
|
|
||||||
const int halfLife = qRound(1000.0 * m_expectedTime / TimerInterval);
|
|
||||||
const int progress = MathUtils::interpolateTangential(m_currentTime, halfLife, 0, 100);
|
|
||||||
m_futureInterface.setProgressValue(progress);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // Core
|
} // Core
|
||||||
|
|||||||
@@ -11,8 +11,6 @@
|
|||||||
#include <QFutureInterfaceBase>
|
#include <QFutureInterfaceBase>
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
QT_FORWARD_DECLARE_CLASS(QTimer)
|
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
class FutureProgress;
|
class FutureProgress;
|
||||||
|
|
||||||
@@ -58,21 +56,6 @@ private:
|
|||||||
friend class Core::Internal::ProgressManagerPrivate;
|
friend class Core::Internal::ProgressManagerPrivate;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CORE_EXPORT ProgressTimer : public QObject
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ProgressTimer(const QFutureInterfaceBase &futureInterface, int expectedSeconds,
|
|
||||||
QObject *parent = nullptr);
|
|
||||||
|
|
||||||
private:
|
|
||||||
void handleTimeout();
|
|
||||||
|
|
||||||
QFutureInterfaceBase m_futureInterface;
|
|
||||||
int m_expectedTime;
|
|
||||||
int m_currentTime = 0;
|
|
||||||
QTimer *m_timer;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace Core
|
} // namespace Core
|
||||||
|
|
||||||
Q_DECLARE_OPERATORS_FOR_FLAGS(Core::ProgressManager::ProgressFlags)
|
Q_DECLARE_OPERATORS_FOR_FLAGS(Core::ProgressManager::ProgressFlags)
|
||||||
|
|||||||
Reference in New Issue
Block a user