File indexing completed on 2024-05-12 16:09:25

0001 /*
0002     SPDX-FileCopyrightText: 2016 Sven Brauch <svenbrauch@gmail.com>
0003 
0004     SPDX-License-Identifier: GPL-2.0-or-later
0005 */
0006 
0007 #include "projectconfigpage.h"
0008 
0009 #include "ui_projectconfig.h"
0010 
0011 #include "duchain/helpers.h"
0012 #include <QLineEdit>
0013 
0014 namespace Python {
0015 
0016 ProjectConfigPage::ProjectConfigPage(KDevelop::IPlugin* self, const KDevelop::ProjectConfigOptions& options, QWidget* parent)
0017     : KDevelop::ConfigPage(self, nullptr, parent)
0018     , m_ui(new Ui_ProjectConfig)
0019 {
0020     m_configGroup = options.project->projectConfiguration()->group("pythonsupport");
0021     m_ui->setupUi(this);
0022     m_project = options.project;
0023     // So apply button activates
0024     connect(m_ui->pythonInterpreter, &QLineEdit::textChanged, this, &ProjectConfigPage::changed);
0025 }
0026 
0027 void Python::ProjectConfigPage::apply()
0028 {
0029     m_configGroup.writeEntry("interpreter", m_ui->pythonInterpreter->text());
0030     // remove cached paths, so they are updated on the next parse job run
0031     QMutexLocker lock(&Helper::cacheMutex);
0032     Helper::cachedSearchPaths.remove(m_project);
0033 }
0034 
0035 void Python::ProjectConfigPage::defaults()
0036 {
0037     m_ui->pythonInterpreter->setText(QString());
0038 }
0039 
0040 void Python::ProjectConfigPage::reset()
0041 {
0042     m_ui->pythonInterpreter->setText(m_configGroup.readEntry("interpreter"));
0043 }
0044 
0045 QString Python::ProjectConfigPage::name() const
0046 {
0047     return i18n("Python Settings");
0048 }
0049 
0050 }
0051 
0052