forked from qt-creator/qt-creator
Coco: Slim down project panel creation interface
Change-Id: I7ac8c3551e906fdf2f19d2fbcee0db586fb94aae Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -104,7 +104,6 @@ public:
|
||||
}
|
||||
|
||||
void initialize() final;
|
||||
void addEntryToProjectSettings();
|
||||
|
||||
private:
|
||||
CocoLanguageClient *m_client = nullptr;
|
||||
@@ -121,27 +120,12 @@ void CocoPlugin::initialize()
|
||||
|
||||
GlobalSettings::read();
|
||||
GlobalSettingsPage::instance().widget();
|
||||
addEntryToProjectSettings();
|
||||
|
||||
setupCocoProjectPanel();
|
||||
|
||||
initLanguageServer();
|
||||
}
|
||||
|
||||
void CocoPlugin::addEntryToProjectSettings()
|
||||
{
|
||||
auto panelFactory = new ProjectPanelFactory;
|
||||
panelFactory->setPriority(50);
|
||||
panelFactory->setDisplayName(tr("Coco Code Coverage"));
|
||||
panelFactory->setSupportsFunction([](Project *project) {
|
||||
if (Target *target = project->activeTarget()) {
|
||||
if (BuildConfiguration *abc = target->activeBuildConfiguration())
|
||||
return BuildSettings::supportsBuildConfig(*abc);
|
||||
}
|
||||
return false;
|
||||
});
|
||||
panelFactory->setCreateWidgetFunction(
|
||||
[](Project *project) { return new CocoProjectSettingsWidget(project); });
|
||||
}
|
||||
|
||||
} // namespace Coco
|
||||
|
||||
#include "cocoplugin.moc"
|
||||
|
@@ -5,36 +5,67 @@
|
||||
|
||||
#include "cocopluginconstants.h"
|
||||
#include "cocoprojectwidget.h"
|
||||
#include "cocotr.h"
|
||||
|
||||
#include <cmakeprojectmanager/cmakeprojectconstants.h>
|
||||
|
||||
#include <projectexplorer/buildconfiguration.h>
|
||||
#include <projectexplorer/project.h>
|
||||
#include <projectexplorer/projectpanelfactory.h>
|
||||
#include <projectexplorer/projectsettingswidget.h>
|
||||
#include <projectexplorer/target.h>
|
||||
|
||||
#include <qmakeprojectmanager/qmakeprojectmanagerconstants.h>
|
||||
|
||||
#include <QVBoxLayout>
|
||||
#include <QDebug>
|
||||
|
||||
using namespace ProjectExplorer;
|
||||
|
||||
namespace Coco::Internal {
|
||||
|
||||
CocoProjectSettingsWidget::CocoProjectSettingsWidget(ProjectExplorer::Project *project)
|
||||
: m_layout{new QVBoxLayout}
|
||||
class CocoProjectSettingsWidget final : public ProjectSettingsWidget
|
||||
{
|
||||
setUseGlobalSettingsCheckBoxVisible(false);
|
||||
setGlobalSettingsId(Constants::COCO_SETTINGS_PAGE_ID);
|
||||
public:
|
||||
explicit CocoProjectSettingsWidget(Project *project)
|
||||
{
|
||||
setUseGlobalSettingsCheckBoxVisible(false);
|
||||
setGlobalSettingsId(Constants::COCO_SETTINGS_PAGE_ID);
|
||||
|
||||
if (auto *target = project->activeTarget()) {
|
||||
auto abc = target->activeBuildConfiguration();
|
||||
auto layout = new QVBoxLayout;
|
||||
if (auto *target = project->activeTarget()) {
|
||||
auto abc = target->activeBuildConfiguration();
|
||||
|
||||
if (abc->id() == QmakeProjectManager::Constants::QMAKE_BC_ID
|
||||
|| abc->id() == CMakeProjectManager::Constants::CMAKE_BUILDCONFIGURATION_ID)
|
||||
m_layout->addWidget(new CocoProjectWidget(project, abc));
|
||||
if (abc->id() == QmakeProjectManager::Constants::QMAKE_BC_ID
|
||||
|| abc->id() == CMakeProjectManager::Constants::CMAKE_BUILDCONFIGURATION_ID)
|
||||
layout->addWidget(new CocoProjectWidget(project, abc));
|
||||
}
|
||||
setLayout(layout);
|
||||
}
|
||||
setLayout(m_layout);
|
||||
}
|
||||
};
|
||||
|
||||
CocoProjectSettingsWidget::~CocoProjectSettingsWidget()
|
||||
class CocoProjectPanelFactory final : public ProjectPanelFactory
|
||||
{
|
||||
delete m_layout;
|
||||
public:
|
||||
CocoProjectPanelFactory()
|
||||
{
|
||||
setPriority(50);
|
||||
setDisplayName(Tr::tr("Coco Code Coverage"));
|
||||
setSupportsFunction([](Project *project) {
|
||||
if (Target *target = project->activeTarget()) {
|
||||
if (BuildConfiguration *abc = target->activeBuildConfiguration())
|
||||
return BuildSettings::supportsBuildConfig(*abc);
|
||||
}
|
||||
return false;
|
||||
});
|
||||
setCreateWidgetFunction(
|
||||
[](Project *project) { return new CocoProjectSettingsWidget(project); });
|
||||
}
|
||||
};
|
||||
|
||||
void setupCocoProjectPanel()
|
||||
{
|
||||
static CocoProjectPanelFactory theCocoProjectPanelFactory;
|
||||
}
|
||||
|
||||
} // namespace Coco::Internal
|
||||
|
@@ -3,26 +3,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <projectexplorer/projectsettingswidget.h>
|
||||
|
||||
#include <QVBoxLayout>
|
||||
|
||||
namespace ProjectExplorer {
|
||||
class Project;
|
||||
}
|
||||
|
||||
namespace Coco::Internal {
|
||||
|
||||
class CocoProjectSettingsWidget : public ProjectExplorer::ProjectSettingsWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CocoProjectSettingsWidget(ProjectExplorer::Project *project);
|
||||
~CocoProjectSettingsWidget();
|
||||
|
||||
private:
|
||||
QVBoxLayout *m_layout;
|
||||
};
|
||||
void setupCocoProjectPanel();
|
||||
|
||||
} // namespace Coco::Internal
|
||||
|
Reference in New Issue
Block a user