blob: b43dc625f7fca18426ef52de2adf0dadac1d6a38 (
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
|
/***************************************************************************************************
Copyright (C) 2023 The Qt Company Ltd.
SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
***************************************************************************************************/
using Microsoft.VisualStudio.ProjectSystem;
using Microsoft.VisualStudio.ProjectSystem.Properties;
using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Linq;
using System.Threading.Tasks;
namespace QtVsTools.QtMsBuild
{
using Core;
[Export(typeof(IPropertyPageUIValueEditor))]
[ExportMetadata("Name", "QtModulesEditor")]
[AppliesTo("IntegratedConsoleDebugging")]
internal sealed class QtModulesEditor : IPropertyPageUIValueEditor
{
public async Task<object> EditValueAsync(
IServiceProvider serviceProvider,
IProperty ruleProperty,
object currentValue)
{
await Task.Yield();
var qtSettings = ruleProperty.ContainingRule;
var qtVersion = await qtSettings.GetPropertyValueAsync("QtInstall");
var vm = QtVersionManager.The();
var versionInfo = vm.GetVersionInfo(qtVersion);
if (versionInfo == null)
versionInfo = vm.GetVersionInfo(vm.GetDefaultVersion());
var modules = QtModules.Instance.GetAvailableModules(versionInfo.qtMajor)
.Where(x => !string.IsNullOrEmpty(x.proVarQT))
.Select(x => new QtModulesPopup.Module
{
Id = x.Id,
Name = x.Name,
IsReadOnly = !x.Selectable,
QT = x.proVarQT.Split(' ').ToHashSet(),
})
.ToList();
HashSet<string> selectedQt = null;
IEnumerable<string> extraQt = null;
if (currentValue != null) {
var allQt = modules.SelectMany(x => x.QT).ToHashSet();
selectedQt = currentValue.ToString().Split(';').ToHashSet();
extraQt = selectedQt.Except(allQt);
foreach (var module in modules)
module.IsSelected = module.QT.Intersect(selectedQt).Count() == module.QT.Count;
}
var popup = new QtModulesPopup();
popup.SetModules(modules.OrderBy(module => module.Name));
if (popup.ShowModal().GetValueOrDefault()) {
selectedQt = modules
.Where(x => x.IsSelected)
.SelectMany(x => x.QT)
.Union(extraQt ?? Enumerable.Empty<string>())
.ToHashSet();
}
return selectedQt == null ? "" : string.Join(";", selectedQt);
}
}
}
|