// Being a db::local::FileScanner::Observer unsigned int OnFile(const std::string& s) { // Called on wrong thread QApplication::postEvent(this, new choraleqt::StringEvent(s)); if (wasCanceled()) return ECANCELED; return 0; }
void ExportNotesJob::slotNoteJobTerminated() { if (wasCanceled()) { Q_EMIT jobFinished(); return; } mIndexIdentifier++; QTimer::singleShot(0, this, &ExportNotesJob::slotWriteNextArchiveResource); }
void ExportNotesJob::slotCheckBackupConfig() { if (mTypeSelected & Utils::Config) { backupConfig(); increaseProgressDialog(); if (wasCanceled()) { Q_EMIT jobFinished(); return; } } Q_EMIT jobFinished(); }
BOOL MyQProgressDialog::updateAndCancelCheck(int progress) { if (!m_isCanceled && isUpdateReady) { if (wasCanceled()) { m_isCanceled = isUpdateReady = TRUE; TaskProgress::end(); } else { isUpdateReady = FALSE; if (m_indeterminateMode || (progress == -1)) { if (!m_indeterminateMode) { // Switch to indeterminateMode mode m_indeterminateMode = TRUE; TaskProgress::setProgress(-1); setRange(0, 0); m_lastProgress = 1; } // Progress value has to fluctuate for Qt animations to occur setValue(m_lastProgress++); } else { if (progress > 100) progress = 100; else // progress 0 is a special case if (progress < 1) progress = 1; if (progress != m_lastProgress) { setValue(progress); TaskProgress::setProgress(progress); m_lastProgress = progress; } } // Let Qt event queue have a tick QApplication::processEvents(); } } return(m_isCanceled); }
void GeneralProgressDialog::updateProgress(double p) { assert(QThread::currentThread() == qApp->thread()); p = std::max(std::min(p, 1.), 0.); _imp->progressBar->setValue(p * 100.); double timeElapsedSecs = _imp->timer.getTimeSinceCreation(); _imp->timeRemaining = p == 0 ? 0 : timeElapsedSecs * (1. - p) / p; if (!isVisible() && !wasCanceled()) { ///Show the dialog if the total estimated time is gt NATRON_SHOW_PROGRESS_TOTAL_ESTIMATED_TIME_MS double totalTime = p == 0 ? 0 : timeElapsedSecs * 1. / p; //also, don't show if it was not shown yet but there are less than NATRON_SHOW_PROGRESS_TOTAL_ESTIMATED_TIME_MS remaining if (_imp->timerLabelSet && std::min(_imp->timeRemaining, totalTime) * 1000 > NATRON_SHOW_PROGRESS_TOTAL_ESTIMATED_TIME_MS) { printf("timeRemaining=%g\n", _imp->timeRemaining); show(); } } }
bool onFrameCompleted(int frame, int column) { bool ret = wasCanceled(); Message(this, ++m_frameCounter, m_columnCounter, ret ? -1 : ++m_pbCounter, m_progressBarString).send(); return !ret; }