Commit bc0aea92 authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle

Merge branch 'red' into 'master'

file dialog fixes

See merge request !73
parents 6606ae8c b035ef57
Pipeline #13375 passed with stage
in 14 minutes and 29 seconds
......@@ -109,6 +109,18 @@ QStringList ClipCreationDialog::getExtensions()
return allExtensions;
}
QString ClipCreationDialog::getExtensionsFilter(const QStringList& additionalFilters)
{
const QString allExtensions = ClipCreationDialog::getExtensions().join(QLatin1Char(' '));
QString filter = i18n("All Supported Files") + " (" + allExtensions + ')';
if (!additionalFilters.isEmpty()) {
filter += ";;";
filter.append(additionalFilters.join(";;"));
}
return filter;
}
// static
void ClipCreationDialog::createColorClip(KdenliveDoc *doc, const QString &parentFolder, std::shared_ptr<ProjectItemModel> model)
{
......
......@@ -38,6 +38,7 @@ class ProjectItemModel;
namespace ClipCreationDialog {
QStringList getExtensions();
QString getExtensionsFilter(const QStringList& additionalFilters = QStringList());
void createColorClip(KdenliveDoc *doc, const QString &parentFolder, std::shared_ptr<ProjectItemModel> model);
void createQTextClip(KdenliveDoc *doc, const QString &parentId, Bin *bin, ProjectClip *clip = nullptr);
void createSlideshowClip(KdenliveDoc *doc, const QString &parentId, std::shared_ptr<ProjectItemModel> model);
......
......@@ -62,7 +62,7 @@ TitleTemplateDialog::TitleTemplateDialog(const QString &folder, QWidget *parent)
m_view.template_list->comboBox()->setCurrentIndex(current);
}
const QStringList mimeTypeFilters = {QStringLiteral("application/x-kdenlivetitle")};
m_view.template_list->setFilter(mimeTypeFilters.join(' '));
m_view.template_list->setMimeTypeFilters(mimeTypeFilters);
connect(m_view.template_list->comboBox(), static_cast<void (KComboBox::*)(int)>(&KComboBox::currentIndexChanged), this,
&TitleTemplateDialog::updatePreview);
updatePreview();
......
......@@ -468,7 +468,7 @@ void DvdWizardMenu::checkBackgroundType(int ix)
m_scene->removeItem(m_background);
}
m_view.background_image->clear();
m_view.background_image->setFilter(QStringLiteral("video/mpeg"));
m_view.background_image->setMimeTypeFilters({QStringLiteral("video/mpeg")});
m_view.loop_movie->setVisible(true);
}
}
......
......@@ -265,9 +265,8 @@ void DvdWizardVob::slotCheckProfiles()
void DvdWizardVob::slotAddVobList(QList<QUrl> list)
{
if (list.isEmpty()) {
QString allExtensions = ClipCreationDialog::getExtensions().join(QLatin1Char(' '));
QString dialogFilter = i18n("All Supported Files") + QStringLiteral(" (") + allExtensions + QStringLiteral(");; ") + i18n("MPEG Files") +
QStringLiteral(" (*.mpeg *.mpg *.vob);; ") + i18n("All Files") + QStringLiteral(" (*.*)");
auto extraFilters = QStringList() << i18n("MPEG Files") + QStringLiteral(" (*.mpeg *.mpg *.vob)") << i18n("All Files") + QStringLiteral(" (*.*)");
const QString dialogFilter = ClipCreationDialog::getExtensionsFilter(extraFilters);
list = QFileDialog::getOpenFileUrls(this, i18n("Add new video file"), QUrl::fromLocalFile(KRecentDirs::dir(QStringLiteral(":KdenliveDvdFolder"))),
dialogFilter);
if (!list.isEmpty()) {
......
......@@ -240,9 +240,7 @@ void CollapsibleEffectView::slotCreateGroup()
void CollapsibleEffectView::slotCreateRegion()
{
QString allExtensions = ClipCreationDialog::getExtensions().join(QLatin1Char(' '));
const QString dialogFilter =
allExtensions + QLatin1Char(' ') + QLatin1Char('|') + i18n("All Supported Files") + QStringLiteral("\n* ") + QLatin1Char('|') + i18n("All Files");
const QString dialogFilter = ClipCreationDialog::getExtensionsFilter(QStringList() << i18n("All Files") + QStringLiteral(" (*)"));
QString clipFolder = KRecentDirs::dir(QStringLiteral(":KdenliveClipFolder"));
if (clipFolder.isEmpty()) {
clipFolder = QDir::homePath();
......
......@@ -3264,9 +3264,7 @@ void MainWindow::slotTranscode(const QStringList &urls)
void MainWindow::slotTranscodeClip()
{
QString allExtensions = ClipCreationDialog::getExtensions().join(QLatin1Char(' '));
const QString dialogFilter =
i18n("All Supported Files") + QLatin1Char('(') + allExtensions + QStringLiteral(");;") + i18n("All Files") + QStringLiteral("(*)");
const QString dialogFilter = ClipCreationDialog::getExtensionsFilter(QStringList() << i18n("All Files") + QStringLiteral(" (*)"));
QString clipFolder = KRecentDirs::dir(QStringLiteral(":KdenliveClipFolder"));
QStringList urls = QFileDialog::getOpenFileNames(this, i18n("Files to transcode"), clipFolder, dialogFilter);
if (urls.isEmpty()) {
......
......@@ -1115,7 +1115,7 @@ void ClipPropertiesController::slotAddMarker()
void ClipPropertiesController::slotSaveMarkers()
{
QScopedPointer<QFileDialog> fd(new QFileDialog(this, i18n("Save Clip Markers"), pCore->projectManager()->current()->projectDataFolder()));
fd->setMimeTypeFilters(QStringList() << QStringLiteral("text/plain"));
fd->setMimeTypeFilters(QStringList() << QStringLiteral("application/json") << QStringLiteral("text/plain"));
fd->setFileMode(QFileDialog::AnyFile);
fd->setAcceptMode(QFileDialog::AcceptSave);
if (fd->exec() != QDialog::Accepted) {
......@@ -1141,7 +1141,7 @@ void ClipPropertiesController::slotSaveMarkers()
void ClipPropertiesController::slotLoadMarkers()
{
QScopedPointer<QFileDialog> fd(new QFileDialog(this, i18n("Load Clip Markers"), pCore->projectManager()->current()->projectDataFolder()));
fd->setMimeTypeFilters(QStringList() << QStringLiteral("text/plain"));
fd->setMimeTypeFilters(QStringList() << QStringLiteral("application/json") << QStringLiteral("text/plain"));
fd->setFileMode(QFileDialog::ExistingFile);
if (fd->exec() != QDialog::Accepted) {
return;
......
......@@ -642,10 +642,12 @@ QStringList ProjectSettings::extractSlideshowUrls(const QString &url)
void ProjectSettings::slotExportToText()
{
const QString savePath = QFileDialog::getSaveFileName(this, QString(), project_folder->url().toLocalFile(), QStringLiteral("text/plain"));
if (savePath.isEmpty()) {
return;
}
QFileDialog fd(this);
fd.setMimeTypeFilters(QStringList() << "text/plain");
if (fd.exec() != QDialog::Accepted) { return; }
const QString savePath = fd.selectedFiles().first();
QString text;
text.append(i18n("Project folder: %1", project_folder->url().toLocalFile()) + '\n');
text.append(i18n("Project profile: %1", m_pw->selectedProfile()) + '\n');
......
......@@ -52,6 +52,15 @@ the Free Software Foundation, either version 3 of the License, or
#include <QTimeZone>
#include <audiomixer/mixermanager.hpp>
static QString getProjectNameFilters(bool ark=true) {
auto filter = i18n("Kdenlive project (*.kdenlive)");
if (ark) {
filter.append(";;" + i18n("Archived project (*.tar.gz)"));
}
return filter;
}
ProjectManager::ProjectManager(QObject *parent)
: QObject(parent)
, m_mainTimelineModel(nullptr)
......@@ -342,13 +351,14 @@ bool ProjectManager::saveFileAs()
{
QFileDialog fd(pCore->window());
fd.setDirectory(m_project->url().isValid() ? m_project->url().adjusted(QUrl::RemoveFilename).toLocalFile() : KdenliveSettings::defaultprojectfolder());
fd.setMimeTypeFilters(QStringList() << QStringLiteral("application/x-kdenlive"));
fd.setNameFilter(getProjectNameFilters(false));
fd.setAcceptMode(QFileDialog::AcceptSave);
fd.setFileMode(QFileDialog::AnyFile);
fd.setDefaultSuffix(QStringLiteral("kdenlive"));
if (fd.exec() != QDialog::Accepted || fd.selectedFiles().isEmpty()) {
return false;
}
QString outputFile = fd.selectedFiles().constFirst();
bool ok = false;
......@@ -384,7 +394,7 @@ void ProjectManager::openFile()
return;
}
QUrl url = QFileDialog::getOpenFileUrl(pCore->window(), QString(), QUrl::fromLocalFile(KRecentDirs::dir(QStringLiteral(":KdenliveProjectsFolder"))),
getMimeType());
getProjectNameFilters());
if (!url.isValid()) {
return;
}
......@@ -576,15 +586,6 @@ void ProjectManager::slotRevert()
}
}
QString ProjectManager::getMimeType(bool open)
{
QString mimetype = i18n("Kdenlive project (*.kdenlive)");
if (open) {
mimetype.append(QStringLiteral(";;") + i18n("Archived project (*.tar.gz)"));
}
return mimetype;
}
KdenliveDoc *ProjectManager::current()
{
return m_project;
......
......@@ -174,10 +174,6 @@ protected:
bool updateTimeline(int pos = -1, int scrollPos = -1);
private:
/** @brief Checks that the Kdenlive MIME type is correctly installed.
* @param open If set to true, this will return the MIME type allowed for file opening (adds .tar.gz format)
* @return The MIME type */
QString getMimeType(bool open = true);
/** @brief checks if autoback files exists, recovers from it if user says yes, returns true if files were recovered. */
bool checkForBackupFile(const QUrl &url, bool newFile = false);
......
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