aboutsummaryrefslogtreecommitdiffstats
path: root/QtVsTools.Core/Options/QtVersion.cs
blob: e1cb05456f6b4324488310085d0802508ba8e77c (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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
// Copyright (C) 2025 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

using System.Collections.Generic;
using System.ComponentModel;
using System.Runtime.CompilerServices;

namespace QtVsTools.Core.Options
{
    using QtVsTools.Common;

    public class QtVersion : INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;

        private bool isDefault;
        public bool IsDefault
        {
            get => isDefault;
            set
            {
                if (isDefault == value)
                    return;
                isDefault = value;
                OnPropertyChanged();
            }
        }
        public bool InitialIsDefault { get; set; }

        private string name;
        public string Name
        {
            get => name;
            set
            {
                if (name == value)
                    return;
                name = value;
                OnPropertyChanged();
            }
        }

        public string InitialName { get; set; } = "";

        private string path;
        public string Path
        {
            get => path;
            set
            {
                if (path == value)
                    return;
                path = value;
                OnPropertyChanged();
            }
        }
        public string InitialPath { get; set; } = "";

        private BuildHost host;
        public BuildHost Host
        {
            get => host;
            set
            {
                if (host == value)
                    return;
                host = value;
                OnPropertyChanged();
            }
        }
        public BuildHost InitialHost { get; set; } = BuildHost.Windows;

        private string compiler;
        public string Compiler
        {
            get => compiler;
            set
            {
                if (compiler == value)
                    return;
                compiler = value;
                OnPropertyChanged();
            }
        }
        public string InitialCompiler { get; set; } = "msvc";

        private string errorMessage;
        public string ErrorMessage
        {
            get => errorMessage;
            set
            {
                if (errorMessage == value)
                    return;
                errorMessage = value;
                OnPropertyChanged(nameof(HasError));
                OnPropertyChanged();
            }
        }
        public bool HasError => !string.IsNullOrEmpty(ErrorMessage);

        public State State { get; set; } = State.Existing;

        public static IEnumerable<string> BuildHostStrings()
        {
            return EnumExt.GetValues<string>(typeof(BuildHost));
        }

        private void OnPropertyChanged([CallerMemberName] string member = null)
        {
            PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(member));
        }
    }
}