Commit 92c63e83 authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Text edit: add bookmarks, save analysed speech in bin clip, various fixes

parent 9a20bbcc
......@@ -56,6 +56,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "xml/xml.hpp"
#include <utils/thumbnailcache.hpp>
#include <profiles/profilemodel.hpp>
#include <dialogs/textbasededit.h>
#include <KColorScheme>
#include <KRatingPainter>
......@@ -1713,6 +1714,7 @@ void Bin::setMonitor(Monitor *monitor)
connect(m_monitor, &Monitor::refreshCurrentClip, this, &Bin::slotOpenCurrent);
connect(this, &Bin::openClip, [&](std::shared_ptr<ProjectClip> clip, int in, int out) {
m_monitor->slotOpenClip(clip, in, out);
pCore->textEditWidget()->openClip(clip);
});
}
......@@ -4337,7 +4339,7 @@ void Bin::checkProjectAudioTracks(QString clipId, int minimumTracksCount)
}
}
void Bin::addClipMarker(const QString binId, QList<int> positions)
void Bin::addClipMarker(const QString binId, QList<int> positions, QStringList comments)
{
std::shared_ptr<ProjectClip> clip = getBinClip(binId);
if (!clip) {
......@@ -4345,9 +4347,15 @@ void Bin::addClipMarker(const QString binId, QList<int> positions)
return;
}
QMap <GenTime, QString> markers;
int ix = 0;
for (int pos : positions) {
GenTime p(pos, pCore->getCurrentFps());
markers.insert(p, pCore->currentDoc()->timecode().getDisplayTimecode(p, false));
if (comments.size() == positions.size()) {
markers.insert(p, comments.at(ix));
} else {
markers.insert(p, pCore->currentDoc()->timecode().getDisplayTimecode(p, false));
}
ix++;
}
clip->getMarkerModel()->addMarkers(markers, KdenliveSettings::default_marker_type());
}
......@@ -4435,13 +4443,19 @@ void Bin::savePlaylist(const QString &binId, QString savePath, QVector<QPoint> z
return;
}
Mlt::Tractor t(pCore->getCurrentProfile()->profile());
Mlt::Playlist pl(pCore->getCurrentProfile()->profile());
std::shared_ptr<Mlt::Producer> prod(new Mlt::Producer(clip->originalProducer().get()));
QMapIterator<QString, QString> i(properties);
Mlt::Playlist main(pCore->getCurrentProfile()->profile());
main.set("id", "main_bin");
main.set("xml_retain", 1);
// Here we could store some kdenlive settings in the main playlist
/*QMapIterator<QString, QString> i(properties);
while (i.hasNext()) {
i.next();
prod->set(i.key().toUtf8().constData(), i.value().toUtf8().constData());
}
main.set(i.key().toUtf8().constData(), i.value().toUtf8().constData());
}*/
main.append(*prod.get());
t.set("xml_retain main_bin", main.get_service(), 0);
Mlt::Playlist pl(pCore->getCurrentProfile()->profile());
for (auto &zone : zones) {
std::shared_ptr<Mlt::Producer> cut(prod->cut(zone.x(), zone.y()));
pl.append(*cut.get());
......@@ -4453,6 +4467,13 @@ void Bin::savePlaylist(const QString &binId, QString savePath, QVector<QPoint> z
cons.run();
if (createNew) {
const QString id = slotAddClipToProject(QUrl::fromLocalFile(savePath));
// Set properties directly on the clip
std::shared_ptr<ProjectClip> playlistClip = m_itemModel->getClipByBinID(id);
QMapIterator<QString, QString> i(properties);
while (i.hasNext()) {
i.next();
playlistClip->setProducerProperty(i.key(), i.value());
}
selectClipById(id);
}
}
......@@ -225,8 +225,8 @@ public:
/** @brief Returns the state of a given clip: AudioOnly, VideoOnly, Disabled (Disabled means it has audio and video capabilities */
PlaylistState::ClipState getClipState(int itemId) const;
/** @brief Add markers on clip @param binId at @param positions */
void addClipMarker(const QString binId, QList<int> positions);
/** @brief Add markers on clip @param binId at @param positions with @comments text if given */
void addClipMarker(const QString binId, QList<int> positions, QStringList comments = {});
/** @brief Returns a list of selected clip ids.
* @param allowSubClips: if true, will include subclip ids in the form: "master clip id/in/out"
......
This diff is collapsed.
......@@ -31,6 +31,8 @@
#include <QMouseEvent>
#include <QTimer>
class ProjectClip;
/**
* @class VideoTextEdit: Video speech text editor
* @brief A dialog for editing markers and guides.
......@@ -47,14 +49,30 @@ public:
int lineNumberAreaWidth();
void repaintLines();
void cleanup();
/** @brief returns the link for the first word at position start in the text.
* This will seek forwards until a word is found in case selection starts with a space
* @param cursor the current text cursor
* @param start the first position of the selection
* @param max the last position to check in seek operation*/
const QString selectionStartAnchor(QTextCursor &cursor, int start, int max);
/** @brief returns the link for the last word at position end in the text.
* This will seek backwards until a word is found in case selection ends with a space
* @param cursor the current text cursor
* @param end the last position of the selection
* @param min the first position to check in seek operation*/
const QString selectionEndAnchor(QTextCursor &cursor, int end, int min);
void checkHoverBlock(int yPos);
void blockClicked(Qt::KeyboardModifiers modifiers, bool play = false);
QVector<QPoint> processedZones(QVector<QPoint> sourceZones);
QVector<QPoint> getInsertZones();
/** @brief Remove all text outside loadZones
*/
void processCutZones(QList <QPoint> loadZones);
void rebuildZones();
QVector< QPair<double, double> > speechZones;
double clipOffset;
QVector <QPoint> cutZones;
QAction *bookmarkAction;
QAction *deleteAction;
protected:
void mouseMoveEvent(QMouseEvent *e) override;
......@@ -62,6 +80,7 @@ protected:
void mouseReleaseEvent(QMouseEvent *e) override;
void keyPressEvent(QKeyEvent *e) override;
void resizeEvent(QResizeEvent *e) override;
void contextMenuEvent(QContextMenuEvent *event) override;
private slots:
void updateLineNumberArea(const QRect &rect, int dy);
......@@ -135,6 +154,7 @@ class TextBasedEdit : public QWidget, public Ui::TextBasedEdit_UI
public:
explicit TextBasedEdit(QWidget *parent = nullptr);
void openClip(std::shared_ptr<ProjectClip>);
public slots:
void deleteItem();
......@@ -152,13 +172,17 @@ private slots:
void previewPlaylist(bool createNew = true);
/** @brief Display info message */
void showMessage(const QString &text, KMessageWidget::MessageType type);
void addBookmark();
protected:
bool eventFilter(QObject *obj, QEvent *event) override;
private:
std::unique_ptr<QProcess> m_speechJob;
/** @brief Id of the master bin clip on which speech processing is done */
QString m_binId;
/** @brief Id of the playlist which is processed from the master clip */
QString m_refId;
QString m_sourceUrl;
double m_clipDuration;
int m_lastPosition;
......@@ -168,6 +192,7 @@ private:
QTextDocument m_document;
QString m_playlist;
QTimer m_hideTimer;
double m_clipOffset;
};
#endif
......@@ -6,28 +6,122 @@
<rect>
<x>0</x>
<y>0</y>
<width>504</width>
<width>411</width>
<height>422</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QFrame" name="text_frame">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item row="2" column="0">
<widget class="KMessageWidget" name="info_message"/>
</item>
<item row="4" column="0">
<widget class="QFrame" name="edit_frame">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="10">
<widget class="QToolButton" name="vosk_config">
<property name="text">
<string>...</string>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="6">
<widget class="QToolButton" name="button_search">
<property name="text">
<string>...</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="9">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>244</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="1">
<widget class="QToolButton" name="button_insert">
<property name="text">
<string>...</string>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="8">
<widget class="QCheckBox" name="speech_zone">
<property name="text">
<string>Selected zone only</string>
</property>
</widget>
</item>
<item row="0" column="5">
<widget class="QToolButton" name="button_delete">
<property name="text">
<string>...</string>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QToolButton" name="button_add">
<property name="text">
<string>...</string>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="4">
<widget class="QToolButton" name="button_bookmark">
<property name="text">
<string>...</string>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="4" column="0">
<item row="5" column="0">
<widget class="QFrame" name="search_frame">
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
......@@ -63,48 +157,23 @@
</layout>
</widget>
</item>
<item row="2" column="0">
<widget class="QFrame" name="frame_progress">
<item row="1" column="0">
<widget class="QFrame" name="text_frame">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Plain</enum>
<enum>QFrame::Raised</enum>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="leftMargin">
<number>0</number>
</property>
<property name="topMargin">
<number>0</number>
</property>
<property name="rightMargin">
<number>0</number>
</property>
<property name="bottomMargin">
<number>0</number>
</property>
<item>
<widget class="QToolButton" name="button_abort">
<property name="text">
<string>...</string>
</property>
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QProgressBar" name="speech_progress">
<property name="value">
<number>24</number>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="5" column="0">
<item row="6" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QComboBox" name="language_box"/>
......@@ -131,18 +200,15 @@
</item>
</layout>
</item>
<item row="1" column="0">
<widget class="KMessageWidget" name="info_message"/>
</item>
<item row="3" column="0">
<widget class="QFrame" name="edit_frame">
<widget class="QFrame" name="frame_progress">
<property name="frameShape">
<enum>QFrame::NoFrame</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
<enum>QFrame::Plain</enum>
</property>
<layout class="QGridLayout" name="gridLayout">
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="leftMargin">
<number>0</number>
</property>
......@@ -155,67 +221,33 @@
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="10">
<widget class="QToolButton" name="vosk_config">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="0" column="6">
<widget class="QToolButton" name="button_search">
<item>
<widget class="QToolButton" name="button_abort">
<property name="text">
<string>...</string>
</property>
<property name="checkable">
<property name="autoRaise">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="9">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>244</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="1">
<widget class="QToolButton" name="button_insert">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="0" column="8">
<widget class="QCheckBox" name="speech_zone">
<property name="text">
<string>Selected zone only</string>
</property>
</widget>
</item>
<item row="0" column="5">
<widget class="QToolButton" name="button_delete">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="0" column="3">
<widget class="QToolButton" name="button_add">
<property name="text">
<string>...</string>
<item>
<widget class="QProgressBar" name="speech_progress">
<property name="value">
<number>24</number>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="clipNameLabel">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</widget>
<customwidgets>
......
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