mirror of
https://github.com/Palm1r/QodeAssist.git
synced 2026-07-01 02:29:13 -04:00
fix: Remove files and folder watches
This commit is contained in:
@@ -16,11 +16,9 @@
|
||||
#include <utils/filepath.h>
|
||||
#include <utils/theme/theme.h>
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QDesktopServices>
|
||||
#include <QDir>
|
||||
#include <QFile>
|
||||
#include <QFileSystemWatcher>
|
||||
#include <QFont>
|
||||
#include <QFontMetrics>
|
||||
#include <QFrame>
|
||||
@@ -153,26 +151,6 @@ public:
|
||||
&AgentListPane::selectByName);
|
||||
}
|
||||
|
||||
m_reloadDebounce = new QTimer(this);
|
||||
m_reloadDebounce->setSingleShot(true);
|
||||
m_reloadDebounce->setInterval(300);
|
||||
connect(m_reloadDebounce, &QTimer::timeout, this, [this] {
|
||||
constexpr qint64 kSelfWriteIgnoreMs = 1500;
|
||||
if (QDateTime::currentMSecsSinceEpoch() - m_lastSelfWriteMs < kSelfWriteIgnoreMs) {
|
||||
armWatcher();
|
||||
return;
|
||||
}
|
||||
reloadFromDisk();
|
||||
});
|
||||
|
||||
m_watcher = new QFileSystemWatcher(this);
|
||||
connect(m_watcher, &QFileSystemWatcher::directoryChanged, this, [this](const QString &) {
|
||||
m_reloadDebounce->start();
|
||||
});
|
||||
connect(m_watcher, &QFileSystemWatcher::fileChanged, this, [this](const QString &) {
|
||||
m_reloadDebounce->start();
|
||||
});
|
||||
|
||||
reloadFromDisk();
|
||||
|
||||
if (m_navigator) {
|
||||
@@ -194,21 +172,6 @@ private:
|
||||
m_agentFactory->reload();
|
||||
updateUserPathLabel();
|
||||
m_listPane->refresh();
|
||||
armWatcher();
|
||||
}
|
||||
|
||||
void armWatcher()
|
||||
{
|
||||
if (!m_watcher)
|
||||
return;
|
||||
const QStringList watched = m_watcher->files() + m_watcher->directories();
|
||||
if (!watched.isEmpty())
|
||||
m_watcher->removePaths(watched);
|
||||
const QString dir = QodeAssist::AgentFactory::userAgentsDir();
|
||||
m_watcher->addPath(dir);
|
||||
const QDir userDir(dir);
|
||||
for (const QString &f : userDir.entryList({QStringLiteral("*.toml")}, QDir::Files))
|
||||
m_watcher->addPath(userDir.filePath(f));
|
||||
}
|
||||
|
||||
void updateUserPathLabel()
|
||||
@@ -246,7 +209,6 @@ private:
|
||||
|
||||
void customizeAgent(const AgentConfig &parent)
|
||||
{
|
||||
m_lastSelfWriteMs = QDateTime::currentMSecsSinceEpoch();
|
||||
const AgentDuplicateResult res = duplicateAgentInUserDir(parent, *m_agentFactory);
|
||||
if (!res.ok) {
|
||||
QMessageBox::warning(this, tr("Duplicate"), res.error);
|
||||
@@ -272,7 +234,6 @@ private:
|
||||
QMessageBox::No)
|
||||
!= QMessageBox::Yes)
|
||||
return;
|
||||
m_lastSelfWriteMs = QDateTime::currentMSecsSinceEpoch();
|
||||
if (!QFile::remove(sourcePath)) {
|
||||
QMessageBox::warning(
|
||||
this,
|
||||
@@ -296,9 +257,6 @@ private:
|
||||
AgentListPane *m_listPane = nullptr;
|
||||
QScrollArea *m_detailScroll = nullptr;
|
||||
AgentDetailPane *m_detail = nullptr;
|
||||
QFileSystemWatcher *m_watcher = nullptr;
|
||||
QTimer *m_reloadDebounce = nullptr;
|
||||
qint64 m_lastSelfWriteMs = 0;
|
||||
};
|
||||
|
||||
class AgentsSettingsPage : public Core::IOptionsPage
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
#include <QLabel>
|
||||
#include <QListWidget>
|
||||
#include <QPushButton>
|
||||
|
||||
#include "ProjectSettings.hpp"
|
||||
#include "SettingsConstants.hpp"
|
||||
@@ -90,6 +91,9 @@ static ProjectSettingsWidget *createProjectPanel(Project *project)
|
||||
QObject::connect(
|
||||
&settings->projectSkillDirs, &Utils::BaseAspect::changed, skillsList, refreshSkills);
|
||||
|
||||
auto *reloadSkillsButton = new QPushButton(Tr::tr("Reload"));
|
||||
QObject::connect(reloadSkillsButton, &QPushButton::clicked, skillsList, refreshSkills);
|
||||
|
||||
Column{
|
||||
generalWidget,
|
||||
Space{8},
|
||||
@@ -97,7 +101,7 @@ static ProjectSettingsWidget *createProjectPanel(Project *project)
|
||||
title(Tr::tr("Skills")),
|
||||
Column{
|
||||
settings->projectSkillDirs,
|
||||
new QLabel(Tr::tr("Discovered project skills:")),
|
||||
Row{new QLabel(Tr::tr("Discovered project skills:")), st, reloadSkillsButton},
|
||||
skillsList,
|
||||
},
|
||||
},
|
||||
|
||||
@@ -86,6 +86,13 @@ public:
|
||||
headerRow->setSpacing(8);
|
||||
headerRow->addWidget(m_titleLabel, 1);
|
||||
|
||||
auto *reloadButton = new QPushButton(tr("Reload from disk"), this);
|
||||
connect(reloadButton, &QPushButton::clicked, this, [this] {
|
||||
if (m_factory)
|
||||
m_factory->reload();
|
||||
});
|
||||
headerRow->addWidget(reloadButton);
|
||||
|
||||
auto *headerSep = new QFrame(this);
|
||||
headerSep->setFrameShape(QFrame::HLine);
|
||||
headerSep->setFrameShadow(QFrame::Sunken);
|
||||
|
||||
Reference in New Issue
Block a user