FileSystemWatcher: update after file deletion only

This commit is contained in:
lupoDharkael
2017-12-26 16:50:49 +01:00
parent c019e19109
commit c5d85de482
3 changed files with 5 additions and 13 deletions

View File

@@ -38,12 +38,11 @@ ConfigWindow::ConfigWindow(QWidget *parent) : QTabWidget(parent) {
setWindowTitle(tr("Configuration")); setWindowTitle(tr("Configuration"));
auto changedSlot = [this](QString s){ auto changedSlot = [this](QString s){
Q_UNUSED(s); QStringList files = m_configWatcher->files();
this->m_configWatcher->removePath(s); if (!files.contains(s)) {
this->m_configWatcher->addPath(s); this->m_configWatcher->addPath(s);
if(!this->hasFocus()) {
Q_EMIT updateComponents();
} }
Q_EMIT updateChildren();
}; };
m_configWatcher = new QFileSystemWatcher(this); m_configWatcher = new QFileSystemWatcher(this);
m_configWatcher->addPath(ConfigHandler().configFilePath()); m_configWatcher->addPath(ConfigHandler().configFilePath());
@@ -97,10 +96,6 @@ ConfigWindow::ConfigWindow(QWidget *parent) : QTabWidget(parent) {
m_generalConfig, &GeneneralConf::updateComponents); m_generalConfig, &GeneneralConf::updateComponents);
} }
void ConfigWindow::updateComponents() {
Q_EMIT updateChildren();
}
void ConfigWindow::keyPressEvent(QKeyEvent *e) { void ConfigWindow::keyPressEvent(QKeyEvent *e) {
if (e->key() == Qt::Key_Escape) { if (e->key() == Qt::Key_Escape) {
close(); close();

View File

@@ -31,9 +31,6 @@ class ConfigWindow : public QTabWidget {
public: public:
explicit ConfigWindow(QWidget *parent = nullptr); explicit ConfigWindow(QWidget *parent = nullptr);
public slots:
void updateComponents();
signals: signals:
void updateChildren(); void updateChildren();

View File

@@ -147,6 +147,6 @@ void Controller::sendTrayNotification(
void Controller::updateConfigComponents() { void Controller::updateConfigComponents() {
if (m_configWindow) { if (m_configWindow) {
m_configWindow->updateComponents(); m_configWindow->updateChildren();
} }
} }