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

#include "iossettingspage.h"

#include "iosconfigurations.h"
#include "iosconstants.h"
#include "iostr.h"

#include <coreplugin/dialogs/ioptionspage.h>

#include <projectexplorer/projectexplorerconstants.h>

#include <utils/layoutbuilder.h>

#include <QCheckBox>

using namespace std::placeholders;

namespace Ios::Internal {

class IosSettingsWidget final : public Core::IOptionsPageWidget
{
public:
    IosSettingsWidget();
    ~IosSettingsWidget() final;

private:
    void apply() final;

    void saveSettings();

private:
    QCheckBox *m_deviceAskCheckBox;
};

IosSettingsWidget::IosSettingsWidget()
{
    setWindowTitle(Tr::tr("iOS Configuration"));

    m_deviceAskCheckBox = new QCheckBox(Tr::tr("Ask about devices not in developer mode"));
    m_deviceAskCheckBox->setChecked(!IosConfigurations::ignoreAllDevices());

    auto xcodeLabel = new QLabel(
        Tr::tr("Configure available simulator devices in <a href=\"%1\">Xcode</a>.")
            .arg("https://developer.apple.com/documentation/xcode/"
                 "running-your-app-in-simulator-or-on-a-device/"
                 "#Configure-the-list-of-simulated-devices"));
    xcodeLabel->setOpenExternalLinks(true);

    // clang-format off
    using namespace Layouting;
    Column {
        Group {
            title(Tr::tr("Devices")),
            Row { m_deviceAskCheckBox }
        },
        Group {
            title(Tr::tr("Simulator")),
            Row { xcodeLabel }
        },
        st
    }.attachTo(this);
    // clang-format on
}

IosSettingsWidget::~IosSettingsWidget() = default;

void IosSettingsWidget::apply()
{
    saveSettings();
    IosConfigurations::updateAutomaticKitList();
}

void IosSettingsWidget::saveSettings()
{
    IosConfigurations::setIgnoreAllDevices(!m_deviceAskCheckBox->isChecked());
}

// IosSettingsPage

class IosSettingsPage final : public Core::IOptionsPage
{
public:
    IosSettingsPage()
    {
        setId(Constants::IOS_SETTINGS_ID);
        setDisplayName(Tr::tr("iOS"));
        setCategory(ProjectExplorer::Constants::DEVICE_SETTINGS_CATEGORY);
        setWidgetCreator([] { return new IosSettingsWidget; });
    }
};

void setupIosSettingsPage()
{
    static IosSettingsPage theIosSettingsPage;
}

} // Ios::Internal