Add shortcut to collapse/expand current effect or track

Default shortcut set as '<'
CCBUG: 416680
parent 9cf41f26
Pipeline #13762 passed with stage
in 20 minutes and 16 seconds
......@@ -398,6 +398,13 @@ void AssetPanel::deleteCurrentEffect()
}
}
void AssetPanel::collapseCurrentEffect()
{
if (m_effectStackWidget->isVisible()) {
m_effectStackWidget->switchCollapsed();
}
}
void AssetPanel::slotCheckWheelEventFilter()
{
// If the effect stack widget has no scrollbar, we will not filter the
......
......@@ -74,6 +74,8 @@ public slots:
void clearAssetPanel(int itemId);
void assetPanelWarning(const QString service, const QString id, const QString message);
void deleteCurrentEffect();
/** @brief Collapse/expand current effect */
void collapseCurrentEffect();
void slotCheckWheelEventFilter();
protected:
......
......@@ -497,6 +497,13 @@ void CollapsibleEffectView::updateHeight()
emit switchHeight(m_model, height());
}
void CollapsibleEffectView::switchCollapsed(int row)
{
if (row == m_model->row()) {
slotSwitch(!m_model->isCollapsed());
}
}
void CollapsibleEffectView::slotSwitch(bool collapse)
{
widgetFrame->setFixedHeight(collapse ? 0 : m_view->height());
......
......@@ -92,6 +92,8 @@ public slots:
void updateHeight();
/** @brief Should we block wheel event (if parent is a view with scrollbar) */
void blockWheenEvent(bool block);
/** @brief Switch between collapsed/expanded state */
void switchCollapsed(int row);
private slots:
void setWidgetHeight(qreal value);
......
......@@ -238,6 +238,7 @@ void EffectStackView::loadEffects()
emit seekToPos(pos + clipIn);
});
connect(this, &EffectStackView::doActivateEffect, view, &CollapsibleEffectView::slotActivateEffect);
connect(this, &EffectStackView::switchCollapsedView, view, &CollapsibleEffectView::switchCollapsed);
QModelIndex ix = m_model->getIndexFromItem(effectModel);
m_effectsTree->setIndexWidget(ix, view);
auto *del = static_cast<WidgetDelegate *>(m_effectsTree->itemDelegate(ix));
......@@ -400,6 +401,15 @@ bool EffectStackView::isStackEnabled() const
return false;
}
void EffectStackView::switchCollapsed()
{
if (m_model) {
int max = m_model->rowCount();
int active = qBound(0, m_model->getActiveEffect(), max - 1);
emit switchCollapsedView(active);
}
}
/*
void EffectStackView::switchBuiltStack(bool show)
{
......
......@@ -73,6 +73,9 @@ public:
*/
void enableStack(bool enable);
bool isStackEnabled() const;
/** @brief Collaps / expand current effect
*/
void switchCollapsed();
protected:
void dragEnterEvent(QDragEnterEvent *event) override;
......@@ -106,6 +109,7 @@ private slots:
signals:
void doActivateEffect(QModelIndex);
void switchCollapsedView(int row);
void seekToPos(int);
void reloadEffect(const QString &path);
void updateEnabledState();
......
......@@ -1026,6 +1026,11 @@ void MainWindow::setupActions()
toolGroup->addAction(m_buttonRazorTool);
toolGroup->addAction(m_buttonSpacerTool);
toolGroup->setExclusive(true);
QAction *collapseItem = new QAction(QIcon::fromTheme(QStringLiteral("collapse-all")), i18n("Collapse/Expand Item"), this);
addAction(QStringLiteral("collapse_expand"), collapseItem, Qt::Key_Less);
connect(collapseItem, &QAction::triggered, this, &MainWindow::slotCollapse);
// toolbar->setToolButtonStyle(Qt::ToolButtonIconOnly);
/*QWidget * actionWidget;
......@@ -3855,6 +3860,27 @@ void MainWindow::slotGrabItem()
getCurrentTimeline()->controller()->grabCurrent();
}
void MainWindow::slotCollapse()
{
if ((QApplication::focusWidget() != nullptr) && (QApplication::focusWidget()->parentWidget() != nullptr) &&
QApplication::focusWidget()->parentWidget() == pCore->bin()) {
// Bin expand/collapse?
} else {
QWidget *widget = QApplication::focusWidget();
while ((widget != nullptr) && widget != this) {
if (widget == m_effectStackDock) {
m_assetPanel->collapseCurrentEffect();
return;
}
widget = widget->parentWidget();
}
// Collapse / expand track
getMainTimeline()->controller()->collapseActiveTrack();
}
}
#ifdef DEBUG_MAINW
#undef DEBUG_MAINW
#endif
......@@ -473,6 +473,8 @@ private slots:
void resetTimelineTracks();
/** @brief Set keyboard grabbing on current timeline item */
void slotGrabItem();
/** @brief Collapse or expand current item (depending on focused widget: effet, track)*/
void slotCollapse();
signals:
Q_SCRIPTABLE void abortRenderJob(const QString &url);
......
......@@ -40,7 +40,7 @@ Rectangle {
property int iconSize: root.baseUnit * 2
property string trackTag
property int thumbsFormat: 0
property int collapsedHeight: expandButton.height
property int collapsedHeight: iconSize
border.width: 1
border.color: root.frameColor
signal clicked()
......
......@@ -810,7 +810,7 @@ Rectangle {
width: headerWidth
current: item === timeline.activeTrack
trackId: item
height: model.trackHeight
height: Math.max(collapsedHeight, model.trackHeight)
onIsLockedChanged: tracksRepeater.itemAt(index).isLocked = isLocked
collapsed: height <= collapsedHeight
onMyTrackHeightChanged: {
......@@ -1309,7 +1309,7 @@ Rectangle {
width: tracksContainerArea.width
border.width: 1
border.color: root.frameColor
height: model.trackHeight
height: Math.max(root.baseUnit * 2, model.trackHeight)
color: tracksRepeater.itemAt(index) ? ((tracksRepeater.itemAt(index).trackInternalId === timeline.activeTrack) ? Qt.tint(getTrackColor(tracksRepeater.itemAt(index).isAudio, false), selectedTrackColor) : getTrackColor(tracksRepeater.itemAt(index).isAudio, false)) : 'red'
}
}
......
......@@ -2736,3 +2736,12 @@ bool TimelineController::refreshIfVisible(int cid)
}
return false;
}
void TimelineController::collapseActiveTrack()
{
if (m_activeTrack == -1) {
return;
}
int collapsed = m_model->getTrackProperty(m_activeTrack, QStringLiteral("kdenlive:collapsed")).toInt();
m_model->setTrackProperty(m_activeTrack, QStringLiteral("kdenlive:collapsed"), collapsed > 0 ? QStringLiteral("0") : QStringLiteral("5"));
}
......@@ -475,6 +475,8 @@ public:
Q_INVOKABLE void showMasterEffects();
/** @brief Return true if an instance of this bin clip is currently undet timeline cursor */
bool refreshIfVisible(int cid);
/** @brief Collapse / expand active track */
void collapseActiveTrack();
public slots:
void resetView();
......
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