+void TitleWidget::deleteAnimInfoText()
+{
+ // end animation editing, remove info text
+ while (!m_startViewport->childItems().isEmpty()) {
+ QGraphicsItem *item = m_startViewport->childItems().at(0);
+ m_scene->removeItem(item);
+ delete item;
+ }
+ while (!m_endViewport->childItems().isEmpty()) {
+ QGraphicsItem *item = m_endViewport->childItems().at(0);
+ m_scene->removeItem(item);
+ delete item;
+ }
+}
+
+
+void TitleWidget::slotKeepAspect(bool keep)
+{
+ if (m_endViewport->zValue() == 1100) {
+ m_endViewport->setData(0, keep == true ? m_frameWidth : QVariant());
+ m_endViewport->setData(1, keep == true ? m_frameHeight : QVariant());
+ } else {
+ m_startViewport->setData(0, keep == true ? m_frameWidth : QVariant());
+ m_startViewport->setData(1, keep == true ? m_frameHeight : QVariant());
+ }
+}
+
+void TitleWidget::slotResize50()
+{
+ if (m_endViewport->zValue() == 1100) {
+ m_endViewport->setRect(0, 0, m_frameWidth / 2, m_frameHeight / 2);
+ } else m_startViewport->setRect(0, 0, m_frameWidth / 2, m_frameHeight / 2);
+}
+
+void TitleWidget::slotResize100()
+{
+ if (m_endViewport->zValue() == 1100) {
+ m_endViewport->setRect(0, 0, m_frameWidth, m_frameHeight);
+ } else m_startViewport->setRect(0, 0, m_frameWidth, m_frameHeight);
+}
+
+void TitleWidget::slotResize200()
+{
+ if (m_endViewport->zValue() == 1100) {
+ m_endViewport->setRect(0, 0, m_frameWidth * 2, m_frameHeight * 2);
+ } else m_startViewport->setRect(0, 0, m_frameWidth * 2, m_frameHeight * 2);
+}
+
+void TitleWidget::slotAddEffect(int ix)
+{
+ QList<QGraphicsItem*> l = graphicsView->scene()->selectedItems();
+ int effect = effect_list->itemData(ix).toInt();
+ if (effect == NOEFFECT) {
+ if (l.size() == 1) l[0]->setData(100, QVariant());
+ effect_stack->setHidden(true);
+ return;
+ }
+ effect_stack->setCurrentIndex(effect - 1);
+ effect_stack->setHidden(false);
+ if (effect == TYPEWRITEREFFECT) {
+ 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);
+ }
+ } else if (effect == SHADOWEFFECT) {
+ if (l.size() == 1) {
+ QGraphicsEffect *eff = new QGraphicsDropShadowEffect();
+ l[0]->setGraphicsEffect(eff);
+ }
+ }
+
+#endif
+}
+
+
+void TitleWidget::slotFontText(const QString& s)
+{
+ const QFont f(s);
+ if (f.exactMatch()) {
+ // Font really exists (could also just be a «d» if the user
+ // starts typing «dejavu» for example).
+ font_family->setCurrentFont(f);
+ }
+ // Note: Typing dejavu serif does not recognize the font (takes sans)
+ // in older Qt versions.
+}
+
+void TitleWidget::slotEditTypewriter(int /*ix*/)
+{
+ QList<QGraphicsItem*> l = graphicsView->scene()->selectedItems();
+ if (l.size() == 1) {
+ QStringList effdata = QStringList() << "typewriter" << QString::number(typewriter_delay->value()) + ";" + QString::number(typewriter_start->value());
+ l[0]->setData(100, effdata);
+ }
+}
+
+void TitleWidget::slotEditBlur(int ix)
+{
+#if QT_VERSION < 0x040600
+ return;
+#else
+ QList<QGraphicsItem*> l = graphicsView->scene()->selectedItems();
+ if (l.size() == 1) {
+ QGraphicsEffect *eff = l[0]->graphicsEffect();
+ QGraphicsBlurEffect *blur = static_cast <QGraphicsBlurEffect *>(eff);
+ if (blur) blur->setBlurRadius(ix);
+ }
+#endif
+}
+
+void TitleWidget::slotEditShadow()
+{
+#if QT_VERSION < 0x040600
+ return;
+#else
+ QList<QGraphicsItem*> l = graphicsView->scene()->selectedItems();
+ if (l.size() == 1) {
+ QGraphicsEffect *eff = l[0]->graphicsEffect();
+ QGraphicsDropShadowEffect *shadow = static_cast <QGraphicsDropShadowEffect *>(eff);
+ if (shadow) {
+ shadow->setBlurRadius(shadow_radius->value());
+ shadow->setOffset(shadow_x->value(), shadow_y->value());
+ }
+ }
+#endif
+}
+
+qreal TitleWidget::zIndexBounds(bool maxBound, bool intersectingOnly)
+{
+ qreal bound = maxBound ? -99 : 99;
+ QList<QGraphicsItem*> l = graphicsView->scene()->selectedItems();
+ if (l.size() > 0) {
+ QList<QGraphicsItem*> lItems;
+ // Get items (all or intersecting only)
+ if (intersectingOnly) {
+ lItems = graphicsView->scene()->items(l[0]->sceneBoundingRect(), Qt::IntersectsItemShape);
+ } else {
+ lItems = graphicsView->scene()->items();
+ }
+ if (lItems.size() > 0) {
+ int n = lItems.size();
+ qreal z;
+ if (maxBound) {
+ for (int i = 0; i < n; i++) {
+ z = lItems[i]->zValue();
+ if (z > bound && !lItems[i]->isSelected()) {
+ bound = z;
+ }
+ }
+ } else {
+ // Get minimum z index.
+ for (int i = 0; i < n; i++) {
+ z = lItems[i]->zValue();
+ if (z < bound && !lItems[i]->isSelected() && z > -999) {
+ // There are items at the very bottom (background e.g.) with z-index < -1000.
+ bound = z;
+ }
+ }
+ }
+ }
+ }
+ return bound;
+}
+
+void TitleWidget::slotZIndexUp()
+{
+ QList<QGraphicsItem*> l = graphicsView->scene()->selectedItems();
+ if (l.size() >= 1) {
+ qreal currentZ = l[0]->zValue();
+ qreal max = zIndexBounds(true, true);
+ if (currentZ <= max) {
+ l[0]->setZValue(currentZ + 1);
+ updateDimension(l[0]);
+ }
+ }
+}
+
+void TitleWidget::slotZIndexTop()
+{
+ QList<QGraphicsItem*> l = graphicsView->scene()->selectedItems();
+ if (l.size() >= 1) {
+ qreal currentZ = l[0]->zValue();
+ qreal max = zIndexBounds(true, false);
+ if (currentZ <= max) {
+ l[0]->setZValue(max + 1);
+ updateDimension(l[0]);
+ }
+ }
+}
+
+void TitleWidget::slotZIndexDown()
+{
+ QList<QGraphicsItem*> l = graphicsView->scene()->selectedItems();
+ if (l.size() >= 1) {
+ qreal currentZ = l[0]->zValue();
+ qreal min = zIndexBounds(false, true);
+ if (currentZ >= min) {
+ l[0]->setZValue(currentZ - 1);
+ updateDimension(l[0]);
+ }
+ }
+}
+
+void TitleWidget::slotZIndexBottom()
+{
+ QList<QGraphicsItem*> l = graphicsView->scene()->selectedItems();
+ if (l.size() >= 1) {
+ qreal currentZ = l[0]->zValue();
+ qreal min = zIndexBounds(false, false);
+ if (currentZ >= min) {
+ l[0]->setZValue(min - 1);
+ updateDimension(l[0]);
+ }
+ }
+}