aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhjk <hjk@qt.io>2021-07-26 17:41:28 +0200
committerhjk <hjk@qt.io>2021-08-06 08:56:51 +0000
commitb8f369c436cddd0323ea752a6c1b623431cb5096 (patch)
tree3391d3355a20263b500603344908809279af67d1
parentef1653698e7be4bb58a86857ff36f4bde74c1248 (diff)
Use the new file dialog wrappers in some places
Change-Id: I326c883f2f76593e6fcb0f3e376d387273312982 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
-rw-r--r--src/plugins/diffeditor/diffeditorplugin.cpp24
-rw-r--r--src/plugins/projectexplorer/project.cpp10
-rw-r--r--src/plugins/projectexplorer/projectexplorer.cpp27
-rw-r--r--src/plugins/projectexplorer/projectwindow.cpp10
-rw-r--r--src/plugins/studiowelcome/examplecheckout.cpp7
5 files changed, 34 insertions, 44 deletions
diff --git a/src/plugins/diffeditor/diffeditorplugin.cpp b/src/plugins/diffeditor/diffeditorplugin.cpp
index a83c5a7fbb4..5fb59e4e9e4 100644
--- a/src/plugins/diffeditor/diffeditorplugin.cpp
+++ b/src/plugins/diffeditor/diffeditorplugin.cpp
@@ -566,32 +566,28 @@ void DiffEditorPluginPrivate::diffOpenFiles()
void DiffEditorPluginPrivate::diffExternalFiles()
{
- const QString fileName1 = QFileDialog::getOpenFileName(ICore::dialogParent(),
- tr("Select First File for Diff"),
- QString());
- if (fileName1.isNull())
+ const FilePath filePath1 = FileUtils::getOpenFilePath(tr("Select First File for Diff"));
+ if (filePath1.isEmpty())
return;
- if (EditorManager::skipOpeningBigTextFile(FilePath::fromString(fileName1)))
+ if (EditorManager::skipOpeningBigTextFile(filePath1))
return;
- const QString fileName2 = QFileDialog::getOpenFileName(ICore::dialogParent(),
- tr("Select Second File for Diff"),
- QString());
- if (fileName2.isNull())
+ const FilePath filePath2 = FileUtils::getOpenFilePath(tr("Select Second File for Diff"));
+ if (filePath2.isEmpty())
return;
- if (EditorManager::skipOpeningBigTextFile(FilePath::fromString(fileName2)))
+ if (EditorManager::skipOpeningBigTextFile(filePath2))
return;
- const QString documentId = Constants::DIFF_EDITOR_PLUGIN
- + QLatin1String(".DiffExternalFiles.") + fileName1 + QLatin1Char('.') + fileName2;
- const QString title = tr("Diff \"%1\", \"%2\"").arg(fileName1, fileName2);
+ const QString documentId = QLatin1String(Constants::DIFF_EDITOR_PLUGIN)
+ + ".DiffExternalFiles." + filePath1.toString() + '.' + filePath2.toString();
+ const QString title = tr("Diff \"%1\", \"%2\"").arg(filePath1.toString(), filePath2.toString());
auto const document = qobject_cast<DiffEditorDocument *>(
DiffEditorController::findOrCreateDocument(documentId, title));
if (!document)
return;
if (!DiffEditorController::controller(document))
- new DiffExternalFilesController(document, fileName1, fileName2);
+ new DiffExternalFilesController(document, filePath1.toString(), filePath2.toString());
EditorManager::activateEditorForDocument(document);
document->reload();
}
diff --git a/src/plugins/projectexplorer/project.cpp b/src/plugins/projectexplorer/project.cpp
index 89a61abb38d..b6ecb8e69b8 100644
--- a/src/plugins/projectexplorer/project.cpp
+++ b/src/plugins/projectexplorer/project.cpp
@@ -720,12 +720,10 @@ Utils::FilePath Project::projectDirectory(const Utils::FilePath &top)
void Project::changeRootProjectDirectory()
{
- Utils::FilePath rootPath = Utils::FilePath::fromString(
- QFileDialog::getExistingDirectory(Core::ICore::dialogParent(),
- tr("Select the Root Directory"),
- rootProjectDirectory().toString(),
- QFileDialog::ShowDirsOnly
- | QFileDialog::DontResolveSymlinks));
+ Utils::FilePath rootPath = Utils::FileUtils::getExistingDirectory(
+ tr("Select the Root Directory"),
+ rootProjectDirectory(),
+ QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
if (rootPath != d->m_rootProjectDirectory) {
d->m_rootProjectDirectory = rootPath;
setNamedSettings(Constants::PROJECT_ROOT_PATH_KEY, d->m_rootProjectDirectory.toString());
diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp
index d7eb090c323..c44bc033dc8 100644
--- a/src/plugins/projectexplorer/projectexplorer.cpp
+++ b/src/plugins/projectexplorer/projectexplorer.cpp
@@ -3577,24 +3577,24 @@ void ProjectExplorerPluginPrivate::addExistingProjects()
projectNode = currentNode->asContainerNode()->rootProjectNode();
QTC_ASSERT(projectNode, return);
const FilePath dir = currentNode->directory();
- QStringList subProjectFilePaths = QFileDialog::getOpenFileNames(
- ICore::dialogParent(), tr("Choose Project File"), dir.toString(),
+ FilePaths subProjectFilePaths = Utils::FileUtils::getOpenFilePaths(
+ tr("Choose Project File"), dir,
projectNode->subProjectFileNamePatterns().join(";;"));
if (!ProjectTree::hasNode(projectNode))
return;
const QList<Node *> childNodes = projectNode->nodes();
- Utils::erase(subProjectFilePaths, [childNodes](const QString &filePath) {
+ Utils::erase(subProjectFilePaths, [childNodes](const FilePath &filePath) {
return Utils::anyOf(childNodes, [filePath](const Node *n) {
- return n->filePath().toString() == filePath;
+ return n->filePath() == filePath;
});
});
if (subProjectFilePaths.empty())
return;
- QStringList failedProjects;
+ FilePaths failedProjects;
QStringList addedProjects;
- for (const QString &filePath : qAsConst(subProjectFilePaths)) {
- if (projectNode->addSubProject(filePath))
- addedProjects << filePath;
+ for (const FilePath &filePath : qAsConst(subProjectFilePaths)) {
+ if (projectNode->addSubProject(filePath.toString()))
+ addedProjects << filePath.toString();
else
failedProjects << filePath;
}
@@ -3602,7 +3602,7 @@ void ProjectExplorerPluginPrivate::addExistingProjects()
const QString message = tr("The following subprojects could not be added to project "
"\"%1\":").arg(projectNode->managingProject()->displayName());
QMessageBox::warning(ICore::dialogParent(), tr("Adding Subproject Failed"),
- message + "\n " + failedProjects.join("\n "));
+ message + "\n " + FilePath::formatFilePaths(failedProjects, "\n "));
return;
}
VcsManager::promptToAdd(dir.toString(), addedProjects);
@@ -3615,13 +3615,12 @@ void ProjectExplorerPluginPrivate::handleAddExistingFiles()
QTC_ASSERT(folderNode, return);
- QStringList fileNames = QFileDialog::getOpenFileNames(ICore::dialogParent(),
- tr("Add Existing Files"), node->directory().toString());
- if (fileNames.isEmpty())
+ const FilePaths filePaths =
+ Utils::FileUtils::getOpenFilePaths(tr("Add Existing Files"), node->directory());
+ if (filePaths.isEmpty())
return;
- ProjectExplorerPlugin::addExistingFiles(folderNode,
- Utils::transform(fileNames, &FilePath::fromString));
+ ProjectExplorerPlugin::addExistingFiles(folderNode, filePaths);
}
void ProjectExplorerPluginPrivate::addExistingDirectory()
diff --git a/src/plugins/projectexplorer/projectwindow.cpp b/src/plugins/projectexplorer/projectwindow.cpp
index 85fea189901..793b2d26c86 100644
--- a/src/plugins/projectexplorer/projectwindow.cpp
+++ b/src/plugins/projectexplorer/projectwindow.cpp
@@ -754,15 +754,13 @@ public:
ProjectImporter *projectImporter = project ? project->projectImporter() : nullptr;
QTC_ASSERT(projectImporter, return);
- QString dir = project->projectDirectory().toString();
- QString importDir = QFileDialog::getExistingDirectory(ICore::dialogParent(),
- ProjectWindow::tr("Import Directory"),
- dir);
- FilePath path = FilePath::fromString(importDir);
+ FilePath importDir =
+ Utils::FileUtils::getExistingDirectory(ProjectWindow::tr("Import Directory"),
+ project->projectDirectory());
Target *lastTarget = nullptr;
BuildConfiguration *lastBc = nullptr;
- for (const BuildInfo &info : projectImporter->import(path, false)) {
+ for (const BuildInfo &info : projectImporter->import(importDir, false)) {
Target *target = project->target(info.kitId);
if (!target)
target = project->addTargetForKit(KitManager::kit(info.kitId));
diff --git a/src/plugins/studiowelcome/examplecheckout.cpp b/src/plugins/studiowelcome/examplecheckout.cpp
index 42344d3527a..a1145ba764f 100644
--- a/src/plugins/studiowelcome/examplecheckout.cpp
+++ b/src/plugins/studiowelcome/examplecheckout.cpp
@@ -239,12 +239,11 @@ QString FileExtractor::targetPath() const
void FileExtractor::browse()
{
- const QString path = QFileDialog::getExistingDirectory(Core::ICore::dialogParent(),
- (tr("Choose Directory")),
- m_targetPath.toString());
+ const Utils::FilePath path =
+ Utils::FileUtils::getExistingDirectory(tr("Choose Directory"), m_targetPath);
if (!path.isEmpty())
- m_targetPath = Utils::FilePath::fromString(path);
+ m_targetPath = path;
emit targetPathChanged();
emit targetFolderExistsChanged();