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

#include "extensionmanagerlegalnotice.h"

#include "extensionmanagersettings.h"
#include "extensionmanagertr.h"

#include <utils/infobar.h>

#include <coreplugin/icore.h>

#include <QGuiApplication>

using namespace Core;
using namespace Utils;

namespace ExtensionManager {

void setLegalNoticeVisible(bool visible)
{
    const char kEnableExternalRepo[] = "EnableExternalRepo";

    InfoBar *infoBar = ICore::popupInfoBar();

    if (!visible) {
        if (infoBar->containsInfo(kEnableExternalRepo))
            infoBar->removeInfo(kEnableExternalRepo);
        return;
    }
    if (Internal::settings().useExternalRepo() || !infoBar->canInfoBeAdded(kEnableExternalRepo))
        return;

    const QString text = Tr::tr("Qt Creator Extensions are available from configured online "
                                "sources, such as Qt Creator Extensions Store provided by "
                                "Qt Group, but also third-party provided sources. "
                                "Extensions for Qt Creator may be created and owned by "
                                "third-parties.\n"
                                "\n"
                                "You acknowledge that you download, install, or use Extensions "
                                "from the Qt Creator Extensions Store at your own discretion "
                                "and risk. All Qt Creator Extensions are provided \"as is\" "
                                "without warranties of any kind, and may be subject to "
                                "additional license terms imposed by their owners or licensors.\n"
                                "\n"
                                "You can manage the use of Extensions in Preferences > Extensions.");

    InfoBarEntry info(kEnableExternalRepo, text, InfoBarEntry::GlobalSuppression::Disabled);
    info.setTitle(Tr::tr("Use %1 Extensions?").arg(QGuiApplication::applicationDisplayName()));
    info.setInfoType(InfoLabel::Information);
    info.addCustomButton(
        Tr::tr("Use"),
        [] { Internal::setUseExternalRepo(true); },
        {},
        InfoBarEntry::ButtonAction::SuppressPersistently);
    info.addCustomButton(
        Tr::tr("Do Not Use"),
        [] { Internal::setUseExternalRepo(false); },
        {},
        InfoBarEntry::ButtonAction::SuppressPersistently);
    infoBar->addInfo(info);
}

} // ExtensionManager