Hide message about too many audio streams if enough streams are disabled

parent 34c40090
Pipeline #20289 passed with stage
in 9 minutes and 28 seconds
......@@ -117,7 +117,7 @@ public:
rect.adjust(option.rect.width() / 12, 0, 0, 0);
int rate = 0;
if (me->pos().x() > rect.x()) {
rate = KRatingPainter::getRatingFromPosition(rect, Qt::AlignLeft, qApp->layoutDirection(), me->pos());
rate = KRatingPainter::getRatingFromPosition(rect, Qt::AlignLeft | Qt::AlignVCenter, qApp->layoutDirection(), me->pos());
}
if (rate > -1) {
// Full star rating only
......@@ -360,7 +360,7 @@ public:
painter->setOpacity(1);
if (index.data(AbstractProjectItem::ItemTypeRole).toInt() != AbstractProjectItem::FolderItem) {
r1.adjust(r1.width() / 12, 0, 0, 0);
KRatingPainter::paintRating(painter, r1, Qt::AlignLeft, index.data().toInt());
KRatingPainter::paintRating(painter, r1, Qt::AlignLeft | Qt::AlignVCenter, index.data().toInt());
}
} else {
QStyledItemDelegate::paint(painter, option, index);
......@@ -1519,7 +1519,7 @@ void Bin::slotLocateClip()
qCDebug(KDENLIVE_LOG) << " / / " + url.toString();
} else {
if (!exists) {
pCore->displayMessage(i18n("Could not locate %1", url.toString()), ErrorMessage, 300);
pCore->displayMessage(i18n("Could not locate %1", url.toString()), MessageType::ErrorMessage, 300);
}
return;
}
......@@ -2748,7 +2748,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, bool showCloseButton)
void Bin::doDisplayMessage(const QString &text, KMessageWidget::MessageType type, const QList<QAction *> &actions, bool showCloseButton, BinMessage::BinCategory messageCategory)
{
// Remove existing actions if any
QList<QAction *> acts = m_infoMessage->actions();
......@@ -2757,6 +2757,7 @@ void Bin::doDisplayMessage(const QString &text, KMessageWidget::MessageType type
m_infoMessage->removeAction(a);
delete a;
}
m_currentMessage = messageCategory;
m_infoMessage->setText(text);
m_infoMessage->setWordWrap(text.length() > 35);
for (QAction *action : actions) {
......@@ -2771,6 +2772,7 @@ void Bin::doDisplayMessage(const QString &text, KMessageWidget::MessageType type
void Bin::doDisplayMessage(const QString &text, KMessageWidget::MessageType type, const QString &logInfo)
{
// Remove existing actions if any
m_currentMessage = BinMessage::BinCategory::InformationMessage;
QList<QAction *> acts = m_infoMessage->actions();
while (!acts.isEmpty()) {
QAction *a = acts.takeFirst();
......@@ -2875,7 +2877,7 @@ void Bin::slotItemDropped(const QStringList &ids, const QModelIndex &parent)
}
}
if (moveCommand->childCount() == 0) {
pCore->displayMessage(i18n("No valid clip to insert"), InformationMessage, 500);
pCore->displayMessage(i18n("No valid clip to insert"), MessageType::InformationMessage, 500);
} else {
m_doc->commandStack()->push(moveCommand);
}
......@@ -2899,7 +2901,7 @@ void Bin::slotAddEffect(QString id, const QStringList &effectData)
return;
}
}
pCore->displayMessage(i18n("Select a clip to apply an effect"), InformationMessage, 500);
pCore->displayMessage(i18n("Select a clip to apply an effect"), MessageType::InformationMessage, 500);
}
void Bin::slotEffectDropped(const QStringList &effectData, const QModelIndex &parent)
......@@ -2933,7 +2935,7 @@ void Bin::slotEffectDropped(const QStringList &effectData, const QModelIndex &pa
res = std::static_pointer_cast<ProjectClip>(parentItem)->addEffect(effectData.constFirst());
}
if (!res) {
pCore->displayMessage(i18n("Cannot add effect to clip"), InformationMessage);
pCore->displayMessage(i18n("Cannot add effect to clip"), MessageType::InformationMessage);
} else {
m_proxyModel->selectionModel()->clearSelection();
const QModelIndex id = m_itemModel->index(row, 0, parentIndex);
......@@ -2979,14 +2981,14 @@ void Bin::slotTagDropped(const QString &tag, const QModelIndex &parent)
return;
}
}
pCore->displayMessage(i18n("Select a clip to add a tag"), InformationMessage);
pCore->displayMessage(i18n("Select a clip to add a tag"), MessageType::InformationMessage);
}
void Bin::switchTag(const QString &tag, bool add)
{
const QModelIndexList indexes = m_proxyModel->selectionModel()->selectedIndexes();
if (indexes.isEmpty()) {
pCore->displayMessage(i18n("Select a clip to add a tag"), InformationMessage);
pCore->displayMessage(i18n("Select a clip to add a tag"), MessageType::InformationMessage);
}
// Check for folders
QList <QString> allClips;
......@@ -3565,6 +3567,7 @@ void Bin::showTitleWidget(const std::shared_ptr<ProjectClip> &clip)
void Bin::slotResetInfoMessage()
{
m_errorLog.clear();
m_currentMessage = BinMessage::BinCategory::NoMessage;
QList<QAction *> actions = m_infoMessage->actions();
for (int i = 0; i < actions.count(); ++i) {
m_infoMessage->removeAction(actions.at(i));
......@@ -4066,23 +4069,25 @@ void Bin::slotBack()
}
}
void Bin::checkProjectAudioTracks(int minimumTracksCount)
void Bin::checkProjectAudioTracks(QString clipId, int minimumTracksCount)
{
if (m_infoMessage->isVisible()) {
if (m_currentMessage == BinMessage::BinCategory::ProfileMessage) {
// Don't show this message if another one is active
return;
}
int requestedTracks = minimumTracksCount - pCore->projectManager()->tracksCount().second;
const QString currentClipId = m_monitor->activeClipId();
if (requestedTracks > 0) {
if (clipId.isEmpty()) {
clipId = m_monitor->activeClipId();
}
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);
connect(ac2, &QAction::triggered, [this, clipId]() {
selectClipById(clipId);
for (QWidget *w : m_propertiesPanel->findChildren<ClipPropertiesController *>()) {
if (w->parentWidget() && w->parentWidget()->parentWidget()) {
// Raise panel
......@@ -4098,6 +4103,9 @@ void Bin::checkProjectAudioTracks(int minimumTracksCount)
});
//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);
doDisplayMessage(i18n("Your project needs more audio tracks to handle all streams. Add %1 audio tracks ?", requestedTracks), KMessageWidget::Information, list, true, BinMessage::BinCategory::StreamsMessage);
} else if (m_currentMessage == BinMessage::BinCategory::StreamsMessage) {
// Clip streams number ok for the project, hide message
m_infoMessage->animatedHide();
}
}
......@@ -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 *>(), bool showCloseButton = false);
void doDisplayMessage(const QString &text, KMessageWidget::MessageType type, const QList<QAction *> &actions = QList<QAction *>(), bool showCloseButton = false, BinMessage::BinCategory messageCategory = BinMessage::BinCategory::NoMessage);
void doDisplayMessage(const QString &text, KMessageWidget::MessageType type, const QString &logInfo);
/** @brief Reset all clip usage to 0 */
void resetUsageCount();
......@@ -387,8 +387,11 @@ 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);
/** @brief Check and propose auto adding audio tracks.
* @param clipId The clip whose streams have to be checked
* @param minimumTracksCount the number of active streams for this clip
*/
void checkProjectAudioTracks(QString clipId, int minimumTracksCount);
protected:
/* This function is called whenever an item is selected to propagate signals
......@@ -456,6 +459,7 @@ private:
QToolButton *m_filterButton;
/** @brief The info widget for failed jobs. */
KMessageWidget *m_infoMessage;
BinMessage::BinCategory m_currentMessage;
QStringList m_errorLog;
InvalidDialog *m_invalidClipDialog;
/** @brief Set to true if widget just gained focus (means we have to update effect stack . */
......
......@@ -516,10 +516,6 @@ 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;
......@@ -1112,6 +1108,7 @@ void ProjectClip::setProperties(const QMap<QString, QString> &properties, bool r
pCore->bin()->updateTargets(clipId());
if (!audioStreamChanged) {
pCore->bin()->reloadMonitorStreamIfActive(clipId());
pCore->bin()->checkProjectAudioTracks(clipId(), m_audioInfo->activeStreams().count());
refreshPanel = true;
}
}
......
......@@ -634,9 +634,9 @@ void Core::displayMessage(const QString &message, MessageType type, int timeout)
}
}
void Core::displayBinMessage(const QString &text, int type, const QList<QAction *> &actions)
void Core::displayBinMessage(const QString &text, int type, const QList<QAction *> &actions, bool showClose, BinMessage::BinCategory messageCategory)
{
m_binWidget->doDisplayMessage(text, (KMessageWidget::MessageType)type, actions);
m_binWidget->doDisplayMessage(text, (KMessageWidget::MessageType)type, actions, showClose, messageCategory);
}
void Core::displayBinLogMessage(const QString &text, int type, const QString &logInfo)
......
......@@ -257,7 +257,7 @@ private:
public slots:
void triggerAction(const QString &name);
/** @brief display a user info/warning message in the project bin */
void displayBinMessage(const QString &text, int type, const QList<QAction *> &actions = QList<QAction *>());
void displayBinMessage(const QString &text, int type, const QList<QAction *> &actions = QList<QAction *>(), bool showClose = false, BinMessage::BinCategory messageCategory = BinMessage::BinCategory::NoMessage);
void displayBinLogMessage(const QString &text, int type, const QString &logInfo);
/** @brief Create small thumbnails for luma used in compositions */
void buildLumaThumbs(const QStringList &values);
......
......@@ -138,6 +138,10 @@ enum MonitorSceneType {
enum MessageType { DefaultMessage, ProcessingJobMessage, OperationCompletedMessage, InformationMessage, ErrorMessage, MltError };
namespace BinMessage {
enum BinCategory { NoMessage = 0, ProfileMessage, StreamsMessage, InformationMessage };
};
enum TrackType { AudioTrack = 0, VideoTrack = 1, AnyTrack = 2 };
enum CacheType { SystemCacheRoot = -1, CacheRoot = 0, CacheBase = 1, CachePreview = 2, CacheProxy = 3, CacheAudio = 4, CacheThumbs = 5 };
......
......@@ -1470,7 +1470,7 @@ void KdenliveDoc::switchProfile(std::unique_ptr<ProfileParam> &profile, const QS
connect(ac, &QAction::triggered, [this, profilePath]() { this->slotSwitchProfile(profilePath, true); });
QAction *ac2 = new QAction(QIcon::fromTheme(QStringLiteral("dialog-cancel")), i18n("Cancel"), this);
list << ac << ac2;
pCore->displayBinMessage(i18n("Switch to clip profile %1?", profile->descriptiveString()), KMessageWidget::Information, list);
pCore->displayBinMessage(i18n("Switch to clip profile %1?", profile->descriptiveString()), KMessageWidget::Information, list, false, BinMessage::BinCategory::ProfileMessage);
} else {
// No known profile, ask user if he wants to use clip profile anyway
if (qFuzzyCompare((double)profile->m_frame_rate_num / profile->m_frame_rate_den, fps)) {
......
......@@ -137,7 +137,7 @@ void TimelineController::setTargetTracks(bool hasVideo, QMap <int, QString> audi
++it;
}
if (KdenliveSettings::multistream_checktrack() && audioTargets.count() > tracks.count()) {
pCore->bin()->checkProjectAudioTracks(audioTargets.count());
pCore->bin()->checkProjectAudioTracks(QString(), audioTargets.count());
}
QMapIterator <int, QString>st(audioTargets);
while (st.hasNext()) {
......
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