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

Show number of Bin clips / selected clip in status bar, fix rename / focus clip in icon view

parent faede6fb
Pipeline #126899 passed with stage
in 5 minutes and 31 seconds
......@@ -648,12 +648,12 @@ void MyListView::mouseMoveEvent(QMouseEvent *event)
}
m_lastHoveredItem = index;
}
pCore->window()->showKeyBinding(i18n("<b>Shift+seek</b> over thumbnail to set default thumbnail, <b>F2</b> to rename selected item"));
pCore->bin()->updateKeyBinding(i18n("<b>Shift+seek</b> over thumbnail to set default thumbnail, <b>F2</b> to rename selected item"));
} else {
pCore->window()->showKeyBinding(i18n("<b>F2</b> to rename selected item"));
pCore->bin()->updateKeyBinding(i18n("<b>F2</b> to rename selected item"));
}
} else {
pCore->window()->showKeyBinding();
pCore->bin()->updateKeyBinding();
if (m_lastHoveredItem.isValid()) {
emit displayBinFrame(m_lastHoveredItem, -1);
m_lastHoveredItem = QModelIndex();
......@@ -733,16 +733,16 @@ void MyTreeView::mouseMoveEvent(QMouseEvent *event)
m_lastHoveredItem = QModelIndex();
}
}
pCore->window()->showKeyBinding(i18n("<b>Shift+seek</b> over thumbnail to set default thumbnail, <b>F2</b> to rename selected item"));
pCore->bin()->updateKeyBinding(i18n("<b>Shift+seek</b> over thumbnail to set default thumbnail, <b>F2</b> to rename selected item"));
} else {
pCore->window()->showKeyBinding(i18n("<b>F2</b> to rename selected item"));
pCore->bin()->updateKeyBinding(i18n("<b>F2</b> to rename selected item"));
}
} else {
if (m_lastHoveredItem.isValid()) {
emit displayBinFrame(m_lastHoveredItem, -1);
m_lastHoveredItem = QModelIndex();
}
pCore->window()->showKeyBinding();
pCore->bin()->updateKeyBinding();
}
}
if (!dragged) {
......@@ -1386,6 +1386,8 @@ Bin::Bin(std::shared_ptr<ProjectItemModel> model, QWidget *parent, bool isMainBi
m_infoMessage->hide();
connect(this, &Bin::requesteInvalidRemoval, this, &Bin::slotQueryRemoval);
connect(pCore.get(), &Core::updatePalette, this, &Bin::slotUpdatePalette);
connect(m_itemModel.get(), &QAbstractItemModel::rowsInserted, this, &Bin::updateClipsCount);
connect(m_itemModel.get(), &QAbstractItemModel::rowsRemoved, this, &Bin::updateClipsCount);
connect(this, SIGNAL(displayBinMessage(QString,KMessageWidget::MessageType)), this, SLOT(doDisplayMessage(QString,KMessageWidget::MessageType)));
wheelAccumulatedDelta = 0;
}
......@@ -2080,9 +2082,9 @@ void Bin::slotAddFolder()
void Bin::ensureCurrent()
{
const QModelIndexList indexes = m_proxyModel->selectionModel()->selectedRows(0);
const QModelIndexList indexes = m_proxyModel->selectionModel()->selection().indexes();
for (const QModelIndex &ix : indexes) {
if (!ix.isValid()) {
if (!ix.isValid() || ix.column() != 0) {
continue;
}
m_itemView->setCurrentIndex(ix);
......@@ -2233,6 +2235,7 @@ void Bin::selectProxyModel(const QModelIndex &id)
// Display black bg in clip monitor
emit openClip(std::shared_ptr<ProjectClip>());
}
updateClipsCount();
}
std::vector<QString> Bin::selectedClipsIds(bool allowSubClips)
......@@ -4232,9 +4235,9 @@ void Bin::slotRenameItem()
}
return;
}
const QModelIndexList indexes = m_proxyModel->selectionModel()->selectedRows(0);
const QModelIndexList indexes = m_proxyModel->selectionModel()->selection().indexes();
for (const QModelIndex &ix : indexes) {
if (!ix.isValid()) {
if (!ix.isValid() || ix.column() != 0) {
continue;
}
m_itemView->setCurrentIndex(ix);
......@@ -4913,3 +4916,39 @@ bool Bin::addProjectClipInFolder(const QString &path, const QString &parentFolde
}
return ok;
}
void Bin::updateClipsCount()
{
int count = m_itemModel->clipsCount();
if (count < 2) {
m_clipsCountMessage = QString();
} else {
int selected = 0;
const QModelIndexList indexes = m_proxyModel->selectionModel()->selection().indexes();
for (const QModelIndex &ix : indexes) {
if (ix.isValid() && ix.column() == 0) {
std::shared_ptr<AbstractProjectItem> item = m_itemModel->getBinItemByIndex(m_proxyModel->mapToSource(ix));
if (item->itemType() == AbstractProjectItem::ClipItem) {
selected++;
}
}
}
if (selected == 0) {
m_clipsCountMessage = i18n("<b>%1</b> clips | ", count);
} else {
m_clipsCountMessage = i18n("<b>%1</b> clips (%2 selected) | ", count, selected);
}
}
showBinInfo();
}
void Bin::updateKeyBinding(const QString &bindingMessage)
{
m_keyBindingMessage = bindingMessage;
showBinInfo();
}
void Bin::showBinInfo()
{
pCore->window()->showKeyBinding(QString("%1%2").arg(m_clipsCountMessage, m_keyBindingMessage));
}
......@@ -341,6 +341,8 @@ public:
static void checkProfile(const std::shared_ptr<Mlt::Producer> &producer);
/** @brief Should we process a profile check for added clips */
std::atomic<bool> shouldCheckProfile;
/** @brief Set the message for key binding info. */
void updateKeyBinding(const QString &bindingMessage = QString());
private slots:
void slotAddClip();
......@@ -401,6 +403,8 @@ private slots:
*/
void editTags(const QList <QString> &allClips, const QString &tag, bool add);
void slotUpdatePalette();
/** @brief Update the string description of the clips count, like: 123 clips (3 selected). */
void updateClipsCount();
public slots:
void slotRemoveInvalidClip(const QString &id, bool replace, const QString &errorMessage);
......@@ -558,6 +562,10 @@ private:
void processAudioThumbs();
void updateSortingAction(int ix);
int wheelAccumulatedDelta;
QString m_keyBindingMessage;
QString m_clipsCountMessage;
/** @brief Show the clip count and key binfing info in status bar. */
void showBinInfo();
signals:
void itemUpdated(std::shared_ptr<AbstractProjectItem>);
......
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