aboutsummaryrefslogtreecommitdiffstats
path: root/QtVsTools.Package/Editors/Editor.QtLinguist.cs
blob: 32f7f1e25d2102a953196ac0e2c3910296d8efb3 (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
// 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;
using System.Diagnostics;
using System.Runtime.InteropServices;

namespace QtVsTools.Package.Editors
{
    using Core;
    using Core.Options;

    [Guid(GuidString)]
    public class QtLinguist : Editor
    {
        public const string GuidString = "4A1333DC-5C94-4F14-A7BF-DC3D96092234";
        public const string Title = "Qt Linguist";

        public QtLinguist()
            : base(new QtLinguistFileSniffer())
        { }

        private Guid? guid;
        public override Guid Guid => guid ??= new Guid(GuidString);

        public override string ExecutableName => "linguist.exe";

        public override Func<string, bool> WindowFilter =>
            caption => caption.EndsWith(Title);

        protected override string GetTitle(Process editorProcess)
        {
            return Title;
        }

        protected override bool Detached => QtOptionsPage.LinguistDetached;

        protected override bool ShowDetachNotification => QtOptionsPage.NotifyLinguistDetachable;

        protected override void DisableDetachNotification()
        {
            try {
                QtOptionsPage.NotifyLinguistDetachable = false;
                QtOptionsPage.SaveSettingsToStorageStatic();
            } catch (Exception ex) {
                ex.Log();
            }
        }
    }
}