Start getting rid of KFileDialog, fix opening project file

parent 510ac1eb
......@@ -27,9 +27,8 @@
#include "kdenlivesettings.h"
#include <QDebug>
#include <QFileDialog>
#include <KIO/NetAccess>
#include <KFileDialog>
#include <KApplication>
#include <KUrlRequesterDialog>
#include <KMessageBox>
......@@ -455,7 +454,7 @@ void DocumentChecker::setProperty(QDomElement effect, const QString &name, const
void DocumentChecker::slotSearchClips()
{
QString newpath = KFileDialog::getExistingDirectory(QUrl("kfiledialog:///clipfolder"), kapp->activeWindow(), i18n("Clips folder"));
QString newpath = QFileDialog::getExistingDirectory(kapp->activeWindow(), i18n("Clips folder"), "kfiledialog:///clipfolder");
if (newpath.isEmpty()) return;
int ix = 0;
bool fixed = false;
......
......@@ -35,12 +35,10 @@
#include "project/notesplugin.h"
#include "project/dialogs/noteswidget.h"
#include <QDebug>
#include <KStandardDirs>
#include <KMessageBox>
#include <KProgressDialog>
#include <KLocalizedString>
#include <KFileDialog>
#include <KIO/NetAccess>
#include <KIO/CopyJob>
#include <KIO/JobUiDelegate>
......@@ -51,6 +49,8 @@
#include <QCryptographicHash>
#include <QFile>
#include <QDebug>
#include <QFileDialog>
#include <QInputDialog>
#include <QDomImplementation>
#include <QUndoGroup>
......@@ -139,9 +139,8 @@ KdenliveDoc::KdenliveDoc(const QUrl &url, const QUrl &projectFolder, QUndoGroup
*openBackup = false;
if (!url.isEmpty()) {
QString tmpFile;
success = KIO::NetAccess::download(url.path(), tmpFile, parent);
if (!success) {
QFile file(url.path());
if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
// The file cannot be opened
if (KMessageBox::warningContinueCancel(parent, i18n("Cannot open the project file, error is:\n%1\nDo you want to open a backup file?", KIO::NetAccess::lastErrorString()), i18n("Error opening file"), KGuiItem(i18n("Open Backup"))) == KMessageBox::Continue) {
*openBackup = true;
......@@ -149,7 +148,6 @@ KdenliveDoc::KdenliveDoc(const QUrl &url, const QUrl &projectFolder, QUndoGroup
//KMessageBox::error(parent, KIO::NetAccess::lastErrorString());
}
else {
QFile file(tmpFile);
QString errorMsg;
int line;
int col;
......@@ -350,7 +348,6 @@ KdenliveDoc::KdenliveDoc(const QUrl &url, const QUrl &projectFolder, QUndoGroup
}
}
}
KIO::NetAccess::removeTempFile(tmpFile);
}
}
......@@ -1115,7 +1112,7 @@ bool KdenliveDoc::addClip(QDomElement elem, const QString &clipId, bool createCl
if (elem.attribute("type").toInt() == SlideShow) {
int res = KMessageBox::questionYesNoCancel(kapp->activeWindow(), i18n("Clip <b>%1</b><br />is invalid or missing, what do you want to do?", path), i18n("File not found"), KGuiItem(i18n("Search manually")), KGuiItem(i18n("Keep as placeholder")));
if (res == KMessageBox::Yes)
newpath = KFileDialog::getExistingDirectory(QUrl("kfiledialog:///clipfolder"), kapp->activeWindow(), i18n("Looking for %1", path));
newpath = QFileDialog::getExistingDirectory(kapp->activeWindow(), i18n("Looking for %1", path), "kfiledialog:///clipfolder");
else {
// Abort project loading
action = res;
......@@ -1123,7 +1120,7 @@ bool KdenliveDoc::addClip(QDomElement elem, const QString &clipId, bool createCl
} else {
int res = KMessageBox::questionYesNoCancel(kapp->activeWindow(), i18n("Clip <b>%1</b><br />is invalid or missing, what do you want to do?", path), i18n("File not found"), KGuiItem(i18n("Search manually")), KGuiItem(i18n("Keep as placeholder")));
if (res == KMessageBox::Yes)
newpath = KFileDialog::getOpenFileName(QUrl("kfiledialog:///clipfolder"), QString(), kapp->activeWindow(), i18n("Looking for %1", path));
newpath = QFileDialog::getOpenFileName(kapp->activeWindow(), i18n("Looking for %1", path), "kfiledialog:///clipfolder");
else {
// Abort project loading
action = res;
......@@ -1132,7 +1129,7 @@ bool KdenliveDoc::addClip(QDomElement elem, const QString &clipId, bool createCl
}
if (action == KMessageBox::Yes) {
//qDebug() << "// ASKED FOR SRCH CLIP: " << clipId;
m_searchFolder = KFileDialog::getExistingDirectory(QUrl("kfiledialog:///clipfolder"), kapp->activeWindow());
m_searchFolder = QFileDialog::getExistingDirectory(kapp->activeWindow(), QString(), "kfiledialog:///clipfolder");
if (!m_searchFolder.isEmpty())
newpath = searchFileRecursively(QDir(m_searchFolder), size, hash);
} else if (action == KMessageBox::Cancel) {
......@@ -1326,7 +1323,7 @@ void KdenliveDoc::slotCreateTextTemplateClip(const QString &group, const QString
{
QString titlesFolder = QDir::cleanPath(projectFolder().path() + QDir::separator() + "titles/");
if (path.isEmpty()) {
path = KFileDialog::getOpenUrl(QUrl(titlesFolder), "application/x-kdenlivetitle", kapp->activeWindow(), i18n("Enter Template Path"));
path = QFileDialog::getOpenFileUrl(kapp->activeWindow(), i18n("Enter Template Path"), QUrl("kfiledialog:///clipfolder"), "application/x-kdenlivetitle");
}
if (path.isEmpty()) return;
......
......@@ -28,13 +28,13 @@
#include <KLocalizedString>
#include <KFileDialog>
#include <kmimetype.h>
#include <KIO/NetAccess>
#include <KMessageBox>
#include <QFile>
#include <QTimer>
#include <QFileDialog>
#include <QDomDocument>
#include <QMenu>
#include <QGridLayout>
......@@ -88,7 +88,6 @@ DvdWizard::DvdWizard(MonitorManager *manager, const QString &url, QWidget *paren
m_status.iso_image->setUrl(QUrl(QDir::homePath() + "/untitled.iso"));
m_status.iso_image->setFilter("*.iso");
m_status.iso_image->setMode(KFile::File);
m_status.iso_image->fileDialog()->setFileMode(QFileDialog::AnyFile);//KFileDialog::Saving);
#if KDE_IS_VERSION(4,7,0)
m_isoMessage = new KMessageWidget;
......@@ -909,7 +908,7 @@ void DvdWizard::slotAbort()
void DvdWizard::slotSave()
{
QUrl url = KFileDialog::getSaveUrl(QUrl("kfiledialog:///projectfolder"), "*.kdvd", this, i18n("Save DVD Project"));
QUrl url = QFileDialog::getSaveFileUrl(this, i18n("Save DVD Project"), QUrl("kfiledialog:///projectfolder"), "*.kdvd");
if (url.isEmpty())
return;
......@@ -946,7 +945,7 @@ void DvdWizard::slotSave()
void DvdWizard::slotLoad()
{
const QUrl url = KFileDialog::getOpenUrl(QUrl("kfiledialog:///projectfolder"), "*.kdvd");
const QUrl url = QFileDialog::getOpenFileUrl(this, QString(), QUrl("kfiledialog:///projectfolder"), "*.kdvd");
if (url.isEmpty())
return;
QDomDocument doc;
......
......@@ -26,11 +26,11 @@
#include <QDebug>
#include <KFileDialog>
#include <KGlobal>
#include <KConfigGroup>
#include <kio/global.h>
#include <QFileDialog>
#include <QHBoxLayout>
#include <QDomDocument>
#include <QTreeWidgetItem>
......@@ -185,7 +185,7 @@ void DvdWizardVob::slotAddVobList(const QList<QUrl> &list)
void DvdWizardVob::slotAddVobFile(QUrl url, const QString &chapters, bool checkFormats)
{
if (url.isEmpty()) url = KFileDialog::getOpenUrl(QUrl("kfiledialog:///projectfolder"), "video/mpeg", this, i18n("Add new video file"));
if (url.isEmpty()) url = QFileDialog::getOpenFileUrl(this, i18n("Add new video file"), QUrl("kfiledialog:///projectfolder"), "video/mpeg");
if (url.isEmpty()) return;
QFile f(url.path());
qint64 fileSize = f.size();
......
......@@ -32,13 +32,12 @@
#include <QWheelEvent>
#include <QMimeData>
#include <QFontDatabase>
#include <QFileDialog>
#include <QDebug>
#include <KComboBox>
#include <KComboBox>
#include <KLocalizedString>
#include <KMessageBox>
#include <KFileDialog>
#include <KApplication>
......@@ -159,12 +158,10 @@ void CollapsibleEffect::slotCreateRegion()
{
QString allExtensions = ProjectList::getExtensions().join(" ");
const QString dialogFilter = allExtensions + ' ' + QLatin1Char('|') + i18n("All Supported Files") + "\n* " + QLatin1Char('|') + i18n("All Files");
QPointer<KFileDialog> d = new KFileDialog(QUrl("kfiledialog:///clipfolder"), dialogFilter, kapp->activeWindow());
d->setOperationMode(KFileDialog::Opening);
d->setMode(KFile::File);
if (d->exec() == QDialog::Accepted) {
QUrl url = d->selectedUrl();
if (!url.isEmpty()) emit createRegion(effectIndex(), url);
QPointer<QFileDialog> d = new QFileDialog(kapp->activeWindow(), QString(), "kfiledialog:///clipfolder", dialogFilter);
d->setFileMode(QFileDialog::ExistingFile);
if (d->exec() == QDialog::Accepted && !d->selectedUrls().isEmpty()) {
emit createRegion(effectIndex(), d->selectedUrls().first());
}
delete d;
}
......
......@@ -68,7 +68,6 @@
#include <KActionMenu>
#include <KStandardAction>
#include <KShortcutsDialog>
#include <KFileDialog>
#include <KMessageBox>
#include <QDebug>
#include <KIO/NetAccess>
......@@ -97,6 +96,7 @@
#include <QDesktopWidget>
#include <QBitmap>
#include <QUndoGroup>
#include <QFileDialog>
#include <stdlib.h>
#include <QStandardPaths>
......@@ -2712,7 +2712,7 @@ void MainWindow::slotTranscode(const QList<QUrl> &urls)
void MainWindow::slotTranscodeClip()
{
QList<QUrl> urls = KFileDialog::getOpenUrls(QUrl("kfiledialog:///projectfolder"));
QList<QUrl> urls = QFileDialog::getOpenFileUrls(this, i18n("Files to transcode"), QUrl("kfiledialog:///projectfolder"));
if (urls.isEmpty()) return;
slotTranscode(urls);
}
......@@ -2739,7 +2739,7 @@ void MainWindow::slotPrepareRendering(bool scriptExport, bool zoneOnly, const QS
//QString scriptsFolder = project->projectFolder().path(QUrl::AddTrailingSlash) + "scripts/";
QString path = m_renderWidget->getFreeScriptName(project->url());
QPointer<KUrlRequesterDialog> getUrl = new KUrlRequesterDialog(path, i18n("Create Render Script"), this);
getUrl->fileDialog()->setFileMode(QFileDialog::AnyFile);
getUrl->urlRequester()->setMode(KFile::File);
if (getUrl->exec() == QDialog::Rejected) {
delete getUrl;
return;
......@@ -2968,47 +2968,6 @@ void MainWindow::slotChangePalette(QAction *action)
}
}
QPixmap MainWindow::createSchemePreviewIcon(const KSharedConfigPtr &config)
{
// code taken from kdebase/workspace/kcontrol/colors/colorscm.cpp
const uchar bits1[] = { 0xff, 0xff, 0xff, 0x2c, 0x16, 0x0b };
const uchar bits2[] = { 0x68, 0x34, 0x1a, 0xff, 0xff, 0xff };
const QSize bitsSize(24, 2);
const QBitmap b1 = QBitmap::fromData(bitsSize, bits1);
const QBitmap b2 = QBitmap::fromData(bitsSize, bits2);
QPixmap pixmap(23, 16);
pixmap.fill(Qt::black); // ### use some color other than black for borders?
KConfigGroup group(config, "WM");
QPainter p(&pixmap);
KColorScheme windowScheme(QPalette::Active, KColorScheme::Window, config);
p.fillRect(1, 1, 7, 7, windowScheme.background());
p.fillRect(2, 2, 5, 2, QBrush(windowScheme.foreground().color(), b1));
KColorScheme buttonScheme(QPalette::Active, KColorScheme::Button, config);
p.fillRect(8, 1, 7, 7, buttonScheme.background());
p.fillRect(9, 2, 5, 2, QBrush(buttonScheme.foreground().color(), b1));
p.fillRect(15, 1, 7, 7, group.readEntry("activeBackground", QColor(96, 148, 207)));
p.fillRect(16, 2, 5, 2, QBrush(group.readEntry("activeForeground", QColor(255, 255, 255)), b1));
KColorScheme viewScheme(QPalette::Active, KColorScheme::View, config);
p.fillRect(1, 8, 7, 7, viewScheme.background());
p.fillRect(2, 12, 5, 2, QBrush(viewScheme.foreground().color(), b2));
KColorScheme selectionScheme(QPalette::Active, KColorScheme::Selection, config);
p.fillRect(8, 8, 7, 7, selectionScheme.background());
p.fillRect(9, 12, 5, 2, QBrush(selectionScheme.foreground().color(), b2));
p.fillRect(15, 8, 7, 7, group.readEntry("inactiveBackground", QColor(224, 223, 222)));
p.fillRect(16, 12, 5, 2, QBrush(group.readEntry("inactiveForeground", QColor(20, 19, 18)), b2));
p.end();
return pixmap;
}
void MainWindow::slotSwitchMonitors()
{
pCore->monitorManager()->slotSwitchMonitors(!m_clipMonitor->isActive());
......@@ -3139,7 +3098,7 @@ void MainWindow::slotSaveTimelineClip()
m_messageLabel->setMessage(i18n("Select a clip to save"), InformationMessage);
return;
}
QUrl url = KFileDialog::getSaveUrl(pCore->projectManager()->current()->projectFolder(), "video/mlt-playlist");
QUrl url = QFileDialog::getSaveFileUrl(this, i18n("Save clip"), pCore->projectManager()->current()->projectFolder(), "video/mlt-playlist");
if (!url.isEmpty()) {
m_projectMonitor->render->saveClip(pCore->projectManager()->current()->tracksCount() - clip->track(), clip->startPos(), url);
}
......
......@@ -246,7 +246,6 @@ private:
QByteArray m_timelineState;
void loadTranscoders();
void loadClipActions();
QPixmap createSchemePreviewIcon(const KSharedConfigPtr &config);
QTime m_timer;
/** @brief The last selected clip in timeline. */
......
......@@ -31,7 +31,6 @@
#include <QDebug>
#include <KLocalizedString>
#include <KFileDialog>
#include <QMouseEvent>
#include <QMenu>
......@@ -42,6 +41,7 @@
#include <QVBoxLayout>
#include <QSlider>
#include <QDrag>
#include <QFileDialog>
#include <QMimeData>
#define SEEK_INACTIVE (-1)
......@@ -605,15 +605,12 @@ void Monitor::slotExtractCurrentFrame()
frame = render->extractFrame(render->seekFramePosition(), m_currentClip->fileURL().path());
}
else frame = render->extractFrame(render->seekFramePosition());
QPointer<KFileDialog> fs = new KFileDialog(QUrl(), "image/png", this);
fs->setOperationMode(KFileDialog::Saving);
fs->setMode(KFile::File);
fs->setConfirmOverwrite(true);
fs->setKeepLocation(true);
QPointer<QFileDialog> fs = new QFileDialog(this, i18n("Save Image"), "kfiledialog:///framefolder", "image/png");
fs->setFileMode(QFileDialog::AnyFile);
if (fs->exec()) {
QString path = fs->selectedFile();
QStringList path = fs->selectedFiles();
if (!path.isEmpty()) {
frame.save(path);
frame.save(path.first());
}
}
delete fs;
......
......@@ -28,7 +28,6 @@
#include <QDebug>
#include <KFileItem>
#include <KFileDialog>
#include <kdeversion.h>
#include <KRun>
#include <QFontDatabase>
......@@ -54,7 +53,7 @@
#include <QPainter>
#include <QFileDialog>
#include <QStandardPaths>
#include <QFileDialog>
static const int VIDEOTAB = 0;
static const int AUDIOTAB = 1;
......
......@@ -28,7 +28,6 @@
#include <QFontDatabase>
#include <KMessageBox>
#include <KColorScheme>
#include <KFileDialog>
ClipStabilize::ClipStabilize(const QStringList &urls, const QString &filterName,QWidget * parent) :
QDialog(parent),
......@@ -64,13 +63,10 @@ ClipStabilize::ClipStabilize(const QStringList &urls, const QString &filterName,
QUrl dest(newFile);
dest_url->setMode(KFile::File);
dest_url->setUrl(QUrl(newFile));
dest_url->fileDialog()->setFileMode(QFileDialog::AnyFile); //setOperationMode(KFileDialog::Saving);
} else {
label_dest->setText(i18n("Destination folder"));
dest_url->setMode(KFile::Directory);
dest_url->setMode(KFile::Directory | KFile::ExistingOnly);
dest_url->setUrl(QUrl(m_urls.first()).adjusted(QUrl::RemoveFilename));
dest_url->fileDialog()->setFileMode(QFileDialog::Directory); //OperationMode(KFileDialog::Saving);
}
if (m_filtername=="vidstab"){
......
......@@ -30,7 +30,6 @@
#include <QDebug>
#include <kio/directorysizejob.h>
#include <KIO/NetAccess>
#include <KFileDialog>
#include <KStandardDirs>
#include <QTemporaryFile>
......
......@@ -17,6 +17,7 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
***************************************************************************/
#include "core.h"
#include "projectlist.h"
#include "projectitem.h"
#include "projectcommands.h"
......@@ -46,7 +47,6 @@
#include <QDebug>
#include <KLocalizedString>
#include <KFileDialog>
#include <KMessageBox>
#include <KIO/NetAccess>
#include <KFileItem>
......@@ -81,6 +81,7 @@
#include <QHeaderView>
#include <QVBoxLayout>
#include <QtConcurrent>
#include <QFileDialog>
MyMessageWidget::MyMessageWidget(QWidget *parent) : KMessageWidget(parent) {}
MyMessageWidget::MyMessageWidget(const QString &text, QWidget *parent) : KMessageWidget(text, parent) {}
......@@ -1710,20 +1711,24 @@ void ProjectList::slotAddClip(const QList <QUrl> &givenList, const QString &grou
b->setChecked(KdenliveSettings::autoimagesequence());
QCheckBox *c = new QCheckBox(i18n("Transparent background for images"));
c->setChecked(KdenliveSettings::autoimagetransparency());
QFrame *f = new QFrame;
QFrame *f = new QFrame();
f->setFrameShape(QFrame::NoFrame);
QHBoxLayout *l = new QHBoxLayout;
l->addWidget(b);
l->addWidget(c);
l->addStretch(5);
f->setLayout(l);
QPointer<KFileDialog> d = new KFileDialog(QUrl("kfiledialog:///clipfolder"), dialogFilter, kapp->activeWindow(), f);
d->setOperationMode(KFileDialog::Opening);
d->setMode(KFile::Files);
QPointer<QFileDialog> d = new QFileDialog(kapp->activeWindow(), i18n("Open Clips"), m_doc->getDocumentProperty("QFileDialogClipFolder"), dialogFilter);
//TODO: KF5, how to add a custom widget to file dialog
/*QGridLayout *layout = (QGridLayout*)d->layout();
layout->addWidget(f, 0, 0);*/
d->setFileMode(QFileDialog::ExistingFiles);
if (d->exec() == QDialog::Accepted) {
KdenliveSettings::setAutoimagetransparency(c->isChecked());
list = d->selectedUrls();
if (!list.isEmpty()) m_doc->setDocumentProperty("QFileDialogClipFolder", list.first().adjusted(QUrl::RemoveFilename).path());
if (b->isChecked() && list.count() == 1) {
// Check for image sequence
QUrl url = list.at(0);
......@@ -1976,7 +1981,7 @@ void ProjectList::slotAddTitleTemplateClip()
mimeTypeFilters <<"application/x-kdenlivetitle";
dia_ui.template_list->fileDialog()->setMimeTypeFilters(mimeTypeFilters);
//warning: setting base directory doesn't work??
dia_ui.template_list->fileDialog()->setDirectory(path);
dia_ui.template_list->setPath(path);
dia_ui.text_box->setHidden(true);
if (dia->exec() == QDialog::Accepted) {
QString textTemplate = dia_ui.template_list->comboBox()->itemData(dia_ui.template_list->comboBox()->currentIndex()).toString();
......
......@@ -54,7 +54,6 @@ public:
void doOpenFile(const QUrl &url, KAutoSaveFile *stale);
void recoverFiles(const QList<KAutoSaveFile *> &staleFiles, const QUrl &originUrl);
KRecentFilesAction *recentFilesAction();
public slots:
......
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