Don't store current variables (doc, itemmodel) in media browser, add clip to...

Don't store current variables (doc, itemmodel) in media browser, add clip to project on double click
Related to #768
parent 984f452f
Pipeline #46587 passed with stage
in 10 minutes and 36 seconds
......@@ -824,14 +824,9 @@ bool LineEventEater::eventFilter(QObject *obj, QEvent *event)
return QObject::eventFilter(obj, event);
}
void ClipWidget::init(QDockWidget* m_DockClipWidget, KdenliveDoc* doc,
std::shared_ptr<ProjectItemModel> model)
void ClipWidget::init(QDockWidget* m_DockClipWidget)
{
ClipCreationDialog::clipWidget(m_DockClipWidget, doc, model);
/*QString clipFolder = KRecentDirs::dir(QStringLiteral(":KdenliveClipFolder"));
KFileWidget* fileWidget = new KFileWidget(QUrl::fromLocalFile(clipFolder), m_DockClipWidget);
fileWidget->setMode(KFile::Files);
m_DockClipWidget->setWidget(fileWidget);*/
ClipCreationDialog::clipWidget(m_DockClipWidget);
}
Bin::Bin(std::shared_ptr<ProjectItemModel> model, QWidget *parent)
......@@ -4385,5 +4380,5 @@ ClipWidget* Bin::getWidget(){
}
void Bin::dockWidgetInit(QDockWidget* m_DockClipWidget){
m_clipWidget->init(m_DockClipWidget, m_doc, m_itemModel);
m_clipWidget->init(m_DockClipWidget);
}
......@@ -172,8 +172,7 @@ class ClipWidget : public QWidget
public:
explicit ClipWidget(){}
~ClipWidget() override;
void init(QDockWidget* m_DockClipWidget, KdenliveDoc* doc,
std::shared_ptr<ProjectItemModel> model );
void init(QDockWidget* m_DockClipWidget);
};
class Bin : public QWidget
......
......@@ -45,6 +45,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <KMessageBox>
#include <KRecentDirs>
#include <KWindowConfig>
#include <KDirOperator>
#include <QDialog>
#include <QDir>
......@@ -56,6 +57,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <QWindow>
#include <unordered_map>
#include <utility>
// static
QStringList ClipCreationDialog::getExtensions()
{
......@@ -450,8 +452,7 @@ void ClipCreationDialog::createClipsCommand(KdenliveDoc *doc, const QString &par
}
}
void ClipCreationDialog::clipWidget(QDockWidget* m_DockClipWidget,
KdenliveDoc* doc, const std::shared_ptr<ProjectItemModel> model)
void ClipCreationDialog::clipWidget(QDockWidget* m_DockClipWidget)
{
QString clipFolder = KRecentDirs::dir(QStringLiteral(":KdenliveClipFolder"));
KFileWidget* fileWidget = new KFileWidget(QUrl::fromLocalFile(clipFolder), m_DockClipWidget);
......@@ -459,11 +460,18 @@ void ClipCreationDialog::clipWidget(QDockWidget* m_DockClipWidget,
QPushButton* importseq = new QPushButton(i18n("Import image sequence"));
fileWidget->setCustomWidget(importseq);
QObject::connect(fileWidget, &KFileWidget::accepted, fileWidget, [=] {
KFileItemList files = fileWidget->dirOperator()->selectedItems();
QList <QUrl> urls;
for (auto &f : files) {
urls << f.url();
}
pCore->bin()->droppedUrls(urls);
});
QObject::connect(importseq, &QPushButton::clicked, fileWidget, &KFileWidget::slotOk);
QObject::connect(importseq, &QPushButton::clicked, fileWidget, &KFileWidget::accepted);
QObject::connect(importseq, &QPushButton::clicked, fileWidget, &KFileWidget::accept);
QObject::connect(importseq, &QPushButton::clicked, fileWidget, [=, &doc]{
QObject::connect(importseq, &QPushButton::clicked, fileWidget, [=]{
QUrl url;
url = fileWidget->selectedUrl();
QStringList patternlist;
......@@ -476,6 +484,7 @@ void ClipCreationDialog::clipWidget(QDockWidget* m_DockClipWidget,
fileName.chop(1);
}
QString parentFolder = "-1";
KdenliveDoc *doc = pCore->currentDoc();
QString duration = doc->timecode().reformatSeparators(KdenliveSettings::sequence_duration());
std::unordered_map<QString, QString> properties;
properties[QStringLiteral("ttl")] = QString::number(doc->getFramePos(duration));
......@@ -485,7 +494,7 @@ void ClipCreationDialog::clipWidget(QDockWidget* m_DockClipWidget,
properties[QStringLiteral("luma_duration")] =
QString::number(doc->getFramePos(doc->timecode().getTimecodeFromFrames(int(ceil(doc->timecode().fps())))));
int frame_duration = doc->getFramePos(duration) * count;
ClipCreator::createSlideshowClip(pattern, frame_duration, fileName, parentFolder, properties, model);
ClipCreator::createSlideshowClip(pattern, frame_duration, fileName, parentFolder, properties, pCore->projectItemModel());
return;
}
......
......@@ -46,7 +46,7 @@ void createSlideshowClip(KdenliveDoc *doc, const QString &parentId, std::shared_
void createTitleClip(KdenliveDoc *doc, const QString &parentFolder, const QString &templatePath, std::shared_ptr<ProjectItemModel> model);
void createTitleTemplateClip(KdenliveDoc *doc, const QString &parentFolder, std::shared_ptr<ProjectItemModel> model);
void createClipsCommand(KdenliveDoc *doc, const QString &parentFolder, const std::shared_ptr<ProjectItemModel> &model);
void clipWidget(QDockWidget* m_DockClipWidget, KdenliveDoc* doc, const std::shared_ptr<ProjectItemModel> model);
void clipWidget(QDockWidget* m_DockClipWidget);
} // namespace ClipCreationDialog
#endif
......@@ -339,15 +339,21 @@ void MainWindow::init()
connect(spectrumDock, &QDockWidget::visibilityChanged, this, [&](bool visible) {
m_audioSpectrum->dockVisible(visible);
});
// Close library and audiospectrum on first run
// Project bin
m_projectBinDock = addDock(i18n("Project Bin"), QStringLiteral("project_bin"), pCore->bin());
// Media browser widget
QDockWidget* clipDockWidget = addDock(i18n("Media Browser"), QStringLiteral("bin_clip"), pCore->bin()->getWidget());
pCore->bin()->dockWidgetInit(clipDockWidget);
// Close library and audiospectrum and others on first run
screenGrabDock->close();
libraryDock->close();
subtitlesDock->close();
spectrumDock->close();
clipDockWidget->close();
m_projectBinDock = addDock(i18n("Project Bin"), QStringLiteral("project_bin"), pCore->bin());
QDockWidget* m_ClipDockWidget = addDock(i18n("Media Browser"), QStringLiteral("bin_clip"), pCore->bin()->getWidget());
pCore->bin()->dockWidgetInit(m_ClipDockWidget);
m_assetPanel = new AssetPanel(this);
m_effectStackDock = addDock(i18n("Effect/Composition Stack"), QStringLiteral("effect_stack"), m_assetPanel);
connect(m_assetPanel, &AssetPanel::doSplitEffect, m_projectMonitor, &Monitor::slotSwitchCompare);
......
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