summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmr Essam <amr.elsayed@qt.io>2022-12-09 02:52:31 -0800
committerThomas Hartmann <thomas.hartmann@qt.io>2022-12-09 12:03:02 +0000
commitc223af0101496395a38642876ed5bc4a0b3c4cfb (patch)
treeb038175a3cc4729231bf45df4ce81614dc193f8b
parent2a506b42358a7878ded5f35b1ae8a532544fee17 (diff)
downloadqt-creator-c223af0101496395a38642876ed5bc4a0b3c4cfb.tar.gz
QmlDesigner: fix adding effect to 2D does not work on windows
Effect cannot be added in windows, during to latest changes in QDS-7344 The QFileSystemModel::dataChanged doesn't emit with some file types So I used Utils::FileSystemWatcher for watching files changes Task-number: QDS-8452 Change-Id: Id381a78556a3dad56268cec506a0182d4343f0a2 Reviewed-by: Amr Elsayed <amr.elsayed@qt.io> Reviewed-by: Thomas Hartmann <thomas.hartmann@qt.io>
-rw-r--r--src/plugins/qmldesigner/components/assetslibrary/assetslibrarymodel.cpp28
-rw-r--r--src/plugins/qmldesigner/components/assetslibrary/assetslibrarymodel.h3
-rw-r--r--src/plugins/qmldesigner/components/componentcore/modelnodeoperations.cpp2
3 files changed, 17 insertions, 16 deletions
diff --git a/src/plugins/qmldesigner/components/assetslibrary/assetslibrarymodel.cpp b/src/plugins/qmldesigner/components/assetslibrary/assetslibrarymodel.cpp
index 864660a147..6587c89cf3 100644
--- a/src/plugins/qmldesigner/components/assetslibrary/assetslibrarymodel.cpp
+++ b/src/plugins/qmldesigner/components/assetslibrary/assetslibrarymodel.cpp
@@ -35,24 +35,17 @@ void AssetsLibraryModel::createBackendModel()
setSourceModel(m_sourceFsModel);
QObject::connect(m_sourceFsModel, &QFileSystemModel::directoryLoaded, this, &AssetsLibraryModel::directoryLoaded);
- QObject::connect(m_sourceFsModel, &QFileSystemModel::dataChanged, this, &AssetsLibraryModel::onDataChanged);
QObject::connect(m_sourceFsModel, &QFileSystemModel::directoryLoaded, this,
[this]([[maybe_unused]] const QString &dir) {
- syncHaveFiles();
- });
-}
-
-void AssetsLibraryModel::onDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight,
- [[maybe_unused]] const QList<int> &roles)
-{
- for (int i = topLeft.row(); i <= bottomRight.row(); ++i) {
- QModelIndex index = m_sourceFsModel->index(i, 0, topLeft.parent());
- QString path = m_sourceFsModel->filePath(index);
+ syncHaveFiles();
+ });
- if (!isDirectory(path))
- emit fileChanged(path);
- }
+ m_fileWatcher = new Utils::FileSystemWatcher(parent());
+ QObject::connect(m_fileWatcher, &Utils::FileSystemWatcher::fileChanged, this,
+ [this] (const QString &path) {
+ emit fileChanged(path);
+ });
}
void AssetsLibraryModel::destroyBackendModel()
@@ -61,6 +54,10 @@ void AssetsLibraryModel::destroyBackendModel()
m_sourceFsModel->disconnect(this);
m_sourceFsModel->deleteLater();
m_sourceFsModel = nullptr;
+
+ m_fileWatcher->disconnect(this);
+ m_fileWatcher->deleteLater();
+ m_fileWatcher = nullptr;
}
void AssetsLibraryModel::setSearchText(const QString &searchText)
@@ -196,6 +193,9 @@ bool AssetsLibraryModel::filterAcceptsRow(int sourceRow, const QModelIndex &sour
QModelIndex sourceIdx = m_sourceFsModel->index(sourceRow, 0, sourceParent);
QString sourcePath = m_sourceFsModel->filePath(sourceIdx);
+ if (QFileInfo(sourcePath).isFile() && !m_fileWatcher->watchesFile(sourcePath))
+ m_fileWatcher->addFile(sourcePath, Utils::FileSystemWatcher::WatchModifiedDate);
+
if (!m_searchText.isEmpty() && path.startsWith(m_rootPath) && QFileInfo{path}.isDir()) {
QString sourceName = m_sourceFsModel->fileName(sourceIdx);
diff --git a/src/plugins/qmldesigner/components/assetslibrary/assetslibrarymodel.h b/src/plugins/qmldesigner/components/assetslibrary/assetslibrarymodel.h
index f73d7fb7e3..99c9601708 100644
--- a/src/plugins/qmldesigner/components/assetslibrary/assetslibrarymodel.h
+++ b/src/plugins/qmldesigner/components/assetslibrary/assetslibrarymodel.h
@@ -8,6 +8,7 @@
#include <QFileInfo>
#include <utils/qtcassert.h>
+#include <utils/filesystemwatcher.h>
namespace QmlDesigner {
@@ -73,7 +74,6 @@ signals:
private:
void setHaveFiles(bool value);
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
- void onDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight, const QList<int> &roles);
void resetModel();
void createBackendModel();
void destroyBackendModel();
@@ -84,6 +84,7 @@ private:
QString m_rootPath;
QFileSystemModel *m_sourceFsModel = nullptr;
bool m_haveFiles = false;
+ Utils::FileSystemWatcher *m_fileWatcher = nullptr;
};
} // namespace QmlDesigner
diff --git a/src/plugins/qmldesigner/components/componentcore/modelnodeoperations.cpp b/src/plugins/qmldesigner/components/componentcore/modelnodeoperations.cpp
index 3a3dd7d683..711b84c379 100644
--- a/src/plugins/qmldesigner/components/componentcore/modelnodeoperations.cpp
+++ b/src/plugins/qmldesigner/components/componentcore/modelnodeoperations.cpp
@@ -1725,7 +1725,7 @@ bool validateEffect(const QString &effectPath)
msgBox.setDefaultButton(QMessageBox::Yes);
msgBox.setIcon(QMessageBox::Question);
if (msgBox.exec() == QMessageBox::Yes)
- ModelNodeOperations::openEffectMaker(effectName);
+ ModelNodeOperations::openEffectMaker(effectPath);
return false;
}
return true;