Commit 8b8a947c authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle

Merge branch '2012'

parents 2806f145 4c86e2b5
Pipeline #40614 passed with stage
in 10 minutes and 17 seconds
......@@ -239,6 +239,11 @@ void SubtitleModel::parseSubtitle(const QString subPath)
//jsontoSubtitle(toJson());
}
const QString SubtitleModel::getUrl()
{
return m_subtitleFilter->get("av.filename");
}
GenTime SubtitleModel::stringtoTime(QString &str)
{
QStringList total,secs;
......
......@@ -101,6 +101,8 @@ public:
/** @brief Exports the subtitle model to json */
QString toJson();
/** @brief Returns the path to sub file */
const QString getUrl();
public slots:
/** @brief Function that parses through a subtitle file */
......
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
<kpartgui name="kdenlive" version="196" translationDomain="kdenlive">
<kpartgui name="kdenlive" version="197" translationDomain="kdenlive">
<MenuBar>
<Menu name="file" >
<Action name="file_save"/>
......@@ -31,6 +31,7 @@
<Action name="subtitle_tool" />
<Action name="add_subtitle" />
<Action name="import_subtitle" />
<Action name="export_subtitle" />
</Menu>
<Separator />
<Action name="bin_view_mode" />
......
......@@ -1707,7 +1707,8 @@ void MainWindow::setupActions()
addAction(QStringLiteral("delete_all_guides"), i18n("Delete All Guides"), this, SLOT(slotDeleteAllGuides()),
QIcon::fromTheme(QStringLiteral("edit-delete")));
addAction(QStringLiteral("add_subtitle"), i18n("Add Subtitle"), this, SLOT(slotAddSubtitle()), QIcon::fromTheme(QStringLiteral("list-add")), Qt::SHIFT +Qt::Key_S);
addAction(QStringLiteral("import_subtitle"), i18n("Import Subtitle File"), this, SLOT(slotImportSubtitle()), QIcon::fromTheme(QStringLiteral("list-add")));
addAction(QStringLiteral("import_subtitle"), i18n("Import Subtitle File"), this, SLOT(slotImportSubtitle()), QIcon::fromTheme(QStringLiteral("document-import")));
addAction(QStringLiteral("export_subtitle"), i18n("Export Subtitle File"), this, SLOT(slotExportSubtitle()), QIcon::fromTheme(QStringLiteral("document-export")));
addAction(QStringLiteral("delete_subtitle_clip"), i18n("Delete Subtitle"), this, SLOT(slotDeleteItem()), QIcon::fromTheme(QStringLiteral("edit-delete")));
m_saveAction = KStandardAction::save(pCore->projectManager(), SLOT(saveFile()), actionCollection());
......@@ -4211,6 +4212,15 @@ void MainWindow::slotImportSubtitle()
getCurrentTimeline()->controller()->importSubtitle();
}
void MainWindow::slotExportSubtitle()
{
if (pCore->currentDoc()->getSubtitleModel() == nullptr) {
pCore->displayMessage(i18n("No subtitles in current project"), InformationMessage);
return;
}
getCurrentTimeline()->controller()->exportSubtitle();
}
#ifdef DEBUG_MAINW
#undef DEBUG_MAINW
#endif
......@@ -516,6 +516,8 @@ private slots:
void slotAddSubtitle();
/** @brief Import a subtitle file */
void slotImportSubtitle();
/** @brief Export a subtitle file */
void slotExportSubtitle();
signals:
Q_SCRIPTABLE void abortRenderJob(const QString &url);
......
......@@ -53,6 +53,7 @@
#include "ui_import_subtitle_ui.h"
#include <KColorScheme>
#include <KUrlRequesterDialog>
#include <KRecentDirs>
#include <QApplication>
#include <QClipboard>
......@@ -3869,6 +3870,26 @@ void TimelineController::importSubtitle()
}
}
void TimelineController::exportSubtitle()
{
auto subtitleModel = pCore->projectManager()->current()->getSubtitleModel();
if (subtitleModel == nullptr) {
return;
}
QString currentSub = subtitleModel->getUrl();
if (currentSub.isEmpty()) {
pCore->displayMessage(i18n("No subtitles in current project"), InformationMessage);
return;
}
const QString url =
QFileDialog::getSaveFileName(qApp->activeWindow(), i18n("Export subtitle file"), QFileInfo(currentSub).absolutePath(), i18n("Subtitle File (*.srt)"));
if (url.isEmpty()) {
return;
}
QFile src(currentSub);
src.copy(url);
}
void TimelineController::deleteSubtitle(int startframe, int endframe, QString text)
{
auto subtitleModel = pCore->projectManager()->current()->getSubtitleModel();
......
......@@ -584,6 +584,8 @@ public:
Q_INVOKABLE void deleteSubtitle(int frameframe, int endframe, QString Ctext);
/** @brief Import a subtitle file*/
void importSubtitle();
/** @brief Export a subtitle file*/
void exportSubtitle();
public slots:
void resetView();
......
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