blob: d73ea62ea97787c5326ef81823c8bf1caeb479cd (
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
|
// 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 "qmlpuppetpaths.h"
#include "designersettings.h"
#include <app/app_version.h>
#include <coreplugin/icore.h>
#include <projectexplorer/kit.h>
#include <projectexplorer/target.h>
#include <qtsupport/baseqtversion.h>
#include <qtsupport/qtkitinformation.h>
namespace QmlDesigner {
namespace QmlPuppetPaths {
namespace {
Utils::FilePath qmlPuppetExecutablePath(const Utils::FilePath &workingDirectory)
{
return workingDirectory.pathAppended(QString{"qml2puppet-"} + Core::Constants::IDE_VERSION_LONG)
.withExecutableSuffix();
}
Utils::FilePath qmlPuppetFallbackDirectory(const DesignerSettings &settings)
{
auto puppetFallbackDirectory = Utils::FilePath::fromString(
settings.value(DesignerSettingsKey::PUPPET_DEFAULT_DIRECTORY).toString());
if (puppetFallbackDirectory.isEmpty() || !puppetFallbackDirectory.exists())
return Core::ICore::libexecPath();
return puppetFallbackDirectory;
}
std::pair<Utils::FilePath, Utils::FilePath> qmlPuppetFallbackPaths(const DesignerSettings &settings)
{
auto workingDirectory = qmlPuppetFallbackDirectory(settings);
return {workingDirectory, qmlPuppetExecutablePath(workingDirectory)};
}
std::pair<Utils::FilePath, Utils::FilePath> pathsForKitPuppet(ProjectExplorer::Target *target)
{
if (!target || !target->kit())
return {};
QtSupport::QtVersion *currentQtVersion = QtSupport::QtKitAspect::qtVersion(target->kit());
if (currentQtVersion) {
auto path = currentQtVersion->binPath();
return {path, qmlPuppetExecutablePath(path)};
}
return {};
}
} // namespace
std::pair<Utils::FilePath, Utils::FilePath> qmlPuppetPaths(ProjectExplorer::Target *target,
const DesignerSettings &settings)
{
auto [workingDirectoryPath, puppetPath] = pathsForKitPuppet(target);
if (workingDirectoryPath.isEmpty() || !puppetPath.exists())
return qmlPuppetFallbackPaths(settings);
return {workingDirectoryPath, puppetPath};
}
} // namespace QmlPuppetPaths
} // namespace QmlDesigner
|