aboutsummaryrefslogtreecommitdiffstats
path: root/src/tools/sdktool/settings.cpp
blob: 064cbd951b6ece121463d7ec1acac9c846bdaf5a (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
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0

#include "settings.h"
#include "operation.h"

#include <app/app_version.h>

#include <QCoreApplication>

static Settings *m_instance = nullptr;

Settings *Settings::instance()
{
    return m_instance;
}

Settings::Settings()
{
    Q_ASSERT(!m_instance);
    m_instance = this;

    // autodetect sdk dir:
    sdkPath = Utils::FilePath::fromUserInput(QCoreApplication::applicationDirPath())
            .pathAppended(DATA_PATH).cleanPath()
            .pathAppended(Core::Constants::IDE_SETTINGSVARIANT_STR)
            .pathAppended(Core::Constants::IDE_ID);
}

Utils::FilePath Settings::getPath(const QString &file)
{
    Utils::FilePath result = sdkPath;
    const QString lowerFile = file.toLower();
    const QStringList identical = {
        "android", "cmaketools", "debuggers", "devices", "profiles", "qtversions", "toolchains", "abi"
    };
    if (lowerFile == "cmake")
        result = result.pathAppended("cmaketools");
    else if (lowerFile == "kits")
        result = result.pathAppended("profiles");
    else if (lowerFile == "qtversions")
        result = result.pathAppended("qtversion");
    else if (identical.contains(lowerFile))
        result = result.pathAppended(lowerFile);
    else
        result = result.pathAppended(file); // handle arbitrary file names not known yet
    return result.stringAppended(".xml");
}