Exemple #1
0
void AMLoopAction3::internalOnCurrentActionProgressChanged(double numerator, double denominator)
{
	if(internalAllActionsHaveExpectedDuration()) {
		double totalNumerator = 0, totalDenominator = 0;
		for(int i=0, cc=subActionCount(); i<cc; i++) {
			AMAction3* action = subActionAt(i);

			double expectedSecs = action->info()->expectedDuration();
			totalDenominator += expectedSecs*loopCount();
			int timesFinished = currentIteration_;
			if(i < currentSubActionIndex_)
				timesFinished++;
			totalNumerator += expectedSecs*timesFinished;

			if(i == currentSubActionIndex())	// if it's the current action, we have some partial progress.
				totalNumerator += numerator/denominator * expectedSecs;
		}
		setProgress(totalNumerator, totalDenominator);
		setExpectedDuration(totalDenominator);
	}
	// Otherwise, assume every subaction makes up an equal unit ('1') of the total amount of work. Our denominator will be the number of sub-actions * the number of loops, and our numerator will be the sub-actions we've completed (plus the current sub-action's fraction done).
	else {
		double totalDenominator = subActionCount()*loopCount();
		double totalNumerator = subActionCount()*currentIteration_;	// add the completed full loops
		totalNumerator += currentSubActionIndex_;	// add the actions done in this loop
		totalNumerator += numerator/denominator;	// add the fraction done for the current action.
		setProgress(totalNumerator, totalDenominator);
		setExpectedDuration(runningTime()*totalDenominator/totalNumerator);
	}
}
Exemple #2
0
void AMLoopAction3::internalDoNextAction()
{
	// did an action just finish completing?
	if(currentSubActionIndex_ >= 0) {

		internalDisconnectAction(currentSubAction_);
		// delete it later (since we might still be executing inside the action's functions).
		currentSubAction_->scheduleForDeletion();
		//currentSubAction_->deleteLater();
	}

	// Check if we are stopping now.
	if (skipAfterCurrentAction_)
		setSkipped();

	// do we have a next action in this loop? [This will also trigger the start of the very first action]
	else if(currentSubActionIndex_ < subActionCount()-1) {
		emit currentSubActionChanged(++currentSubActionIndex_);

		currentSubAction_ = subActions_.at(currentSubActionIndex_)->createCopy();
		internalConnectAction(currentSubAction_);

		if(state() == AMAction3::Pausing)
			setPaused();
		else if(state() == AMAction3::Running)
			currentSubAction_->start();
	}
	else {
		// done this loop.
		emit currentIterationChanged(++currentIteration_);

		if(generateScanActionMessages_){
			AMAgnosticDataAPILoopIncrementMessage loopIncrementedMessage(info()->shortDescription(), currentIteration_);
			AMAgnosticDataAPISupport::handlerFromLookupKey("ScanActions")->postMessage(loopIncrementedMessage);
		}

		// Are we stopping now that we are at the end of this iteration?
		if (skipAfterCurrentIteration_)
			setSkipped();

		// Is there a next one?
		else if(currentIteration_ < loopCount()) {
			setStatusText(QString("Loop %1 of %2.").arg(currentIteration_+1).arg(loopCount()));
			emit currentSubActionChanged(currentSubActionIndex_ = 0);

			currentSubAction_ = subActions_.at(currentSubActionIndex_)->createCopy();
			internalConnectAction(currentSubAction_);

			if(state() == AMAction3::Pausing)
				setPaused();
			else if(state() == AMAction3::Running)
				currentSubAction_->start();
		}
		// Nope, that's the end.
		else {
			setSucceeded();
		}
	}
}
Exemple #3
0
void AMLoopAction3::startImplementation()
{
	// done already with nothing to do.
	if(subActionCount() == 0 || loopCount() == 0) {
		setStarted();
		setSucceeded();
		return;
	}

	setStarted();
	setStatusText(QString("Loop %1 of %2").arg(currentIteration_+1).arg(loopCount()));
	internalDoNextAction();
}
void ImageDocument::setContents(const ImageContents &contents)
{
    Q_D(ImageDocument);

    if (contents.isNull()) {
        clear();
        return;
    }

    const auto header = contents.header();
    d->type = header.type();
    d->size = header.size();
    d->imageFormat = header.imageFormat();
    d->imageCount = header.imageCount();
    d->mipmapCount = header.mipmapCount();
    d->frameDelay = header.frameDelay();
    d->loopCount = header.loopCount();
    for (int index = 0; index < d->imageCount; ++index) {
        for (int level = 0; level < d->mipmapCount; ++level) {
            auto image = contents.image(index, level);
            std::unique_ptr<ImageDocumentItem> item(new ImageDocumentItem(this));
            item->setSize(image.size());
            item->setImage(image);
            d->items[ImageDocumentPrivate::ImageIndex(index, level)] = std::move(item);
        }
    }

    emit contentsChanged();
}
 QVariant option( ImageOption option ) const override {
     switch( option ) {
     case Animation:
         return loaded() ? loopCount() != 0 : true; //TODO: is true the good default?
     default:
         return {};
     }
 }
