forked from qt-creator/qt-creator
EffectComposer: Consider effect changes to be part of current document
This will allow saving effects when current document is saved for any reason, including at application shutdown. If effect is not yet saved once (i.e. it doesn't have a name yet), it will not be saved in response to global save triggers to avoid complications with requiring user input to provide the name. Fixes: QDS-11436 Fixes: QDS-11446 Change-Id: I412ee4893e926d527b4f03f5f6c0c9b4e923bc1e Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
This commit is contained in:
@@ -16,6 +16,8 @@
|
||||
#include "theme.h"
|
||||
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/idocument.h>
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
|
||||
#include <qmldesigner/documentmanager.h>
|
||||
#include <qmldesigner/qmldesignerconstants.h>
|
||||
@@ -108,6 +110,23 @@ EffectComposerWidget::EffectComposerWidget(EffectComposerView *view)
|
||||
|
||||
m_importScan.timer->start(100);
|
||||
});
|
||||
|
||||
connect(m_effectComposerModel.data(), &EffectComposerModel::hasUnsavedChangesChanged,
|
||||
this, [this]() {
|
||||
if (m_effectComposerModel->hasUnsavedChanges() && !m_effectComposerModel->currentComposition().isEmpty()) {
|
||||
if (auto doc = QmlDesigner::QmlDesignerPlugin::instance()->documentManager().currentDesignDocument())
|
||||
doc->setModified();
|
||||
}
|
||||
});
|
||||
|
||||
connect(Core::EditorManager::instance(), &Core::EditorManager::aboutToSave,
|
||||
this, [this](Core::IDocument *document) {
|
||||
if (m_effectComposerModel->hasUnsavedChanges()) {
|
||||
QString compName = m_effectComposerModel->currentComposition();
|
||||
if (!compName.isEmpty())
|
||||
m_effectComposerModel->saveComposition(compName);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
@@ -427,6 +427,12 @@ bool DesignDocument::hasProject() const
|
||||
return !DocumentManager::currentProjectDirPath().isEmpty();
|
||||
}
|
||||
|
||||
void DesignDocument::setModified()
|
||||
{
|
||||
if (!m_documentTextModifier.isNull())
|
||||
m_documentTextModifier->textDocument()->setModified(true);
|
||||
}
|
||||
|
||||
void DesignDocument::changeToInFileComponentModel(ComponentTextModifier *textModifer)
|
||||
{
|
||||
m_inFileComponentTextModifier.reset(textModifer);
|
||||
|
@@ -89,6 +89,8 @@ public:
|
||||
Utils::FilePath projectFolder() const;
|
||||
bool hasProject() const;
|
||||
|
||||
void setModified();
|
||||
|
||||
signals:
|
||||
void displayNameChanged(const QString &newFileName);
|
||||
void dirtyStateChanged(bool newState);
|
||||
|
Reference in New Issue
Block a user