const int RECTITEM = 3;
const int TEXTITEM = 8;
-TitleWidget::TitleWidget(KUrl url, QString projectPath, Render *render, QWidget *parent) :
+TitleWidget::TitleWidget(KUrl url, QString projectTitlePath, Render *render, QWidget *parent) :
QDialog(parent),
Ui::TitleWidget_UI(),
m_startViewport(NULL),
m_render(render),
m_count(0),
m_unicodeDialog(new UnicodeDialog(UnicodeDialog::InputHex)),
- m_projectPath(projectPath)
+ m_projectTitlePath(projectTitlePath)
{
setupUi(this);
setFont(KGlobalSettings::toolBarFont());
}
//static
-QStringList TitleWidget::getFreeTitleInfo(const KUrl &projectUrl)
+QStringList TitleWidget::getFreeTitleInfo(const KUrl &projectUrl, bool isClone)
{
QStringList result;
- QString titlePath = projectUrl.path() + "/titles/";
+ QString titlePath = projectUrl.path(KUrl::AddTrailingSlash) + "titles/";
KStandardDirs::makeDir(titlePath);
- QString titleName = "title";
+ titlePath.append((isClone == false) ? "title" : "clone");
int counter = 0;
- QString path = titlePath + titleName + QString::number(counter).rightJustified(3, '0', false);
- while (QFile::exists(path + ".png")) {
+ QString path;
+ while (path.isEmpty() || QFile::exists(path)) {
counter++;
- path = titlePath + titleName + QString::number(counter).rightJustified(3, '0', false);
+ path = titlePath + QString::number(counter).rightJustified(3, '0', false) + ".png";
}
- result.append(titleName + QString::number(counter).rightJustified(3, '0', false));
- result.append(path + ".png");
+ result.append(((isClone == false) ? i18n("Title") : i18n("Clone")) + ' ' + QString::number(counter).rightJustified(3, '0', false));
+ result.append(path);
return result;
}
QString TitleWidget::getTitleResourceFromName(const KUrl &projectUrl, const QString &titleName)
{
QStringList result;
- QString titlePath = projectUrl.path() + "/titles/";
+ QString titlePath = projectUrl.path(KUrl::AddTrailingSlash) + "titles/";
KStandardDirs::makeDir(titlePath);
return titlePath + titleName + ".png";
}
void TitleWidget::loadTitle()
{
- KUrl url = KFileDialog::getOpenUrl(KUrl(m_projectPath), "*.kdenlivetitle", this, i18n("Load Title"));
+ KUrl url = KFileDialog::getOpenUrl(KUrl(m_projectTitlePath), "*.kdenlivetitle", this, i18n("Load Title"));
if (!url.isEmpty()) {
QList<QGraphicsItem *> items = m_scene->items();
for (int i = 0; i < items.size(); i++) {
void TitleWidget::saveTitle(KUrl url)
{
- if (url.isEmpty()) url = KFileDialog::getSaveUrl(KUrl(m_projectPath), "*.kdenlivetitle", this, i18n("Save Title"));
+ if (url.isEmpty()) url = KFileDialog::getSaveUrl(KUrl(m_projectTitlePath), "*.kdenlivetitle", this, i18n("Save Title"));
if (!url.isEmpty()) {
if (m_titledocument.saveDocument(url, m_startViewport, m_endViewport) == false)
KMessageBox::error(this, i18n("Cannot write to file %1", url.path()));
public:
/** \brief Constructor
* \param projectPath Path to use when user requests loading or saving of titles as .kdenlivetitle documents */
- TitleWidget(KUrl url, QString projectPath, Render *render, QWidget *parent = 0);
+ TitleWidget(KUrl url, QString projectTitlePath, Render *render, QWidget *parent = 0);
virtual ~TitleWidget();
QDomDocument xml();
void setXml(QDomDocument doc);
* ".png" as the second element.
*
* The path "/titles/" is appended to projectUrl to locate the actual directory that contains the title pngs. */
- static QStringList getFreeTitleInfo(const KUrl &projectUrl);
+ static QStringList getFreeTitleInfo(const KUrl &projectUrl, bool isClone = false);
/** \brief Build a filename from a projectUrl and a titleName
* \param projectUrl Url to directory of project.
/** \brief Dialog for entering unicode in text fields */
UnicodeDialog *m_unicodeDialog;
/** project path for storing title clips */
- QString m_projectPath;
+ QString m_projectTitlePath;
/** \brief Store the current choices of font, background and rect values */
void writeChoices();
/** \brief Read the last stored choices into the dialog */