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;