Commit 5764ab3c authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Add an "effect start" param to typewriter that allows to set a delay before the effect starts

svn path=/trunk/kdenlive/; revision=4113
parent 0cc837dd
......@@ -100,7 +100,7 @@ QDomDocument TitleDocument::xml(QGraphicsRectItem* startv, QGraphicsRectItem* en
if (!t->data(100).isNull()) {
QStringList effectParams = t->data(100).toStringList();
content.setAttribute(effectParams.at(0), effectParams.at(1));
content.setAttribute(effectParams.takeFirst(), effectParams.join(";"));
}
// Only save when necessary.
......@@ -295,7 +295,7 @@ int TitleDocument::loadFromXml(QDomDocument doc, QGraphicsRectItem* startv, QGra
// Effects
if (!txtProperties.namedItem("typewriter").isNull()) {
QStringList effData = QStringList() << "typewriter" << QString::number(txtProperties.namedItem("typewriter").nodeValue().toInt());
QStringList effData = QStringList() << "typewriter" << txtProperties.namedItem("typewriter").nodeValue();
txt->setData(100, effData);
}
......
......@@ -102,10 +102,12 @@ TitleWidget::TitleWidget(KUrl url, Timecode tc, QString projectTitlePath, Render
connect(endViewportX, SIGNAL(valueChanged(int)), this, SLOT(setupViewports()));
connect(endViewportY, SIGNAL(valueChanged(int)), this, SLOT(setupViewports()));
connect(endViewportSize, SIGNAL(valueChanged(int)), this, SLOT(setupViewports()));*/
// Fill effects
effect_list->addItem(i18n("None"), NOEFFECT);
effect_list->addItem(i18n("Typewriter"), TYPEWRITEREFFECT);
effect_list->addItem(i18n("Blur"), BLUREFFECT);
connect(zValue, SIGNAL(valueChanged(int)), this, SLOT(zIndexChanged(int)));
connect(itemzoom, SIGNAL(valueChanged(int)), this, SLOT(itemScaled(int)));
......@@ -118,6 +120,7 @@ TitleWidget::TitleWidget(KUrl url, Timecode tc, QString projectTitlePath, Render
connect(itemright, SIGNAL(clicked()), this, SLOT(itemRight()));
connect(effect_list, SIGNAL(currentIndexChanged(int)), this, SLOT(slotAddEffect(int)));
connect(typewriter_delay, SIGNAL(valueChanged(int)), this, SLOT(slotEditTypewriter(int)));
connect(typewriter_start, SIGNAL(valueChanged(int)), this, SLOT(slotEditTypewriter(int)));
connect(blur_radius, SIGNAL(valueChanged(int)), this, SLOT(slotEditBlur(int)));
connect(shadow_radius, SIGNAL(valueChanged(int)), this, SLOT(slotEditShadow()));
connect(shadow_x, SIGNAL(valueChanged(int)), this, SLOT(slotEditShadow()));
......@@ -665,9 +668,9 @@ void TitleWidget::selectionChanged()
itemzoom->blockSignals(true);
itemrotate->blockSignals(true);
if (l.size() == 0) {
effect_stack->setHidden(true);
effect_frame->setEnabled(false);
effect_list->setCurrentIndex(0);
effect_stack->setHidden(true);
effect_frame->setEnabled(false);
effect_list->setCurrentIndex(0);
bool blockX = !origin_x_left->signalsBlocked();
bool blockY = !origin_y_top->signalsBlocked();
if (blockX) origin_x_left->blockSignals(true);
......@@ -681,10 +684,10 @@ void TitleWidget::selectionChanged()
if (blockY) origin_y_top->blockSignals(false);
itemzoom->setEnabled(false);
itemrotate->setEnabled(false);
frame_properties->setEnabled(false);
frame_properties->setEnabled(false);
} else if (l.size() == 1) {
effect_frame->setEnabled(true);
frame_properties->setEnabled(true);
effect_frame->setEnabled(true);
frame_properties->setEnabled(true);
if (l.at(0) != m_startViewport && l.at(0) != m_endViewport) {
itemzoom->setEnabled(true);
itemrotate->setEnabled(true);
......@@ -696,34 +699,40 @@ void TitleWidget::selectionChanged()
if (l.at(0)->type() == TEXTITEM) {
showToolbars(TITLE_TEXT);
QGraphicsTextItem* i = static_cast <QGraphicsTextItem *>(l.at(0));
if (!i->data(100).isNull()) {
// Item has an effect
QStringList effdata = i->data(100).toStringList();
if (effdata.at(0) == "typewriter") {
typewriter_delay->setValue(effdata.at(1).toInt());
effect_list->setCurrentIndex(effect_list->findData((int) TYPEWRITEREFFECT));
effect_stack->setHidden(false);
}
} else {
if (i->graphicsEffect()) {
QGraphicsBlurEffect *blur = static_cast <QGraphicsBlurEffect *>(i->graphicsEffect());
if (blur) {
effect_list->setCurrentIndex(effect_list->findData((int) BLUREFFECT));
int rad = (int) blur->blurRadius();
blur_radius->setValue(rad);
effect_stack->setHidden(false);
} else {
QGraphicsDropShadowEffect *shad = static_cast <QGraphicsDropShadowEffect *>(i->graphicsEffect());
if (shad) {
effect_list->setCurrentIndex(effect_list->findData((int) SHADOWEFFECT));
shadow_radius->setValue(shad->blurRadius());
shadow_x->setValue(shad->xOffset());
shadow_y->setValue(shad->yOffset());
effect_stack->setHidden(false);
}
}
} else effect_stack->setHidden(true);
}
if (!i->data(100).isNull()) {
// Item has an effect
QStringList effdata = i->data(100).toStringList();
QString effectName = effdata.takeFirst();
if (effectName == "typewriter") {
QStringList params = effdata.at(0).split(';');
typewriter_delay->setValue(params.at(0).toInt());
typewriter_start->setValue(params.at(1).toInt());
effect_list->setCurrentIndex(effect_list->findData((int) TYPEWRITEREFFECT));
effect_stack->setHidden(false);
}
}
else {
if (i->graphicsEffect()) {
QGraphicsBlurEffect *blur = static_cast <QGraphicsBlurEffect *> (i->graphicsEffect());
if (blur) {
effect_list->setCurrentIndex(effect_list->findData((int) BLUREFFECT));
int rad = (int) blur->blurRadius();
blur_radius->setValue(rad);
effect_stack->setHidden(false);
}
else {
QGraphicsDropShadowEffect *shad = static_cast <QGraphicsDropShadowEffect *> (i->graphicsEffect());
if (shad) {
effect_list->setCurrentIndex(effect_list->findData((int) SHADOWEFFECT));
shadow_radius->setValue(shad->blurRadius());
shadow_x->setValue(shad->xOffset());
shadow_y->setValue(shad->yOffset());
effect_stack->setHidden(false);
}
}
}
else effect_stack->setHidden(true);
}
//if (l[0]->hasFocus())
//toolBox->setCurrentIndex(0);
//toolBox->setItemEnabled(2, true);
......@@ -1785,32 +1794,32 @@ void TitleWidget::slotAddEffect(int ix)
{
int effect = effect_list->itemData(ix).toInt();
if (effect == 0) {
effect_stack->setHidden(true);
return;
effect_stack->setHidden(true);
return;
}
effect_stack->setCurrentIndex(effect - 1);
effect_stack->setHidden(false);
QList<QGraphicsItem*> l = graphicsView->scene()->selectedItems();
if (effect == TYPEWRITEREFFECT) {
if (l.size() == 1 && l.at(0)->type() == TEXTITEM) {
QStringList effdata = QStringList() << "typewriter" << QString::number(typewriter_delay->value());
l[0]->setData(100, effdata);
}
if (l.size() == 1 && l.at(0)->type() == TEXTITEM) {
QStringList effdata = QStringList() << "typewriter" << QString::number(typewriter_delay->value()) + ";" + QString::number(typewriter_start->value());
l[0]->setData(100, effdata);
}
}
#if QT_VERSION < 0x040600
return;
#else
if (effect == BLUREFFECT) {
// Blur effect
if (l.size() == 1) {
QGraphicsEffect *eff = new QGraphicsBlurEffect();
l[0]->setGraphicsEffect(eff);
}
if (l.size() == 1) {
QGraphicsEffect *eff = new QGraphicsBlurEffect();
l[0]->setGraphicsEffect(eff);
}
} else if (effect == SHADOWEFFECT) {
if (l.size() == 1) {
QGraphicsEffect *eff = new QGraphicsDropShadowEffect();
l[0]->setGraphicsEffect(eff);
}
if (l.size() == 1) {
QGraphicsEffect *eff = new QGraphicsDropShadowEffect();
l[0]->setGraphicsEffect(eff);
}
}
#endif
......@@ -1833,7 +1842,7 @@ void TitleWidget::slotEditTypewriter(int ix)
{
QList<QGraphicsItem*> l = graphicsView->scene()->selectedItems();
if (l.size() == 1) {
QStringList effdata = QStringList() << "typewriter" << QString::number(typewriter_delay->value());
QStringList effdata = QStringList() << "typewriter" << QString::number(typewriter_delay->value()) + ";" + QString::number(typewriter_start->value());
l[0]->setData(100, effdata);
}
}
......
......@@ -618,7 +618,7 @@
<item row="2" column="0" colspan="2">
<widget class="QStackedWidget" name="effect_stack">
<property name="currentIndex">
<number>0</number>
<number>2</number>
</property>
<widget class="QWidget" name="page">
<layout class="QGridLayout" name="gridLayout_10">
......@@ -707,10 +707,13 @@
</widget>
<widget class="QWidget" name="page_3">
<layout class="QGridLayout" name="gridLayout_15">
<property name="margin">
<number>0</number>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_13">
<property name="text">
<string>Delay (frames)</string>
<string>Delay</string>
</property>
</widget>
</item>
......@@ -722,11 +725,44 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="suffix">
<string> frames</string>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="value">
<number>5</number>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_16">
<property name="text">
<string>Start at</string>
</property>
</widget>
</item>
<item row="2" column="0">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="1" column="1">
<widget class="QSpinBox" name="typewriter_start">
<property name="suffix">
<string> frames</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment