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
|
||||
|
||||
function onAboutToShow() {
|
||||
EffectComposerBackend.effectComposerModel.previewComboAboutToOpen()
|
||||
root.calculateWindowGeometry()
|
||||
|
||||
window.show()
|
||||
@@ -170,7 +171,9 @@ StudioControls.ComboBox {
|
||||
required property var modelData
|
||||
|
||||
color: "transparent"
|
||||
border.color: root.selectedImage === modelData ? StudioTheme.Values.themeInteraction
|
||||
border.color: root.selectedImage === modelData
|
||||
|| index == 0 && root.selectedImage == EffectComposerBackend.effectComposerModel.customPreviewImage
|
||||
? StudioTheme.Values.themeInteraction
|
||||
: "transparent"
|
||||
|
||||
width: 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
|
||||
{
|
||||
return m_fragmentShader;
|
||||
@@ -1067,8 +1078,12 @@ void EffectComposerModel::saveComposition(const QString &name)
|
||||
json.insert("tool", "EffectComposer");
|
||||
|
||||
Utils::FilePath customPreviewPath = Utils::FilePath::fromUrl(m_customPreviewImage);
|
||||
if (m_customPreviewImage.isLocalFile())
|
||||
if (m_customPreviewImage.isLocalFile()) {
|
||||
if (customPreviewPath.exists())
|
||||
customPreviewPath = customPreviewPath.relativePathFrom(compositionDir);
|
||||
else
|
||||
customPreviewPath = {};
|
||||
}
|
||||
json.insert("customPreviewImage", customPreviewPath.toUrl().toString());
|
||||
|
||||
QUrl previewUrl = m_currentPreviewImage;
|
||||
@@ -1259,6 +1274,7 @@ void EffectComposerModel::openComposition(const QString &path)
|
||||
m_customPreviewImage.clear();
|
||||
if (json.contains("customPreviewImage")) {
|
||||
QUrl imageUrl{json["customPreviewImage"].toString()};
|
||||
if (!imageUrl.isEmpty()) {
|
||||
Utils::FilePath imagePath = Utils::FilePath::fromUrl(imageUrl);
|
||||
if (imagePath.isAbsolutePath()) {
|
||||
if (imagePath.exists())
|
||||
@@ -1269,6 +1285,7 @@ void EffectComposerModel::openComposition(const QString &path)
|
||||
m_customPreviewImage = imagePath.toUrl();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (json.contains("nodes") && json["nodes"].isArray()) {
|
||||
beginResetModel();
|
||||
|
@@ -81,6 +81,7 @@ public:
|
||||
Q_INVOKABLE QString getUniqueEffectName() const;
|
||||
Q_INVOKABLE bool nameExists(const QString &name) const;
|
||||
Q_INVOKABLE void chooseCustomPreviewImage();
|
||||
Q_INVOKABLE void previewComboAboutToOpen();
|
||||
|
||||
bool shadersUpToDate() const;
|
||||
void setShadersUpToDate(bool newShadersUpToDate);
|
||||
|
Reference in New Issue
Block a user