Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Always select first clip added to bin

parent f3c74051
......@@ -197,6 +197,11 @@ void AbstractTreeModel::deregisterItem(int id, TreeItem *item)
m_allItems.erase(id);
}
int AbstractTreeModel::clipsCount() const
{
return m_allItems.size();
}
std::shared_ptr<TreeItem> AbstractTreeModel::getItemById(int id) const
{
if (id == rootItem->getId()) {
......
......@@ -78,6 +78,9 @@ public:
/* @brief Helper function to generate a lambda that changes the row of an item */
Fun moveItem_lambda(int id, int destRow);
/* @brief Returns the number of clips in bin */
int clipsCount() const;
friend class TreeItem;
friend class AbstractProjectItem;
......
......@@ -233,6 +233,11 @@ Bin *Core::bin()
return m_binWidget;
}
void Core::selectBinClip(const QString &clipId, int frame, const QPoint &zone)
{
m_binWidget->selectClipById(clipId, frame, zone);
}
std::shared_ptr<JobManager> Core::jobManager()
{
return m_jobManager;
......
......@@ -91,6 +91,8 @@ public:
std::shared_ptr<BinController> binController();
/** @brief Returns a pointer to the view of the project bin. */
Bin *bin();
/** @brief Select a clip in the Bin from its id. */
void selectBinClip(const QString &id, int frame = -1, const QPoint &zone = QPoint());
/** @brief Returns a pointer to the model of the project bin. */
std::shared_ptr<ProjectItemModel> projectItemModel();
/** @brief Returns a pointer to the job manager. Please do not store it. */
......
......@@ -531,6 +531,10 @@ bool LoadJob::commitResult(Fun &undo, Fun &redo)
};
bool ok = operation();
if (ok) {
if (pCore->projectItemModel()->clipsCount() == 2) {
// Always select first added clip
pCore->selectBinClip(m_clipId);
}
UPDATE_UNDO_REDO_NOLOCK(operation, reverse, undo, redo);
}
return ok;
......
......@@ -1901,7 +1901,7 @@ void MainWindow::addTimelineClip(const QString &url)
if (pCore->currentDoc()) {
QStringList ids = pCore->binController()->getBinIdsByResource(QFileInfo(url));
if (!ids.isEmpty()) {
pCore->bin()->selectClipById(ids.constFirst());
pCore->selectBinClip(ids.constFirst());
slotInsertClipInsert();
}
}
......@@ -2942,7 +2942,7 @@ void MainWindow::slotClipInProjectTree()
if (m_projectMonitor->isActive()) {
slotSwitchMonitors();
}
pCore->bin()->selectClipById(getMainTimeline()->controller()->getClipBinId(ids.constFirst()), -1, zone);
pCore->selectBinClip(getMainTimeline()->controller()->getClipBinId(ids.constFirst()), -1, zone);
}
}
......
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