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

Fix some file dialogs and url handling

parent 6e81478c
......@@ -837,11 +837,10 @@ void KdenliveDoc::setProjectFolder(QUrl url)
{
if (url == m_projectFolder) return;
setModified(true);
QDir dir;
if (!QFileInfo::exists(url.path())) {
dir.mkpath(url.path());
QDir dir(url.toLocalFile());
if (!dir.exists()) {
dir.mkpath(dir.absolutePath());
}
dir.setPath(url.path());
dir.mkdir("titles");
dir.mkdir("thumbs");
dir.mkdir("proxy");
......
......@@ -605,8 +605,9 @@ void Monitor::slotExtractCurrentFrame()
frame = render->extractFrame(render->seekFramePosition(), m_currentClip->fileURL().path());
}
else frame = render->extractFrame(render->seekFramePosition());
QPointer<QFileDialog> fs = new QFileDialog(this, i18n("Save Image"), "kfiledialog:///framefolder", "image/png");
fs->setFileMode(QFileDialog::AnyFile);
QPointer<QFileDialog> fs = new QFileDialog(this, i18n("Save Image"), "");
fs->setMimeTypeFilters(QStringList() << "image/png");
fs->setAcceptMode(QFileDialog::AcceptSave);
if (fs->exec()) {
QStringList path = fs->selectedFiles();
if (!path.isEmpty()) {
......
......@@ -273,11 +273,10 @@ void ClipStabilize::slotValidate()
}
}
else {
QUrl folder(dest_url->url());
QDir folder(dest_url->url().toLocalFile());
QStringList existingFiles;
foreach(const QString &path, m_urls) {
QFileInfo dest(folder.path(), QUrl(path).fileName());
if (QFile::exists(dest.filePath() + ".mlt")) existingFiles.append(dest.filePath() + ".mlt");
if (folder.exists(path + ".mlt")) existingFiles.append(folder.absoluteFilePath(path + ".mlt"));
}
if (!existingFiles.isEmpty()) {
if (KMessageBox::warningContinueCancelList(this, i18n("The stabilize job will overwrite the following files:"), existingFiles) == KMessageBox::Cancel) return;
......
......@@ -91,9 +91,10 @@ SlideshowClip::SlideshowClip(const Timecode &tc, QWidget * parent) :
QStringList customLumas = QStandardPaths::locateAll(QStandardPaths::DataLocation, "lumas");
foreach(const QString & folder, customLumas) {
QStringList filesnames = QDir(folder).entryList(filters, QDir::Files);
QDir directory(folder);
QStringList filesnames = directory.entryList(filters, QDir::Files);
foreach(const QString & fname, filesnames) {
QString filePath = QFileInfo(folder, fname).filePath();
QString filePath = directory.absoluteFilePath(fname);
m_view.luma_file->addItem(QIcon::fromTheme(filePath), fname, filePath);
}
}
......@@ -105,7 +106,7 @@ SlideshowClip::SlideshowClip(const Timecode &tc, QWidget * parent) :
QDir lumafolder(folder);
QStringList filesnames = lumafolder.entryList(filters, QDir::Files);
foreach(const QString & fname, filesnames) {
QString filePath = QFileInfo(folder, fname).filePath();
QString filePath = lumafolder.absoluteFilePath(fname);
m_view.luma_file->addItem(QIcon::fromTheme(filePath), fname, filePath);
}
......
......@@ -1655,9 +1655,9 @@ void ProjectList::slotAddClip(const QList <QUrl> &givenList, const QString &grou
l->addWidget(c);
l->addStretch(5);
f->setLayout(l);
QPointer<QFileDialog> d = new QFileDialog(QApplication::activeWindow(), i18n("Open Clips"), m_doc->getDocumentProperty("QFileDialogClipFolder"), dialogFilter);
QString clipFolder = m_doc->getDocumentProperty("QFileDialogClipFolder");
if (clipFolder.isEmpty()) clipFolder = QDir::homePath();
QPointer<QFileDialog> d = new QFileDialog(QApplication::activeWindow(), i18n("Open Clips"), clipFolder, dialogFilter);
//TODO: KF5, how to add a custom widget to file dialog
/*QGridLayout *layout = (QGridLayout*)d->layout();
layout->addWidget(f, 0, 0);*/
......@@ -1721,8 +1721,7 @@ void ProjectList::slotAddClip(const QList <QUrl> &givenList, const QString &grou
QList <QUrl> folderFiles;
folderFiles << file;
foreach(const QString & path, result) {
QFileInfo f(file.path(), path);
folderFiles.append(QUrl(f.filePath()));
folderFiles.append(QUrl::fromLocalFile(dir.absoluteFilePath(path)));
}
if (folderFiles.count() > 1) foldersList.append(folderFiles);
}
......@@ -2259,11 +2258,12 @@ void ProjectList::slotReplyGetFileProperties(const QString &clipId, Mlt::Produce
else maxSize = m_doc->getDocumentProperty("proxyminsize").toInt();
if ((((t == AV || t == Video || t == Playlist) && generateProxy()) || (t == Image && generateImageProxy())) && (size.section('x', 0, 0).toInt() > maxSize || size.section('x', 1, 1).toInt() > maxSize)) {
if (clip->getProperty("proxy").isEmpty()) {
QFileInfo proxyPath(m_doc->projectFolder().path() + QDir::separator() + "proxy/", clip->getClipHash() + '.' + (t == Image ? "png" : m_doc->getDocumentProperty("proxyextension")));
QDir folder(m_doc->projectFolder().path());
folder.cd("proxy");
QMap <QString, QString> newProps;
// insert required duration for proxy
if (t != Image) newProps.insert("proxy_out", clip->producerProperty("out"));
newProps.insert("proxy", proxyPath.filePath());
newProps.insert("proxy", folder.absoluteFilePath(clip->getClipHash() + '.' + (t == Image ? "png" : m_doc->getDocumentProperty("proxyextension"))));
QMap <QString, QString> oldProps = clip->properties();
oldProps.insert("proxy", QString());
EditClipCommand *command = new EditClipCommand(this, clipId, oldProps, newProps, true);
......
......@@ -260,7 +260,8 @@ void ProjectManager::openFile()
m_startUrl = QUrl();
return;
}
QUrl url = QFileDialog::getOpenFileUrl(QApplication::activeWindow(), QString(), QUrl("kfiledialog:///projectfolder"), getMimeType());
//TODO KF5 set default location to project folder
QUrl url = QFileDialog::getOpenFileUrl(QApplication::activeWindow(), QString(), QUrl(), getMimeType());
if (url.isValid()) {
return;
}
......
......@@ -5428,8 +5428,10 @@ void CustomTrackView::slotSaveClipMarkers(const QString &id)
}
cbox->setCurrentIndex(0);
//TODO KF5 how to ass custom cbox to Qfiledialog
QPointer<QFileDialog> fd = new QFileDialog(this, i18n("Save Clip Markers"), "kfiledialog:///projectfolder", "text/plain");
QPointer<QFileDialog> fd = new QFileDialog(this, i18n("Save Clip Markers"), "");
fd->setMimeTypeFilters(QStringList() << "text/plain");
fd->setFileMode(QFileDialog::AnyFile);
fd->setAcceptMode(QFileDialog::AcceptSave);
if (fd->exec() != QDialog::Accepted) return;
QStringList selection = fd->selectedFiles();
QString url;
......
......@@ -1735,8 +1735,10 @@ void TitleWidget::saveTitle(QUrl url)
embed_image=false;
}
if (!url.isValid()) {
QPointer<QFileDialog> fs = new QFileDialog(this, i18n("Save Title"), m_projectTitlePath, i18n("Kdenlive title (*.kdenlivetitle)"));
QPointer<QFileDialog> fs = new QFileDialog(this, i18n("Save Title"), m_projectTitlePath);
fs->setMimeTypeFilters(QStringList() << "application/x-kdenlivetitle");
fs->setFileMode(QFileDialog::AnyFile);
fs->setAcceptMode(QFileDialog::AcceptSave);
//TODO: KF5 porting?
//fs->setConfirmOverwrite(true);
//fs->setKeepLocation(true);
......
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