Python: check for pyside tools after installation

Change-Id: Icf9ae0ec08a78efc51216daa3304e76f8e812d5f
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
David Schulz
2022-06-16 15:33:32 +02:00
parent ca47064020
commit e74999cced
4 changed files with 23 additions and 3 deletions

View File

@@ -106,6 +106,10 @@ void PySideInstaller::installPyside(const Utils::FilePath &python,
auto install = new PipInstallTask(python); auto install = new PipInstallTask(python);
connect(install, &PipInstallTask::finished, install, &QObject::deleteLater); connect(install, &PipInstallTask::finished, install, &QObject::deleteLater);
connect(install, &PipInstallTask::finished, this, [=](bool success){
if (success)
emit pySideInstalled(python, pySide);
});
install->setPackage(PipPackage(pySide)); install->setPackage(PipPackage(pySide));
install->run(); install->run();
} }

View File

@@ -40,13 +40,17 @@ namespace Internal {
class PySideInstaller : public QObject class PySideInstaller : public QObject
{ {
Q_DECLARE_TR_FUNCTIONS(Python::Internal::PySideInstaller) Q_OBJECT
public: public:
static PySideInstaller *instance(); static PySideInstaller *instance();
static void checkPySideInstallation(const Utils::FilePath &python, static void checkPySideInstallation(const Utils::FilePath &python,
TextEditor::TextDocument *document); TextEditor::TextDocument *document);
signals:
void pySideInstalled(const Utils::FilePath &python, const QString &pySide);
private: private:
PySideInstaller(); PySideInstaller();

View File

@@ -202,6 +202,12 @@ PythonRunConfiguration::PythonRunConfiguration(Target *target, Id id)
setRunnableModifier([](Runnable &r) { setRunnableModifier([](Runnable &r) {
r.workingDirectory = r.workingDirectory.onDevice(r.command.executable()); r.workingDirectory = r.workingDirectory.onDevice(r.command.executable());
}); });
connect(PySideInstaller::instance(), &PySideInstaller::pySideInstalled, this,
[this](const FilePath &python) {
if (python == aspect<InterpreterAspect>()->currentInterpreter().command)
checkForPySide(python);
});
} }
PythonRunConfiguration::~PythonRunConfiguration() PythonRunConfiguration::~PythonRunConfiguration()
@@ -209,9 +215,8 @@ PythonRunConfiguration::~PythonRunConfiguration()
qDeleteAll(m_extraCompilers); qDeleteAll(m_extraCompilers);
} }
void PythonRunConfiguration::currentInterpreterChanged() void PythonRunConfiguration::checkForPySide(const FilePath &python)
{ {
const FilePath python = aspect<InterpreterAspect>()->currentInterpreter().command;
BuildStepList *buildSteps = target()->activeBuildConfiguration()->buildSteps(); BuildStepList *buildSteps = target()->activeBuildConfiguration()->buildSteps();
Utils::FilePath pySideProjectPath; Utils::FilePath pySideProjectPath;
@@ -255,6 +260,12 @@ void PythonRunConfiguration::currentInterpreterChanged()
if (auto pySideBuildStep = buildSteps->firstOfType<PySideBuildStep>()) if (auto pySideBuildStep = buildSteps->firstOfType<PySideBuildStep>())
pySideBuildStep->updatePySideProjectPath(pySideProjectPath); pySideBuildStep->updatePySideProjectPath(pySideProjectPath);
}
void PythonRunConfiguration::currentInterpreterChanged()
{
const FilePath python = aspect<InterpreterAspect>()->currentInterpreter().command;
checkForPySide(python);
for (FilePath &file : project()->files(Project::AllFiles)) { for (FilePath &file : project()->files(Project::AllFiles)) {
if (auto document = TextEditor::TextDocument::textDocumentForFilePath(file)) { if (auto document = TextEditor::TextDocument::textDocumentForFilePath(file)) {

View File

@@ -43,6 +43,7 @@ public:
QList<PySideUicExtraCompiler *> extraCompilers() const; QList<PySideUicExtraCompiler *> extraCompilers() const;
private: private:
void checkForPySide(const Utils::FilePath &python);
void updateExtraCompilers(); void updateExtraCompilers();
Utils::FilePath m_pySideUicPath; Utils::FilePath m_pySideUicPath;