summaryrefslogtreecommitdiff
path: root/src/plugins/qmldesigner/components/contentlibrary/contentlibrarytexture.h
blob: 074d4abb7702fa36780aa355d0b96ed88dbbcee4 (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
// 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 <QFileInfo>
#include <QObject>
#include <QSize>
#include <QUrl>

namespace QmlDesigner {

class ContentLibraryTexture : public QObject
{
    Q_OBJECT

    Q_PROPERTY(QString textureIconPath MEMBER m_iconPath CONSTANT)
    Q_PROPERTY(QString textureParentPath READ parentDirPath CONSTANT)
    Q_PROPERTY(QString textureToolTip MEMBER m_toolTip NOTIFY textureToolTipChanged)
    Q_PROPERTY(QUrl textureIcon MEMBER m_icon CONSTANT)
    Q_PROPERTY(bool textureVisible MEMBER m_visible NOTIFY textureVisibleChanged)
    Q_PROPERTY(QString textureWebUrl MEMBER m_webUrl CONSTANT)

public:
    ContentLibraryTexture(QObject *parent, const QFileInfo &iconFileInfo,
                          const QString &downloadPath, const QUrl &icon, const QString &webUrl,
                          const QString &fileExt, const QSize &dimensions, const qint64 sizeInBytes);

    Q_INVOKABLE bool isDownloaded() const;
    Q_INVOKABLE void setDownloaded();

    bool filter(const QString &searchText);

    QUrl icon() const;
    QString iconPath() const;
    QString downloadedTexturePath() const;
    QString parentDirPath() const;

signals:
    void textureVisibleChanged();
    void textureToolTipChanged();

private:
    QString resolveFileExt();
    QString resolveToolTipText();
    void doSetDownloaded();

    QString m_iconPath;
    QString m_downloadPath;
    QString m_webUrl;
    QString m_toolTip;
    QString m_baseName;
    QString m_fileExt;
    QUrl m_icon;
    QSize m_dimensions;
    qint64 m_sizeInBytes = -1;
    bool m_isDownloaded = false;

    bool m_visible = true;
};

} // namespace QmlDesigner