Python: add PySide installation check on document open

Checks if the document imports PySide and whether the selected python
interpreter can find a PySide installation. If not show a global info
bar that can install PySide via pip like the python lsp server.

Task-number: PYSIDE-1742
Change-Id: I02c0d5f6eb268f3d8826d4fb9d9ec3c7c48b8638
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
David Schulz
2022-03-16 09:35:02 +01:00
parent 9f3941cda3
commit 7cb3a726d4
9 changed files with 272 additions and 4 deletions

View File

@@ -25,6 +25,7 @@
#include "pythonrunconfiguration.h"
#include "pyside.h"
#include "pythonconstants.h"
#include "pythonlanguageclient.h"
#include "pythonproject.h"
@@ -244,7 +245,7 @@ PythonRunConfiguration::PythonRunConfiguration(Target *target, Utils::Id id)
auto interpreterAspect = addAspect<InterpreterAspect>();
interpreterAspect->setSettingsKey("PythonEditor.RunConfiguation.Interpreter");
connect(interpreterAspect, &InterpreterAspect::changed,
this, &PythonRunConfiguration::updateLanguageServer);
this, &PythonRunConfiguration::interpreterChanged);
connect(PythonSettings::instance(), &PythonSettings::interpretersChanged,
interpreterAspect, &InterpreterAspect::updateInterpreters);
@@ -292,7 +293,7 @@ PythonRunConfiguration::PythonRunConfiguration(Target *target, Utils::Id id)
connect(target, &Target::buildSystemUpdated, this, &RunConfiguration::update);
}
void PythonRunConfiguration::updateLanguageServer()
void PythonRunConfiguration::interpreterChanged()
{
using namespace LanguageClient;
@@ -300,8 +301,10 @@ void PythonRunConfiguration::updateLanguageServer()
for (FilePath &file : project()->files(Project::AllFiles)) {
if (auto document = TextEditor::TextDocument::textDocumentForFilePath(file)) {
if (document->mimeType() == Constants::C_PY_MIMETYPE)
if (document->mimeType() == Constants::C_PY_MIMETYPE) {
PyLSConfigureAssistant::instance()->openDocumentWithPython(python, document);
PySideInstaller::instance()->checkPySideInstallation(python, document);
}
}
}
}