In Bin, when selecting a clip with more audio streams than current project,

show message allowing to add tracks or edit the streams.
Related to #382
parent 95e26813
Pipeline #20149 passed with stage
in 9 minutes and 28 seconds
......@@ -2737,7 +2737,7 @@ void Bin::slotUpdateJobStatus(const QString &id, int jobType, int status, const
*/
}
void Bin::doDisplayMessage(const QString &text, KMessageWidget::MessageType type, const QList<QAction *> &actions)
void Bin::doDisplayMessage(const QString &text, KMessageWidget::MessageType type, const QList<QAction *> &actions, bool showCloseButton)
{
// Remove existing actions if any
QList<QAction *> acts = m_infoMessage->actions();
......@@ -2752,7 +2752,7 @@ void Bin::doDisplayMessage(const QString &text, KMessageWidget::MessageType type
m_infoMessage->addAction(action);
connect(action, &QAction::triggered, this, &Bin::slotMessageActionTriggered);
}
m_infoMessage->setCloseButtonVisible(actions.isEmpty());
m_infoMessage->setCloseButtonVisible(showCloseButton || actions.isEmpty());
m_infoMessage->setMessageType(type);
m_infoMessage->animatedShow();
}
......@@ -4055,3 +4055,34 @@ void Bin::slotBack()
}
}
void Bin::checkProjectAudioTracks(int minimumTracksCount)
{
int requestedTracks = minimumTracksCount - pCore->projectManager()->tracksCount().second;
const QString currentClipId = m_monitor->activeClipId();
if (requestedTracks > 0) {
QList<QAction *> list;
QAction *ac = new QAction(QIcon::fromTheme(QStringLiteral("dialog-ok")), i18n("Add Tracks"), this);
connect(ac, &QAction::triggered, [requestedTracks]() {
pCore->projectManager()->addAudioTracks(requestedTracks);
});
QAction *ac2 = new QAction(QIcon::fromTheme(QStringLiteral("document-edit")), i18n("Edit Streams"), this);
connect(ac2, &QAction::triggered, [this, currentClipId]() {
selectClipById(currentClipId);
for (QWidget *w : m_propertiesPanel->findChildren<ClipPropertiesController *>()) {
if (w->parentWidget() && w->parentWidget()->parentWidget()) {
// Raise panel
w->parentWidget()->parentWidget()->raise();
}
// Show audio tab
static_cast<ClipPropertiesController *>(w)->activatePage(2);
}
});
QAction *ac3 = new QAction(QIcon::fromTheme(QStringLiteral("dialog-ok")), i18n("Don't ask again"), this);
connect(ac3, &QAction::triggered, [&]() {
KdenliveSettings::setMultistream_checktrack(false);
});
//QAction *ac4 = new QAction(QIcon::fromTheme(QStringLiteral("dialog-cancel")), i18n("Cancel"), this);
list << ac << ac2 << ac3; // << ac4;
doDisplayMessage(i18n("Your project needs more audio tracks to handle all streams. Add %1 audio tracks ?", requestedTracks), KMessageWidget::Information, list, true);
}
}
......@@ -371,7 +371,7 @@ public slots:
void slotExpandUrl(const ItemInfo &info, const QString &url, QUndoCommand *command);
/** @brief Abort all ongoing operations to prepare close. */
void abortOperations();
void doDisplayMessage(const QString &text, KMessageWidget::MessageType type, const QList<QAction *> &actions = QList<QAction *>());
void doDisplayMessage(const QString &text, KMessageWidget::MessageType type, const QList<QAction *> &actions = QList<QAction *>(), bool showCloseButton = false);
void doDisplayMessage(const QString &text, KMessageWidget::MessageType type, const QString &logInfo);
/** @brief Reset all clip usage to 0 */
void resetUsageCount();
......@@ -387,6 +387,8 @@ public slots:
PlaylistState::ClipState getClipState(int itemId) const;
/** @brief Adjust project profile to current clip. */
void adjustProjectProfileToItem();
/** @brief Check and propose auto adding audio tracks. */
void checkProjectAudioTracks(int minimumTracksCount);
protected:
/* This function is called whenever an item is selected to propagate signals
......
......@@ -516,6 +516,10 @@ bool ProjectClip::setProducer(std::shared_ptr<Mlt::Producer> producer, bool repl
}
});
}
if (KdenliveSettings::multistream_checktrack() && !isIncludedInTimeline() && activeStreams().count() > 1) {
// Check we have enough tracks in the project for its audio streams
//pCore->bin()->checkProjectAudioTracks(activeStreams().count());
}
replaceInTimeline();
updateTimelineClips({TimelineModel::IsProxyRole});
return true;
......
......@@ -259,6 +259,11 @@
<default>0</default>
</entry>
<entry name="multistream_checktrack" type="Bool">
<label>Check if project has enough tracks on multi stream clips, and propose to add new tracks.</label>
<default>true</default>
</entry>
<entry name="videothumbnails" type="Bool">
<label>Display video thumbnails in timeline.</label>
<default>true</default>
......
......@@ -1824,9 +1824,9 @@ void MainWindow::slotRefreshProfiles()
void MainWindow::slotEditProjectSettings()
{
KdenliveDoc *project = pCore->currentDoc();
QPoint p = getMainTimeline()->getTracksCount();
QPair <int, int> p = getMainTimeline()->getTracksCount();
ProjectSettings *w = new ProjectSettings(project, project->metadata(), getMainTimeline()->controller()->extractCompositionLumas(), p.x(), p.y(),
ProjectSettings *w = new ProjectSettings(project, project->metadata(), getMainTimeline()->controller()->extractCompositionLumas(), p.first, p.second,
project->projectTempFolder(), true, !project->isModified(), this);
connect(w, &ProjectSettings::disableProxies, this, &MainWindow::slotDisableProxies);
// connect(w, SIGNAL(disablePreview()), pCore->projectManager()->currentTimeline(), SLOT(invalidateRange()));
......
......@@ -1474,6 +1474,11 @@ void ClipPropertiesController::slotTextChanged()
m_originalProperties = properties;
}
void ClipPropertiesController::activatePage(int ix)
{
m_tabWidget->setCurrentIndex(ix);
}
void ClipPropertiesController::slotDeleteSelectedMarkers()
{
if (m_tabWidget->currentIndex() == 3) {
......
......@@ -63,6 +63,7 @@ public:
*/
explicit ClipPropertiesController(ClipController *controller, QWidget *parent);
~ClipPropertiesController() override;
void activatePage(int ix);
public slots:
void slotReloadProperties();
......
......@@ -1036,3 +1036,13 @@ void ProjectManager::saveWithUpdatedProfile(const QString &updatedProfile)
openFile(QUrl::fromLocalFile(convertedFile));
pCore->displayBinMessage(i18n("Project profile changed"), KMessageWidget::Information);
}
QPair<int, int> ProjectManager::tracksCount()
{
return pCore->window()->getMainTimeline()->controller()->getTracksCount();
}
void ProjectManager::addAudioTracks(int tracksCount)
{
pCore->window()->getMainTimeline()->controller()->addTracks(0, tracksCount);
}
......@@ -89,6 +89,14 @@ public:
*/
void saveWithUpdatedProfile(const QString &updatedProfile);
/** @brief Get the number of tracks in this projec (video, audio).
*/
QPair<int, int> tracksCount();
/** @brief Add requested audio tracks number to projet.
*/
void addAudioTracks(int tracksCount);
public slots:
void newFile(QString profileName, bool showProjectSettings = true);
void newFile(bool showProjectSettings = true);
......
......@@ -1076,7 +1076,8 @@ bool TimelineModel::requestClipInsertion(const QString &binClipId, int trackId,
target_track = {mirror};
QList <int> audioTids = getLowerTracksId(mirror, TrackType::AudioTrack);
if (streamsCount > audioTids.count() + 1) {
pCore->displayMessage(i18n("Not enough audio tracks for all streams (%1)", streamsCount), ErrorMessage);
// Project has not enough tracks to handle this clip
//pCore->displayMessage(i18n("Not enough audio tracks for all streams (%1)", streamsCount), ErrorMessage);
res = false;
} else {
while (streamsCount > 1 && !audioTids.isEmpty()) {
......
......@@ -136,6 +136,9 @@ void TimelineController::setTargetTracks(bool hasVideo, QMap <int, QString> audi
}
++it;
}
if (KdenliveSettings::multistream_checktrack() && audioTargets.count() > tracks.count()) {
pCore->bin()->checkProjectAudioTracks(audioTargets.count());
}
QMapIterator <int, QString>st(audioTargets);
while (st.hasNext()) {
st.next();
......@@ -1404,13 +1407,12 @@ void TimelineController::refreshItem(int id)
}
}
QPoint TimelineController::getTracksCount() const
QPair<int, int> TimelineController::getTracksCount() const
{
QVariant returnedValue;
QMetaObject::invokeMethod(m_root, "getTracksCount", Q_RETURN_ARG(QVariant, returnedValue));
QVariantList tracks = returnedValue.toList();
QPoint p(tracks.at(0).toInt(), tracks.at(1).toInt());
return p;
return {tracks.at(0).toInt(), tracks.at(1).toInt()};
}
QStringList TimelineController::extractCompositionLumas() const
......@@ -3390,3 +3392,32 @@ QMap <int, QString> TimelineController::getCurrentTargets(int trackId, int &acti
}
return m_binAudioTargets;
}
void TimelineController::addTracks(int videoTracks, int audioTracks)
{
bool result = false;
int total = videoTracks + audioTracks;
Fun undo = []() { return true; };
Fun redo = []() { return true; };
for (int ix = 0; videoTracks + audioTracks > 0; ++ix) {
int newTid;
if (audioTracks > 0) {
result = m_model->requestTrackInsertion(0, newTid, QString(), true, undo, redo);
audioTracks--;
} else {
result = m_model->requestTrackInsertion(-1, newTid, QString(), false, undo, redo);
videoTracks--;
}
if (result) {
m_model->setTrackProperty(newTid, "kdenlive:timeline_active", QStringLiteral("1"));
} else {
break;
}
}
if (result) {
pCore->pushUndo(undo, redo, i18np("Insert Track", "Insert Tracks", total));
} else {
pCore->displayMessage(i18n("Could not insert track"), InformationMessage, 500);
undo();
}
}
......@@ -418,7 +418,7 @@ public:
bool positionIsInItem(int id);
/* @brief Returns the number of tracks (audioTrakcs, videoTracks)
*/
QPoint getTracksCount() const;
QPair<int, int>getTracksCount() const;
/* @brief Request monitor refresh if item (clip or composition) is under timeline cursor
*/
void refreshItem(int id);
......@@ -537,6 +537,9 @@ public:
/** @brief Define audio stream target for a track index */
void assignAudioTarget(int trackId, int stream);
/** @brief Add tracks to project */
void addTracks(int videoTracks, int audioTracks);
public slots:
void resetView();
void setAudioTarget(QMap<int, int> tracks);
......
......@@ -394,7 +394,7 @@ void TimelineWidget::setTool(ProjectTool tool)
rootObject()->setProperty("activeTool", (int)tool);
}
QPoint TimelineWidget::getTracksCount() const
QPair<int, int> TimelineWidget::getTracksCount() const
{
return m_proxy->getTracksCount();
}
......
......@@ -48,7 +48,7 @@ public:
TimelineController *controller();
std::shared_ptr<TimelineItemModel> model();
void setTool(ProjectTool tool);
QPoint getTracksCount() const;
QPair<int, int>getTracksCount() const;
/* @brief calculate zoom level for a scale */
int zoomForScale(double value) const;
/* @brief Give keyboard focus to timeline qml */
......
......@@ -6,11 +6,18 @@
<rect>
<x>0</x>
<y>0</y>
<width>488</width>
<height>460</height>
<width>531</width>
<height>505</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="3" column="0" colspan="4">
<widget class="QCheckBox" name="kcfg_autoscroll">
<property name="text">
<string>Autoscroll while playing</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="4">
<widget class="QCheckBox" name="kcfg_ffmpegaudiothumbnails">
<property name="text">
......@@ -18,6 +25,56 @@
</property>
</widget>
</item>
<item row="8" column="0" colspan="4">
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Raise properties pane when selecting in timeline</string>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QCheckBox" name="kcfg_raisepropsclips">
<property name="text">
<string>Clips</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="kcfg_raisepropstransitions">
<property name="text">
<string>Transitions</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QCheckBox" name="kcfg_raisepropstracks">
<property name="text">
<string>Tracks</string>
</property>
</widget>
</item>
<item row="0" column="3">
<spacer name="horizontalSpacer_3">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>231</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
<item row="5" column="0" colspan="4">
<widget class="QCheckBox" name="kcfg_automatictransitions">
<property name="text">
<string>Create new transitions as automatic transitions</string>
</property>
</widget>
</item>
<item row="6" column="0" colspan="4">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
......@@ -55,89 +112,48 @@
</item>
</layout>
</item>
<item row="5" column="0" colspan="4">
<widget class="QCheckBox" name="kcfg_automatictransitions">
<property name="text">
<string>Create new transitions as automatic transitions</string>
</property>
</widget>
</item>
<item row="8" column="0" colspan="4">
<widget class="QGroupBox" name="groupBox_2">
<item row="0" column="0" colspan="4">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Raise properties pane when selecting in timeline</string>
<string>Thumbnails</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QCheckBox" name="kcfg_raisepropsclips">
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QCheckBox" name="kcfg_videothumbnails">
<property name="text">
<string>Clips</string>
<string>Video</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="kcfg_raisepropstransitions">
<item row="0" column="1">
<widget class="QCheckBox" name="kcfg_audiothumbnails">
<property name="text">
<string>Transitions</string>
<string>Audio</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="kcfg_raisepropstracks">
<property name="text">
<string>Tracks</string>
<item row="0" column="2">
<widget class="QCheckBox" name="kcfg_displayallchannels">
<property name="enabled">
<bool>false</bool>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="0" column="0" colspan="4">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>Thumbnails</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QCheckBox" name="kcfg_videothumbnails">
<property name="text">
<string>Video</string>
<string>Separate channels</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QCheckBox" name="kcfg_audiothumbnails">
<property name="text">
<string>Audio</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="kcfg_displayallchannels">
<property name="enabled">
<bool>false</bool>
</property>
<property name="text">
<string>Separate channels</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
<item row="0" column="3">
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
......@@ -162,11 +178,52 @@
</property>
</widget>
</item>
<item row="3" column="0" colspan="4">
<widget class="QCheckBox" name="kcfg_autoscroll">
<property name="text">
<string>Autoscroll while playing</string>
<item row="7" column="0" colspan="4">
<widget class="QGroupBox" name="groupBox_3">
<property name="title">
<string>Multi stream audio clips</string>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<item row="0" column="1">
<widget class="QComboBox" name="kcfg_multistream">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<item>
<property name="text">
<string>All audio streams</string>
</property>
</item>
<item>
<property name="text">
<string>First audio stream</string>
</property>
</item>
<item>
<property name="text">
<string>First 2 audio streams</string>
</property>
</item>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>On import, enable</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QCheckBox" name="kcfg_multistream_checktrack">
<property name="text">
<string>Check if project contains enough tracks</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
<item row="2" column="0" colspan="2">
......@@ -176,38 +233,9 @@
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>For clips with multiple audio streams, enable </string>
</property>
</widget>
</item>
<item row="7" column="1" colspan="3">
<widget class="QComboBox" name="kcfg_multistream">
<item>
<property name="text">
<string>All streams</string>
</property>
</item>
<item>
<property name="text">
<string>First stream</string>
</property>
</item>
<item>
<property name="text">
<string>First 2 streams</string>
</property>
</item>
</widget>
</item>
</layout>
</widget>
<tabstops>
<tabstop>kcfg_videothumbnails</tabstop>
<tabstop>kcfg_audiothumbnails</tabstop>
<tabstop>kcfg_displayallchannels</tabstop>
<tabstop>kcfg_ffmpegaudiothumbnails</tabstop>
<tabstop>kcfg_showmarkers</tabstop>
<tabstop>kcfg_autoscroll</tabstop>
......
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