forked from qt-creator/qt-creator
GitLab: Hide plugin class definition in .cpp
Change-Id: I362bcbd09ef4694f0478c8982ea627cb9d8c310b Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
@@ -188,7 +188,7 @@ void GitLabDialog::requestMainViewUpdate()
|
|||||||
bool linked = false;
|
bool linked = false;
|
||||||
m_currentServerId = Id();
|
m_currentServerId = Id();
|
||||||
if (auto project = ProjectExplorer::ProjectManager::startupProject()) {
|
if (auto project = ProjectExplorer::ProjectManager::startupProject()) {
|
||||||
GitLabProjectSettings *projSettings = GitLabPlugin::projectSettings(project);
|
GitLabProjectSettings *projSettings = projectSettings(project);
|
||||||
if (projSettings->isLinked()) {
|
if (projSettings->isLinked()) {
|
||||||
m_currentServerId = projSettings->currentServer();
|
m_currentServerId = projSettings->currentServer();
|
||||||
linked = true;
|
linked = true;
|
||||||
|
|||||||
@@ -15,6 +15,8 @@
|
|||||||
#include <coreplugin/actionmanager/actionmanager.h>
|
#include <coreplugin/actionmanager/actionmanager.h>
|
||||||
#include <coreplugin/icore.h>
|
#include <coreplugin/icore.h>
|
||||||
|
|
||||||
|
#include <extensionsystem/iplugin.h>
|
||||||
|
|
||||||
#include <git/gitplugin.h>
|
#include <git/gitplugin.h>
|
||||||
|
|
||||||
#include <projectexplorer/project.h>
|
#include <projectexplorer/project.h>
|
||||||
@@ -56,22 +58,23 @@ public:
|
|||||||
|
|
||||||
static GitLabPluginPrivate *dd = nullptr;
|
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()) {
|
if (!dd->projectSettings.isEmpty()) {
|
||||||
qDeleteAll(dd->projectSettings);
|
qDeleteAll(dd->projectSettings);
|
||||||
dd->projectSettings.clear();
|
dd->projectSettings.clear();
|
||||||
}
|
}
|
||||||
delete dd;
|
delete dd;
|
||||||
dd = nullptr;
|
dd = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GitLabPlugin::initialize()
|
void initialize() final
|
||||||
{
|
{
|
||||||
dd = new GitLabPluginPrivate;
|
dd = new GitLabPluginPrivate;
|
||||||
gitLabParameters().fromSettings(Core::ICore::settings());
|
gitLabParameters().fromSettings(Core::ICore::settings());
|
||||||
|
|
||||||
@@ -85,10 +88,10 @@ void GitLabPlugin::initialize()
|
|||||||
connect(ProjectExplorer::ProjectManager::instance(),
|
connect(ProjectExplorer::ProjectManager::instance(),
|
||||||
&ProjectExplorer::ProjectManager::startupProjectChanged,
|
&ProjectExplorer::ProjectManager::startupProjectChanged,
|
||||||
this, &GitLabPlugin::onStartupProjectChanged);
|
this, &GitLabPlugin::onStartupProjectChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GitLabPlugin::openView()
|
void openView()
|
||||||
{
|
{
|
||||||
if (dd->dialog.isNull()) {
|
if (dd->dialog.isNull()) {
|
||||||
while (!gitLabParameters().isValid()) {
|
while (!gitLabParameters().isValid()) {
|
||||||
QMessageBox::warning(Core::ICore::dialogParent(), Tr::tr("Error"),
|
QMessageBox::warning(Core::ICore::dialogParent(), Tr::tr("Error"),
|
||||||
@@ -108,10 +111,10 @@ void GitLabPlugin::openView()
|
|||||||
dd->dialog->setWindowState(state & ~Qt::WindowMinimized);
|
dd->dialog->setWindowState(state & ~Qt::WindowMinimized);
|
||||||
dd->dialog->show();
|
dd->dialog->show();
|
||||||
dd->dialog->raise();
|
dd->dialog->raise();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GitLabPlugin::onStartupProjectChanged()
|
void onStartupProjectChanged()
|
||||||
{
|
{
|
||||||
QTC_ASSERT(dd, return);
|
QTC_ASSERT(dd, return);
|
||||||
disconnect(&dd->notificationTimer);
|
disconnect(&dd->notificationTimer);
|
||||||
ProjectExplorer::Project *project = ProjectExplorer::ProjectManager::startupProject();
|
ProjectExplorer::Project *project = ProjectExplorer::ProjectManager::startupProject();
|
||||||
@@ -120,7 +123,7 @@ void GitLabPlugin::onStartupProjectChanged()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const GitLabProjectSettings *projSettings = projectSettings(project);
|
const GitLabProjectSettings *projSettings = GitLab::projectSettings(project);
|
||||||
if (!projSettings->isLinked()) {
|
if (!projSettings->isLinked()) {
|
||||||
dd->notificationTimer.stop();
|
dd->notificationTimer.stop();
|
||||||
return;
|
return;
|
||||||
@@ -128,7 +131,9 @@ void GitLabPlugin::onStartupProjectChanged()
|
|||||||
|
|
||||||
dd->fetchEvents();
|
dd->fetchEvents();
|
||||||
dd->setupNotificationTimer();
|
dd->setupNotificationTimer();
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
void GitLabPluginPrivate::setupNotificationTimer()
|
void GitLabPluginPrivate::setupNotificationTimer()
|
||||||
{
|
{
|
||||||
@@ -146,7 +151,7 @@ void GitLabPluginPrivate::fetchEvents()
|
|||||||
if (runningQuery)
|
if (runningQuery)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const GitLabProjectSettings *projSettings = GitLabPlugin::projectSettings(project);
|
const GitLabProjectSettings *projSettings = GitLab::projectSettings(project);
|
||||||
projectName = projSettings->currentProject();
|
projectName = projSettings->currentProject();
|
||||||
serverId = projSettings->currentServer();
|
serverId = projSettings->currentServer();
|
||||||
|
|
||||||
@@ -207,6 +212,16 @@ void GitLabPluginPrivate::handleUser(const User &user)
|
|||||||
createAndSendEventsRequest(timeStamp);
|
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)
|
void GitLabPluginPrivate::handleEvents(const Events &events, const QDateTime &timeStamp)
|
||||||
{
|
{
|
||||||
runningQuery = false;
|
runningQuery = false;
|
||||||
@@ -214,7 +229,7 @@ void GitLabPluginPrivate::handleEvents(const Events &events, const QDateTime &ti
|
|||||||
ProjectExplorer::Project *project = ProjectExplorer::ProjectManager::startupProject();
|
ProjectExplorer::Project *project = ProjectExplorer::ProjectManager::startupProject();
|
||||||
QTC_ASSERT(project, return);
|
QTC_ASSERT(project, return);
|
||||||
|
|
||||||
GitLabProjectSettings *projSettings = GitLabPlugin::projectSettings(project);
|
GitLabProjectSettings *projSettings = GitLab::projectSettings(project);
|
||||||
QTC_ASSERT(projSettings->currentProject() == projectName, return);
|
QTC_ASSERT(projSettings->currentProject() == projectName, return);
|
||||||
|
|
||||||
if (!projSettings->isLinked()) // link state has changed meanwhile - ignore the request
|
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);
|
createAndSendEventsRequest(timeStamp, events.pageInfo.currentPage + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
GitLabProjectSettings *GitLabPlugin::projectSettings(ProjectExplorer::Project *project)
|
bool handleCertificateIssue(const Utils::Id &serverId)
|
||||||
{
|
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
QTC_ASSERT(dd, return false);
|
QTC_ASSERT(dd, return false);
|
||||||
|
|
||||||
@@ -280,7 +285,7 @@ bool GitLabPlugin::handleCertificateIssue(const Utils::Id &serverId)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void GitLabPlugin::linkedStateChanged(bool enabled)
|
void linkedStateChanged(bool enabled)
|
||||||
{
|
{
|
||||||
QTC_ASSERT(dd, return);
|
QTC_ASSERT(dd, return);
|
||||||
|
|
||||||
@@ -305,3 +310,5 @@ void GitLabPlugin::linkedStateChanged(bool enabled)
|
|||||||
}
|
}
|
||||||
|
|
||||||
} // namespace GitLab
|
} // namespace GitLab
|
||||||
|
|
||||||
|
#include "gitlabplugin.moc"
|
||||||
|
|||||||
@@ -3,35 +3,17 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "gitlabparameters.h"
|
|
||||||
|
|
||||||
#include <extensionsystem/iplugin.h>
|
|
||||||
|
|
||||||
namespace ProjectExplorer { class Project; }
|
namespace ProjectExplorer { class Project; }
|
||||||
|
namespace Utils { class Id; }
|
||||||
|
|
||||||
namespace GitLab {
|
namespace GitLab {
|
||||||
|
|
||||||
class Events;
|
|
||||||
class GitLabProjectSettings;
|
class GitLabProjectSettings;
|
||||||
|
|
||||||
class GitLabPlugin : public ExtensionSystem::IPlugin
|
GitLabProjectSettings *projectSettings(ProjectExplorer::Project *project);
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QtCreatorPlugin" FILE "GitLab.json")
|
|
||||||
|
|
||||||
public:
|
bool handleCertificateIssue(const Utils::Id &serverId);
|
||||||
GitLabPlugin();
|
|
||||||
~GitLabPlugin() override;
|
|
||||||
|
|
||||||
void initialize() override;
|
void linkedStateChanged(bool enabled);
|
||||||
|
|
||||||
static GitLabProjectSettings *projectSettings(ProjectExplorer::Project *project);
|
} // GitLab
|
||||||
static bool handleCertificateIssue(const Utils::Id &serverId);
|
|
||||||
|
|
||||||
static void linkedStateChanged(bool enabled);
|
|
||||||
private:
|
|
||||||
void openView();
|
|
||||||
void onStartupProjectChanged();
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace GitLab
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include "gitlabprojectsettings.h"
|
#include "gitlabprojectsettings.h"
|
||||||
|
|
||||||
#include "gitlaboptionspage.h"
|
#include "gitlaboptionspage.h"
|
||||||
|
#include "gitlabparameters.h"
|
||||||
#include "gitlabplugin.h"
|
#include "gitlabplugin.h"
|
||||||
#include "gitlabtr.h"
|
#include "gitlabtr.h"
|
||||||
#include "queryrunner.h"
|
#include "queryrunner.h"
|
||||||
@@ -137,7 +138,7 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
GitLabProjectSettingsWidget::GitLabProjectSettingsWidget(ProjectExplorer::Project *project)
|
GitLabProjectSettingsWidget::GitLabProjectSettingsWidget(ProjectExplorer::Project *project)
|
||||||
: m_projectSettings(GitLabPlugin::projectSettings(project))
|
: m_projectSettings(projectSettings(project))
|
||||||
{
|
{
|
||||||
setUseGlobalSettingsCheckBoxVisible(false);
|
setUseGlobalSettingsCheckBoxVisible(false);
|
||||||
setUseGlobalSettingsLabelVisible(true);
|
setUseGlobalSettingsLabelVisible(true);
|
||||||
@@ -195,7 +196,7 @@ void GitLabProjectSettingsWidget::unlink()
|
|||||||
m_projectSettings->setLinked(false);
|
m_projectSettings->setLinked(false);
|
||||||
m_projectSettings->setCurrentProject({});
|
m_projectSettings->setCurrentProject({});
|
||||||
updateEnabledStates();
|
updateEnabledStates();
|
||||||
GitLabPlugin::linkedStateChanged(false);
|
linkedStateChanged(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GitLabProjectSettingsWidget::checkConnection(CheckMode mode)
|
void GitLabProjectSettingsWidget::checkConnection(CheckMode mode)
|
||||||
@@ -258,7 +259,7 @@ void GitLabProjectSettingsWidget::onConnectionChecked(const Project &project,
|
|||||||
m_projectSettings->setCurrentServerHost(remote);
|
m_projectSettings->setCurrentServerHost(remote);
|
||||||
m_projectSettings->setLinked(true);
|
m_projectSettings->setLinked(true);
|
||||||
m_projectSettings->setCurrentProject(projectName);
|
m_projectSettings->setCurrentProject(projectName);
|
||||||
GitLabPlugin::linkedStateChanged(true);
|
linkedStateChanged(true);
|
||||||
}
|
}
|
||||||
updateEnabledStates();
|
updateEnabledStates();
|
||||||
}
|
}
|
||||||
@@ -296,10 +297,10 @@ void GitLabProjectSettingsWidget::updateUi()
|
|||||||
m_hostCB->setCurrentIndex(m_hostCB->findData(QVariant::fromValue(serverHost)));
|
m_hostCB->setCurrentIndex(m_hostCB->findData(QVariant::fromValue(serverHost)));
|
||||||
m_linkedGitLabServer->setCurrentIndex(
|
m_linkedGitLabServer->setCurrentIndex(
|
||||||
m_linkedGitLabServer->findData(QVariant::fromValue(server)));
|
m_linkedGitLabServer->findData(QVariant::fromValue(server)));
|
||||||
GitLabPlugin::linkedStateChanged(true);
|
linkedStateChanged(true);
|
||||||
} else {
|
} else {
|
||||||
m_projectSettings->setLinked(false);
|
m_projectSettings->setLinked(false);
|
||||||
GitLabPlugin::linkedStateChanged(false);
|
linkedStateChanged(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
updateEnabledStates();
|
updateEnabledStates();
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ QueryRunner::QueryRunner(const Query &query, const Id &id, QObject *parent)
|
|||||||
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) // common ssl certificate issues
|
&& (exitCode == 35 || exitCode == 60) // common ssl certificate issues
|
||||||
&& GitLabPlugin::handleCertificateIssue(id)) {
|
&& handleCertificateIssue(id)) {
|
||||||
// prepend -k for re-requesting the same query
|
// prepend -k for re-requesting the same query
|
||||||
CommandLine cmdline = m_process.commandLine();
|
CommandLine cmdline = m_process.commandLine();
|
||||||
cmdline.prependArgs({"-k"});
|
cmdline.prependArgs({"-k"});
|
||||||
|
|||||||
Reference in New Issue
Block a user