aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/python/pyside.h
blob: f6f8f25f1e3361fa81fa8f9b907df93c9baf67e2 (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
// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

#pragma once

#include <utils/filepath.h>

#include <QCoreApplication>
#include <QFutureWatcher>
#include <QPointer>
#include <QTextDocument>

namespace Core { class IDocument; }
namespace TextEditor { class TextDocument; }
namespace ProjectExplorer { class RunConfiguration; }

namespace Python::Internal {

class PySideTools
{
public:
    Utils::FilePath pySideProjectPath;
    Utils::FilePath pySideUicPath;
};

class PySideInstaller : public QObject
{
    Q_OBJECT

public:
    void checkPySideInstallation(const Utils::FilePath &python, TextEditor::TextDocument *document);
    static PySideInstaller &instance();
    void installPySide(const Utils::FilePath &python, const QString &pySide, bool quiet = false);

public slots:
    void installPySide(const QUrl &url);

signals:
    void pySideInstalled(const Utils::FilePath &python, const QString &pySide);

private:
    PySideInstaller();
    ~PySideInstaller();

    void handlePySideMissing(const Utils::FilePath &python,
                             const QString &pySide,
                             TextEditor::TextDocument *document);
    void handleDocumentOpened(Core::IDocument *document);

    void runPySideChecker(const Utils::FilePath &python,
                          const QString &pySide,
                          TextEditor::TextDocument *document);
    static bool missingPySideInstallation(const Utils::FilePath &python, const QString &pySide);
    static QString usedPySide(const QString &text, const QString &mimeType);

    QHash<Utils::FilePath, QList<TextEditor::TextDocument *>> m_infoBarEntries;
    QHash<TextEditor::TextDocument *, QPointer<QFutureWatcher<bool>>> m_futureWatchers;
};

} // Python::Internal