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

#include "vcpkgsettings.h"

#include "vcpkgconstants.h"
#include "vcpkgtr.h"

#include <cmakeprojectmanager/cmakeprojectconstants.h>

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

#include <QDesktopServices>
#include <QToolButton>

namespace Vcpkg::Internal {

static VcpkgSettings *theSettings = nullptr;

VcpkgSettings &settings()
{
    return *theSettings;
}

VcpkgSettings::VcpkgSettings()
{
    theSettings = this;

    setSettingsGroup("Vcpkg");
    setId(Constants::TOOLSSETTINGSPAGE_ID);
    setDisplayName("Vcpkg");
    setCategory(CMakeProjectManager::Constants::Settings::CATEGORY);

    vcpkgRoot.setSettingsKey("VcpkgRoot");
    vcpkgRoot.setExpectedKind(Utils::PathChooser::ExistingDirectory);
    vcpkgRoot.setDefaultValue(Utils::qtcEnvironmentVariable(Constants::ENVVAR_VCPKG_ROOT));

    setLayouter([this] {
        using namespace Layouting;
        auto websiteButton = new QToolButton;
        websiteButton->setIcon(Utils::Icons::ONLINE.icon());
        websiteButton->setToolTip(Constants::WEBSITE_URL);

        connect(websiteButton, &QAbstractButton::clicked, [] {
            QDesktopServices::openUrl(QUrl::fromUserInput(Constants::WEBSITE_URL));
        });

        // clang-format off
        using namespace Layouting;
        return Column {
            Group {
                title(Tr::tr("Vcpkg installation")),
                Form {
                    Utils::PathChooser::label(),
                    Span { 2, Row { vcpkgRoot, websiteButton } },
                },
            },
            st,
        };
        // clang-format on
    });

    readSettings();
}

} // Vcpkg::Internal