CompilerExplorer: Fix saving

Change-Id: I7f6770170c76d636fa2d3631d9ff462da9e227bd
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
Marcus Tillmanns
2023-09-26 07:25:25 +02:00
parent e85f750deb
commit d7ef2f816c

View File

@@ -107,8 +107,11 @@ JsonSettingsDocument::JsonSettingsDocument(QUndoStack *undoStack)
{ {
setId(Constants::CE_EDITOR_ID); setId(Constants::CE_EDITOR_ID);
setMimeType("application/compiler-explorer"); setMimeType("application/compiler-explorer");
connect(&m_ceSettings, &CompilerExplorerSettings::changed, this, [this] { emit changed(); }); connect(&m_ceSettings, &CompilerExplorerSettings::changed, this, [this] {
m_ceSettings.setAutoApply(true); emit changed();
emit contentsChanged();
});
m_ceSettings.setAutoApply(false);
m_ceSettings.setUndoStack(undoStack); m_ceSettings.setUndoStack(undoStack);
} }
@@ -157,8 +160,10 @@ bool JsonSettingsDocument::saveImpl(QString *errorString, const FilePath &newFil
Utils::FilePath path = newFilePath.isEmpty() ? filePath() : newFilePath; Utils::FilePath path = newFilePath.isEmpty() ? filePath() : newFilePath;
if (!newFilePath.isEmpty() && !autoSave) if (!newFilePath.isEmpty() && !autoSave) {
setPreferredDisplayName({});
setFilePath(newFilePath); setFilePath(newFilePath);
}
auto result = path.writeFileContents(jsonFromStore(store)); auto result = path.writeFileContents(jsonFromStore(store));
if (!result && errorString) { if (!result && errorString) {
@@ -182,6 +187,8 @@ bool JsonSettingsDocument::setContents(const QByteArray &contents)
m_ceSettings.fromMap(*result); m_ceSettings.fromMap(*result);
emit settingsChanged(); emit settingsChanged();
emit changed();
emit contentsChanged();
return true; return true;
} }