GitLab: Hide plugin class definition in .cpp

Change-Id: I362bcbd09ef4694f0478c8982ea627cb9d8c310b
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
hjk
2024-01-15 10:05:29 +01:00
parent b52368b0de
commit 1165e078fe
5 changed files with 100 additions and 110 deletions

View File

@@ -188,7 +188,7 @@ void GitLabDialog::requestMainViewUpdate()
bool linked = false;
m_currentServerId = Id();
if (auto project = ProjectExplorer::ProjectManager::startupProject()) {
GitLabProjectSettings *projSettings = GitLabPlugin::projectSettings(project);
GitLabProjectSettings *projSettings = projectSettings(project);
if (projSettings->isLinked()) {
m_currentServerId = projSettings->currentServer();
linked = true;

View File

@@ -15,6 +15,8 @@
#include <coreplugin/actionmanager/actionmanager.h>
#include <coreplugin/icore.h>
#include <extensionsystem/iplugin.h>
#include <git/gitplugin.h>
#include <projectexplorer/project.h>
@@ -56,11 +58,12 @@ public:
static GitLabPluginPrivate *dd = nullptr;
GitLabPlugin::GitLabPlugin()
class GitLabPlugin final : public ExtensionSystem::IPlugin
{
}
Q_OBJECT
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "GitLab.json")
GitLabPlugin::~GitLabPlugin()
~GitLabPlugin() final
{
if (!dd->projectSettings.isEmpty()) {
qDeleteAll(dd->projectSettings);
@@ -70,7 +73,7 @@ GitLabPlugin::~GitLabPlugin()
dd = nullptr;
}
void GitLabPlugin::initialize()
void initialize() final
{
dd = new GitLabPluginPrivate;
gitLabParameters().fromSettings(Core::ICore::settings());
@@ -87,7 +90,7 @@ void GitLabPlugin::initialize()
this, &GitLabPlugin::onStartupProjectChanged);
}
void GitLabPlugin::openView()
void openView()
{
if (dd->dialog.isNull()) {
while (!gitLabParameters().isValid()) {
@@ -110,7 +113,7 @@ void GitLabPlugin::openView()
dd->dialog->raise();
}
void GitLabPlugin::onStartupProjectChanged()
void onStartupProjectChanged()
{
QTC_ASSERT(dd, return);
disconnect(&dd->notificationTimer);
@@ -120,7 +123,7 @@ void GitLabPlugin::onStartupProjectChanged()
return;
}
const GitLabProjectSettings *projSettings = projectSettings(project);
const GitLabProjectSettings *projSettings = GitLab::projectSettings(project);
if (!projSettings->isLinked()) {
dd->notificationTimer.stop();
return;
@@ -129,6 +132,8 @@ void GitLabPlugin::onStartupProjectChanged()
dd->fetchEvents();
dd->setupNotificationTimer();
}
};
void GitLabPluginPrivate::setupNotificationTimer()
{
@@ -146,7 +151,7 @@ void GitLabPluginPrivate::fetchEvents()
if (runningQuery)
return;
const GitLabProjectSettings *projSettings = GitLabPlugin::projectSettings(project);
const GitLabProjectSettings *projSettings = GitLab::projectSettings(project);
projectName = projSettings->currentProject();
serverId = projSettings->currentServer();
@@ -207,6 +212,16 @@ void GitLabPluginPrivate::handleUser(const User &user)
createAndSendEventsRequest(timeStamp);
}
GitLabProjectSettings *projectSettings(ProjectExplorer::Project *project)
{
QTC_ASSERT(project, return nullptr);
QTC_ASSERT(dd, return nullptr);
auto &settings = dd->projectSettings[project];
if (!settings)
settings = new GitLabProjectSettings(project);
return settings;
}
void GitLabPluginPrivate::handleEvents(const Events &events, const QDateTime &timeStamp)
{
runningQuery = false;
@@ -214,7 +229,7 @@ void GitLabPluginPrivate::handleEvents(const Events &events, const QDateTime &ti
ProjectExplorer::Project *project = ProjectExplorer::ProjectManager::startupProject();
QTC_ASSERT(project, return);
GitLabProjectSettings *projSettings = GitLabPlugin::projectSettings(project);
GitLabProjectSettings *projSettings = GitLab::projectSettings(project);
QTC_ASSERT(projSettings->currentProject() == projectName, return);
if (!projSettings->isLinked()) // link state has changed meanwhile - ignore the request
@@ -245,17 +260,7 @@ void GitLabPluginPrivate::handleEvents(const Events &events, const QDateTime &ti
createAndSendEventsRequest(timeStamp, events.pageInfo.currentPage + 1);
}
GitLabProjectSettings *GitLabPlugin::projectSettings(ProjectExplorer::Project *project)
{
QTC_ASSERT(project, return nullptr);
QTC_ASSERT(dd, return nullptr);
auto &settings = dd->projectSettings[project];
if (!settings)
settings = new GitLabProjectSettings(project);
return settings;
}
bool GitLabPlugin::handleCertificateIssue(const Utils::Id &serverId)
bool handleCertificateIssue(const Utils::Id &serverId)
{
QTC_ASSERT(dd, return false);
@@ -280,7 +285,7 @@ bool GitLabPlugin::handleCertificateIssue(const Utils::Id &serverId)
return false;
}
void GitLabPlugin::linkedStateChanged(bool enabled)
void linkedStateChanged(bool enabled)
{
QTC_ASSERT(dd, return);
@@ -305,3 +310,5 @@ void GitLabPlugin::linkedStateChanged(bool enabled)
}
} // namespace GitLab
#include "gitlabplugin.moc"

View File

@@ -3,35 +3,17 @@
#pragma once
#include "gitlabparameters.h"
#include <extensionsystem/iplugin.h>
namespace ProjectExplorer { class Project; }
namespace Utils { class Id; }
namespace GitLab {
class Events;
class GitLabProjectSettings;
class GitLabPlugin : public ExtensionSystem::IPlugin
{
Q_OBJECT
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "GitLab.json")
GitLabProjectSettings *projectSettings(ProjectExplorer::Project *project);
public:
GitLabPlugin();
~GitLabPlugin() override;
bool handleCertificateIssue(const Utils::Id &serverId);
void initialize() override;
void linkedStateChanged(bool enabled);
static GitLabProjectSettings *projectSettings(ProjectExplorer::Project *project);
static bool handleCertificateIssue(const Utils::Id &serverId);
static void linkedStateChanged(bool enabled);
private:
void openView();
void onStartupProjectChanged();
};
} // namespace GitLab
} // GitLab

View File

@@ -4,6 +4,7 @@
#include "gitlabprojectsettings.h"
#include "gitlaboptionspage.h"
#include "gitlabparameters.h"
#include "gitlabplugin.h"
#include "gitlabtr.h"
#include "queryrunner.h"
@@ -137,7 +138,7 @@ private:
};
GitLabProjectSettingsWidget::GitLabProjectSettingsWidget(ProjectExplorer::Project *project)
: m_projectSettings(GitLabPlugin::projectSettings(project))
: m_projectSettings(projectSettings(project))
{
setUseGlobalSettingsCheckBoxVisible(false);
setUseGlobalSettingsLabelVisible(true);
@@ -195,7 +196,7 @@ void GitLabProjectSettingsWidget::unlink()
m_projectSettings->setLinked(false);
m_projectSettings->setCurrentProject({});
updateEnabledStates();
GitLabPlugin::linkedStateChanged(false);
linkedStateChanged(false);
}
void GitLabProjectSettingsWidget::checkConnection(CheckMode mode)
@@ -258,7 +259,7 @@ void GitLabProjectSettingsWidget::onConnectionChecked(const Project &project,
m_projectSettings->setCurrentServerHost(remote);
m_projectSettings->setLinked(true);
m_projectSettings->setCurrentProject(projectName);
GitLabPlugin::linkedStateChanged(true);
linkedStateChanged(true);
}
updateEnabledStates();
}
@@ -296,10 +297,10 @@ void GitLabProjectSettingsWidget::updateUi()
m_hostCB->setCurrentIndex(m_hostCB->findData(QVariant::fromValue(serverHost)));
m_linkedGitLabServer->setCurrentIndex(
m_linkedGitLabServer->findData(QVariant::fromValue(server)));
GitLabPlugin::linkedStateChanged(true);
linkedStateChanged(true);
} else {
m_projectSettings->setLinked(false);
GitLabPlugin::linkedStateChanged(false);
linkedStateChanged(false);
}
}
updateEnabledStates();

View File

@@ -100,7 +100,7 @@ QueryRunner::QueryRunner(const Query &query, const Id &id, QObject *parent)
const int exitCode = m_process.exitCode();
if (m_process.exitStatus() == QProcess::NormalExit
&& (exitCode == 35 || exitCode == 60) // common ssl certificate issues
&& GitLabPlugin::handleCertificateIssue(id)) {
&& handleCertificateIssue(id)) {
// prepend -k for re-requesting the same query
CommandLine cmdline = m_process.commandLine();
cmdline.prependArgs({"-k"});