aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/qmakeprojectmanager/qmakesettings.cpp
blob: e0ab9a47082c9ff315373b6a36d27bdf5e9198b4 (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
// Copyright (C) 2019 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

#include "qmakesettings.h"
#include "qmakeprojectmanagertr.h"

#include <coreplugin/dialogs/ioptionspage.h>

#include <projectexplorer/projectexplorerconstants.h>

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

using namespace Utils;

namespace QmakeProjectManager::Internal {

QmakeSettings &settings()
{
    static QmakeSettings theSettings;
    return theSettings;
}

QmakeSettings::QmakeSettings()
{
    setAutoApply(false);
    setSettingsGroup("QmakeProjectManager");

    warnAgainstUnalignedBuildDir.setSettingsKey("WarnAgainstUnalignedBuildDir");
    warnAgainstUnalignedBuildDir.setDefaultValue(HostOsInfo::isWindowsHost());
    warnAgainstUnalignedBuildDir.setLabelText(Tr::tr("Warn if a project's source and "
        "build directories are not at the same level"));
    warnAgainstUnalignedBuildDir.setToolTip(Tr::tr("Qmake has subtle bugs that "
        "can be triggered if source and build directory are not at the same level."));

    alwaysRunQmake.setSettingsKey("AlwaysRunQmake");
    alwaysRunQmake.setLabelText(Tr::tr("Run qmake on every build"));
    alwaysRunQmake.setToolTip(Tr::tr("This option can help to prevent failures on "
        "incremental builds, but might slow them down unnecessarily in the general case."));

    ignoreSystemFunction.setSettingsKey("RunSystemFunction");
    ignoreSystemFunction.setLabelText(Tr::tr("Ignore qmake's system() function when parsing a project"));
    ignoreSystemFunction.setToolTip(Tr::tr("Checking this option avoids unwanted side effects, "
         "but may result in inexact parsing results."));
    // The settings value has been stored with the opposite meaning for a while.
    // Avoid changing the stored value, but flip it on read/write:
    const auto invertBoolVariant = [](const QVariant &v) { return QVariant(!v.toBool()); };
    ignoreSystemFunction.setFromSettingsTransformation(invertBoolVariant);
    ignoreSystemFunction.setToSettingsTransformation(invertBoolVariant);

    setLayouter([this] {
        using namespace Layouting;
        return Column {
            warnAgainstUnalignedBuildDir,
            alwaysRunQmake,
            ignoreSystemFunction,
            st
        };
    });

    readSettings();
}

class QmakeSettingsPage : public Core::IOptionsPage
{
public:
    QmakeSettingsPage()
    {
        setId("K.QmakeProjectManager.QmakeSettings");
        setDisplayName(Tr::tr("Qmake"));
        setCategory(ProjectExplorer::Constants::BUILD_AND_RUN_SETTINGS_CATEGORY);
        setSettingsProvider([] { return &settings(); });
    }
};

static const QmakeSettingsPage settingsPage;

} // QmakeProjectManager::Internal