2023-05-23 08:58:07 +02:00
|
|
|
// Copyright (C) 2023 The Qt Company Ltd.
|
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
|
|
|
|
|
|
|
|
|
#include "copilotprojectpanel.h"
|
|
|
|
|
#include "copilotconstants.h"
|
|
|
|
|
#include "copilotsettings.h"
|
|
|
|
|
|
|
|
|
|
#include <projectexplorer/project.h>
|
|
|
|
|
#include <projectexplorer/projectsettingswidget.h>
|
|
|
|
|
|
|
|
|
|
#include <utils/layoutbuilder.h>
|
|
|
|
|
|
|
|
|
|
#include <QWidget>
|
|
|
|
|
|
|
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
|
|
|
|
|
namespace Copilot::Internal {
|
|
|
|
|
|
|
|
|
|
class CopilotProjectSettingsWidget : public ProjectExplorer::ProjectSettingsWidget
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
|
CopilotProjectSettingsWidget()
|
|
|
|
|
{
|
|
|
|
|
setGlobalSettingsId(Constants::COPILOT_GENERAL_OPTIONS_ID);
|
|
|
|
|
setUseGlobalSettingsCheckBoxVisible(true);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
ProjectSettingsWidget *createCopilotProjectPanel(Project *project)
|
|
|
|
|
{
|
|
|
|
|
using namespace Layouting;
|
|
|
|
|
using namespace ProjectExplorer;
|
|
|
|
|
|
|
|
|
|
auto widget = new CopilotProjectSettingsWidget;
|
2023-07-27 15:13:31 +02:00
|
|
|
auto settings = new CopilotProjectSettings(project);
|
|
|
|
|
settings->setParent(widget);
|
2023-05-23 08:58:07 +02:00
|
|
|
|
|
|
|
|
QObject::connect(widget,
|
|
|
|
|
&ProjectSettingsWidget::useGlobalSettingsChanged,
|
|
|
|
|
settings,
|
|
|
|
|
&CopilotProjectSettings::setUseGlobalSettings);
|
|
|
|
|
|
|
|
|
|
widget->setUseGlobalSettings(settings->useGlobalSettings());
|
|
|
|
|
widget->setEnabled(!settings->useGlobalSettings());
|
|
|
|
|
|
|
|
|
|
QObject::connect(widget,
|
|
|
|
|
&ProjectSettingsWidget::useGlobalSettingsChanged,
|
|
|
|
|
widget,
|
|
|
|
|
[widget](bool useGlobal) { widget->setEnabled(!useGlobal); });
|
|
|
|
|
|
|
|
|
|
// clang-format off
|
|
|
|
|
Column {
|
|
|
|
|
settings->enableCopilot,
|
|
|
|
|
}.attachTo(widget);
|
|
|
|
|
// clang-format on
|
|
|
|
|
|
|
|
|
|
return widget;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace Copilot::Internal
|