forked from qt-creator/qt-creator
EffectComposer: Fix custom preview issues
- Custom preview saving and loading fixed when file is deleted - Custom preview not shown in combo when it's opened after file deletion - Fixed selected highlight on custom preview Fixes: QDS-13880 Change-Id: I8ef3fed5cfc220e3b37007b302f54fe3bf01899d Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
This commit is contained in:
@@ -69,6 +69,7 @@ StudioControls.ComboBox {
|
|||||||
target: root.popup
|
target: root.popup
|
||||||
|
|
||||||
function onAboutToShow() {
|
function onAboutToShow() {
|
||||||
|
EffectComposerBackend.effectComposerModel.previewComboAboutToOpen()
|
||||||
root.calculateWindowGeometry()
|
root.calculateWindowGeometry()
|
||||||
|
|
||||||
window.show()
|
window.show()
|
||||||
@@ -170,8 +171,10 @@ StudioControls.ComboBox {
|
|||||||
required property var modelData
|
required property var modelData
|
||||||
|
|
||||||
color: "transparent"
|
color: "transparent"
|
||||||
border.color: root.selectedImage === modelData ? StudioTheme.Values.themeInteraction
|
border.color: root.selectedImage === modelData
|
||||||
: "transparent"
|
|| index == 0 && root.selectedImage == EffectComposerBackend.effectComposerModel.customPreviewImage
|
||||||
|
? StudioTheme.Values.themeInteraction
|
||||||
|
: "transparent"
|
||||||
|
|
||||||
width: 200
|
width: 200
|
||||||
height: 200
|
height: 200
|
||||||
|
@@ -294,6 +294,17 @@ void EffectComposerModel::chooseCustomPreviewImage()
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EffectComposerModel::previewComboAboutToOpen()
|
||||||
|
{
|
||||||
|
if (!m_customPreviewImage.isEmpty() && !Utils::FilePath::fromUrl(m_customPreviewImage).exists()) {
|
||||||
|
if (m_currentPreviewImage == m_customPreviewImage) {
|
||||||
|
m_customPreviewImage.clear();
|
||||||
|
emit customPreviewImageChanged();
|
||||||
|
setCurrentPreviewImage({});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
QString EffectComposerModel::fragmentShader() const
|
QString EffectComposerModel::fragmentShader() const
|
||||||
{
|
{
|
||||||
return m_fragmentShader;
|
return m_fragmentShader;
|
||||||
@@ -1067,8 +1078,12 @@ void EffectComposerModel::saveComposition(const QString &name)
|
|||||||
json.insert("tool", "EffectComposer");
|
json.insert("tool", "EffectComposer");
|
||||||
|
|
||||||
Utils::FilePath customPreviewPath = Utils::FilePath::fromUrl(m_customPreviewImage);
|
Utils::FilePath customPreviewPath = Utils::FilePath::fromUrl(m_customPreviewImage);
|
||||||
if (m_customPreviewImage.isLocalFile())
|
if (m_customPreviewImage.isLocalFile()) {
|
||||||
customPreviewPath = customPreviewPath.relativePathFrom(compositionDir);
|
if (customPreviewPath.exists())
|
||||||
|
customPreviewPath = customPreviewPath.relativePathFrom(compositionDir);
|
||||||
|
else
|
||||||
|
customPreviewPath = {};
|
||||||
|
}
|
||||||
json.insert("customPreviewImage", customPreviewPath.toUrl().toString());
|
json.insert("customPreviewImage", customPreviewPath.toUrl().toString());
|
||||||
|
|
||||||
QUrl previewUrl = m_currentPreviewImage;
|
QUrl previewUrl = m_currentPreviewImage;
|
||||||
@@ -1259,14 +1274,16 @@ void EffectComposerModel::openComposition(const QString &path)
|
|||||||
m_customPreviewImage.clear();
|
m_customPreviewImage.clear();
|
||||||
if (json.contains("customPreviewImage")) {
|
if (json.contains("customPreviewImage")) {
|
||||||
QUrl imageUrl{json["customPreviewImage"].toString()};
|
QUrl imageUrl{json["customPreviewImage"].toString()};
|
||||||
Utils::FilePath imagePath = Utils::FilePath::fromUrl(imageUrl);
|
if (!imageUrl.isEmpty()) {
|
||||||
if (imagePath.isAbsolutePath()) {
|
Utils::FilePath imagePath = Utils::FilePath::fromUrl(imageUrl);
|
||||||
if (imagePath.exists())
|
if (imagePath.isAbsolutePath()) {
|
||||||
m_customPreviewImage = imageUrl;
|
if (imagePath.exists())
|
||||||
} else {
|
m_customPreviewImage = imageUrl;
|
||||||
imagePath = effectPath.absolutePath().resolvePath(imagePath);
|
} else {
|
||||||
if (imagePath.exists())
|
imagePath = effectPath.absolutePath().resolvePath(imagePath);
|
||||||
m_customPreviewImage = imagePath.toUrl();
|
if (imagePath.exists())
|
||||||
|
m_customPreviewImage = imagePath.toUrl();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -81,6 +81,7 @@ public:
|
|||||||
Q_INVOKABLE QString getUniqueEffectName() const;
|
Q_INVOKABLE QString getUniqueEffectName() const;
|
||||||
Q_INVOKABLE bool nameExists(const QString &name) const;
|
Q_INVOKABLE bool nameExists(const QString &name) const;
|
||||||
Q_INVOKABLE void chooseCustomPreviewImage();
|
Q_INVOKABLE void chooseCustomPreviewImage();
|
||||||
|
Q_INVOKABLE void previewComboAboutToOpen();
|
||||||
|
|
||||||
bool shadersUpToDate() const;
|
bool shadersUpToDate() const;
|
||||||
void setShadersUpToDate(bool newShadersUpToDate);
|
void setShadersUpToDate(bool newShadersUpToDate);
|
||||||
|
Reference in New Issue
Block a user