diff options
Diffstat (limited to 'src/plugins/python/pythoneditor.cpp')
-rw-r--r-- | src/plugins/python/pythoneditor.cpp | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/src/plugins/python/pythoneditor.cpp b/src/plugins/python/pythoneditor.cpp index c3e9ec0c51..2a6c0d094c 100644 --- a/src/plugins/python/pythoneditor.cpp +++ b/src/plugins/python/pythoneditor.cpp @@ -24,9 +24,12 @@ ****************************************************************************/ #include "pythoneditor.h" + +#include "pyside.h" #include "pythonconstants.h" #include "pythonhighlighter.h" #include "pythonindenter.h" +#include "pythonlanguageclient.h" #include "pythonsettings.h" #include "pythonutils.h" @@ -102,6 +105,36 @@ static QWidget *createEditorWidget() return widget; } +class PythonDocument : public TextEditor::TextDocument +{ +public: + PythonDocument() : TextEditor::TextDocument(Constants::C_PYTHONEDITOR_ID) + { + connect(PythonSettings::instance(), + &PythonSettings::pylsEnabledChanged, + this, + [this](const bool enabled) { + if (!enabled) + return; + const Utils::FilePath &python = detectPython(filePath()); + if (python.exists()) + PyLSConfigureAssistant::openDocumentWithPython(python, this); + }); + connect(this, &PythonDocument::openFinishedSuccessfully, + this, &PythonDocument::checkForPyls); + } + + void checkForPyls() + { + const Utils::FilePath &python = detectPython(filePath()); + if (!python.exists()) + return; + + PyLSConfigureAssistant::openDocumentWithPython(python, this); + PySideInstaller::checkPySideInstallation(python, this); + } +}; + PythonEditorFactory::PythonEditorFactory() { registerReplAction(this); @@ -116,7 +149,7 @@ PythonEditorFactory::PythonEditorFactory() | TextEditor::TextEditorActionHandler::UnCollapseAll | TextEditor::TextEditorActionHandler::FollowSymbolUnderCursor); - setDocumentCreator([] { return new TextEditor::TextDocument(Constants::C_PYTHONEDITOR_ID); }); + setDocumentCreator([]() { return new PythonDocument; }); setEditorWidgetCreator(createEditorWidget); setIndenterCreator([](QTextDocument *doc) { return new PythonIndenter(doc); }); setSyntaxHighlighterCreator([] { return new PythonHighlighter; }); |