Ejemplo n.º 1
0
void SharedTimerQt::timerEvent(QTimerEvent* ev)
{
    if (!m_timerFunction || ev->timerId() != m_timer.timerId())
        return;

    m_timer.stop();
    (m_timerFunction)();
}
Ejemplo n.º 2
0
 void toggleRunning() {
    if (timer.isActive())
       timer.stop();
    else {
       timer.start(10, this);
       el.start();
    }
 }
Ejemplo n.º 3
0
void Worker::timerEvent(QTimerEvent * ev)
{
    const int busyTime = 50; // [ms] - longest amount of time to stay busy
    const int testFactor = 128; // number of iterations between time tests
    const int maxCounter = 10000;
    if (ev->timerId() != m_timer.timerId()) return;

    QElapsedTimer t;
    t.start();
    while (1) {
        // do some "work"
        Helper::usleep(100);
        m_counter ++;
        // exit when the work is done
        if (m_counter > maxCounter) {
            emit progress(100);
            emit done();
            m_busy = false;
            break;
        }
        // exit when we're done with a timed "chunk" of work
        // Note: QElapsedTimer::elapsed() may be expensive, so we call it once every testFactor iterations
        if ((m_counter % testFactor) == 1 && t.elapsed() > busyTime) {
            emit progress(m_counter*100/maxCounter);
            break;
        }
    }
}
Ejemplo n.º 4
0
 void timerEvent(QTimerEvent *ev) override {
    if (ev->timerId() == timer.timerId() && painter) {
       qreal const t = el.restart() / (qreal)10;
       for (auto &s : state)
          s.advance(t, dst.rect());
       update();
    }
 }
static PyObject *meth_QBasicTimer_isActive(PyObject *sipSelf, PyObject *sipArgs)
{
    PyObject *sipParseErr = NULL;

    {
        QBasicTimer *sipCpp;

        if (sipParseArgs(&sipParseErr, sipArgs, "B", &sipSelf, sipType_QBasicTimer, &sipCpp))
        {
            bool sipRes;

            Py_BEGIN_ALLOW_THREADS
            sipRes = sipCpp->isActive();
            Py_END_ALLOW_THREADS

            return PyBool_FromLong(sipRes);
        }
    }
Ejemplo n.º 6
0
void SharedTimerQt::start(double fireTime)
{
    double interval = fireTime - currentTime();
    unsigned int intervalInMS;
    if (interval < 0)
        intervalInMS = 0;
    else {
        interval *= 1000;
        intervalInMS = (unsigned int)interval;
    }

    m_timer.start(intervalInMS, this);
}
Ejemplo n.º 7
0
 void timerEvent(QTimerEvent * ev) override {
   if (ev->timerId() != m_timer.timerId()) return;
   int timeout = m_app->m_timeout;
   auto now = QDateTime::currentMSecsSinceEpoch();
   m_toEmit.clear();
   QMutexLocker lock(&m_app->m_mutex);
   for (auto it = m_app->m_threads.begin(); it != m_app->m_threads.end(); ++it) {
     if (it->ping == 0) continue;
     qint64 elapsed = now - it->ping;
     it->stuck = elapsed > timeout;
     m_toEmit.push_back({it.key(), it->stuck ? elapsed : 0});
   }
   lock.unlock();
   for (auto &sig : qAsConst(m_toEmit)) emit m_app->loopStateChanged(sig.thread, sig.elapsed);
 }
Ejemplo n.º 8
0
 explicit StuckEventLoopNotifier(MonitoringApp * app) : m_app(app) {
   m_timer.start(100, Qt::CoarseTimer, this);
 }
Ejemplo n.º 9
0
				void Start (int interval)
				{
					if (!Timer_.isActive ())
						Timer_.start (interval, this);
				}
Ejemplo n.º 10
0
				void Stop ()
				{
					Timer_.stop ();
				}
Ejemplo n.º 11
0
 Q_SLOT void start() {
     if (m_busy) return;
     m_counter = 0;
     m_busy = true;
     m_timer.start(0, this);
 }
Ejemplo n.º 12
0
 void startTicker(QObject *object)
 {
     if (!ticker.isActive())
         ticker.start(15, object);
     timeCounter.start();
 }
Ejemplo n.º 13
0
 UIQT(QWidget *parent = {}) : QWidget(parent) {
    m_layout.addWidget(&m_label, 0, 0);
    m_timer.start(500, this);
    refreshImage();
 }
Ejemplo n.º 14
0
 void timerEvent(QTimerEvent *ev) override {
    if (ev->timerId() == m_timer.timerId())
       refreshImage();
 }
Ejemplo n.º 15
0
 Q_SLOT void on_lineEdit_textEdited() {
    if (m_queryBehavior == FinalQuery || !m_queryTimer.isActive())
       m_queryTimer.start(100, this);
 }
Ejemplo n.º 16
0
void SharedTimerQt::stop()
{
    m_timer.stop();
}
Ejemplo n.º 17
0
 void timerEvent(QTimerEvent * ev) {
    if (ev->timerId() != m_queryTimer.timerId()) return;
    m_queryTimer.stop();
    emit queryRequest();
 }