From 11cef62b9eec2982e6c359858326eaa901272bdf Mon Sep 17 00:00:00 2001 From: hjk Date: Wed, 4 Dec 2024 08:57:56 +0100 Subject: [PATCH] Core: Always use dialogParent() for FileUtils::showInGraphicalShell() Change-Id: I02b0ded14c78872b59bd9ec4cfb53878d3f96ad5 Reviewed-by: Eike Ziller --- src/plugins/android/androidbuildapkstep.cpp | 2 +- src/plugins/coreplugin/coreplugin.cpp | 2 +- src/plugins/coreplugin/editormanager/editormanager.cpp | 4 ++-- src/plugins/coreplugin/fileutils.cpp | 10 +++++----- src/plugins/coreplugin/fileutils.h | 6 +----- src/plugins/coreplugin/icore.cpp | 4 ++-- src/plugins/projectexplorer/projectexplorer.cpp | 2 +- .../assetexporterplugin/assetexportdialog.cpp | 2 +- .../components/assetslibrary/assetslibrarywidget.cpp | 2 +- 9 files changed, 15 insertions(+), 19 deletions(-) diff --git a/src/plugins/android/androidbuildapkstep.cpp b/src/plugins/android/androidbuildapkstep.cpp index b6563eb870f..9b6e99be433 100644 --- a/src/plugins/android/androidbuildapkstep.cpp +++ b/src/plugins/android/androidbuildapkstep.cpp @@ -826,7 +826,7 @@ void AndroidBuildApkStep::showInGraphicalShell() return; } } - Core::FileUtils::showInGraphicalShell(Core::ICore::dialogParent(), packagePath); + Core::FileUtils::showInGraphicalShell(packagePath); } QWidget *AndroidBuildApkStep::createConfigWidget() diff --git a/src/plugins/coreplugin/coreplugin.cpp b/src/plugins/coreplugin/coreplugin.cpp index 899eb5465bc..2ac1b1dceac 100644 --- a/src/plugins/coreplugin/coreplugin.cpp +++ b/src/plugins/coreplugin/coreplugin.cpp @@ -204,7 +204,7 @@ static void addToPathChooserContextMenu(PathChooser *pathChooser, QMenu *menu) if (pathChooser->filePath().exists()) { auto showInGraphicalShell = new QAction(FileUtils::msgGraphicalShellAction(), menu); QObject::connect(showInGraphicalShell, &QAction::triggered, pathChooser, [pathChooser] { - Core::FileUtils::showInGraphicalShell(pathChooser, pathChooser->filePath()); + Core::FileUtils::showInGraphicalShell(pathChooser->filePath()); }); menu->insertAction(firstAction, showInGraphicalShell); diff --git a/src/plugins/coreplugin/editormanager/editormanager.cpp b/src/plugins/coreplugin/editormanager/editormanager.cpp index 946836f740c..937f4b2082c 100644 --- a/src/plugins/coreplugin/editormanager/editormanager.cpp +++ b/src/plugins/coreplugin/editormanager/editormanager.cpp @@ -518,7 +518,7 @@ void EditorManagerPrivate::init() return; const FilePath fp = EditorManager::currentDocument()->filePath(); if (!fp.isEmpty()) - FileUtils::showInGraphicalShell(ICore::dialogParent(), fp); + FileUtils::showInGraphicalShell(fp); }); ActionBuilder showInFileSystem(this, Constants::SHOWINFILESYSTEMVIEW); @@ -560,7 +560,7 @@ void EditorManagerPrivate::init() connect(m_openGraphicalShellContextAction, &QAction::triggered, this, [this] { if (!m_contextMenuDocument || m_contextMenuEntry->filePath().isEmpty()) return; - FileUtils::showInGraphicalShell(ICore::dialogParent(), m_contextMenuEntry->filePath()); + FileUtils::showInGraphicalShell(m_contextMenuEntry->filePath()); }); connect(m_showInFileSystemViewContextAction, &QAction::triggered, this, [this] { if (!m_contextMenuDocument || m_contextMenuEntry->filePath().isEmpty()) diff --git a/src/plugins/coreplugin/fileutils.cpp b/src/plugins/coreplugin/fileutils.cpp index 30d02bd3ad7..85915cd8f0d 100644 --- a/src/plugins/coreplugin/fileutils.cpp +++ b/src/plugins/coreplugin/fileutils.cpp @@ -55,21 +55,21 @@ static FilePath windowsDirectory() } // Show error with option to open settings. -static void showGraphicalShellError(QWidget *parent, const QString &app, const QString &error) +static void showGraphicalShellError(const QString &app, const QString &error) { const QString title = Tr::tr("Launching a file browser failed"); const QString msg = Tr::tr("Unable to start the file manager:\n\n%1\n\n").arg(app); - QMessageBox mbox(QMessageBox::Warning, title, msg, QMessageBox::Close, parent); + QMessageBox mbox(QMessageBox::Warning, title, msg, QMessageBox::Close, ICore::dialogParent()); if (!error.isEmpty()) mbox.setDetailedText(Tr::tr("\"%1\" returned the following error:\n\n%2").arg(app, error)); QAbstractButton *settingsButton = mbox.addButton(Core::ICore::msgShowOptionsDialog(), QMessageBox::ActionRole); mbox.exec(); if (mbox.clickedButton() == settingsButton) - ICore::showOptionsDialog(Constants::SETTINGS_ID_INTERFACE, parent); + ICore::showOptionsDialog(Constants::SETTINGS_ID_INTERFACE, ICore::dialogParent()); } -void showInGraphicalShell(QWidget *parent, const FilePath &pathIn) +void showInGraphicalShell(const FilePath &pathIn) { const QFileInfo fileInfo = pathIn.toFileInfo(); // Mac, Windows support folder or file. @@ -98,7 +98,7 @@ void showInGraphicalShell(QWidget *parent, const FilePath &pathIn) error = Tr::tr("Error while starting file browser."); } if (!error.isEmpty()) - showGraphicalShellError(parent, app, error); + showGraphicalShellError(app, error); } } diff --git a/src/plugins/coreplugin/fileutils.h b/src/plugins/coreplugin/fileutils.h index 984673ec44e..d762ad09eb7 100644 --- a/src/plugins/coreplugin/fileutils.h +++ b/src/plugins/coreplugin/fileutils.h @@ -7,10 +7,6 @@ #include -QT_BEGIN_NAMESPACE -class QWidget; -QT_END_NAMESPACE - namespace Utils { class Environment; } namespace Core { @@ -20,7 +16,7 @@ enum class HandleIncludeGuards { No, Yes }; namespace FileUtils { // Helpers for common directory browser options. -CORE_EXPORT void showInGraphicalShell(QWidget *parent, const Utils::FilePath &path); +CORE_EXPORT void showInGraphicalShell(const Utils::FilePath &path); CORE_EXPORT void showInFileSystemView(const Utils::FilePath &path); CORE_EXPORT void openTerminal(const Utils::FilePath &path, const Utils::Environment &env); CORE_EXPORT QString msgFindInDirectory(); diff --git a/src/plugins/coreplugin/icore.cpp b/src/plugins/coreplugin/icore.cpp index 617ece82771..6168acfd6c6 100644 --- a/src/plugins/coreplugin/icore.cpp +++ b/src/plugins/coreplugin/icore.cpp @@ -2539,9 +2539,9 @@ void ICorePrivate::changeLog() connect(showInExplorer, &QPushButton::clicked, this, [versionCombo, versionedFiles] { const int index = versionCombo->currentIndex(); if (index >= 0 && index < versionedFiles.size()) - FileUtils::showInGraphicalShell(ICore::dialogParent(), versionedFiles.at(index).second); + FileUtils::showInGraphicalShell(versionedFiles.at(index).second); else - FileUtils::showInGraphicalShell(ICore::dialogParent(), ICore::resourcePath("changelog")); + FileUtils::showInGraphicalShell(ICore::resourcePath("changelog")); }); dialog->show(); diff --git a/src/plugins/projectexplorer/projectexplorer.cpp b/src/plugins/projectexplorer/projectexplorer.cpp index 80535e5c958..437ba6b4101 100644 --- a/src/plugins/projectexplorer/projectexplorer.cpp +++ b/src/plugins/projectexplorer/projectexplorer.cpp @@ -3795,7 +3795,7 @@ void ProjectExplorerPluginPrivate::showInGraphicalShell() { Node *currentNode = ProjectTree::currentNode(); QTC_ASSERT(currentNode, return); - Core::FileUtils::showInGraphicalShell(ICore::dialogParent(), currentNode->path()); + Core::FileUtils::showInGraphicalShell(currentNode->path()); } void ProjectExplorerPluginPrivate::showInFileSystemPane() diff --git a/src/plugins/qmldesigner/assetexporterplugin/assetexportdialog.cpp b/src/plugins/qmldesigner/assetexporterplugin/assetexportdialog.cpp index cee25240cfc..658bbc88437 100644 --- a/src/plugins/qmldesigner/assetexporterplugin/assetexportdialog.cpp +++ b/src/plugins/qmldesigner/assetexporterplugin/assetexportdialog.cpp @@ -92,7 +92,7 @@ AssetExportDialog::AssetExportDialog(const FilePath &exportPath, m_exportPath->setPromptDialogFilter(tr("Metadata file (*.metadata)")); m_exportPath->lineEdit()->setReadOnly(true); m_exportPath->addButton(tr("Open"), this, [this] { - Core::FileUtils::showInGraphicalShell(Core::ICore::dialogParent(), m_exportPath->filePath()); + Core::FileUtils::showInGraphicalShell(m_exportPath->filePath()); }); m_exportAssetsCheck = new QCheckBox(tr("Export assets"), this); diff --git a/src/plugins/qmldesigner/components/assetslibrary/assetslibrarywidget.cpp b/src/plugins/qmldesigner/components/assetslibrary/assetslibrarywidget.cpp index 7d182b99c42..4ac39bfc8c0 100644 --- a/src/plugins/qmldesigner/components/assetslibrary/assetslibrarywidget.cpp +++ b/src/plugins/qmldesigner/components/assetslibrary/assetslibrarywidget.cpp @@ -221,7 +221,7 @@ bool AssetsLibraryWidget::canCreateEffects() const void AssetsLibraryWidget::showInGraphicalShell(const QString &path) { - Core::FileUtils::showInGraphicalShell(Core::ICore::dialogParent(), Utils::FilePath::fromString(path)); + Core::FileUtils::showInGraphicalShell(Utils::FilePath::fromString(path)); } QString AssetsLibraryWidget::showInGraphicalShellMsg() const