diff options
author | hjk <[email protected]> | 2021-08-11 09:01:53 +0200 |
---|---|---|
committer | hjk <[email protected]> | 2021-08-17 12:54:08 +0000 |
commit | 8885ef7e5aa66bc1a4e9541c46d90a46bdeca1b3 (patch) | |
tree | 7c5903139aa68627531d7fdbc7fc2cfe6d7b4bd6 /src/libs/utils/fileutils.cpp | |
parent | 7726267d071cb0c3d6dfad8ee4d1551140fcb06a (diff) |
Utils: Pass dialog parent to Utils::* file dialog
Amends 3edc5673b58e55.
Turns out quite a few potential uses have other parents than
ICore::dialogParent().
Use a nullptr parent to mean ICore::dialogParent() to keep the
caller side simple.
Change-Id: Icfe1daafd710ae273d286679e0c8e2a3a27da552
Reviewed-by: Christian Stenger <[email protected]>
Diffstat (limited to 'src/libs/utils/fileutils.cpp')
-rw-r--r-- | src/libs/utils/fileutils.cpp | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/src/libs/utils/fileutils.cpp b/src/libs/utils/fileutils.cpp index 589d3f307c3..60a2d6e62fa 100644 --- a/src/libs/utils/fileutils.cpp +++ b/src/libs/utils/fileutils.cpp @@ -429,18 +429,19 @@ void FileUtils::setDialogParentGetter(const std::function<QWidget *()> &getter) s_dialogParentGetter = getter; } -static QWidget *dialogParent() +static QWidget *dialogParent(QWidget *parent) { - return s_dialogParentGetter ? s_dialogParentGetter() : nullptr; + return parent ? parent : s_dialogParentGetter ? s_dialogParentGetter() : nullptr; } -FilePath FileUtils::getOpenFilePath(const QString &caption, +FilePath FileUtils::getOpenFilePath(QWidget *parent, + const QString &caption, const FilePath &dir, const QString &filter, QString *selectedFilter, QFileDialog::Options options) { - const QString result = QFileDialog::getOpenFileName(dialogParent(), + const QString result = QFileDialog::getOpenFileName(dialogParent(parent), caption, dir.toString(), filter, @@ -449,13 +450,14 @@ FilePath FileUtils::getOpenFilePath(const QString &caption, return FilePath::fromString(result); } -FilePath FileUtils::getSaveFilePath(const QString &caption, - const FilePath &dir, - const QString &filter, - QString *selectedFilter, - QFileDialog::Options options) +FilePath FileUtils::getSaveFilePath(QWidget *parent, + const QString &caption, + const FilePath &dir, + const QString &filter, + QString *selectedFilter, + QFileDialog::Options options) { - const QString result = QFileDialog::getSaveFileName(dialogParent(), + const QString result = QFileDialog::getSaveFileName(dialogParent(parent), caption, dir.toString(), filter, @@ -464,24 +466,26 @@ FilePath FileUtils::getSaveFilePath(const QString &caption, return FilePath::fromString(result); } -FilePath FileUtils::getExistingDirectory(const QString &caption, - const FilePath &dir, - QFileDialog::Options options) +FilePath FileUtils::getExistingDirectory(QWidget *parent, + const QString &caption, + const FilePath &dir, + QFileDialog::Options options) { - const QString result = QFileDialog::getExistingDirectory(dialogParent(), + const QString result = QFileDialog::getExistingDirectory(dialogParent(parent), caption, dir.toString(), options); return FilePath::fromString(result); } -FilePaths FileUtils::getOpenFilePaths(const QString &caption, +FilePaths FileUtils::getOpenFilePaths(QWidget *parent, + const QString &caption, const FilePath &dir, const QString &filter, QString *selectedFilter, QFileDialog::Options options) { - const QStringList result = QFileDialog::getOpenFileNames(dialogParent(), + const QStringList result = QFileDialog::getOpenFileNames(dialogParent(parent), caption, dir.toString(), filter, |