QmlDesigner: Add placeholder controls for when the assets view is empty

Change-Id: I8cf864f97aff09f846411e50cec17e7cdf1be2d0
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Samuel Ghinet <samuel.ghinet@qt.io>
Reviewed-by: Miikka Heikkinen <miikka.heikkinen@qt.io>
This commit is contained in:
Mahmoud Badri
2021-11-05 00:45:34 +02:00
parent 33122b564a
commit d06ddd12b6
7 changed files with 62 additions and 6 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 494 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 871 B

View File

@@ -31,5 +31,7 @@
<file>images/asset_sound_384.png</file>
<file>images/x.png</file>
<file>images/x@2x.png</file>
<file>images/browse.png</file>
<file>images/browse@2x.png</file>
</qresource>
</RCC>

View File

@@ -42,16 +42,18 @@ QPixmap ItemLibraryAssetsIconProvider::requestPixmap(const QString &id, QSize *s
{
QPixmap pixmap;
const QString suffix = "*." + id.split('.').last().toLower();
if (ItemLibraryAssetsModel::supportedFontSuffixes().contains(suffix))
if (id == "browse")
pixmap = Utils::StyleHelper::dpiSpecificImageFile(":/ItemLibrary/images/browse.png");
else if (ItemLibraryAssetsModel::supportedFontSuffixes().contains(suffix))
pixmap = generateFontIcons(id);
else if (ItemLibraryAssetsModel::supportedImageSuffixes().contains(suffix))
pixmap = Utils::StyleHelper::dpiSpecificImageFile(id);
else if (ItemLibraryAssetsModel::supportedTexture3DSuffixes().contains(suffix))
pixmap = HdrImage{id}.toPixmap();
else if (ItemLibraryAssetsModel::supportedShaderSuffixes().contains(suffix))
pixmap = QPixmap(Utils::StyleHelper::dpiSpecificImageFile(":/ItemLibrary/images/asset_shader_48.png"));
pixmap = Utils::StyleHelper::dpiSpecificImageFile(":/ItemLibrary/images/asset_shader_48.png");
else if (ItemLibraryAssetsModel::supportedAudioSuffixes().contains(suffix))
pixmap = QPixmap(Utils::StyleHelper::dpiSpecificImageFile(":/ItemLibrary/images/asset_sound_48.png"));
pixmap = Utils::StyleHelper::dpiSpecificImageFile(":/ItemLibrary/images/asset_sound_48.png");
if (size) {
size->setWidth(pixmap.width());

View File

@@ -275,7 +275,7 @@ void ItemLibraryAssetsModel::setRootPath(const QString &path)
beginResetModel();
m_assetsDir = new ItemLibraryAssetsDir(path, 0, true, this);
parseDirRecursive(m_assetsDir, 1);
m_isEmpty = parseDirRecursive(m_assetsDir, 1);
endResetModel();
}

View File

@@ -51,8 +51,8 @@ public:
Utils::FileSystemWatcher *fileSystemWatcher,
QObject *parent = nullptr);
QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const override;
int rowCount(const QModelIndex & parent = QModelIndex()) const override;
QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const override;
int rowCount(const QModelIndex &parent = QModelIndex()) const override;
QHash<int, QByteArray> roleNames() const override;
void refresh();
@@ -81,6 +81,7 @@ public:
Q_INVOKABLE void toggleExpandAll(bool expand);
Q_INVOKABLE DirExpandState getAllExpandedState() const;
Q_INVOKABLE void removeFile(const QString &filePath);
Q_INVOKABLE bool isEmpty() const { return m_isEmpty; };
private:
const QSet<QString> &supportedSuffixes() const;
@@ -91,6 +92,7 @@ private:
QString m_searchText;
Utils::FileSystemWatcher *m_fileSystemWatcher = nullptr;
ItemLibraryAssetsDir *m_assetsDir = nullptr;
bool m_isEmpty = true;
QHash<int, QByteArray> m_roleNames;
inline static QHash<QString, bool> m_expandedStateHash; // <assetPath, isExpanded>