aboutsummaryrefslogtreecommitdiffstats
path: root/QtVsTools.Package/Editors/Editor.QtResourceEditor.cs
blob: f7094c437f127e039613fc882f66e4a43b9e99ad (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
// 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;
    using QtVsTools.Core.Common;

    [Guid(GuidString)]
    public class QtResourceEditor : Editor
    {
        public const string GuidString = "D0FFB6E6-5829-4DD9-835E-2965449AC6BF";
        public const string Title = "Qt Resource Editor";

        public QtResourceEditor()
            : base(new QtResourceFileSniffer())
        { }

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

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

        protected override string GetToolsPath() => Utils.PackageInstallPath;

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

        protected override string GetTitle(Process editorProcess) => Title;

        protected override bool Detached => QtOptionsPage.ResourceEditorDetached;

        protected override bool ShowDetachNotification => QtOptionsPage
            .NotifyResourceEditorDetachable;

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