2023-01-20 07:09:01 +01: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 "copilotplugin.h"
|
|
|
|
|
|
|
|
|
|
#include "copilotclient.h"
|
|
|
|
|
#include "copilotoptionspage.h"
|
|
|
|
|
#include "copilotsettings.h"
|
|
|
|
|
|
|
|
|
|
#include <coreplugin/icore.h>
|
|
|
|
|
|
|
|
|
|
using namespace Utils;
|
|
|
|
|
|
|
|
|
|
namespace Copilot {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2023-02-27 11:11:02 +01:00
|
|
|
CopilotPlugin::~CopilotPlugin()
|
|
|
|
|
{
|
|
|
|
|
if (m_client)
|
|
|
|
|
m_client->shutdown();
|
|
|
|
|
|
|
|
|
|
m_client = nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-20 07:09:01 +01:00
|
|
|
void CopilotPlugin::initialize()
|
|
|
|
|
{
|
|
|
|
|
CopilotSettings::instance().readSettings(Core::ICore::settings());
|
|
|
|
|
|
|
|
|
|
m_client = new CopilotClient();
|
|
|
|
|
|
2023-02-27 11:11:02 +01:00
|
|
|
connect(m_client, &CopilotClient::finished, this, [this]() { m_client = nullptr; });
|
|
|
|
|
|
2023-01-20 07:09:01 +01:00
|
|
|
connect(&CopilotSettings::instance(), &CopilotSettings::applied, this, [this]() {
|
|
|
|
|
if (m_client)
|
|
|
|
|
m_client->shutdown();
|
|
|
|
|
m_client = nullptr;
|
|
|
|
|
m_client = new CopilotClient();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CopilotPlugin::extensionsInitialized()
|
|
|
|
|
{
|
|
|
|
|
CopilotOptionsPage::instance().init();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Copilot
|