aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/projectexplorer/toolchainconfigwidget.h
blob: 28f475a8b34dd629c21116437d78297ae8db77f2 (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
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

#pragma once

#include "projectexplorer_export.h"

#include "toolchain.h"

#include <QScrollArea>

#include <utility>

namespace Utils { class PathChooser; }

QT_BEGIN_NAMESPACE
class QCheckBox;
class QFormLayout;
class QLineEdit;
class QLabel;
QT_END_NAMESPACE

namespace ProjectExplorer {

class PROJECTEXPLORER_EXPORT ToolchainConfigWidget : public QScrollArea
{
    Q_OBJECT

public:
    explicit ToolchainConfigWidget(const ToolchainBundle &bundle);

    ToolchainBundle bundle() const { return m_bundle; }

    void apply();
    void makeReadOnly();
    void setFallbackBrowsePath(const Utils::FilePath &path);

signals:
    void compilerCommandChanged(Utils::Id language);
    void dirty();

protected:
    void setErrorMessage(const QString &);
    void clearErrorMessage();

    virtual void applyImpl() = 0;
    virtual void makeReadOnlyImpl() = 0;

    void addErrorLabel();
    static QStringList splitString(const QString &s);
    Utils::FilePath compilerCommand(Utils::Id language);
    bool hasAnyCompiler() const;
    void setCommandVersionArguments(const QStringList &args);
    void deriveCxxCompilerCommand();

    QFormLayout *m_mainLayout;

private:
    using ToolchainChooser = std::pair<const Toolchain *, Utils::PathChooser *>;
    ToolchainChooser compilerPathChooser(Utils::Id language);
    void setupCompilerPathChoosers();

    ToolchainBundle m_bundle;
    QLineEdit *m_nameLineEdit = nullptr;
    QLabel *m_errorLabel = nullptr;
    QCheckBox *m_manualCxxCompilerCheckBox = nullptr;
    QList<ToolchainChooser> m_commands;
};

} // namespace ProjectExplorer