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

Multiple bins: put folder name as widget title, enable up button and double...

Multiple bins: put folder name as widget title, enable up button and double click to enter folder in secondary bins
parent 0c3df81f
......@@ -1775,9 +1775,10 @@ void Bin::cleanDocument()
m_itemView = nullptr;
}
void Bin::setDocument(KdenliveDoc *project, const QString &id)
const QString Bin::setDocument(KdenliveDoc *project, const QString &id)
{
m_doc = project;
QString folderName;
if (m_isMainBin) {
m_infoLabel->slotSetJobCount(0);
}
......@@ -1808,15 +1809,19 @@ void Bin::setDocument(KdenliveDoc *project, const QString &id)
m_itemModel->setBinEffectsEnabled(!binEffectsDisabled);
if (!id.isEmpty()) {
// Open view in a specific folder
std::shared_ptr<AbstractProjectItem> clip = m_itemModel->getItemByBinId(id);
auto parentIx = m_itemModel->getIndexFromItem(clip);
std::shared_ptr<AbstractProjectItem> item = m_itemModel->getItemByBinId(id);
auto parentIx = m_itemModel->getIndexFromItem(item);
m_itemView->setRootIndex(m_proxyModel->mapFromSource(parentIx));
folderName = item->name();
m_upAction->setEnabled(true);
m_upAction->setVisible(true);
}
//setBinEffectsEnabled(!binEffectsDisabled, false);
QMap <QString, QString> projectTags = m_doc->getProjectTags();
m_tagsWidget->rebuildTags(projectTags);
rebuildFilters(projectTags);
return folderName;
}
void Bin::rebuildFilters(QMap <QString, QString> tags)
......@@ -2545,10 +2550,19 @@ void Bin::slotItemDoubleClicked(const QModelIndex &ix, const QPoint &pos, uint m
if (m_listType == BinIconView) {
if (item->childCount() > 0 || item->itemType() == AbstractProjectItem::FolderItem) {
m_itemView->setRootIndex(ix);
parentWidget()->setWindowTitle(item->name());
m_upAction->setEnabled(true);
return;
}
}
else {
if (!m_isMainBin && item->itemType() == AbstractProjectItem::FolderItem) {
// Double click a folder in secondary bin will set it as bin root
m_itemView->setRootIndex(ix);
parentWidget()->setWindowTitle(item->name());
m_upAction->setEnabled(true);
return;
}
} else {
if (ix.column() == 0 && item->childCount() > 0) {
QRect IconRect = m_itemView->visualRect(ix);
IconRect.setWidth(int(double(IconRect.height()) / m_itemView->iconSize().height() * m_itemView->iconSize().width()));
......@@ -4478,10 +4492,12 @@ void Bin::slotBack()
QModelIndex parentId = getIndexForId(parentItem->clipId(), parentItem->itemType() == AbstractProjectItem::FolderItem);
if (parentId.isValid()) {
m_itemView->setRootIndex(m_proxyModel->mapFromSource(parentId));
parentWidget()->setWindowTitle(parentItem->name());
}
} else {
m_itemView->setRootIndex(QModelIndex());
m_upAction->setEnabled(false);
parentWidget()->setWindowTitle(i18n("Project Bin"));
}
}
......
......@@ -202,7 +202,7 @@ public:
bool isLoading;
void dockWidgetInit(QDockWidget* m_DockClipWidget);
/** @brief Sets the document for the bin and initialize some stuff */
void setDocument(KdenliveDoc *project, const QString &id = QString());
const QString setDocument(KdenliveDoc *project, const QString &id = QString());
/** @brief Delete all project related data, to be called before setDocument */
void cleanDocument();
......
......@@ -1192,6 +1192,6 @@ void Core::addBin(const QString &id)
std::shared_ptr<Bin> bin(new Bin(m_projectItemModel, m_mainWindow, false));
bin->setupMenu();
bin->setMonitor(m_monitorManager->clipMonitor());
bin->setDocument(pCore->currentDoc(), id);
m_mainWindow->addBin(bin);
const QString folderName = bin->setDocument(pCore->currentDoc(), id);
m_mainWindow->addBin(bin, folderName);
}
......@@ -4548,7 +4548,7 @@ bool MainWindow::eventFilter(QObject *object, QEvent *event)
return QObject::eventFilter(object, event);
}
void MainWindow::addBin(std::shared_ptr<Bin> bin)
void MainWindow::addBin(std::shared_ptr<Bin> bin, const QString &binName)
{
connect(bin.get(), &Bin::findInTimeline, this, &MainWindow::slotClipInTimeline, Qt::DirectConnection);
connect(bin.get(), &Bin::setupTargets, this, [&] (bool hasVideo, QMap <int, QString> audioStreams) {
......@@ -4558,7 +4558,7 @@ void MainWindow::addBin(std::shared_ptr<Bin> bin)
if (!m_binWidgets.isEmpty()) {
// This is a secondary bin widget
int ix = binCount() + 1;
QDockWidget *binDock = addDock(i18n("Project Bin %1", ix), QString("project_bin_%1").arg(ix), bin.get());
QDockWidget *binDock = addDock(binName.isEmpty() ? i18n("Project Bin %1", ix) : binName, QString("project_bin_%1").arg(ix), bin.get());
bin->setupGeneratorMenu();
connect(bin.get(), &Bin::requestShowEffectStack, m_assetPanel, &AssetPanel::showEffectStack);
connect(bin.get(), &Bin::requestShowClipProperties, getBin().get(), &Bin::showClipProperties);
......
......@@ -135,7 +135,7 @@ public:
/** @brief Raise (show) the project bin*/
void raiseBin();
/** @brief Add a bin widget*/
void addBin(std::shared_ptr<Bin> bin);
void addBin(std::shared_ptr<Bin> bin, const QString &binName = QString());
/** @brief Get the main (first) bin*/
std::shared_ptr<Bin> getBin();
/** @brief Get the active (focused) bin or first one if none is active*/
......
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