mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-09-20 04:44:43 -04:00
Set default extension when selected filename doesn't have one.
Closes #79
This commit is contained in:
parent
0ea64afe92
commit
98417d6465
3 changed files with 11 additions and 4 deletions
|
@ -330,7 +330,8 @@ bool DatabaseTabWidget::saveDatabaseAs(Database* db)
|
||||||
oldFileName = tr("New database").append(".kdbx");
|
oldFileName = tr("New database").append(".kdbx");
|
||||||
}
|
}
|
||||||
QString fileName = fileDialog()->getSaveFileName(this, tr("Save database as"),
|
QString fileName = fileDialog()->getSaveFileName(this, tr("Save database as"),
|
||||||
oldFileName, tr("KeePass 2 Database").append(" (*.kdbx)"));
|
oldFileName, tr("KeePass 2 Database").append(" (*.kdbx)"),
|
||||||
|
Q_NULLPTR, 0, "kdbx");
|
||||||
if (!fileName.isEmpty()) {
|
if (!fileName.isEmpty()) {
|
||||||
QFileInfo fileInfo(fileName);
|
QFileInfo fileInfo(fileName);
|
||||||
QString lockFilePath;
|
QString lockFilePath;
|
||||||
|
@ -450,7 +451,8 @@ void DatabaseTabWidget::exportToCsv()
|
||||||
}
|
}
|
||||||
|
|
||||||
QString fileName = fileDialog()->getSaveFileName(this, tr("Export database to CSV file"),
|
QString fileName = fileDialog()->getSaveFileName(this, tr("Export database to CSV file"),
|
||||||
QString(), tr("CSV file").append(" (*.csv)"));
|
QString(), tr("CSV file").append(" (*.csv)"),
|
||||||
|
Q_NULLPTR, 0, "csv");
|
||||||
if (fileName.isEmpty()) {
|
if (fileName.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,7 +53,7 @@ QString FileDialog::getOpenFileName(QWidget* parent, const QString& caption, QSt
|
||||||
|
|
||||||
QString FileDialog::getSaveFileName(QWidget* parent, const QString& caption, QString dir,
|
QString FileDialog::getSaveFileName(QWidget* parent, const QString& caption, QString dir,
|
||||||
const QString& filter, QString* selectedFilter,
|
const QString& filter, QString* selectedFilter,
|
||||||
QFileDialog::Options options)
|
QFileDialog::Options options, const QString& defaultExtension)
|
||||||
{
|
{
|
||||||
if (!m_nextFileName.isEmpty()) {
|
if (!m_nextFileName.isEmpty()) {
|
||||||
QString result = m_nextFileName;
|
QString result = m_nextFileName;
|
||||||
|
@ -68,6 +68,10 @@ QString FileDialog::getSaveFileName(QWidget* parent, const QString& caption, QSt
|
||||||
QString result = QFileDialog::getSaveFileName(parent, caption, dir, filter,
|
QString result = QFileDialog::getSaveFileName(parent, caption, dir, filter,
|
||||||
selectedFilter, options);
|
selectedFilter, options);
|
||||||
|
|
||||||
|
if (!defaultExtension.isEmpty() && !result.isEmpty() && !result.contains('.')) {
|
||||||
|
result.append(".").append(defaultExtension);
|
||||||
|
}
|
||||||
|
|
||||||
// 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
|
||||||
if (parent) {
|
if (parent) {
|
||||||
parent->activateWindow();
|
parent->activateWindow();
|
||||||
|
|
|
@ -30,7 +30,8 @@ public:
|
||||||
QString* selectedFilter = Q_NULLPTR, QFileDialog::Options options = 0);
|
QString* selectedFilter = Q_NULLPTR, QFileDialog::Options options = 0);
|
||||||
QString getSaveFileName(QWidget* parent = Q_NULLPTR, const QString& caption = QString(),
|
QString getSaveFileName(QWidget* parent = Q_NULLPTR, const QString& caption = QString(),
|
||||||
QString dir = QString(), const QString& filter = QString(),
|
QString dir = QString(), const QString& filter = QString(),
|
||||||
QString* selectedFilter = Q_NULLPTR, QFileDialog::Options options = 0);
|
QString* selectedFilter = Q_NULLPTR, QFileDialog::Options options = 0,
|
||||||
|
const QString& defaultExtension = QString());
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the result of the next get* method call.
|
* Sets the result of the next get* method call.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue