Axivion: Hide plugin class definition in .cpp

This is not meant to be accessed from the outside.

Change-Id: Ieae4d1ef760e1c6829ea8a1c2ae7945198198634
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2024-01-12 08:38:31 +01:00
parent 2a2772ba40
commit cd2068e967
5 changed files with 42 additions and 52 deletions

View File

@@ -94,7 +94,7 @@ void DashboardWidget::updateUi()
delete child->widget(); delete child->widget();
delete child; delete child;
} }
std::shared_ptr<const DashboardClient::ProjectInfo> projectInfo = AxivionPlugin::projectInfo(); std::shared_ptr<const DashboardClient::ProjectInfo> projectInfo = Internal::projectInfo();
if (!projectInfo) if (!projectInfo)
return; return;
const Dto::ProjectInfoDto &info = projectInfo->data; const Dto::ProjectInfoDto &info = projectInfo->data;

View File

@@ -17,6 +17,7 @@
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <coreplugin/messagemanager.h> #include <coreplugin/messagemanager.h>
#include <extensionsystem/iplugin.h>
#include <extensionsystem/pluginmanager.h> #include <extensionsystem/pluginmanager.h>
#include <projectexplorer/buildsystem.h> #include <projectexplorer/buildsystem.h>
@@ -98,35 +99,13 @@ AxivionTextMark::AxivionTextMark(const Utils::FilePath &filePath, const ShortIss
}); });
} }
AxivionPlugin::~AxivionPlugin() void fetchProjectInfo(const QString &projectName)
{
AxivionProjectSettings::destroyProjectSettings();
delete dd;
dd = nullptr;
}
void AxivionPlugin::initialize()
{
dd = new AxivionPluginPrivate;
AxivionProjectSettings::setupProjectPanel();
connect(ProjectExplorer::ProjectManager::instance(),
&ProjectExplorer::ProjectManager::startupProjectChanged,
dd, &AxivionPluginPrivate::onStartupProjectChanged);
connect(Core::EditorManager::instance(), &Core::EditorManager::documentOpened,
dd, &AxivionPluginPrivate::onDocumentOpened);
connect(Core::EditorManager::instance(), &Core::EditorManager::documentClosed,
dd, &AxivionPluginPrivate::onDocumentClosed);
}
void AxivionPlugin::fetchProjectInfo(const QString &projectName)
{ {
QTC_ASSERT(dd, return); QTC_ASSERT(dd, return);
dd->fetchProjectInfo(projectName); dd->fetchProjectInfo(projectName);
} }
std::shared_ptr<const DashboardClient::ProjectInfo> AxivionPlugin::projectInfo() std::shared_ptr<const DashboardClient::ProjectInfo> projectInfo()
{ {
QTC_ASSERT(dd, return {}); QTC_ASSERT(dd, return {});
return dd->m_currentProjectInfo; return dd->m_currentProjectInfo;
@@ -134,7 +113,7 @@ std::shared_ptr<const DashboardClient::ProjectInfo> AxivionPlugin::projectInfo()
// FIXME: extend to give some details? // FIXME: extend to give some details?
// FIXME: move when curl is no more in use? // FIXME: move when curl is no more in use?
bool AxivionPlugin::handleCertificateIssue() bool handleCertificateIssue()
{ {
QTC_ASSERT(dd, return false); QTC_ASSERT(dd, return false);
const QString serverHost = QUrl(settings().server.dashboard).host(); const QString serverHost = QUrl(settings().server.dashboard).host();
@@ -170,7 +149,7 @@ void AxivionPluginPrivate::handleSslErrors(QNetworkReply *reply, const QList<QSs
}; };
if (Utils::allOf(errors, if (Utils::allOf(errors,
[&accepted](const QSslError &e) { return accepted.contains(e.error()); })) { [&accepted](const QSslError &e) { return accepted.contains(e.error()); })) {
if (!settings().server.validateCert || AxivionPlugin::handleCertificateIssue()) if (!settings().server.validateCert || handleCertificateIssue())
reply->ignoreSslErrors(errors); reply->ignoreSslErrors(errors);
} }
#else // ssl #else // ssl
@@ -334,4 +313,34 @@ void AxivionPluginPrivate::handleIssuesForFile(const IssuesList &issues)
} }
} }
class AxivionPlugin final : public ExtensionSystem::IPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "Axivion.json")
~AxivionPlugin() final
{
AxivionProjectSettings::destroyProjectSettings();
delete dd;
dd = nullptr;
}
void initialize() final
{
dd = new AxivionPluginPrivate;
AxivionProjectSettings::setupProjectPanel();
connect(ProjectExplorer::ProjectManager::instance(),
&ProjectExplorer::ProjectManager::startupProjectChanged,
dd, &AxivionPluginPrivate::onStartupProjectChanged);
connect(Core::EditorManager::instance(), &Core::EditorManager::documentOpened,
dd, &AxivionPluginPrivate::onDocumentOpened);
connect(Core::EditorManager::instance(), &Core::EditorManager::documentClosed,
dd, &AxivionPluginPrivate::onDocumentClosed);
}
};
} // Axivion::Internal } // Axivion::Internal
#include "axivionplugin.moc"

