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

Update text based edit, allow preview

parent 67c97f74
......@@ -1514,6 +1514,8 @@ void Bin::slotDeleteClip()
}
Fun undo = []() { return true; };
Fun redo = []() { return true; };
// Ensure we don't delete a parent before a child
// std::sort(items.begin(), items.end(), [](std::shared_ptr<AbstractProjectItem> a, std::shared_ptr<AbstractProjectItem>b) { return a->depth() > b->depth(); });
for (const auto &item : items) {
m_itemModel->requestBinClipDeletion(item, undo, redo);
}
......@@ -4416,3 +4418,29 @@ ClipWidget* Bin::getWidget(){
void Bin::dockWidgetInit(QDockWidget* m_DockClipWidget){
m_clipWidget->init(m_DockClipWidget);
}
void Bin::savePlaylist(const QString &binId, QString savePath, QVector<QPoint> zones, QMap<QString, QString> properties)
{
std::shared_ptr<ProjectClip> clip = m_itemModel->getClipByBinID(binId);
if (!clip) {
pCore->displayMessage(i18n("Could not find master clip"), MessageType::ErrorMessage, 300);
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);
while (i.hasNext()) {
i.next();
prod->set(i.key().toUtf8().constData(), i.value().toUtf8().constData());
}
for (auto &zone : zones) {
std::shared_ptr<Mlt::Producer> cut(prod->cut(zone.x(), zone.y()));
pl.append(*cut.get());
}
t.set_track(pl, 0);
Mlt::Consumer cons(pCore->getCurrentProfile()->profile(), "xml", savePath.toUtf8().constData());
cons.set("store", "kdenlive");
cons.connect(t);
cons.run();
}
......@@ -320,6 +320,8 @@ public:
// TODO refac: remove this and call directly the function in ProjectItemModel
void cleanupUnused();
void selectAll();
/** @brief Save an mlt playlist from a bin id and a list of cuts */
void savePlaylist(const QString &binId, QString savePath, QVector<QPoint> zones, QMap<QString, QString> properties);
private slots:
void slotAddClip();
......
This diff is collapsed.
......@@ -29,6 +29,8 @@
#include <QAction>
#include <QTextEdit>
#include <QMouseEvent>
#include <QTemporaryFile>
#include <QTimer>
/**
* @class VideoTextEdit: Video speech text editor
......@@ -100,13 +102,18 @@ protected:
{
codeEditor->blockClicked(e->modifiers());
QWidget::mousePressEvent(e);
}
void mouseDoubleClickEvent(QMouseEvent *e) override
{
codeEditor->blockClicked(e->modifiers(), true);
QWidget::mouseDoubleClickEvent(e);
}
void wheelEvent(QWheelEvent *e) override
{
qDebug()<<"==== WHEEL OVER LINEAREA";
e->ignore();
//QWidget::wheelEvent(e);
}
void leaveEvent(QEvent *e) override
{
codeEditor->checkHoverBlock(-1);
......@@ -142,6 +149,10 @@ private slots:
void updateAvailability();
/** @brief insert currently selected zones to timeline */
void insertToTimeline();
/** @brief Preview current edited text in the clip monitor */
void previewPlaylist();
/** @brief Display info message */
void showMessage(const QString &text, KMessageWidget::MessageType type);
protected:
bool eventFilter(QObject *obj, QEvent *event) override;
......@@ -156,6 +167,11 @@ private:
QAction *m_logAction;
VideoTextEdit *m_visualEditor;
QTextDocument m_document;
QTemporaryFile m_playlist;
QTimer m_hideTimer;
signals:
void previewClip(const QString &path, const QString &title);
};
#endif
......@@ -352,11 +352,18 @@ void MainWindow::init()
// Online resources widget
ResourceWidget *onlineResources = new ResourceWidget(this);
m_onlineResourcesDock = addDock(i18n("Online Resources"), QStringLiteral("onlineresources"), onlineResources);
connect(onlineResources, &ResourceWidget::previewClip, [&](const QString &path) {
m_clipMonitor->slotPreviewOnlineResource(path);
connect(onlineResources, &ResourceWidget::previewClip, [&](const QString &path, const QString &title) {
m_clipMonitor->slotPreviewResource(path, title);
m_clipMonitorDock->show();
m_clipMonitorDock->raise();
});
connect(pCore->textEditWidget(), &TextBasedEdit::previewClip, [&](const QString &path, const QString title) {
m_clipMonitor->slotPreviewResource(path, title);
m_clipMonitorDock->show();
m_clipMonitorDock->raise();
});
connect(onlineResources, &ResourceWidget::addClip, this, &MainWindow::slotAddProjectClip);
connect(onlineResources, &ResourceWidget::addLicenseInfo, this, &MainWindow::slotAddTextNote);
......
......@@ -1725,15 +1725,17 @@ void Monitor::slotOpenDvdFile(const QString &file)
// render->loadUrl(file);
}
void Monitor::slotPreviewOnlineResource(const QString &path)
void Monitor::slotPreviewResource(const QString &path, const QString &title)
{
warningMessage(i18n("It maybe takes a while until the preview is loaded"), 15000);
if (!QUrl::fromUserInput(path).isLocalFile()) {
warningMessage(i18n("It maybe takes a while until the preview is loaded"), 15000);
}
slotOpenClip(nullptr);
m_streamAction->setVisible(false);
m_glMonitor->setProducer(path);
m_glMonitor->producer();
m_timePos->setRange(0, m_glMonitor->producer()->get_length() - 1);
m_glMonitor->getControllerProxy()->setClipProperties(-1, ClipType::Unknown, false, i18n("Online Resources Preview"));
m_glMonitor->getControllerProxy()->setClipProperties(-1, ClipType::Unknown, false, title);
m_glMonitor->setRulerInfo(m_glMonitor->producer()->get_length() - 1);
loadQmlScene(MonitorSceneDefault);
checkOverlay();
......
......@@ -278,7 +278,7 @@ private slots:
public slots:
void slotSetScreen(int screenIndex);
void slotOpenDvdFile(const QString &);
void slotPreviewOnlineResource(const QString &path);
void slotPreviewResource(const QString &path, const QString &title);
// void slotSetClipProducer(DocClipBase *clip, QPoint zone = QPoint(), bool forceUpdate = false, int position = -1);
void updateClipProducer(const std::shared_ptr<Mlt::Producer> &prod);
void updateClipProducer(const QString &playlist);
......
......@@ -142,6 +142,9 @@ Item {
controller.seek(wheel.angleDelta.x + wheel.angleDelta.y, wheel.modifiers)
}
onEntered: {
// Show clip name
clipNameLabel.opacity = 1
showAnimate.restart()
controller.setWidgetKeyBinding(i18n("<b>Click</b> to play, <b>Double click</b> for fullscreen, <b>Hover right</b> for toolbar, <b>Wheel</b> or <b>arrows</b> to seek, <b>Ctrl wheel</b> to zoom"));
}
onExited: {
......
......@@ -480,7 +480,7 @@ void ResourceWidget::slotPreviewItem()
}
blockUI(true);
emit previewClip(m_currentItem->data(previewRole).toString());
emit previewClip(m_currentItem->data(previewRole).toString(), i18n("Online Resources Preview"));
blockUI(false);
}
......
......@@ -91,7 +91,7 @@ private:
signals:
void addClip(const QUrl &, const QString &);
void addLicenseInfo(const QString &);
void previewClip(const QString &path);
void previewClip(const QString &path, const QString &title);
};
#endif // REOURCEWIDGET_H
......@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>457</width>
<width>504</width>
<height>422</height>
</rect>
</property>
......@@ -155,21 +155,24 @@
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="1">
<widget class="QToolButton" name="button_insert">
<item row="0" column="10">
<widget class="QToolButton" name="vosk_config">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="0" column="5">
<widget class="QToolButton" name="button_down">
<item row="0" column="6">
<widget class="QToolButton" name="button_search">
<property name="text">
<string>...</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="8">
<item row="0" column="9">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
......@@ -182,39 +185,29 @@
</property>
</spacer>
</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>
</widget>
</item>
<item row="0" column="9">
<widget class="QToolButton" name="vosk_config">
<item row="0" column="1">
<widget class="QToolButton" name="button_insert">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="0" column="7">
<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="3">
<widget class="QToolButton" name="button_up">
<item row="0" column="5">
<widget class="QToolButton" name="button_delete">
<property name="text">
<string>...</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QToolButton" name="button_delete">
<item row="0" column="3">
<widget class="QToolButton" name="button_add">
<property name="text">
<string>...</string>
</property>
......
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