feat: Add settings for auto apply changes

This commit is contained in:
Petr Mironychev
2025-10-20 18:10:21 +02:00
parent 0365018834
commit 254fac246d
6 changed files with 109 additions and 22 deletions

View File

@ -20,6 +20,7 @@
#include "FileEditItem.hpp"
#include "Logger.hpp"
#include "settings/GeneralSettings.hpp"
#include <QFile>
#include <QFileInfo>
@ -89,10 +90,15 @@ void FileEditItem::parseFromContent(const QString &content)
emit editModeChanged();
emit originalContentChanged();
emit newContentChanged();
emit contextBeforeChanged();
emit contextAfterChanged();
emit addedLinesChanged();
emit removedLinesChanged();
applyEditInternal(true);
bool autoApplyEnabled = Settings::generalSettings().autoApplyFileEdits.value();
if (autoApplyEnabled) {
applyEditInternal(true);
}
}
void FileEditItem::applyEdit()
@ -102,8 +108,15 @@ void FileEditItem::applyEdit()
void FileEditItem::applyEditInternal(bool isAutomatic, int retryCount)
{
if (!isAutomatic && m_status != EditStatus::Reverted && m_status != EditStatus::Rejected) {
return;
if (isAutomatic) {
if (m_status != EditStatus::Pending) {
return;
}
} else {
if (m_status != EditStatus::Pending && m_status != EditStatus::Reverted
&& m_status != EditStatus::Rejected) {
return;
}
}
if (!acquireFileLock(m_filePath)) {