Core: Always use dialogParent() for FileUtils::showInGraphicalShell()

Change-Id: I02b0ded14c78872b59bd9ec4cfb53878d3f96ad5
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
hjk
2024-12-04 08:57:56 +01:00
parent 05724a2d46
commit 11cef62b9e
9 changed files with 15 additions and 19 deletions

View File

@@ -826,7 +826,7 @@ void AndroidBuildApkStep::showInGraphicalShell()
return;
}
}
Core::FileUtils::showInGraphicalShell(Core::ICore::dialogParent(), packagePath);
Core::FileUtils::showInGraphicalShell(packagePath);
}
QWidget *AndroidBuildApkStep::createConfigWidget()

View File

@@ -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);

View File

@@ -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())

View File

@@ -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);
}
}

View File

@@ -7,10 +7,6 @@
#include <utils/filepath.h>
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();

View File

@@ -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();

View File

@@ -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()

View File

@@ -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);

View File

@@ -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