From 723a79c221c539c95aeb881360b2993f5268aed6 Mon Sep 17 00:00:00 2001 From: sunfengsheng <327123947@qq.com> Date: Sat, 27 Feb 2021 00:57:47 +0800 Subject: [PATCH] add dir watch of desktop --- libsearch/appsearch/app-match.cpp | 11 +++++++++++ libsearch/appsearch/app-match.h | 1 + 2 files changed, 12 insertions(+) diff --git a/libsearch/appsearch/app-match.cpp b/libsearch/appsearch/app-match.cpp index 91ca946..d4f6a44 100644 --- a/libsearch/appsearch/app-match.cpp +++ b/libsearch/appsearch/app-match.cpp @@ -25,6 +25,13 @@ AppMatch::AppMatch(QObject *parent) : QObject(parent) { this->getDesktopFilePath(); + + m_watchAppDir=new QFileSystemWatcher(this); + m_watchAppDir->addPath("/usr/share/applications/"); + connect(m_watchAppDir,&QFileSystemWatcher::directoryChanged,[this](){ + this->getDesktopFilePath(); + }); + qDBusRegisterMetaType>(); qDBusRegisterMetaType>>(); m_interFace=new QDBusInterface ("com.kylin.softwarecenter.getsearchresults", "/com/kylin/softwarecenter/getsearchresults", @@ -41,6 +48,10 @@ AppMatch::~AppMatch(){ delete m_interFace; m_interFace=NULL; } + if(m_watchAppDir){ + delete m_watchAppDir; + m_watchAppDir=NULL; + } } QStringList AppMatch::startMatchApp(QString input){ diff --git a/libsearch/appsearch/app-match.h b/libsearch/appsearch/app-match.h index 44d4ec2..c41ffc7 100644 --- a/libsearch/appsearch/app-match.h +++ b/libsearch/appsearch/app-match.h @@ -55,6 +55,7 @@ private: QStringList m_returnResult; QDBusInterface *m_interFace=nullptr; + QFileSystemWatcher *m_watchAppDir=nullptr; QMap> m_softWareCenterMap; QMap> m_installAppMap; QMap> m_filterInstallAppMap;