| | |
| | | /****************************************************************************
|
| | | **
|
| | | ** Copyright (C) 2021 The Qt Company Ltd.
|
| | | ** Copyright (C) 2022 The Qt Company Ltd.
|
| | | ** Contact: https://www.qt.io/licensing/
|
| | | **
|
| | | ** This file is part of the Qt VS Tools.
|
| | |
| | |
|
| | | using Microsoft.VisualStudio.ProjectSystem;
|
| | | using Microsoft.VisualStudio.ProjectSystem.Properties;
|
| | | using Microsoft.Internal.VisualStudio.PlatformUI;
|
| | | using System;
|
| | | using System.Collections.Generic;
|
| | | using System.ComponentModel.Composition;
|
| | | using System.Linq;
|
| | | using System.Threading.Tasks;
|
| | |
|
| | | namespace QtVsTools.QtMsBuild
|
| | | {
|
| | | using QtVsTools.Core;
|
| | | using Core;
|
| | |
|
| | | [Export(typeof(IPropertyPageUIValueEditor))]
|
| | | [ExportMetadata("Name", "QtModulesEditor")]
|
| | |
| | | {
|
| | | await Task.Yield();
|
| | |
|
| | | var modules = QtModules.Instance.GetAvailableModules()
|
| | | 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
|
| | | {
|
| | |
| | | })
|
| | | .ToList();
|
| | |
|
| | | var allQT = modules.SelectMany(x => x.QT).ToHashSet();
|
| | | var selectedQT = currentValue.ToString().Split(';').ToHashSet();
|
| | | var extraQT = selectedQT.Except(allQT);
|
| | | 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;
|
| | | foreach (var module in modules)
|
| | | module.IsSelected = module.QT.Intersect(selectedQt).Count() == module.QT.Count;
|
| | | }
|
| | |
|
| | | var popup = new QtModulesPopup();
|
| | | popup.SetModules(modules);
|
| | | popup.SetModules(modules.OrderBy(module => module.Name));
|
| | |
|
| | | if (popup.ShowModal().GetValueOrDefault()) {
|
| | | selectedQT = modules
|
| | | selectedQt = modules
|
| | | .Where(x => x.IsSelected)
|
| | | .SelectMany(x => x.QT)
|
| | | .Union(extraQT)
|
| | | .Union(extraQt ?? Enumerable.Empty<string>())
|
| | | .ToHashSet();
|
| | | }
|
| | | return string.Join(";", selectedQT);
|
| | | return selectedQt == null ? "" : string.Join(";", selectedQt);
|
| | | }
|
| | | }
|
| | | }
|