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

Allow closing secondary bin

parent 1e2d827b
......@@ -584,6 +584,7 @@ signals:
void deleteMarkers();
/** @brief Selected all markers in clip properties dialog. */
void selectMarkers();
void requestBinClose();
};
#endif
......@@ -129,26 +129,26 @@ void Core::initGUI(bool isAppImage, const QString &MltPath, const QUrl &Url, con
connect(this, &Core::showConfigDialog, m_mainWindow, &MainWindow::slotPreferences);
m_projectManager = new ProjectManager(this);
std::shared_ptr<Bin> bin(new Bin(m_projectItemModel, m_mainWindow));
Bin *bin = new Bin(m_projectItemModel, m_mainWindow);
m_mainWindow->addBin(bin);
connect(bin.get(), &Bin::requestShowClipProperties, bin.get(), &Bin::showClipProperties);
connect(m_projectItemModel.get(), &ProjectItemModel::refreshPanel, m_mainWindow->activeBin().get(), &Bin::refreshPanel);
connect(m_projectItemModel.get(), &ProjectItemModel::refreshClip, m_mainWindow->activeBin().get(), &Bin::refreshClip);
connect(m_projectItemModel.get(), static_cast<void (ProjectItemModel::*)(const QStringList &, const QModelIndex &)>(&ProjectItemModel::itemDropped), m_mainWindow->activeBin().get(),
connect(bin, &Bin::requestShowClipProperties, bin, &Bin::showClipProperties);
connect(m_projectItemModel.get(), &ProjectItemModel::refreshPanel, m_mainWindow->activeBin(), &Bin::refreshPanel);
connect(m_projectItemModel.get(), &ProjectItemModel::refreshClip, m_mainWindow->activeBin(), &Bin::refreshClip);
connect(m_projectItemModel.get(), static_cast<void (ProjectItemModel::*)(const QStringList &, const QModelIndex &)>(&ProjectItemModel::itemDropped), m_mainWindow->activeBin(),
static_cast<void (Bin::*)(const QStringList &, const QModelIndex &)>(&Bin::slotItemDropped));
connect(m_projectItemModel.get(), static_cast<void (ProjectItemModel::*)(const QList<QUrl> &, const QModelIndex &)>(&ProjectItemModel::itemDropped), m_mainWindow->activeBin().get(),
connect(m_projectItemModel.get(), static_cast<void (ProjectItemModel::*)(const QList<QUrl> &, const QModelIndex &)>(&ProjectItemModel::itemDropped), m_mainWindow->activeBin(),
static_cast<const QString (Bin::*)(const QList<QUrl> &, const QModelIndex &)>(&Bin::slotItemDropped));
connect(m_projectItemModel.get(), &ProjectItemModel::effectDropped, m_mainWindow->activeBin().get(), &Bin::slotEffectDropped);
connect(m_projectItemModel.get(), &ProjectItemModel::addTag, m_mainWindow->activeBin().get(), &Bin::slotTagDropped);
connect(m_projectItemModel.get(), &QAbstractItemModel::dataChanged, m_mainWindow->activeBin().get(), &Bin::slotItemEdited);
connect(m_projectItemModel.get(), &ProjectItemModel::effectDropped, m_mainWindow->activeBin(), &Bin::slotEffectDropped);
connect(m_projectItemModel.get(), &ProjectItemModel::addTag, m_mainWindow->activeBin(), &Bin::slotTagDropped);
connect(m_projectItemModel.get(), &QAbstractItemModel::dataChanged, m_mainWindow->activeBin(), &Bin::slotItemEdited);
m_library = new LibraryWidget(m_projectManager, m_mainWindow);
m_subtitleWidget = new SubtitleEdit(m_mainWindow);
m_mixerWidget = new MixerManager(m_mainWindow);
m_textEditWidget = new TextBasedEdit(m_mainWindow);
m_timeRemapWidget = new TimeRemap(m_mainWindow);
connect(m_library, SIGNAL(addProjectClips(QList<QUrl>)), m_mainWindow->getBin().get(), SLOT(droppedUrls(QList<QUrl>)));
connect(m_library, SIGNAL(addProjectClips(QList<QUrl>)), m_mainWindow->getBin(), SLOT(droppedUrls(QList<QUrl>)));
connect(this, &Core::updateLibraryPath, m_library, &LibraryWidget::slotUpdateLibraryPath);
connect(m_capture.get(), &MediaCapture::recordStateChanged, m_mixerWidget, &MixerManager::recordStateChanged);
connect(m_mixerWidget, &MixerManager::updateRecVolume, m_capture.get(), &MediaCapture::setAudioVolume);
......@@ -328,12 +328,12 @@ Monitor *Core::getMonitor(int id)
Bin *Core::bin()
{
return m_mainWindow->getBin().get();
return m_mainWindow->getBin();
}
Bin *Core::activeBin()
{
return m_mainWindow->activeBin().get();
return m_mainWindow->activeBin();
}
void Core::selectBinClip(const QString &clipId, bool activateMonitor, int frame, const QPoint &zone)
......@@ -1189,7 +1189,7 @@ int Core::getNewStuff(const QString &config)
void Core::addBin(const QString &id)
{
std::shared_ptr<Bin> bin(new Bin(m_projectItemModel, m_mainWindow, false));
Bin *bin = new Bin(m_projectItemModel, m_mainWindow, false);
bin->setupMenu();
bin->setMonitor(m_monitorManager->clipMonitor());
const QString folderName = bin->setDocument(pCore->currentDoc(), id);
......
......@@ -824,6 +824,7 @@ void MainWindow::init(const QString &mltPath)
getMainTimeline()->regainFocus();
}
});
connect(this, &MainWindow::removeBinDock, this, &MainWindow::slotRemoveBinDock);
// m_messageLabel->setMessage(QStringLiteral("This is a beta version. Always backup your data"), MltError);
}
......@@ -1719,7 +1720,7 @@ void MainWindow::setupActions()
// Keyframe actions
m_assetPanel = new AssetPanel(this);
connect(getBin().get(), &Bin::requestShowEffectStack, m_assetPanel, &AssetPanel::showEffectStack);
connect(getBin(), &Bin::requestShowEffectStack, m_assetPanel, &AssetPanel::showEffectStack);
KActionCategory *kfActions = new KActionCategory(i18n("Effect Keyframes"), actionCollection());
addAction(QStringLiteral("keyframe_add"), i18n("Add/Remove Keyframe"), m_assetPanel, SLOT(slotAddRemoveKeyframe()),
QIcon::fromTheme(QStringLiteral("keyframe-add")), QKeySequence(), kfActions);
......@@ -3342,7 +3343,7 @@ void MainWindow::slotClipInTimeline(const QString &clipId, const QList<int> &ids
void MainWindow::raiseBin()
{
std::shared_ptr<Bin> bin = activeBin();
Bin *bin = activeBin();
if (bin && !bin->isVisible()) {
bin->parentWidget()->setVisible(true);
bin->parentWidget()->raise();
......@@ -4550,20 +4551,43 @@ bool MainWindow::eventFilter(QObject *object, QEvent *event)
return QObject::eventFilter(object, event);
}
void MainWindow::addBin(std::shared_ptr<Bin> bin, const QString &binName)
void MainWindow::slotRemoveBinDock(const QString &name)
{
connect(bin.get(), &Bin::findInTimeline, this, &MainWindow::slotClipInTimeline, Qt::DirectConnection);
connect(bin.get(), &Bin::setupTargets, this, [&] (bool hasVideo, QMap <int, QString> audioStreams) {
QWidget *toDelete = nullptr;
Bin *prev = nullptr;
int ix = 0;
for (auto &b : m_binWidgets) {
if (b->parentWidget()->objectName() == name) {
toDelete = b->parentWidget();
prev = m_binWidgets.takeAt(ix);
break;
}
ix++;
}
if (toDelete) {
toDelete->deleteLater();
}
updateDockMenu();
loadDockActions();
}
void MainWindow::addBin(Bin *bin, const QString &binName)
{
connect(bin, &Bin::findInTimeline, this, &MainWindow::slotClipInTimeline, Qt::DirectConnection);
connect(bin, &Bin::setupTargets, this, [&] (bool hasVideo, QMap <int, QString> audioStreams) {
getCurrentTimeline()->controller()->setTargetTracks(hasVideo, audioStreams);
}
);
if (!m_binWidgets.isEmpty()) {
// This is a secondary bin widget
int ix = binCount() + 1;
QDockWidget *binDock = addDock(binName.isEmpty() ? i18n("Project Bin %1", ix) : binName, 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);
bin->setupGeneratorMenu();
connect(bin.get(), &Bin::requestShowEffectStack, m_assetPanel, &AssetPanel::showEffectStack);
connect(bin.get(), &Bin::requestShowClipProperties, getBin().get(), &Bin::showClipProperties);
connect(bin, &Bin::requestShowEffectStack, m_assetPanel, &AssetPanel::showEffectStack);
connect(bin, &Bin::requestShowClipProperties, getBin(), &Bin::showClipProperties);
connect(bin, &Bin::requestBinClose, this, [this, binDock]() {
emit removeBinDock(binDock->objectName());
});
tabifyDockWidget(m_projectBinDock, binDock);
// Disable title bar since it is tabbed
binDock->setTitleBarWidget(new QWidget);
......@@ -4576,7 +4600,7 @@ void MainWindow::addBin(std::shared_ptr<Bin> bin, const QString &binName)
m_binWidgets << bin;
}
std::shared_ptr<Bin> MainWindow::getBin()
Bin *MainWindow::getBin()
{
if (m_binWidgets.isEmpty()) {
return nullptr;
......@@ -4584,12 +4608,12 @@ std::shared_ptr<Bin> MainWindow::getBin()
return m_binWidgets.first();
}
std::shared_ptr<Bin> MainWindow::activeBin()
Bin *MainWindow::activeBin()
{
QWidget* wid = QApplication::focusWidget();
if (wid) {
for (auto &bin : m_binWidgets) {
if (bin.get() == wid || bin->isAncestorOf(wid)) {
if (bin == wid || bin->isAncestorOf(wid)) {
return bin;
}
}
......
......@@ -135,11 +135,11 @@ public:
/** @brief Raise (show) the project bin*/
void raiseBin();
/** @brief Add a bin widget*/
void addBin(std::shared_ptr<Bin> bin, const QString &binName = QString());
void addBin(Bin *bin, const QString &binName = QString());
/** @brief Get the main (first) bin*/
std::shared_ptr<Bin> getBin();
Bin *getBin();
/** @brief Get the active (focused) bin or first one if none is active*/
std::shared_ptr<Bin> activeBin();
Bin *activeBin();
int binCount() const;
/** @brief Hide subtitle track */
......@@ -214,7 +214,7 @@ private:
KSelectAction *m_compositeAction;
TimelineTabs *m_timelineTabs{nullptr};
QVector <std::shared_ptr<Bin> >m_binWidgets;
QVector <Bin*>m_binWidgets;
/** This list holds all the scopes used in Kdenlive, allowing to manage some global settings */
QList<QDockWidget *> m_gfxScopesList;
......@@ -555,6 +555,7 @@ private slots:
void slotSpeechRecognition();
/** @brief Copy debug information like lib versions, gpu mode state,... to clipboard */
void slotCopyDebugInfo();
void slotRemoveBinDock(const QString &name);
signals:
Q_SCRIPTABLE void abortRenderJob(const QString &url);
......@@ -573,6 +574,7 @@ signals:
/** @brief Enable or disable the undo stack. For example undo/redo should not be enabled when dragging a clip in timeline or we risk corruption. */
void enableUndo(bool enable);
bool focusTimeline(bool focus, bool highlight);
void removeBinDock(const QString &name);
};
#endif
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