From f6969659f4b8a2ace136908d36097c9e08434fdb Mon Sep 17 00:00:00 2001 From: Marco Gittler Date: Sun, 21 Feb 2010 19:03:33 +0000 Subject: [PATCH] newstuff and templates for title ask if changes are made to title svn path=/trunk/kdenlive/; revision=4334 --- CMakeLists.txt | 1 + src/CMakeLists.txt | 2 +- src/kdenlive_titles.knsrc | 9 +++++ src/kdenliveui.rc | 1 + src/mainwindow.cpp | 9 +++++ src/mainwindow.h | 1 + src/titlewidget.cpp | 54 +++++++++++++++++++++++++-- src/titlewidget.h | 12 ++++++ src/widgets/titlewidget_ui.ui | 38 ++++++++++++------- titles/CMakeLists.txt | 2 + titles/simple-scroll.kdenlivetitle | 11 ++++++ titles/simple-with-date.kdenlivetitle | 23 ++++++++++++ titles/simple.kdenlivetitle | 11 ++++++ 13 files changed, 156 insertions(+), 18 deletions(-) create mode 100644 src/kdenlive_titles.knsrc create mode 100644 titles/CMakeLists.txt create mode 100644 titles/simple-scroll.kdenlivetitle create mode 100644 titles/simple-with-date.kdenlivetitle create mode 100644 titles/simple.kdenlivetitle diff --git a/CMakeLists.txt b/CMakeLists.txt index 8e1d0471..be663dcf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -52,6 +52,7 @@ add_subdirectory(export) add_subdirectory(icons) add_subdirectory(data) add_subdirectory(lumas) +add_subdirectory(titles) add_subdirectory(po) add_subdirectory(man) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5c9cb0d6..4e27a110 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -232,7 +232,7 @@ install( FILES kdenliveui.rc kdenlive.notifyrc DESTINATION ${DATA_INSTALL_DIR}/ install (FILES kdenlivesettings.kcfg DESTINATION ${KCFG_INSTALL_DIR}) install (FILES kdenlive.desktop DESTINATION ${XDG_APPS_INSTALL_DIR}) kde4_install_icons(${ICON_INSTALL_DIR}) -install( FILES kdenlive_wipes.knsrc kdenlive_renderprofiles.knsrc kdenlive_projectprofiles.knsrc kdenlivetranscodingrc DESTINATION ${CONFIG_INSTALL_DIR} ) +install( FILES kdenlive_titles.knsrc kdenlive_wipes.knsrc kdenlive_renderprofiles.knsrc kdenlive_projectprofiles.knsrc kdenlivetranscodingrc DESTINATION ${CONFIG_INSTALL_DIR} ) kde4_install_icons( ${ICON_INSTALL_DIR} ) diff --git a/src/kdenlive_titles.knsrc b/src/kdenlive_titles.knsrc new file mode 100644 index 00000000..d502c74c --- /dev/null +++ b/src/kdenlive_titles.knsrc @@ -0,0 +1,9 @@ +[KNewStuff2] +ProvidersUrl=http://kdenlive.org/data/titletemplates.xml +TargetDir=kdenlive/titles +Uncompress=archive + +[KNewStuff3] +ProvidersUrl=http://kdenlive.org/data/titletemplates.xml +TargetDir=kdenlive/titles +Uncompress=archive diff --git a/src/kdenliveui.rc b/src/kdenliveui.rc index 3fcb2e01..fa83cb67 100644 --- a/src/kdenliveui.rc +++ b/src/kdenliveui.rc @@ -153,6 +153,7 @@ + Themes diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 1c9f4984..4a1a0c67 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -956,6 +956,8 @@ void MainWindow::setupActions() KNS3::standardAction(i18n("Download New Project Profiles..."), this, SLOT(slotGetNewMltProfileStuff()), actionCollection(), "get_new_mlt_profiles"); + KNS3::standardAction(i18n("Download New Title Templates..."), this, SLOT(slotGetNewTitleStuff()), actionCollection(), "get_new_titles"); + KAction* wizAction = new KAction(KIcon("configure"), i18n("Run Config Wizard"), this); collection->addAction("run_wizard", wizAction); connect(wizAction, SIGNAL(triggered(bool)), this, SLOT(slotRunWizard())); @@ -2930,6 +2932,13 @@ int MainWindow::getNewStuff(const QString &configFile) return entries.size(); } +void MainWindow::slotGetNewTitleStuff() +{ + if (getNewStuff("kdenlive_titles.knsrc") > 0) { + TitleWidget::refreshTitleTemplates(); + } +} + void MainWindow::slotGetNewLumaStuff() { if (getNewStuff("kdenlive_wipes.knsrc") > 0) { diff --git a/src/mainwindow.h b/src/mainwindow.h index 67a8d6ab..7fb488d4 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -309,6 +309,7 @@ private slots: void slotDeleteTrack(int ix = 0); void slotChangeTrack(int ix = 0); void slotGetNewLumaStuff(); + void slotGetNewTitleStuff(); void slotGetNewRenderStuff(); void slotGetNewMltProfileStuff(); void slotAutoTransition(); diff --git a/src/titlewidget.cpp b/src/titlewidget.cpp index 48c369f0..e0e2de94 100644 --- a/src/titlewidget.cpp +++ b/src/titlewidget.cpp @@ -18,7 +18,7 @@ #include "titlewidget.h" #include "kdenlivesettings.h" #include "KoSliderCombo.h" - +#include "kthumb.h" #include #include @@ -38,6 +38,8 @@ #include #include #include +#include +#include #if QT_VERSION >= 0x040600 #include @@ -45,6 +47,8 @@ #include #endif +static QList titletemplates; + int settingUp = false; const int IMAGEITEM = 7; @@ -424,8 +428,18 @@ TitleWidget::TitleWidget(KUrl url, Timecode tc, QString projectTitlePath, Render 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() @@ -507,8 +521,42 @@ QStringList TitleWidget::extractFontList(QString xml) } 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 realy 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*/) { diff --git a/src/titlewidget.h b/src/titlewidget.h index 44e38ced..a76c0855 100644 --- a/src/titlewidget.h +++ b/src/titlewidget.h @@ -29,6 +29,13 @@ #include #include +class TitleTemplate +{ +public: + QString file; + QString name; + QIcon icon; +}; class Transform { @@ -44,6 +51,7 @@ public: double rotatex, rotatey, rotatez; }; + class TitleWidget : public QDialog , public Ui::TitleWidget_UI { Q_OBJECT @@ -85,6 +93,8 @@ public: /** \brief Get clip duration. */ int duration() const; + /** load Title Templates*/ + static void refreshTitleTemplates(); protected: virtual void resizeEvent(QResizeEvent * event); @@ -124,6 +134,7 @@ private: /** project path for storing title clips */ QString m_projectTitlePath; Timecode m_tc; + QString lastDocumentHash; /** See http://doc.trolltech.com/4.5/signalsandslots.html#advanced-signals-and-slots-usage */ QSignalMapper *m_signalMapper; @@ -290,6 +301,7 @@ private slots: void slotZIndexDown(); void slotZIndexTop(); void slotZIndexBottom(); + void templateIndexChanged(int); }; diff --git a/src/widgets/titlewidget_ui.ui b/src/widgets/titlewidget_ui.ui index aa6e53a4..d8182999 100644 --- a/src/widgets/titlewidget_ui.ui +++ b/src/widgets/titlewidget_ui.ui @@ -6,8 +6,8 @@ 0 0 - 977 - 633 + 1383 + 835 @@ -36,7 +36,7 @@ - + @@ -195,7 +195,7 @@ - + @@ -552,14 +552,14 @@ - + 0 0 0 - + 0 0 @@ -737,7 +737,7 @@ - + @@ -785,14 +785,14 @@ - + 0 0 0 - + 0 0 @@ -820,14 +820,14 @@ - + 0 0 0 - + 0 0 @@ -900,14 +900,14 @@ false - + 0 0 0 - + 0 0 @@ -1085,7 +1085,7 @@ - + Qt::Horizontal @@ -1095,6 +1095,16 @@ + + + + + + + Template: + + + diff --git a/titles/CMakeLists.txt b/titles/CMakeLists.txt new file mode 100644 index 00000000..21ce6820 --- /dev/null +++ b/titles/CMakeLists.txt @@ -0,0 +1,2 @@ +FILE(GLOB files "${CMAKE_CURRENT_SOURCE_DIR}/*.kdenlivetitle") +INSTALL (FILES ${files} DESTINATION ${DATA_INSTALL_DIR}/kdenlive/titles) diff --git a/titles/simple-scroll.kdenlivetitle b/titles/simple-scroll.kdenlivetitle new file mode 100644 index 00000000..24df74a4 --- /dev/null +++ b/titles/simple-scroll.kdenlivetitle @@ -0,0 +1,11 @@ + + + + 1,0,0,0,1,0,0,0,1 + + Text here + + + + + diff --git a/titles/simple-with-date.kdenlivetitle b/titles/simple-with-date.kdenlivetitle new file mode 100644 index 00000000..724b47e5 --- /dev/null +++ b/titles/simple-with-date.kdenlivetitle @@ -0,0 +1,23 @@ + + + + 1,0,0,0,1,0,0,0,1 + + 2010/01/01 + + + + 1,0,0,0,1,0,0,0,1 + + Text here + + + + 1,0,0,0,1,0,0,0,1 + + + + + + + diff --git a/titles/simple.kdenlivetitle b/titles/simple.kdenlivetitle new file mode 100644 index 00000000..f12503cc --- /dev/null +++ b/titles/simple.kdenlivetitle @@ -0,0 +1,11 @@ + + + + 1,0,0,0,1,0,0,0,1 + + Text here + + + + + -- 2.39.2