Automatic timeline preview profile selection, can be forced in project settings.

Fix compilation with Qt < 5.6
Ref: T1949
parent f8c140c2
......@@ -242,44 +242,47 @@ KdenliveSettingsDialog::KdenliveSettingsDialog(const QMap<QString, QString>& map
}
// decklink profile
QAction *act = new QAction(KoIconUtils::themedIcon(QStringLiteral("configure")), i18n("Configure profiles"), this);
act->setData(4);
connect(act, SIGNAL(triggered(bool)), this, SLOT(slotManageEncodingProfile()));
m_configCapture.decklink_manageprofile->setDefaultAction(act);
m_configCapture.decklink_showprofileinfo->setIcon(KoIconUtils::themedIcon(QStringLiteral("help-about")));
m_configCapture.decklink_manageprofile->setIcon(KoIconUtils::themedIcon(QStringLiteral("configure")));
m_configCapture.decklink_parameters->setVisible(false);
m_configCapture.decklink_parameters->setMaximumHeight(QFontMetrics(font()).lineSpacing() * 4);
m_configCapture.decklink_parameters->setPlainText(KdenliveSettings::decklink_parameters());
connect(m_configCapture.decklink_manageprofile, SIGNAL(clicked(bool)), this, SLOT(slotManageEncodingProfile()));
connect(m_configCapture.kcfg_decklink_profile, SIGNAL(currentIndexChanged(int)), this, SLOT(slotUpdateDecklinkProfile()));
connect(m_configCapture.decklink_showprofileinfo, SIGNAL(clicked(bool)), m_configCapture.decklink_parameters, SLOT(setVisible(bool)));
// ffmpeg profile
m_configCapture.v4l_showprofileinfo->setIcon(KoIconUtils::themedIcon(QStringLiteral("help-about")));
m_configCapture.v4l_manageprofile->setIcon(KoIconUtils::themedIcon(QStringLiteral("configure")));
m_configCapture.v4l_parameters->setVisible(false);
m_configCapture.v4l_parameters->setMaximumHeight(QFontMetrics(font()).lineSpacing() * 4);
m_configCapture.v4l_parameters->setPlainText(KdenliveSettings::v4l_parameters());
connect(m_configCapture.v4l_manageprofile, SIGNAL(clicked(bool)), this, SLOT(slotManageEncodingProfile()));
act = new QAction(KoIconUtils::themedIcon(QStringLiteral("configure")), i18n("Configure profiles"), this);
act->setData(2);
connect(act, SIGNAL(triggered(bool)), this, SLOT(slotManageEncodingProfile()));
m_configCapture.v4l_manageprofile->setDefaultAction(act);
connect(m_configCapture.kcfg_v4l_profile, SIGNAL(currentIndexChanged(int)), this, SLOT(slotUpdateV4lProfile()));
connect(m_configCapture.v4l_showprofileinfo, SIGNAL(clicked(bool)), m_configCapture.v4l_parameters, SLOT(setVisible(bool)));
// screen grab profile
m_configCapture.grab_showprofileinfo->setIcon(KoIconUtils::themedIcon(QStringLiteral("help-about")));
m_configCapture.grab_manageprofile->setIcon(KoIconUtils::themedIcon(QStringLiteral("configure")));
m_configCapture.grab_parameters->setVisible(false);
m_configCapture.grab_parameters->setMaximumHeight(QFontMetrics(font()).lineSpacing() * 4);
m_configCapture.grab_parameters->setPlainText(KdenliveSettings::grab_parameters());
connect(m_configCapture.grab_manageprofile, SIGNAL(clicked(bool)), this, SLOT(slotManageEncodingProfile()));
act = new QAction(KoIconUtils::themedIcon(QStringLiteral("configure")), i18n("Configure profiles"), this);
act->setData(3);
connect(act, SIGNAL(triggered(bool)), this, SLOT(slotManageEncodingProfile()));
m_configCapture.grab_manageprofile->setDefaultAction(act);
connect(m_configCapture.kcfg_grab_profile, SIGNAL(currentIndexChanged(int)), this, SLOT(slotUpdateGrabProfile()));
connect(m_configCapture.grab_showprofileinfo, SIGNAL(clicked(bool)), m_configCapture.grab_parameters, SLOT(setVisible(bool)));
// Timeline preview
m_configTimeline.tl_showprofileinfo->setIcon(KoIconUtils::themedIcon(QStringLiteral("help-about")));
m_configTimeline.tl_manageprofile->setIcon(KoIconUtils::themedIcon(QStringLiteral("configure")));
m_configTimeline.tl_parameters->setVisible(false);
m_configTimeline.tl_parameters->setMaximumHeight(QFontMetrics(font()).lineSpacing() * 4);
m_configTimeline.tl_parameters->setPlainText(KdenliveSettings::tl_parameters());
connect(m_configTimeline.tl_manageprofile, SIGNAL(clicked(bool)), this, SLOT(slotManageEncodingProfile()));
connect(m_configTimeline.kcfg_tl_profile, SIGNAL(currentIndexChanged(int)), this, SLOT(slotUpdateTlProfile()));
connect(m_configTimeline.tl_showprofileinfo, SIGNAL(clicked(bool)), m_configTimeline.tl_parameters, SLOT(setVisible(bool)));
act = new QAction(KoIconUtils::themedIcon(QStringLiteral("configure")), i18n("Configure profiles"), this);
act->setData(1);
connect(act, SIGNAL(triggered(bool)), this, SLOT(slotManageEncodingProfile()));
m_configTimeline.tl_manageprofile->setDefaultAction(act);
// Project profile management
m_configProject.manage_profiles->setIcon(KoIconUtils::themedIcon("configure"));
......@@ -295,14 +298,18 @@ KdenliveSettingsDialog::KdenliveSettingsDialog(const QMap<QString, QString>& map
m_configProject.proxyparams->setVisible(false);
m_configProject.proxyparams->setMaximumHeight(QFontMetrics(font()).lineSpacing() * 4);
m_configProject.proxyparams->setPlainText(KdenliveSettings::proxyparams());
connect(m_configProject.proxy_manageprofile, SIGNAL(clicked(bool)), this, SLOT(slotManageEncodingProfile()));
act = new QAction(KoIconUtils::themedIcon(QStringLiteral("configure")), i18n("Configure profiles"), this);
act->setData(0);
connect(act, SIGNAL(triggered(bool)), this, SLOT(slotManageEncodingProfile()));
m_configProject.proxy_manageprofile->setDefaultAction(act);
connect(m_configProject.proxy_showprofileinfo, SIGNAL(clicked(bool)), m_configProject.proxyparams, SLOT(setVisible(bool)));
connect(m_configProject.kcfg_proxy_profile, SIGNAL(currentIndexChanged(int)), this, SLOT(slotUpdateProxyProfile()));
slotUpdateProxyProfile(-1);
slotUpdateV4lProfile(-1);
slotUpdateTlProfile(-1);
slotUpdateGrabProfile(-1);
slotUpdateDecklinkProfile(-1);
......@@ -793,13 +800,6 @@ void KdenliveSettingsDialog::updateSettings()
KdenliveSettings::setProxyextension(data.section(';', 1, 1));
}
// Timeline previews
data = m_configTimeline.kcfg_tl_profile->itemData(m_configTimeline.kcfg_tl_profile->currentIndex()).toString();
if (!data.isEmpty() && (data.section(';', 0, 0) != KdenliveSettings::tl_parameters() || data.section(';', 1, 1) != KdenliveSettings::tl_extension())) {
KdenliveSettings::setTl_parameters(data.section(';', 0, 0));
KdenliveSettings::setTl_extension(data.section(';', 1, 1));
}
if (updateCapturePath) emit updateCaptureFolder();
if (updateLibrary) emit updateLibraryFolder();
......@@ -1159,9 +1159,10 @@ void KdenliveSettingsDialog::saveCurrentV4lProfile()
void KdenliveSettingsDialog::slotManageEncodingProfile()
{
QAction *act = qobject_cast<QAction *>(sender());
int type = 0;
if (currentPage() == m_page4) {
type = m_configCapture.tabWidget->currentIndex();
if (act) {
type = act->data().toInt();
}
QPointer<EncodingProfilesDialog> d = new EncodingProfilesDialog(type);
d->exec();
......@@ -1187,20 +1188,6 @@ void KdenliveSettingsDialog::loadEncodingProfiles()
m_configCapture.kcfg_v4l_profile->blockSignals(false);
if (!currentItem.isEmpty()) m_configCapture.kcfg_v4l_profile->setCurrentIndex(m_configCapture.kcfg_v4l_profile->findText(currentItem));
// Load Timeline preview profiles
m_configTimeline.kcfg_tl_profile->blockSignals(true);
currentItem = m_configTimeline.kcfg_tl_profile->currentText();
m_configTimeline.kcfg_tl_profile->clear();
KConfigGroup group5(&conf, "timelinepreview");
values = group5.entryMap();
QMapIterator<QString, QString> m(values);
while (m.hasNext()) {
m.next();
if (!m.key().isEmpty()) m_configTimeline.kcfg_tl_profile->addItem(m.key(), m.value());
}
m_configTimeline.kcfg_tl_profile->blockSignals(false);
if (!currentItem.isEmpty()) m_configTimeline.kcfg_tl_profile->setCurrentIndex(m_configTimeline.kcfg_tl_profile->findText(currentItem));
// Load Screen Grab profiles
m_configCapture.kcfg_grab_profile->blockSignals(true);
currentItem = m_configCapture.kcfg_grab_profile->currentText();
......@@ -1265,16 +1252,6 @@ void KdenliveSettingsDialog::slotUpdateV4lProfile(int ix)
//
}
void KdenliveSettingsDialog::slotUpdateTlProfile(int ix)
{
if (ix == -1) ix = KdenliveSettings::tl_profile();
else ix = m_configTimeline.kcfg_tl_profile->currentIndex();
QString data = m_configTimeline.kcfg_tl_profile->itemData(ix).toString();
if (data.isEmpty()) return;
m_configTimeline.tl_parameters->setPlainText(data.section(';', 0, 0));
//
}
void KdenliveSettingsDialog::slotUpdateGrabProfile(int ix)
{
if (ix == -1) ix = KdenliveSettings::grab_profile();
......
......@@ -78,7 +78,6 @@ private slots:
void slotUpdateDecklinkProfile(int ix = 0);
void slotUpdateProxyProfile(int ix = 0);
void slotUpdateV4lProfile(int ix = 0);
void slotUpdateTlProfile(int ix = 0);
void slotUpdateGrabProfile(int ix = 0);
void slotEditVideo4LinuxProfile();
void slotReloadBlackMagic();
......
......@@ -1616,3 +1616,58 @@ void KdenliveDoc::previewProgress(int p)
{
pCore->window()->setPreviewProgress(p);
}
void KdenliveDoc::selectPreviewProfile()
{
// Read preview profiles and find the best match
KConfig conf(QStringLiteral("encodingprofiles.rc"), KConfig::CascadeConfig, QStandardPaths::DataLocation);
KConfigGroup group(&conf, "timelinepreview");
QMap< QString, QString > values = group.entryMap();
QMapIterator<QString, QString> i(values);
QStringList matchingProfiles;
QStringList fallBackProfiles;
while (i.hasNext()) {
i.next();
// Check for frame rate
QStringList data = i.value().split(" ");
bool rateFound = false;
foreach(const QString arg, data) {
if (arg.startsWith(QStringLiteral("r="))) {
rateFound = true;
double fps = arg.section(QStringLiteral("="), 1).toDouble();
if (fps > 0) {
if (qAbs((int) (m_render->fps() * 100) - (fps * 100)) <= 1) {
matchingProfiles << i.value();
break;
}
}
}
}
if (!rateFound) {
// Profile without fps, can be used as fallBack
fallBackProfiles << i.value();
}
}
QString bestMatch;
if (matchingProfiles.count() > 1) {
// several profiles with matching fps, try to decide based on resolution
QString docSize = QString("s=%1x%2").arg(m_profile.width).arg(m_profile.height);
foreach (const QString &param, matchingProfiles) {
if (param.contains(docSize)) {
bestMatch = param;
break;
}
}
if (bestMatch.isEmpty())
bestMatch = matchingProfiles.first();
} else if (matchingProfiles.count() == 1) {
bestMatch = matchingProfiles.first();
} else if (!fallBackProfiles.isEmpty()) {
bestMatch = fallBackProfiles.first();
}
if (!bestMatch.isEmpty()) {
setDocumentProperty(QStringLiteral("previewparameters"), bestMatch.section(";", 0, 0));
setDocumentProperty(QStringLiteral("previewextension"), bestMatch.section(";", 1, 1));
}
}
......@@ -159,6 +159,8 @@ public:
void doAddAction(const QString &name, QAction *a);
void invalidatePreviews(QList <int> chunks);
void previewProgress(int p);
/** @brief Select most appropriate rendering profile for timeline preview based on fps / size. */
void selectPreviewProfile();
private:
QUrl m_url;
......
......@@ -906,7 +906,7 @@
<label>Name of the chosen deinterlacer.</label>
<default>onefield</default>
</entry>
<entry name="mltinterpolation" type="String">
<label>Name of the chosen interpol method.</label>
<default>nearest</default>
......
......@@ -320,7 +320,7 @@ MainWindow::MainWindow(const QString &MltPath, const QUrl &Url, const QString &
/// Add Widgets
setDockOptions(QMainWindow::AllowNestedDocks | QMainWindow::AllowTabbedDocks);
#if (QT_VERSION >= QT_VERSION_CHECK(5, 4, 0))
#if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0))
setDockOptions(dockOptions() | QMainWindow::GroupedDragging);
#endif
setTabPosition(Qt::AllDockWidgetAreas, KdenliveSettings::verticaltabs() ? QTabWidget::East : QTabWidget::North);
......@@ -1630,6 +1630,7 @@ void MainWindow::slotEditProjectSettings()
if (w->exec() == QDialog::Accepted) {
QString profile = w->selectedProfile();
project->setProjectFolder(w->selectedFolder());
pCore->projectManager()->currentTimeline()->updatePreviewSettings(w->selectedPreview());
bool modified = false;
if (m_recMonitor) {
m_recMonitor->slotUpdateCaptureFolder(project->projectFolder().path() + QDir::separator());
......
......@@ -77,6 +77,8 @@ ProjectSettings::ProjectSettings(KdenliveDoc *doc, QMap <QString, QString> metad
generate_imageproxy->setChecked(doc->getDocumentProperty(QStringLiteral("generateimageproxy")).toInt());
proxy_imageminsize->setValue(doc->getDocumentProperty(QStringLiteral("proxyimageminsize")).toInt());
m_proxyextension = doc->getDocumentProperty(QStringLiteral("proxyextension"));
m_previewparams = doc->getDocumentProperty(QStringLiteral("previewparameters"));
m_previewextension = doc->getDocumentProperty(QStringLiteral("previewextension"));
}
else {
currentProf = KdenliveSettings::default_profile();
......@@ -103,6 +105,7 @@ ProjectSettings::ProjectSettings(KdenliveDoc *doc, QMap <QString, QString> metad
loadProxyProfiles();
loadPreviewProfiles();
// Proxy GUI stuff
proxy_showprofileinfo->setIcon(KoIconUtils::themedIcon(QStringLiteral("help-about")));
......@@ -118,6 +121,20 @@ ProjectSettings::ProjectSettings(KdenliveDoc *doc, QMap <QString, QString> metad
proxyparams->setMaximumHeight(QFontMetrics(font()).lineSpacing() * 5);
connect(proxy_showprofileinfo, SIGNAL(clicked(bool)), proxyparams, SLOT(setVisible(bool)));
// Preview GUI stuff
preview_showprofileinfo->setIcon(KoIconUtils::themedIcon(QStringLiteral("help-about")));
preview_showprofileinfo->setToolTip(i18n("Show default profile parameters"));
preview_manageprofile->setIcon(KoIconUtils::themedIcon(QStringLiteral("configure")));
preview_manageprofile->setToolTip(i18n("Manage timeline preview profiles"));
connect(preview_manageprofile, SIGNAL(clicked(bool)), this, SLOT(slotManagePreviewProfile()));
preview_profile->setToolTip(i18n("Select default preview profile"));
connect(preview_profile, SIGNAL(currentIndexChanged(int)), this, SLOT(slotUpdatePreviewParams()));
previewparams->setVisible(false);
previewparams->setMaximumHeight(QFontMetrics(font()).lineSpacing() * 5);
connect(preview_showprofileinfo, SIGNAL(clicked(bool)), previewparams, SLOT(setVisible(bool)));
if (readOnlyTracks) {
video_tracks->setEnabled(false);
audio_tracks->setEnabled(false);
......@@ -420,8 +437,20 @@ void ProjectSettings::slotUpdateFiles(bool cacheOnly)
delete_unused->setEnabled(unUsed > 0);
}
const QString ProjectSettings::selectedPreview() const
{
return preview_profile->itemData(preview_profile->currentIndex()).toString();
}
void ProjectSettings::accept()
{
QString params = preview_profile->itemData(preview_profile->currentIndex()).toString();
if (!params.isEmpty()) {
if (params.section(";", 0, 0) != m_previewparams || params.section(";", 1, 1) != m_previewextension) {
// Timeline preview settings changed, warn
if (KMessageBox::warningContinueCancel(this, i18n("You changed the timeline preview profile. This will remove all existing timeline previews for this project.\n Are you sure you want to proceed?"), i18n("Confirm profile change")) == KMessageBox::Cancel) return;
}
}
if (!m_savedProject && selectedProfile() != KdenliveSettings::current_profile())
if (KMessageBox::warningContinueCancel(this, i18n("Changing the profile of your project cannot be undone.\nIt is recommended to save your project before attempting this operation that might cause some corruption in transitions.\n Are you sure you want to proceed?"), i18n("Confirm profile change")) == KMessageBox::Cancel) return;
QDialog::accept();
......@@ -647,6 +676,12 @@ void ProjectSettings::slotUpdateProxyParams()
proxyparams->setPlainText(params.section(';', 0, 0));
}
void ProjectSettings::slotUpdatePreviewParams()
{
QString params = preview_profile->itemData(preview_profile->currentIndex()).toString();
previewparams->setPlainText(params.section(';', 0, 0));
}
const QMap <QString, QString> ProjectSettings::metadata() const
{
QMap <QString, QString> metadata;
......@@ -714,6 +749,14 @@ void ProjectSettings::slotManageEncodingProfile()
loadProxyProfiles();
}
void ProjectSettings::slotManagePreviewProfile()
{
QPointer<EncodingProfilesDialog> d = new EncodingProfilesDialog(1);
d->exec();
delete d;
loadPreviewProfiles();
}
void ProjectSettings::loadProxyProfiles()
{
// load proxy profiles
......@@ -744,3 +787,38 @@ void ProjectSettings::loadProxyProfiles()
slotUpdateProxyParams();
}
void ProjectSettings::loadPreviewProfiles()
{
// load proxy profiles
KConfig conf(QStringLiteral("encodingprofiles.rc"), KConfig::CascadeConfig, QStandardPaths::DataLocation);
KConfigGroup group(&conf, "timelinepreview");
QMap <QString, QString> values = group.entryMap();
QMapIterator<QString, QString> k(values);
int ix = -1;
preview_profile->clear();
while (k.hasNext()) {
k.next();
if (!k.key().isEmpty()) {
QString params = k.value().section(';', 0, 0);
QString extension = k.value().section(';', 1, 1);
if (ix == -1 && (params == m_previewparams && extension == m_previewextension)) {
// this is the current profile
ix = preview_profile->count();
}
preview_profile->addItem(k.key(), k.value());
}
}
if (ix == -1) {
// Current project proxy settings not found
ix = preview_profile->count();
if (m_previewparams.isEmpty() && m_previewextension.isEmpty()) {
// Leave empty, will be automatically detected
preview_profile->addItem(i18n("Auto"));
} else {
preview_profile->addItem(i18n("Current Settings"), QString(m_previewparams + ';' + m_previewextension));
}
}
preview_profile->setCurrentIndex(ix);
slotUpdateProxyParams();
}
......@@ -49,6 +49,7 @@ public:
const QMap <QString, QString> metadata() const;
static QStringList extractPlaylistUrls(const QString &path);
static QStringList extractSlideshowUrls(const QUrl &url);
const QString selectedPreview() const;
public slots:
virtual void accept();
......@@ -64,6 +65,7 @@ private slots:
void slotExportToText();
/** @brief Update the displayed proxy parameters when user changes selection. */
void slotUpdateProxyParams();
void slotUpdatePreviewParams();
/** @brief Insert a new metadata field. */
void slotAddMetadataField();
/** @brief Delete current metadata field. */
......@@ -72,6 +74,7 @@ private slots:
void slotEditProfiles();
/** @brief Display proxy profiles management dialog. */
void slotManageEncodingProfile();
void slotManagePreviewProfile();
/** @brief Open editor for metadata item. */
void slotEditMetadata(QTreeWidgetItem *, int );
......@@ -88,6 +91,10 @@ private:
QStringList m_projectThumbs;
/** @brief Fill the proxy profiles combobox. */
void loadProxyProfiles();
QString m_previewparams;
QString m_previewextension;
/** @brief Fill the proxy profiles combobox. */
void loadPreviewProfiles();
signals:
/** @brief User deleted proxies, so disable them in project. */
......
......@@ -155,6 +155,11 @@ void ProjectManager::newFile(bool showProjectSettings, bool force)
documentProperties.insert(QStringLiteral("proxyparams"), w->proxyParams());
documentProperties.insert(QStringLiteral("proxyextension"), w->proxyExtension());
documentProperties.insert(QStringLiteral("generateimageproxy"), QString::number((int) w->generateImageProxy()));
QString preview = w->selectedPreview();
if (!preview.isEmpty()) {
documentProperties.insert(QStringLiteral("previewparameters"), preview.section(";", 0, 0));
documentProperties.insert(QStringLiteral("previewextension"), preview.section(";", 1, 1));
}
documentProperties.insert(QStringLiteral("proxyimageminsize"), QString::number(w->proxyImageMinSize()));
documentMetadata = w->metadata();
delete w;
......
......@@ -1626,7 +1626,7 @@ void Render::abortPreview()
}
}
void Render::previewRendering(QList <int> frames, const QString &cacheDir, const QString &documentId)
void Render::previewRendering(QList <int> frames, const QString &cacheDir, const QString &documentId, QStringList consumerParams, const QString extension)
{
abortPreview();
m_previewChunks << frames;
......@@ -1645,16 +1645,14 @@ void Render::previewRendering(QList <int> frames, const QString &cacheDir, const
return;
xmlConsumer.connect(prod);
xmlConsumer.run();
m_previewThread = QtConcurrent::run(this, &Render::doPreviewRender, dir, documentId, sceneListFile);
m_previewThread = QtConcurrent::run(this, &Render::doPreviewRender, dir, documentId, sceneListFile, consumerParams, extension);
}
void Render::doPreviewRender(QDir folder, QString id, QString scene)
void Render::doPreviewRender(QDir folder, QString id, QString scene, QStringList consumerParams, const QString &extension)
{
int progress;
int chunkSize = KdenliveSettings::timelinechunks();
QStringList consumerParams;
consumerParams << "an=1";
consumerParams << KdenliveSettings::tl_parameters().split(" ");
emit previewRender(0, QString(), 0);
int ct = 0;
while (!m_previewChunks.isEmpty()) {
......@@ -1665,7 +1663,7 @@ void Render::doPreviewRender(QDir folder, QString id, QString scene)
emit previewRender(0, QString(), 1000);
break;
}
QString fileName = id + QString("-%1.%2").arg(i).arg(KdenliveSettings::tl_extension());
QString fileName = id + QString("-%1.%2").arg(i).arg(extension);
if (m_previewChunks.isEmpty()) {
progress = 1000;
} else {
......
......@@ -251,7 +251,7 @@ class Render: public AbstractRender
void prepareProfileReset(double fps);
void finishProfileReset();
void updateSlowMotionProducers(const QString &id, QMap <QString, QString> passProperties);
void previewRendering(QList <int> frames, const QString &cacheDir, const QString &documentId);
void previewRendering(QList <int> frames, const QString &cacheDir, const QString &documentId, QStringList consumerParams, const QString extension);
void abortPreview();
private:
......@@ -312,7 +312,7 @@ private slots:
/** @brief Refreshes the monitor display. */
void refresh();
void slotCheckSeeking();
void doPreviewRender(QDir folder, QString id, QString scene);
void doPreviewRender(QDir folder, QString id, QString scene, QStringList consumerParams, const QString &extension);
signals:
/** @brief The renderer stopped, either playing or rendering. */
......
......@@ -1792,7 +1792,16 @@ void Timeline::startPreviewRender()
if (!chunks.isEmpty()) {
QString cacheDir = QStandardPaths::writableLocation(QStandardPaths::CacheLocation);
QString documentId = m_doc->getDocumentProperty(QStringLiteral("documentid"));
m_doc->renderer()->previewRendering(chunks, cacheDir, documentId);
QString docParams = m_doc->getDocumentProperty(QStringLiteral("previewparameters"));
if (docParams.isEmpty()) {
m_doc->selectPreviewProfile();
docParams = m_doc->getDocumentProperty(QStringLiteral("previewparameters"));
}
if (docParams.isEmpty()) {
KMessageBox::sorry(this, i18n("No available preview profile found, please check the Timeline Settings"));
return;
}
m_doc->renderer()->previewRendering(chunks, cacheDir, documentId, docParams.split(" "), m_doc->getDocumentProperty(QStringLiteral("previewextension")));
}
}
......@@ -1871,3 +1880,15 @@ void Timeline::loadPreviewRender()
}
}
void Timeline::updatePreviewSettings(const QString &profile)
{
if (profile.isEmpty()) return;
QString params = profile.section(";", 0, 0);
QString ext = profile.section(";", 1, 1);
if (params != m_doc->getDocumentProperty(QStringLiteral("previewparameters")) || ext != m_doc->getDocumentProperty(QStringLiteral("previewextension"))) {
// Timeline preview params changed, delete all existing previews.
invalidateRange(ItemInfo());
m_doc->setDocumentProperty(QStringLiteral("previewparameters"), params);
m_doc->setDocumentProperty(QStringLiteral("previewextension"), ext);
}
}
......@@ -167,6 +167,8 @@ public:
void invalidateRange(ItemInfo info = ItemInfo());
/** @brief Add or remove current timeline zone to preview render zone. */
void addPreviewRange(bool add);
/** @brief Check if timeline preview profile changed and remove preview files if necessary. */
void updatePreviewSettings(const QString &profile);
protected:
void keyPressEvent(QKeyEvent * event);
......
......@@ -6,11 +6,18 @@
<rect>
<x>0</x>
<y>0</y>
<width>430</width>
<width>478</width>
<height>621</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="5" column="0" colspan="3">
<widget class="QCheckBox" name="kcfg_splitaudio">
<property name="text">
<string>Automatically split audio and video</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="4">
<widget class="QGroupBox" name="groupBox">
<property name="title">
......@@ -61,20 +68,6 @@
</layout>
</widget>
</item>
<item row="1" column="0" colspan="4">
<widget class="QCheckBox" name="kcfg_ffmpegaudiothumbnails">
<property name="text">
<string>Use FFmpeg for audio thumbnails (faster)</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="QCheckBox" name="kcfg_showmarkers">
<property name="text">
<string>Display clip markers comments</string>
</property>
</widget>
</item>
<item row="3" column="0" colspan="2">
<widget class="QCheckBox" name="kcfg_autoscroll">
<property name="text">
......@@ -82,68 +75,14 @@
</property>
</widget>
</item>
<item row="4" column="0" colspan="3">
<widget class="QCheckBox" name="kcfg_verticalzoom">
<property name="text">
<string>Zoom using vertical drag in ruler</string>
</property>
</widget>
</item>
<item row="5" column="0" colspan="3">
<widget class="QCheckBox" name="kcfg_splitaudio">
<property name="text">
<string>Automatically split audio and video</string>
</property>
</widget>
</item>
<item row="7" column="0">
<widget class="QLabel" name="label_24">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Timeline preview profile</string>
</property>
</widget>
</item>
<item row="7" column="1">
<widget class="KComboBox" name="kcfg_tl_profile">
<property name="sizePolicy">
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
</widget>
</item>
<item row="7" column="2">
<widget class="QToolButton" name="tl_showprofileinfo">
<property name="text">
<string>...</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item row="7" column="3">
<widget class="QToolButton" name="tl_manageprofile">
<item row="1" column="0" colspan="4">
<widget class="QCheckBox" name="kcfg_ffmpegaudiothumbnails">
<property name="text">