titler: add option to save title and add to project in in one pass (through the create button menu)

parent fed2ec3d
......@@ -17,6 +17,7 @@
#include "titlewidget.h"
#include "core.h"
#include "bin/bin.h"
#include "doc/kthumb.h"
#include "gradientwidget.h"
#include "kdenlivesettings.h"
......@@ -49,6 +50,7 @@
#include <QTextCursor>
#include <QTimer>
#include <QToolBar>
#include <QMenu>
#include <QStandardPaths>
#include <iostream>
......@@ -549,7 +551,25 @@ TitleWidget::TitleWidget(const QUrl &url, const Timecode &tc, QString projectTit
connect(anim_end, &QAbstractButton::toggled, this, &TitleWidget::slotAnimEnd);
connect(templateBox, SIGNAL(currentIndexChanged(int)), this, SLOT(templateIndexChanged(int)));
buttonBox->button(QDialogButtonBox::Ok)->setEnabled(KdenliveSettings::hastitleproducer());
createButton->setEnabled(KdenliveSettings::hastitleproducer());
QMenu *addMenu = new QMenu(this);
addMenu->addAction(i18n("Save and add to project"));
m_createTitleAction = new QAction(i18n("Create Title"), this);
createButton->setMenu(addMenu);
connect(addMenu, &QMenu::triggered, [this]() {
const QUrl url = saveTitle();
if (!url.isEmpty()) {
pCore->bin()->slotAddClipToProject(url);
done(QDialog::Rejected);
}
});
createButton->setDefaultAction(m_createTitleAction);
connect(m_createTitleAction, &QAction::triggered, [this]() {
done(QDialog::Accepted);
});
connect(cancelButton, &QPushButton::clicked, [this]() {
done(QDialog::Rejected);
});
if (titletemplates.isEmpty()) {
refreshTitleTemplates(m_projectTitlePath);
}
......@@ -1979,7 +1999,7 @@ void TitleWidget::loadTitle(QUrl url)
}
}
void TitleWidget::saveTitle(QUrl url)
QUrl TitleWidget::saveTitle(QUrl url)
{
if (anim_start->isChecked()) {
slotAnimStart(false);
......@@ -2021,8 +2041,11 @@ void TitleWidget::saveTitle(QUrl url)
if (url.isValid()) {
if (!m_titledocument.saveDocument(url, m_startViewport, m_endViewport, m_tc.getFrameCount(title_duration->text()), embed_image)) {
KMessageBox::error(this, i18n("Cannot write to file %1", url.toLocalFile()));
} else {
return url;
}
}
return QUrl();
}
void TitleWidget::downloadTitleTemplates()
......@@ -2140,6 +2163,11 @@ void TitleWidget::setXml(const QDomDocument &doc, const QString &id)
endViewportX->setValue(m_endViewport->data(0).toInt());
endViewportY->setValue(m_endViewport->data(1).toInt());
endViewportSize->setValue(m_endViewport->data(2).toInt());*/
createButton->setMenu(nullptr);
createButton->setPopupMode(QToolButton::DelayedPopup);
m_createTitleAction->setText(i18n("Update Title"));
QTimer::singleShot(200, this, &TitleWidget::slotAdjustZoom);
slotSelectTool();
......
......@@ -148,6 +148,7 @@ private:
QAction *m_selectRects;
QAction *m_selectImages;
QAction *m_unselectAll;
QAction *m_createTitleAction;
QString m_lastDocumentHash;
QList<QGraphicsLineItem *> m_guides;
......@@ -243,8 +244,8 @@ public slots:
void itemRotateX(int);
void itemRotateY(int);
void itemRotateZ(int);
/** Save a title to a title file */
void saveTitle(QUrl url = QUrl());
/** Save a title to a title file, returns the saved url or empty if error */
QUrl saveTitle(QUrl url = QUrl());
/** Load a title from a title file */
void loadTitle(QUrl url = QUrl());
void slotGotBackground(const QImage &img);
......
......@@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>1666</width>
<height>1188</height>
<width>1096</width>
<height>726</height>
</rect>
</property>
<property name="windowTitle">
......@@ -351,14 +351,14 @@
<property name="flat">
<bool>false</bool>
</property>
<property name="color" stdset="0">
<property name="color">
<color>
<red>255</red>
<green>0</green>
<blue>0</blue>
</color>
</property>
<property name="defaultColor" stdset="0">
<property name="defaultColor">
<color>
<red>255</red>
<green>0</green>
......@@ -643,8 +643,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>544</width>
<height>506</height>
<width>344</width>
<height>433</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_9">
......@@ -821,14 +821,14 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="color" stdset="0">
<property name="color">
<color alpha="100">
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</property>
<property name="alphaChannelEnabled" stdset="0">
<property name="alphaChannelEnabled">
<bool>true</bool>
</property>
</widget>
......@@ -982,14 +982,14 @@
<property name="flat">
<bool>false</bool>
</property>
<property name="color" stdset="0">
<property name="color">
<color>
<red>255</red>
<green>255</green>
<blue>255</blue>
</color>
</property>
<property name="defaultColor" stdset="0">
<property name="defaultColor">
<color>
<red>0</red>
<green>0</green>
......@@ -1047,14 +1047,14 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="color" stdset="0">
<property name="color">
<color>
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</property>
<property name="defaultColor" stdset="0">
<property name="defaultColor">
<color>
<red>0</red>
<green>0</green>
......@@ -1112,14 +1112,14 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="color" stdset="0">
<property name="color">
<color>
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</property>
<property name="defaultColor" stdset="0">
<property name="defaultColor">
<color>
<red>0</red>
<green>0</green>
......@@ -1231,14 +1231,14 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="color" stdset="0">
<property name="color">
<color>
<red>0</red>
<green>0</green>
<blue>0</blue>
</color>
</property>
<property name="defaultColor" stdset="0">
<property name="defaultColor">
<color>
<red>0</red>
<green>0</green>
......@@ -1479,12 +1479,35 @@
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QToolButton" name="createButton">
<property name="text">
<string>Create</string>
</property>
<property name="popupMode">
<enum>QToolButton::MenuButtonPopup</enum>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextOnly</enum>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="cancelButton">
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
......@@ -1506,38 +1529,6 @@
</customwidgets>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>TitleWidget_UI</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>253</x>
<y>558</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>TitleWidget_UI</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>321</x>
<y>558</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>gradient_color</sender>
<signal>toggled(bool)</signal>
......
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