aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/projectexplorer/buildpropertiessettings.cpp
blob: ff7c1808518cecd7510cad335ba2459dbab314d4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
// Copyright (C) 2021 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

#include "buildpropertiessettings.h"

#include "projectexplorerconstants.h"
#include "projectexplorertr.h"

#include <coreplugin/dialogs/ioptionspage.h>

#include <utils/environment.h>
#include <utils/layoutbuilder.h>

using namespace Utils;

namespace ProjectExplorer {

static QString defaultBuildDirectoryTemplate()
{
    return qtcEnvironmentVariable(
        Constants::QTC_DEFAULT_BUILD_DIRECTORY_TEMPLATE,
        "./build/%{Asciify:%{Kit:FileSystemName}-%{BuildConfig:Name}}");
}

BuildPropertiesSettings &buildPropertiesSettings()
{
    static BuildPropertiesSettings theSettings;
    return theSettings;
}

BuildPropertiesSettings::BuildTriStateAspect::BuildTriStateAspect(AspectContainer *container)
    : TriStateAspect(container, Tr::tr("Enable"), Tr::tr("Disable"), Tr::tr("Use Project Default"))
{}

BuildPropertiesSettings::BuildPropertiesSettings()
{
    setAutoApply(false);

    setLayouter([this] {
        using namespace Layouting;

        return Column {
            Form {
                buildDirectoryTemplate, br,
                separateDebugInfo, br,
                qmlDebugging, br,
                qtQuickCompiler
            },
            st
        };
    });

    buildDirectoryTemplate.setDisplayStyle(StringAspect::LineEditDisplay);
    buildDirectoryTemplate.setSettingsKey("Directories/BuildDirectory.TemplateV2");
    buildDirectoryTemplate.setDefaultValue(defaultBuildDirectoryTemplate());
    buildDirectoryTemplate.setLabelText(Tr::tr("Default build directory:"));
    buildDirectoryTemplate.setToolTip(
        Tr::tr("Template used to construct the default build directory.<br><br>"
               "The default value can be set using the environment variable "
               "<tt>%1</tt>")
            .arg(Constants::QTC_DEFAULT_BUILD_DIRECTORY_TEMPLATE));
    buildDirectoryTemplate.setUseGlobalMacroExpander();
    buildDirectoryTemplate.setUseResetButton();

    separateDebugInfo.setSettingsKey("ProjectExplorer/Settings/SeparateDebugInfo");
    separateDebugInfo.setLabelText(Tr::tr("Separate debug info:"));

    qmlDebugging.setSettingsKey("ProjectExplorer/Settings/QmlDebugging");
    qmlDebugging.setLabelText(Tr::tr("QML debugging:"));
    qmlDebugging.setVisible(false);

    qtQuickCompiler.setSettingsKey("ProjectExplorer/Settings/QtQuickCompiler");
    qtQuickCompiler.setLabelText(Tr::tr("Use qmlcachegen:"));
    qtQuickCompiler.setVisible(false);

    readSettings();
}

void BuildPropertiesSettings::showQtSettings()
{
    buildPropertiesSettings().qmlDebugging.setVisible(true);
    buildPropertiesSettings().qtQuickCompiler.setVisible(true);
}

// BuildPropertiesSettingsPage

class BuildPropertiesSettingsPage final : public Core::IOptionsPage
{
public:
    BuildPropertiesSettingsPage()
    {
        setId("AB.ProjectExplorer.BuildPropertiesSettingsPage");
        setDisplayName(Tr::tr("Default Build Properties"));
        setCategory(ProjectExplorer::Constants::BUILD_AND_RUN_SETTINGS_CATEGORY);
        setSettingsProvider([] { return &buildPropertiesSettings(); });
    }
};

const BuildPropertiesSettingsPage settingsPage;

} // ProjectExplorer