Commit 32eb74e4 authored by Halla Rempt's avatar Halla Rempt
Browse files

Better fix for the file dialog default location

Only allow setting the default dir if it's empty.
parent b399c504
......@@ -799,6 +799,7 @@ void KisMainWindow::addViewAndNotifyLoadingCompleted(KisDocument *document)
QStringList KisMainWindow::showOpenFileDialog()
{
KoFileDialog dialog(this, KoFileDialog::ImportFiles, "OpenDocument");
dialog.setDefaultDir(QDesktopServices::storageLocation(QDesktopServices::PicturesLocation));
dialog.setMimeTypeFilters(KisImportExportManager::mimeFilter(KisImportExportManager::Import));
dialog.setCaption(d->isImporting ? i18n("Import Images") : i18n("Open Images"));
......@@ -953,7 +954,7 @@ bool KisMainWindow::saveDocument(KisDocument *document, bool saveas)
// don't want to be reminded about overwriting files etc.
bool justChangingFilterOptions = false;
KoFileDialog dialog(this, KoFileDialog::SaveFile, "SaveDocument");
KoFileDialog dialog(this, KoFileDialog::SaveFile, "OpenDocument");
dialog.setCaption(i18n("untitled"));
if (d->isExporting && !d->lastExportUrl.isEmpty()) {
dialog.setDefaultDir(d->lastExportUrl.toLocalFile());
......@@ -1551,7 +1552,7 @@ KisPrintJob* KisMainWindow::exportToPdf(QString pdfFileName)
pageLayout = layoutDlg->pageLayout();
delete layoutDlg;
KoFileDialog dialog(this, KoFileDialog::SaveFile, "SaveDocument");
KoFileDialog dialog(this, KoFileDialog::SaveFile, "OpenDocument");
dialog.setCaption(i18n("Export as PDF"));
dialog.setDefaultDir(startUrl.toLocalFile());
dialog.setMimeTypeFilters(QStringList() << "application/pdf");
......
......@@ -85,13 +85,11 @@ void KoFileDialog::setCaption(const QString &caption)
void KoFileDialog::setDefaultDir(const QString &defaultDir)
{
QFileInfo f(defaultDir);
d->defaultDirectory = f.absoluteFilePath();
}
void KoFileDialog::setOverrideDir(const QString &overrideDir)
{
d->defaultDirectory = overrideDir;
//qDebug() << d->defaultDirectory << d->dialogName << getUsedDir(d->dialogName);
if (d->defaultDirectory.isEmpty()) {
QFileInfo f(defaultDir);
d->defaultDirectory = f.absoluteFilePath();
}
}
void KoFileDialog::setImageFilters()
......@@ -381,7 +379,7 @@ QString KoFileDialog::getUsedDir(const QString &dialogName)
if (dialogName.isEmpty()) return "";
KConfigGroup group = KSharedConfig::openConfig()->group("File Dialogs");
QString dir = group.readEntry(dialogName);
QString dir = group.readEntry(dialogName, "");
return dir;
}
......
......@@ -72,12 +72,6 @@ public:
*/
void setDefaultDir(const QString &defaultDir);
/**
* @brief setOverrideDir override both the default dir and the saved dir found by dialogName
* @param overrideDir a path to a file or directory
*/
void setOverrideDir(const QString &overrideDir);
/**
* @brief setImageFilters sets the name filters for the file dialog to all
* image formats Qt's QImageReader supports.
......
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