/*!
    Returns the total and effective duration of the animation, including the
    loop count.

    \sa duration(), currentTime
*/
int QAbstractAnimation::totalDuration() const
{
    int dura = duration();
    if (dura <= 0)
        return dura;
    int loopcount = loopCount();
    if (loopcount < 0)
        return -1;
    return dura * loopcount;
}
Exemple #7
0
// OPTIMIZE: if this loops to only one other angle, after first compare fails, insert on other side
// OPTIMIZE: return where insertion succeeded. Then, start next insertion on opposite side
void SkOpAngle::insert(SkOpAngle* angle) {
    if (angle->fNext) {
        if (loopCount() >= angle->loopCount()) {
            if (!merge(angle)) {
                return;
            }
        } else if (fNext) {
            if (!angle->merge(this)) {
                return;
            }
        } else {
            angle->insert(this);
        }
        return;
    }
    bool singleton = NULL == fNext;
    if (singleton) {
        fNext = this;
    }
    SkOpAngle* next = fNext;
    if (next->fNext == this) {
        if (angle->overlap(*this)) {
            return;
        }
        if (singleton || angle->after(this)) {
            this->fNext = angle;
            angle->fNext = next;
        } else {
            next->fNext = angle;
            angle->fNext = this;
        }
        debugValidateNext();
        return;
    }
    SkOpAngle* last = this;
    do {
        SkASSERT(last->fNext == next);
        if (angle->overlap(*last) || angle->overlap(*next)) {
            return;
        }
        if (angle->after(last)) {
            last->fNext = angle;
            angle->fNext = next;
            debugValidateNext();
            return;
        }
        last = next;
        next = next->fNext;
        if (last == this && next->fUnorderable) {
            fUnorderable = true;
            return;
        }
        SkASSERT(last != this);
    } while (true);
}
int QTimeLine::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QObject::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 10)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 10;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< int*>(_v) = duration(); break;
        case 1: *reinterpret_cast< int*>(_v) = updateInterval(); break;
        case 2: *reinterpret_cast< int*>(_v) = currentTime(); break;
        case 3: *reinterpret_cast< Direction*>(_v) = direction(); break;
        case 4: *reinterpret_cast< int*>(_v) = loopCount(); break;
        case 5: *reinterpret_cast< CurveShape*>(_v) = curveShape(); break;
        case 6: *reinterpret_cast< QEasingCurve*>(_v) = easingCurve(); break;
        }
        _id -= 7;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setDuration(*reinterpret_cast< int*>(_v)); break;
        case 1: setUpdateInterval(*reinterpret_cast< int*>(_v)); break;
        case 2: setCurrentTime(*reinterpret_cast< int*>(_v)); break;
        case 3: setDirection(*reinterpret_cast< Direction*>(_v)); break;
        case 4: setLoopCount(*reinterpret_cast< int*>(_v)); break;
        case 5: setCurveShape(*reinterpret_cast< CurveShape*>(_v)); break;
        case 6: setEasingCurve(*reinterpret_cast< QEasingCurve*>(_v)); break;
        }
        _id -= 7;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 7;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 7;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
void QAbstractAnimationJob::finished()
{
    //TODO: update this code so it is valid to delete the animation in animationFinished
    for (int i = 0; i < changeListeners.count(); ++i) {
        const QAbstractAnimationJob::ChangeListener &change = changeListeners.at(i);
        if (change.types & QAbstractAnimationJob::Completion) {
            RETURN_IF_DELETED(change.listener->animationFinished(this));
        }
    }

    if (m_group && (duration() == -1 || loopCount() < 0)) {
        //this is an uncontrolled animation, need to notify the group animation we are finished
        m_group->uncontrolledAnimationFinished(this);
    }
}
int QAbstractAnimation::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QObject::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        if (_id < 11)
            qt_static_metacall(this, _c, _id, _a);
        _id -= 11;
    }
#ifndef QT_NO_PROPERTIES
      else if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< State*>(_v) = state(); break;
        case 1: *reinterpret_cast< int*>(_v) = loopCount(); break;
        case 2: *reinterpret_cast< int*>(_v) = currentTime(); break;
        case 3: *reinterpret_cast< int*>(_v) = currentLoop(); break;
        case 4: *reinterpret_cast< Direction*>(_v) = direction(); break;
        case 5: *reinterpret_cast< int*>(_v) = duration(); break;
        }
        _id -= 6;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 1: setLoopCount(*reinterpret_cast< int*>(_v)); break;
        case 2: setCurrentTime(*reinterpret_cast< int*>(_v)); break;
        case 4: setDirection(*reinterpret_cast< Direction*>(_v)); break;
        }
        _id -= 6;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 6;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 6;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 6;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 6;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 6;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 6;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
Exemple #11
0
bool AMLoopAction3::canPause() const{
	if(currentIteration_ < loopCount()-1)
		return true;
	return AMListAction3::canPause();
}