Пример #1
0
void CollapsibleGroup::dropEvent(QDropEvent *event)
{
    frame->setProperty("target", false);
    frame->setStyleSheet(frame->styleSheet());
    const QString effects = QString::fromUtf8(event->mimeData()->data("kdenlive/effectslist"));
    //event->acceptProposedAction();
    QDomDocument doc;
    doc.setContent(effects, true);
    QDomElement e = doc.documentElement();
    int ix = e.attribute("kdenlive_ix").toInt();
    if (ix == 0 || e.tagName() == "effectgroup") {
	if (e.tagName() == "effectgroup") {
	    // dropped a group on another group
	    QDomNodeList pastedEffects = e.elementsByTagName("effect");
	    if (pastedEffects.isEmpty() || m_subWidgets.isEmpty()) {
		// Buggy groups, should not happen
		event->ignore();
		return;
	    }
	    QList <int> pastedEffectIndexes;
	    QList <int> currentEffectIndexes;
	    EffectInfo pasteInfo;
	    pasteInfo.fromString(pastedEffects.at(0).toElement().attribute("kdenlive_info"));
	    if (pasteInfo.groupIndex == -1) {
		// Group dropped from effects list, add effect
		e.setAttribute("kdenlive_ix", m_subWidgets.last()->effectIndex());
		emit addEffect(e);
		event->setDropAction(Qt::CopyAction);
		event->accept();
		return;
	    }
	    // Moving group
	    for (int i = 0; i < pastedEffects.count(); i++) {
		pastedEffectIndexes << pastedEffects.at(i).toElement().attribute("kdenlive_ix").toInt();
	    }
	    for (int i = 0; i < m_subWidgets.count(); i++) {
		currentEffectIndexes << m_subWidgets.at(i)->effectIndex();
	    }
	    kDebug()<<"PASTING: "<<pastedEffectIndexes<<" TO "<<currentEffectIndexes;
	    if (pastedEffectIndexes.at(0) < currentEffectIndexes.at(0)) {
		// Pasting group after current one:
		emit moveEffect(pastedEffectIndexes, currentEffectIndexes.last(), pasteInfo.groupIndex, pasteInfo.groupName);
	    }
	    else {
		// Group moved before current one
		emit moveEffect(pastedEffectIndexes, currentEffectIndexes.first(), pasteInfo.groupIndex, pasteInfo.groupName);
	    }
	    event->setDropAction(Qt::MoveAction);
	    event->accept();
	    return;
	}
	// effect dropped from effects list, add it
	e.setAttribute("kdenlive_info", m_info.toString());
	if (!m_subWidgets.isEmpty()) {
	    e.setAttribute("kdenlive_ix", m_subWidgets.at(0)->effectIndex());
	}
	emit addEffect(e);
	event->setDropAction(Qt::CopyAction);
	event->accept();
	return;
    }
    if (m_subWidgets.isEmpty()) return;
    int new_index = m_subWidgets.last()->effectIndex();
    emit moveEffect(QList <int> () <<ix, new_index, m_info.groupIndex, m_title->text());
    event->setDropAction(Qt::MoveAction);
    event->accept();
}
Пример #2
0
void EffectManager::paintEvent()
{
    //printf("void EffectManager::paintEvent()\n");

    if(!m_isActive)
        return;

    if(!prev_img.bitmap) {

        GLContext *ctx = glActiveContext();
        int sz = ctx->width *ctx->height *(ctx->depth/8);

        if(prev_img.bitmap)
            free(prev_img.bitmap);

        prev_img.bitmap = malloc(sz);
        prev_img.w = ctx->width;
        prev_img.h = ctx->height;
        prev_img.bit = ctx->depth;
        memcpy(prev_img.bitmap, &glGetPixel16(ctx, 0, 0), sz);
    }

    if(m_effect >= EFFECT_CENTER_SCALE && m_effect <= EFFECT_RIGHT_SCALE)
        scaleEffect(m_effect - EFFECT_CENTER_SCALE);

    else if(m_effect >= EFFECT_LEFT_MOVE && m_effect <= EFFECT_RIGHT_MOVE)
        moveEffect(m_effect - EFFECT_LEFT_MOVE);

    else if(m_effect >= EFFECT_SUB_ALPHA && m_effect <= EFFECT_ADD_ALPHA)
        alphaEffect(m_effect - EFFECT_SUB_ALPHA);

    else if(m_effect >= EFFECT_SUB_DOMINO && m_effect <= EFFECT_ADD_DOMINO)
        dominoEffect(m_effect - EFFECT_SUB_DOMINO);

    else {

        stop();
        return;
    }


    /*
        if(prev_img.bitmap) {
            //glDisable(GL_ALPHA_TEST);
            //glDrawBitmap(start_pos, 0, prev_img.w, prev_img.h, prev_img.bit, prev_img.bitmap);
            //glEnable(GL_ALPHA_TEST);

            if(start_pos > -1) {
                int w_sz = rect().w()-start_pos;
                int h_sz = rect().h() - (rect().h() *(start_pos*100/rect().w()) /100);
                ScaleAndPaint((unsigned short*)prev_img.bitmap, prev_img.w, prev_img.h, start_pos/2, rect().h()*(start_pos*100/rect().w())/100 /2, w_sz, h_sz);
            }
        }

        start_pos += speed;
        speed += speed * 10 / 100+1;

        if(start_pos-50 > (prev_img.w)) {
            stop();
            //printf("effectTimerHandler: cdEffectStop()\n");
        } else {

            //printf("effectTimerHandler: refresh()\n");
            event_mngr->refresh();
        }*/
}