mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-01-27 06:47:02 -05:00
Improve setting the default file extension in FileDialog.
Largely from PR #105 by Charles Brunet <charles@cbrunet.net>
This commit is contained in:
parent
d83fee89bd
commit
e75efb8bfb
@ -65,11 +65,22 @@ QString FileDialog::getSaveFileName(QWidget* parent, const QString& caption, QSt
|
|||||||
dir = config()->get("LastDir").toString();
|
dir = config()->get("LastDir").toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString result = QFileDialog::getSaveFileName(parent, caption, dir, filter,
|
QFileDialog dialog(parent, caption, dir, filter);
|
||||||
selectedFilter, options);
|
dialog.setAcceptMode(QFileDialog::AcceptSave);
|
||||||
|
dialog.setFileMode(QFileDialog::AnyFile);
|
||||||
|
if (selectedFilter) {
|
||||||
|
dialog.selectNameFilter(*selectedFilter);
|
||||||
|
}
|
||||||
|
dialog.setOptions(options);
|
||||||
|
dialog.setDefaultSuffix(defaultExtension);
|
||||||
|
|
||||||
if (!defaultExtension.isEmpty() && !result.isEmpty() && !result.contains('.')) {
|
QString result;
|
||||||
result.append(".").append(defaultExtension);
|
QStringList results;
|
||||||
|
if (dialog.exec()) {
|
||||||
|
results = dialog.selectedFiles();
|
||||||
|
if (!results.isEmpty()) {
|
||||||
|
result = results[0];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// on Mac OS X the focus is lost after closing the native dialog
|
// on Mac OS X the focus is lost after closing the native dialog
|
||||||
|
Loading…
x
Reference in New Issue
Block a user