aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/qmldesignerbase/utils/designerpaths.cpp
blob: da4ce8ce082f3187765696a0dbb2db98a4b380a0 (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
// Copyright (C) 2023 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 "designerpaths.h"

#include <coreplugin/icore.h>
#include <utils/hostosinfo.h>

#include <QStandardPaths>

namespace QmlDesigner::Paths {

Utils::FilePath defaultExamplesPath()
{
    QStandardPaths::StandardLocation location = QStandardPaths::DocumentsLocation;

    return Utils::FilePath::fromString(QStandardPaths::writableLocation(location))
        .pathAppended("QtDesignStudio/examples");
}

Utils::FilePath defaultBundlesPath()
{
    QStandardPaths::StandardLocation location = Utils::HostOsInfo::isMacHost()
                                                    ? QStandardPaths::HomeLocation
                                                    : QStandardPaths::DocumentsLocation;

    return Utils::FilePath::fromString(QStandardPaths::writableLocation(location))
        .pathAppended("QtDesignStudio/bundles");
}

QString examplesPathSetting()
{
    return Core::ICore::settings()->value(exampleDownloadPath, defaultExamplesPath().toString())
        .toString();
}

QString bundlesPathSetting()
{
    return Core::ICore::settings()->value(bundlesDownloadPath, defaultBundlesPath().toString())
        .toString();
}

} // namespace QmlDesigner::Paths