Correctly restore window focus for file dialogs

This commit is contained in:
GriffinR
2024-10-09 12:35:12 -04:00
parent 931b471cf1
commit 1ed9b1ee10
16 changed files with 134 additions and 91 deletions

View File

@@ -2,6 +2,7 @@
#include "config.h"
#include "noscrollcombobox.h"
#include "prefab.h"
#include "filedialog.h"
#include <QAbstractButton>
#include <QFormLayout>
@@ -383,10 +384,10 @@ QString ProjectSettingsEditor::chooseProjectFile(const QString &defaultFilepath)
QString path;
if (defaultFilepath.endsWith("/")){
// Default filepath is a folder, choose a new folder
path = QFileDialog::getExistingDirectory(this, "Choose Project File Folder", startDir) + QDir::separator();
path = FileDialog::getExistingDirectory(this, "Choose Project File Folder", startDir) + QDir::separator();
} else{
// Default filepath is not a folder, choose a new file
path = QFileDialog::getOpenFileName(this, "Choose Project File", startDir);
path = FileDialog::getOpenFileName(this, "Choose Project File", startDir);
}
if (!path.startsWith(this->baseDir)){
@@ -573,10 +574,9 @@ void ProjectSettingsEditor::chooseImageFile(QLineEdit * filepathEdit) {
}
void ProjectSettingsEditor::chooseFile(QLineEdit * filepathEdit, const QString &description, const QString &extensions) {
QString filepath = QFileDialog::getOpenFileName(this, description, this->project->importExportPath, extensions);
QString filepath = FileDialog::getOpenFileName(this, description, "", extensions);
if (filepath.isEmpty())
return;
this->project->setImportExportPath(filepath);
if (filepathEdit)
filepathEdit->setText(this->stripProjectDir(filepath));