View File

@@ -5,34 +5,15 @@
#include "dashboard/dashboardclient.h" #include "dashboard/dashboardclient.h"
#include <extensionsystem/iplugin.h>
#include <memory> #include <memory>
namespace ProjectExplorer { class Project; } namespace ProjectExplorer { class Project; }
namespace Axivion::Internal { namespace Axivion::Internal {
class AxivionProjectSettings; void fetchProjectInfo(const QString &projectName);
class ProjectInfo; std::shared_ptr<const DashboardClient::ProjectInfo> projectInfo();
bool handleCertificateIssue();
class AxivionPlugin final : public ExtensionSystem::IPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "Axivion.json")
public:
AxivionPlugin() {}
~AxivionPlugin() final;
static void fetchProjectInfo(const QString &projectName);
static std::shared_ptr<const DashboardClient::ProjectInfo> projectInfo();
static bool handleCertificateIssue();
private:
void initialize() final;
void extensionsInitialized() final {}
};
} // Axivion::Internal } // Axivion::Internal

View File

@@ -207,7 +207,7 @@ void AxivionProjectSettingsWidget::linkProject()
const QString projectName = selected.first()->text(0); const QString projectName = selected.first()->text(0);
m_projectSettings->setDashboardProjectName(projectName); m_projectSettings->setDashboardProjectName(projectName);
updateUi(); updateUi();
AxivionPlugin::fetchProjectInfo(projectName); fetchProjectInfo(projectName);
} }
void AxivionProjectSettingsWidget::unlinkProject() void AxivionProjectSettingsWidget::unlinkProject()
@@ -216,7 +216,7 @@ void AxivionProjectSettingsWidget::unlinkProject()
m_projectSettings->setDashboardProjectName({}); m_projectSettings->setDashboardProjectName({});
updateUi(); updateUi();
AxivionPlugin::fetchProjectInfo({}); fetchProjectInfo({});
} }
void AxivionProjectSettingsWidget::updateUi() void AxivionProjectSettingsWidget::updateUi()

View File

@@ -70,7 +70,7 @@ AxivionQueryRunner::AxivionQueryRunner(const AxivionQuery &query, QObject *paren
const int exitCode = m_process.exitCode(); const int exitCode = m_process.exitCode();
if (m_process.exitStatus() == QProcess::NormalExit if (m_process.exitStatus() == QProcess::NormalExit
&& (exitCode == 35 || exitCode == 60) && (exitCode == 35 || exitCode == 60)
&& AxivionPlugin::handleCertificateIssue()) { && handleCertificateIssue()) {
// prepend -k for re-requesting same query // prepend -k for re-requesting same query
CommandLine cmdline = m_process.commandLine(); CommandLine cmdline = m_process.commandLine();
cmdline.prependArgs({"-k"}); cmdline.prependArgs({"-k"});