forked from qt-creator/qt-creator
Python: Avoid IOptionPageWidget::widget() in settings
This is planned to become inaccessible for user code. Change-Id: I2530a6ccf9f46cedff68ae62e8ac3d42d6792e0a Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -318,34 +318,37 @@ public:
|
|||||||
setCategory(Constants::C_PYTHON_SETTINGS_CATEGORY);
|
setCategory(Constants::C_PYTHON_SETTINGS_CATEGORY);
|
||||||
setDisplayCategory(Tr::tr("Python"));
|
setDisplayCategory(Tr::tr("Python"));
|
||||||
setCategoryIconPath(":/python/images/settingscategory_python.png");
|
setCategoryIconPath(":/python/images/settingscategory_python.png");
|
||||||
setWidgetCreator([]() { return new InterpreterOptionsWidget(); });
|
setWidgetCreator([this] { m_widget = new InterpreterOptionsWidget; return m_widget; });
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<Interpreter> interpreters()
|
QList<Interpreter> interpreters()
|
||||||
{
|
{
|
||||||
if (auto w = static_cast<InterpreterOptionsWidget *>(widget()))
|
if (m_widget)
|
||||||
return w->interpreters();
|
return m_widget->interpreters();
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
void addInterpreter(const Interpreter &interpreter)
|
void addInterpreter(const Interpreter &interpreter)
|
||||||
{
|
{
|
||||||
if (auto w = static_cast<InterpreterOptionsWidget *>(widget()))
|
if (m_widget)
|
||||||
w->addInterpreter(interpreter);
|
m_widget->addInterpreter(interpreter);
|
||||||
}
|
}
|
||||||
|
|
||||||
void removeInterpreterFrom(const QString &detectionSource)
|
void removeInterpreterFrom(const QString &detectionSource)
|
||||||
{
|
{
|
||||||
if (auto w = static_cast<InterpreterOptionsWidget *>(widget()))
|
if (m_widget)
|
||||||
w->removeInterpreterFrom(detectionSource);
|
m_widget->removeInterpreterFrom(detectionSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<Interpreter> interpreterFrom(const QString &detectionSource)
|
QList<Interpreter> interpreterFrom(const QString &detectionSource)
|
||||||
{
|
{
|
||||||
if (auto w = static_cast<InterpreterOptionsWidget *>(widget()))
|
if (m_widget)
|
||||||
return w->interpreterFrom(detectionSource);
|
return m_widget->interpreterFrom(detectionSource);
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
InterpreterOptionsWidget *m_widget = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
static bool alreadyRegistered(const QList<Interpreter> &pythons, const FilePath &pythonExecutable)
|
static bool alreadyRegistered(const QList<Interpreter> &pythons, const FilePath &pythonExecutable)
|
||||||
|
Reference in New Issue
Block a user