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

Directly update timeline on track height change

Fix tracks not resizable when minimum height was too small
parent bf05f244
......@@ -65,6 +65,7 @@ KdenliveSettingsDialog::KdenliveSettingsDialog(const QMap<QString, QString> &map
{
KdenliveSettings::setV4l_format(0);
QWidget *p1 = new QWidget;
QFontInfo ftInfo(font());
m_configMisc.setupUi(p1);
m_page1 = addPage(p1, i18n("Misc"));
m_page1->setIcon(KoIconUtils::themedIcon(QStringLiteral("configure")));
......@@ -97,6 +98,7 @@ KdenliveSettingsDialog::KdenliveSettingsDialog(const QMap<QString, QString> &map
m_configTimeline.setupUi(p3);
m_page3 = addPage(p3, i18n("Timeline"));
m_page3->setIcon(KoIconUtils::themedIcon(QStringLiteral("video-display")));
m_configTimeline.kcfg_trackheight->setMinimum(ftInfo.pixelSize() * 1.5);
QWidget *p2 = new QWidget;
m_configEnv.setupUi(p2);
......@@ -912,6 +914,11 @@ void KdenliveSettingsDialog::updateSettings()
m_configSdl.kcfg_gpu_accel->setChecked(KdenliveSettings::gpu_accel());
}
}
if (m_configTimeline.kcfg_trackheight->value() != KdenliveSettings::trackheight()) {
KdenliveSettings::setTrackheight(m_configTimeline.kcfg_trackheight->value());
emit resetView();
}
// Mimes
if (m_configEnv.kcfg_addedExtensions->text() != KdenliveSettings::addedExtensions()) {
......
......@@ -127,6 +127,8 @@ signals:
void checkTabPosition();
/** @brief Switch between merged / separate channels for audio thumbs */
void audioThumbFormatChanged();
/** @brief An important timeline property changed, prepare for a reset */
void resetView();
};
#endif
......@@ -2176,6 +2176,7 @@ void MainWindow::slotPreferences(int page, int option)
connect(dialog, &KdenliveSettingsDialog::restartKdenlive, this, &MainWindow::slotRestart);
connect(dialog, &KdenliveSettingsDialog::updateLibraryFolder, pCore.get(), &Core::updateLibraryPath);
connect(dialog, &KdenliveSettingsDialog::audioThumbFormatChanged, m_timelineTabs, &TimelineTabs::audioThumbFormatChanged);
connect(dialog, &KdenliveSettingsDialog::resetView, this, &MainWindow::resetTimelineTracks);
dialog->show();
if (page != -1) {
......@@ -4158,6 +4159,14 @@ TimelineWidget *MainWindow::getCurrentTimeline() const
return m_timelineTabs->getCurrentTimeline();
}
void MainWindow::resetTimelineTracks()
{
TimelineWidget *current = getCurrentTimeline();
if (current) {
current->controller()->resetTrackHeight();
}
}
void MainWindow::slotChangeSpeed(int speed)
{
ObjectId owner = m_assetPanel->effectStackOwner();
......
......@@ -468,6 +468,8 @@ private slots:
void setTimelineToolbarIconSize(QAction *a);
void slotChangeSpeed(int speed);
void updateAction();
/** @brief Request adjust of timeline track height */
void resetTimelineTracks();
signals:
Q_SCRIPTABLE void abortRenderJob(const QString &url);
......
......@@ -35,6 +35,7 @@ Rectangle {
property bool current: false
property int myTrackHeight
property int trackId : -42
property int collapsedHeight: nameEdit.height + 2
border.width: 1
border.color: Qt.rgba(activePalette.windowText.r, activePalette.windowText.g, activePalette.windowText.b, 0.1)
signal clicked()
......@@ -116,10 +117,9 @@ Rectangle {
Layout.leftMargin: 2
ToolButton {
id: expandButton
iconName: buttonBar.visible ? 'arrow-down' : 'arrow-right'
iconName: trackHeadRoot.collapsed ? 'arrow-right' : 'arrow-down'
onClicked: {
trackHeadRoot.collapsed = buttonBar.visible
trackHeadRoot.myTrackHeight = buttonBar.visible ? nameEdit.height + 2 : controller.getTrackProperty(trackId, "kdenlive:trackheight")
trackHeadRoot.myTrackHeight = trackHeadRoot.collapsed ? Math.max(collapsedHeight * 1.5, controller.getTrackProperty(trackId, "kdenlive:trackheight")) : collapsedHeight
}
tooltip: buttonBar.visible? i18n('Minimize') : i18n('Expand')
}
......@@ -342,8 +342,7 @@ Rectangle {
if (mouse.buttons === Qt.LeftButton) {
parent.opacity = 0.5
var newHeight = originalY + (mapToItem(null, x, y).y - startY)
newHeight = Math.max(trackLabel.height + resizer.height + 3, newHeight)
trackHeadRoot.collapsed = newHeight < nameEdit.height * 2
newHeight = Math.max(collapsedHeight, newHeight)
trackHeadRoot.myTrackHeight = newHeight
}
}
......
......@@ -449,6 +449,7 @@ Rectangle {
trackBaseRepeater.itemAt(index).height = myTrackHeight
tracksRepeater.itemAt(index).height = myTrackHeight
height = myTrackHeight
collapsed = height <= collapsedHeight
if (!collapsed) {
controller.setTrackProperty(trackId, "kdenlive:trackheight", myTrackHeight)
}
......
......@@ -1425,3 +1425,16 @@ int TimelineController::videoTarget() const
{
return m_model->m_videoTarget;
}
void TimelineController::resetTrackHeight()
{
int tracksCount = m_model->getTracksCount();
for (int track = tracksCount - 1; track >= 0; track--) {
int trackIx = m_model->getTrackIndexFromPosition(track);
m_model->getTrackById(trackIx)->setProperty(QStringLiteral("kdenlive:trackheight"), QString::number(KdenliveSettings::trackheight()));
}
QModelIndex modelStart = m_model->makeTrackIndexFromID(m_model->getTrackIndexFromPosition(0));
QModelIndex modelEnd = m_model->makeTrackIndexFromID(m_model->getTrackIndexFromPosition(tracksCount - 1));
m_model->dataChanged(modelStart, modelEnd, {TimelineModel::HeightRole});
}
......@@ -320,6 +320,8 @@ public:
void showCompositionKeyframes(int clipId, bool value);
/** @brief Returns last usable timeline position (seek request or current pos) */
int timelinePosition() const;
/** @brief Adjust all timeline tracks height */
void resetTrackHeight();
public slots:
void selectMultitrack();
......
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