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 initialize() final;
|
||||||
void addEntryToProjectSettings();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CocoLanguageClient *m_client = nullptr;
|
CocoLanguageClient *m_client = nullptr;
|
||||||
@@ -121,27 +120,12 @@ void CocoPlugin::initialize()
|
|||||||
|
|
||||||
GlobalSettings::read();
|
GlobalSettings::read();
|
||||||
GlobalSettingsPage::instance().widget();
|
GlobalSettingsPage::instance().widget();
|
||||||
addEntryToProjectSettings();
|
|
||||||
|
setupCocoProjectPanel();
|
||||||
|
|
||||||
initLanguageServer();
|
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
|
} // namespace Coco
|
||||||
|
|
||||||
#include "cocoplugin.moc"
|
#include "cocoplugin.moc"
|
||||||
|
@@ -5,36 +5,67 @@
|
|||||||
|
|
||||||
#include "cocopluginconstants.h"
|
#include "cocopluginconstants.h"
|
||||||
#include "cocoprojectwidget.h"
|
#include "cocoprojectwidget.h"
|
||||||
|
#include "cocotr.h"
|
||||||
|
|
||||||
#include <cmakeprojectmanager/cmakeprojectconstants.h>
|
#include <cmakeprojectmanager/cmakeprojectconstants.h>
|
||||||
|
|
||||||
#include <projectexplorer/buildconfiguration.h>
|
#include <projectexplorer/buildconfiguration.h>
|
||||||
#include <projectexplorer/project.h>
|
#include <projectexplorer/project.h>
|
||||||
|
#include <projectexplorer/projectpanelfactory.h>
|
||||||
|
#include <projectexplorer/projectsettingswidget.h>
|
||||||
#include <projectexplorer/target.h>
|
#include <projectexplorer/target.h>
|
||||||
|
|
||||||
#include <qmakeprojectmanager/qmakeprojectmanagerconstants.h>
|
#include <qmakeprojectmanager/qmakeprojectmanagerconstants.h>
|
||||||
|
|
||||||
|
#include <QVBoxLayout>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
|
using namespace ProjectExplorer;
|
||||||
|
|
||||||
namespace Coco::Internal {
|
namespace Coco::Internal {
|
||||||
|
|
||||||
CocoProjectSettingsWidget::CocoProjectSettingsWidget(ProjectExplorer::Project *project)
|
class CocoProjectSettingsWidget final : public ProjectSettingsWidget
|
||||||
: m_layout{new QVBoxLayout}
|
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
|
explicit CocoProjectSettingsWidget(Project *project)
|
||||||
|
{
|
||||||
setUseGlobalSettingsCheckBoxVisible(false);
|
setUseGlobalSettingsCheckBoxVisible(false);
|
||||||
setGlobalSettingsId(Constants::COCO_SETTINGS_PAGE_ID);
|
setGlobalSettingsId(Constants::COCO_SETTINGS_PAGE_ID);
|
||||||
|
|
||||||
|
auto layout = new QVBoxLayout;
|
||||||
if (auto *target = project->activeTarget()) {
|
if (auto *target = project->activeTarget()) {
|
||||||
auto abc = target->activeBuildConfiguration();
|
auto abc = target->activeBuildConfiguration();
|
||||||
|
|
||||||
if (abc->id() == QmakeProjectManager::Constants::QMAKE_BC_ID
|
if (abc->id() == QmakeProjectManager::Constants::QMAKE_BC_ID
|
||||||
|| abc->id() == CMakeProjectManager::Constants::CMAKE_BUILDCONFIGURATION_ID)
|
|| abc->id() == CMakeProjectManager::Constants::CMAKE_BUILDCONFIGURATION_ID)
|
||||||
m_layout->addWidget(new CocoProjectWidget(project, abc));
|
layout->addWidget(new CocoProjectWidget(project, abc));
|
||||||
}
|
}
|
||||||
setLayout(m_layout);
|
setLayout(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
|
} // namespace Coco::Internal
|
||||||
|
@@ -3,26 +3,8 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <projectexplorer/projectsettingswidget.h>
|
|
||||||
|
|
||||||
#include <QVBoxLayout>
|
|
||||||
|
|
||||||
namespace ProjectExplorer {
|
|
||||||
class Project;
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace Coco::Internal {
|
namespace Coco::Internal {
|
||||||
|
|
||||||
class CocoProjectSettingsWidget : public ProjectExplorer::ProjectSettingsWidget
|
void setupCocoProjectPanel();
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
public:
|
|
||||||
explicit CocoProjectSettingsWidget(ProjectExplorer::Project *project);
|
|
||||||
~CocoProjectSettingsWidget();
|
|
||||||
|
|
||||||
private:
|
|
||||||
QVBoxLayout *m_layout;
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace Coco::Internal
|
} // namespace Coco::Internal
|
||||||
|
Reference in New Issue
Block a user