|
5 | 5 |
|
6 | 6 | #include "cocopluginconstants.h" |
7 | 7 | #include "cocoprojectwidget.h" |
| 8 | +#include "cocotr.h" |
8 | 9 |
|
9 | 10 | #include <cmakeprojectmanager/cmakeprojectconstants.h> |
| 11 | + |
10 | 12 | #include <projectexplorer/buildconfiguration.h> |
11 | 13 | #include <projectexplorer/project.h> |
| 14 | +#include <projectexplorer/projectpanelfactory.h> |
| 15 | +#include <projectexplorer/projectsettingswidget.h> |
12 | 16 | #include <projectexplorer/target.h> |
| 17 | + |
13 | 18 | #include <qmakeprojectmanager/qmakeprojectmanagerconstants.h> |
14 | 19 |
|
| 20 | +#include <QVBoxLayout> |
15 | 21 | #include <QDebug> |
16 | 22 |
|
| 23 | +using namespace ProjectExplorer; |
| 24 | + |
17 | 25 | namespace Coco::Internal { |
18 | 26 |
|
19 | | -CocoProjectSettingsWidget::CocoProjectSettingsWidget(ProjectExplorer::Project *project) |
20 | | - : m_layout{new QVBoxLayout} |
| 27 | +class CocoProjectSettingsWidget final : public ProjectSettingsWidget |
21 | 28 | { |
22 | | - setUseGlobalSettingsCheckBoxVisible(false); |
23 | | - setGlobalSettingsId(Constants::COCO_SETTINGS_PAGE_ID); |
| 29 | +public: |
| 30 | + explicit CocoProjectSettingsWidget(Project *project) |
| 31 | + { |
| 32 | + setUseGlobalSettingsCheckBoxVisible(false); |
| 33 | + setGlobalSettingsId(Constants::COCO_SETTINGS_PAGE_ID); |
24 | 34 |
|
25 | | - if (auto *target = project->activeTarget()) { |
26 | | - auto abc = target->activeBuildConfiguration(); |
| 35 | + auto layout = new QVBoxLayout; |
| 36 | + if (auto *target = project->activeTarget()) { |
| 37 | + auto abc = target->activeBuildConfiguration(); |
27 | 38 |
|
28 | | - if (abc->id() == QmakeProjectManager::Constants::QMAKE_BC_ID |
29 | | - || abc->id() == CMakeProjectManager::Constants::CMAKE_BUILDCONFIGURATION_ID) |
30 | | - m_layout->addWidget(new CocoProjectWidget(project, abc)); |
| 39 | + if (abc->id() == QmakeProjectManager::Constants::QMAKE_BC_ID |
| 40 | + || abc->id() == CMakeProjectManager::Constants::CMAKE_BUILDCONFIGURATION_ID) |
| 41 | + layout->addWidget(new CocoProjectWidget(project, abc)); |
| 42 | + } |
| 43 | + setLayout(layout); |
31 | 44 | } |
32 | | - setLayout(m_layout); |
33 | | -} |
| 45 | +}; |
| 46 | + |
| 47 | +class CocoProjectPanelFactory final : public ProjectPanelFactory |
| 48 | +{ |
| 49 | +public: |
| 50 | + CocoProjectPanelFactory() |
| 51 | + { |
| 52 | + setPriority(50); |
| 53 | + setDisplayName(Tr::tr("Coco Code Coverage")); |
| 54 | + setSupportsFunction([](Project *project) { |
| 55 | + if (Target *target = project->activeTarget()) { |
| 56 | + if (BuildConfiguration *abc = target->activeBuildConfiguration()) |
| 57 | + return BuildSettings::supportsBuildConfig(*abc); |
| 58 | + } |
| 59 | + return false; |
| 60 | + }); |
| 61 | + setCreateWidgetFunction( |
| 62 | + [](Project *project) { return new CocoProjectSettingsWidget(project); }); |
| 63 | + } |
| 64 | +}; |
34 | 65 |
|
35 | | -CocoProjectSettingsWidget::~CocoProjectSettingsWidget() |
| 66 | +void setupCocoProjectPanel() |
36 | 67 | { |
37 | | - delete m_layout; |
| 68 | + static CocoProjectPanelFactory theCocoProjectPanelFactory; |
38 | 69 | } |
39 | 70 |
|
40 | 71 | } // namespace Coco::Internal |
0 commit comments