summaryrefslogtreecommitdiff
path: root/src/plugins/python/pythonutils.cpp
diff options
context:
space:
mode:
authorhjk <hjk@qt.io>2022-04-13 12:26:54 +0200
committerhjk <hjk@qt.io>2022-04-27 08:54:22 +0000
commit28cfdf388ae3e3ed7e073e98a83c737d889d887f (patch)
tree5e984b0bfccee996b8329b6c5a1899aa4c195273 /src/plugins/python/pythonutils.cpp
parent9a6d8aebe79993ee9de17b642fb253b925624739 (diff)
downloadqt-creator-28cfdf388ae3e3ed7e073e98a83c737d889d887f.tar.gz
Promote previously python-specific InterpreterAspect
... and drop PythonRunConfiguration, which is a plain RunConfiguration now. Change-Id: I540cb738180fc1424f730d6d1998886915ce527b Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: David Schulz <david.schulz@qt.io>
Diffstat (limited to 'src/plugins/python/pythonutils.cpp')
-rw-r--r--src/plugins/python/pythonutils.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/plugins/python/pythonutils.cpp b/src/plugins/python/pythonutils.cpp
index 713c48821e..6c8ff9bcba 100644
--- a/src/plugins/python/pythonutils.cpp
+++ b/src/plugins/python/pythonutils.cpp
@@ -39,6 +39,7 @@
#include <utils/mimeutils.h>
#include <utils/qtcprocess.h>
+using namespace ProjectExplorer;
using namespace Utils;
namespace Python {
@@ -51,15 +52,15 @@ FilePath detectPython(const FilePath &documentPath)
PythonProject *project = documentPath.isEmpty()
? nullptr
: qobject_cast<PythonProject *>(
- ProjectExplorer::SessionManager::projectForFile(documentPath));
+ SessionManager::projectForFile(documentPath));
if (!project)
- project = qobject_cast<PythonProject *>(ProjectExplorer::SessionManager::startupProject());
+ project = qobject_cast<PythonProject *>(SessionManager::startupProject());
if (project) {
if (auto target = project->activeTarget()) {
- if (auto runConfig = qobject_cast<PythonRunConfiguration *>(
- target->activeRunConfiguration())) {
- python = runConfig->interpreter().command;
+ if (auto runConfig = target->activeRunConfiguration()) {
+ if (auto interpreter = runConfig->aspect<InterpreterAspect>())
+ python = interpreter->currentInterpreter().command;
}
}
}
@@ -99,7 +100,7 @@ void openPythonRepl(QObject *parent, const FilePath &file, ReplType type)
{
static const auto workingDir = [](const FilePath &file) {
if (file.isEmpty()) {
- if (ProjectExplorer::Project *project = ProjectExplorer::SessionManager::startupProject())
+ if (Project *project = SessionManager::startupProject())
return project->projectDirectory();
return FilePath::fromString(QDir::currentPath());
}
@@ -147,7 +148,7 @@ QString pythonName(const FilePath &pythonPath)
PythonProject *pythonProjectForFile(const FilePath &pythonFile)
{
- for (ProjectExplorer::Project *project : ProjectExplorer::SessionManager::projects()) {
+ for (Project *project : SessionManager::projects()) {
if (auto pythonProject = qobject_cast<PythonProject *>(project)) {
if (pythonProject->isKnownFile(pythonFile))
return pythonProject;