#include "titlewidget.h"
#include "kdenlivesettings.h"
#include "KoSliderCombo.h"
-
+#include "kthumb.h"
#include <cmath>
#include <KDebug>
#include <QSignalMapper>
#include <QTextBlockFormat>
#include <QTextCursor>
+#include <QComboBox>
+#include <QCryptographicHash>
#if QT_VERSION >= 0x040600
#include <QGraphicsEffect>
#include <QGraphicsDropShadowEffect>
#endif
+static QList<TitleTemplate> titletemplates;
+
int settingUp = false;
const int IMAGEITEM = 7;
m_frameHeight = render->renderHeight();
showToolbars(TITLE_SELECT);
+ //If project is drop frame, set the input mask as such.
+ title_duration->setInputMask(m_tc.inputMask());
+
//TODO: get default title duration instead of hardcoded one
title_duration->setText(m_tc.getTimecode(GenTime(5000 / 1000.0)));
connect(buttonAlignRight, SIGNAL(clicked()), this, SLOT(slotUpdateText()));
connect(buttonAlignCenter, SIGNAL(clicked()), this, SLOT(slotUpdateText()));
connect(buttonAlignNone, SIGNAL(clicked()), this, SLOT(slotUpdateText()));
- //connect(buttonInsertUnicode, SIGNAL(clicked()), this, SLOT(slotInsertUnicode()));
connect(displayBg, SIGNAL(stateChanged(int)), this, SLOT(displayBackgroundFrame()));
connect(m_unicodeDialog, SIGNAL(charSelected(QString)), this, SLOT(slotInsertUnicodeString(QString)));
zDown->setDefaultAction(m_zDown);
m_zTop = new QAction(KIcon("kdenlive-zindex-top"), QString(), this);
- m_zTop->setShortcut(Qt::Key_Home);
+ // TODO mbt 1414: Shortcut should change z index only if
+ // cursor is NOT in a text field ...
+ //m_zTop->setShortcut(Qt::Key_Home);
m_zTop->setToolTip(i18n("Raise object to top"));
connect(m_zTop, SIGNAL(triggered()), this, SLOT(slotZIndexTop()));
zTop->setDefaultAction(m_zTop);
m_zBottom = new QAction(KIcon("kdenlive-zindex-bottom"), QString(), this);
- m_zBottom->setShortcut(Qt::Key_End);
+ // TODO mbt 1414
+ //m_zBottom->setShortcut(Qt::Key_End);
m_zBottom->setToolTip(i18n("Lower object to bottom"));
connect(m_zBottom, SIGNAL(triggered()), this, SLOT(slotZIndexBottom()));
zBottom->setDefaultAction(m_zBottom);
initAnimation();
connect(anim_start, SIGNAL(toggled(bool)), this, SLOT(slotAnimStart(bool)));
connect(anim_end, SIGNAL(toggled(bool)), this, SLOT(slotAnimEnd(bool)));
+ connect(templateBox,SIGNAL(currentIndexChanged(int)),this,SLOT(templateIndexChanged(int)));
buttonBox->button(QDialogButtonBox::Ok)->setEnabled(KdenliveSettings::hastitleproducer());
+ refreshTitleTemplates();
+ //templateBox->setIconSize(QSize(60,60));
+ templateBox->clear();
+ templateBox->addItem("");
+ foreach (TitleTemplate t, titletemplates)
+ {
+ templateBox->addItem(t.icon,t.name,t.file);
+ }
+ lastDocumentHash=QCryptographicHash::hash(xml().toString().toAscii(), QCryptographicHash::Md5).toHex();
}
TitleWidget::~TitleWidget()
}
return result;
}
-
-
+//static
+void TitleWidget::refreshTitleTemplates()
+{
+ QStringList titlenamelist = QStringList() << i18n("None");
+ QStringList titlefiles = QStringList() << QString();
+ QStringList filters;
+ filters << "*.kdenlivetitle" ;
+ titletemplates.clear();
+ QStringList titleTemplates = KGlobal::dirs()->findDirs("appdata", "titles");
+ foreach(const QString &folder, titleTemplates) {
+ QStringList filesnames = QDir(folder).entryList(filters, QDir::Files);
+ foreach(const QString &fname, filesnames) {
+ //titlenamelist.append(fname);
+ //titlefiles.append(KUrl(folder).path(KUrl::AddTrailingSlash) + fname);
+ TitleTemplate t;
+ t.name=fname;
+ t.file=KUrl(folder).path(KUrl::AddTrailingSlash) + fname;
+ t.icon=QIcon(KThumb::getImage(t.file,0,60,60));
+ titletemplates.append(t);
+ }
+ }
+ kDebug() << titlenamelist << titlefiles;
+}
+void TitleWidget::templateIndexChanged(int index )
+{
+ QString item=templateBox->itemData(index).toString();
+ if (item!="")
+ {
+ if (lastDocumentHash!=QCryptographicHash::hash(xml().toString().toAscii(), QCryptographicHash::Md5).toHex())
+ {
+ if (KMessageBox::questionYesNo(this, i18n("Title was changed !\nDo you really want to load a new template?\nAll changes in this document are lost !!")) == KMessageBox::No) return;
+ }
+ loadTitle(item);
+ lastDocumentHash=QCryptographicHash::hash(xml().toString().toAscii(), QCryptographicHash::Md5).toHex();
+ }
+}
//virtual
void TitleWidget::resizeEvent(QResizeEvent * /*event*/)
{
x.rotatez = rotlist[2].toDouble();
// Try to adjust zoom
- t.rotate(x.rotatex * (-1), Qt::XAxis);
- t.rotate(x.rotatey * (-1), Qt::YAxis);
- t.rotate(x.rotatez * (-1), Qt::ZAxis);
+ t.rotate(x.rotatex *(-1), Qt::XAxis);
+ t.rotate(x.rotatey *(-1), Qt::YAxis);
+ t.rotate(x.rotatez *(-1), Qt::ZAxis);
x.scalex = t.m11();
x.scaley = t.m22();
} else {
// in older Qt versions.
}
-void TitleWidget::slotEditTypewriter(int ix)
+void TitleWidget::slotEditTypewriter(int /*ix*/)
{
QList<QGraphicsItem*> l = graphicsView->scene()->selectedItems();
if (l.size() == 1) {