-#ifdef USE_NATIVE_FILEDIALOG
- docstring const startsWith = from_utf8(
- makeAbsPath(to_utf8(suggested), to_utf8(path)).absFilename());
- result.second = from_utf8(internal_path(fromqstr(
- QFileDialog::getSaveFileName(qApp->focusWidget(),
- toqstr(title_), toqstr(startsWith), toqstr(filters.as_string()) ))));
-#else
- LyXFileDialog dlg(title_, path, filters, private_->b1, private_->b2);
-#if QT_VERSION != 0x040203
- dlg.setFileMode(QFileDialog::AnyFile);
-#endif
- dlg.setAcceptMode(QFileDialog::AcceptSave);
- dlg.setConfirmOverwrite(false);
-
- if (!suggested.empty())
- dlg.selectFile(toqstr(suggested));
-
- LYXERR(Debug::GUI) << "Synchronous FileDialog: " << endl;
- int res = dlg.exec();
- LYXERR(Debug::GUI) << "result " << res << endl;
- if (res == QDialog::Accepted)
- result.second = from_utf8(internal_path(
- fromqstr(dlg.selectedFiles()[0])));
- dlg.hide();
-#endif
+ if (lyxrc.use_native_filedialog) {
+ QString const startsWith = makeAbsPath(suggested, path);
+ QString const name =
+ QFileDialog::getSaveFileName(qApp->focusWidget(),
+ title_, startsWith, filters.join(";;"),
+ selectedFilter, QFileDialog::DontConfirmOverwrite);
+ if (name.isNull())
+ result.first = FileDialog::Later;
+ else
+ result.second = toqstr(os::internal_path(fromqstr(name)));
+ } else {
+ LyXFileDialog dlg(title_, path, filters, private_->b1, private_->b2);
+ dlg.setFileMode(QFileDialog::AnyFile);
+ dlg.setAcceptMode(QFileDialog::AcceptSave);
+ dlg.setConfirmOverwrite(false);
+ if (selectedFilter != 0 && !selectedFilter->isEmpty())
+ dlg.selectNameFilter(*selectedFilter);
+
+ if (!suggested.isEmpty())
+ dlg.selectFile(suggested);
+
+ LYXERR(Debug::GUI, "Synchronous FileDialog: ");
+ int res = dlg.exec();
+ LYXERR(Debug::GUI, "result " << res);
+ if (res == QDialog::Accepted)
+ result.second = internalPath(dlg.selectedFiles()[0]);
+ else
+ result.first = FileDialog::Later;
+ if (selectedFilter != 0)
+ *selectedFilter = dlg.selectedNameFilter();
+ dlg.hide();
+ }